fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16439] more on eventplanner


From: sigurdne
Subject: [Fmsystem-commits] [16439] more on eventplanner
Date: Thu, 16 Mar 2017 06:24:44 -0400 (EDT)

Revision: 16439
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16439
Author:   sigurdne
Date:     2017-03-16 06:24:44 -0400 (Thu, 16 Mar 2017)
Log Message:
-----------
more on eventplanner

Modified Paths:
--------------
    trunk/eventplanner/inc/class.bocustomer.inc.php
    trunk/eventplanner/inc/class.menu.inc.php
    trunk/eventplanner/inc/class.socustomer.inc.php
    trunk/eventplanner/inc/class.uievents.inc.php
    trunk/eventplanner/inc/model/class.booking.inc.php
    trunk/eventplanner/inc/model/class.customer.inc.php
    trunk/eventplanner/setup/phpgw_no.lang
    trunk/eventplanner/templates/base/config.tpl
    trunk/eventplanner/templates/base/events.xsl

Modified: trunk/eventplanner/inc/class.bocustomer.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bocustomer.inc.php     2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/inc/class.bocustomer.inc.php     2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -88,11 +88,11 @@
                        return $values;
                }
 
-               public function read_single($id, $return_object = true)
+               public function read_single($id, $return_object = true, 
$relaxe_acl = false)
                {
                        if ($id)
                        {
-                               $values = 
eventplanner_socustomer::get_instance()->read_single($id, $return_object);
+                               $values = 
eventplanner_socustomer::get_instance()->read_single($id, $return_object, 
$relaxe_acl);
                        }
                        else
                        {

Modified: trunk/eventplanner/inc/class.menu.inc.php
===================================================================
--- trunk/eventplanner/inc/class.menu.inc.php   2017-03-16 04:44:39 UTC (rev 
16438)
+++ trunk/eventplanner/inc/class.menu.inc.php   2017-03-16 10:24:44 UTC (rev 
16439)
@@ -78,11 +78,6 @@
                                                'text'  => lang('permission'),
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'eventplanner.uipermission.index') )
                                        ),
-                                       'list_atrribs' => array(
-                                               'text' => 
$GLOBALS['phpgw']->translation->translate('custom fields', array(), true),
-                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute',
-                                                       'appname' => 
'eventplanner'))
-                                       ),
                                        'list_functions' => array(
                                                'text' => 
$GLOBALS['phpgw']->translation->translate('custom functions', array(), true),
                                                'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_custom_function',

Modified: trunk/eventplanner/inc/class.socustomer.inc.php
===================================================================
--- trunk/eventplanner/inc/class.socustomer.inc.php     2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/inc/class.socustomer.inc.php     2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -71,7 +71,15 @@
                                }
                        }
 
-                       return '(' . $acl_condition . ' OR 
eventplanner_customer.id IN (' . implode(',', $object_ids) . '))';
+                       if($acl_condition)
+                       {
+                               return '(' . $acl_condition . ' OR 
eventplanner_customer.id IN (' . implode(',', $object_ids) . '))';
+                       }
+                       else
+                       {
+                               return 'eventplanner_customer.id IN (' . 
implode(',', $object_ids) . ')';       
+                       }
+
                }
 
                protected function populate( array $data )

Modified: trunk/eventplanner/inc/class.uievents.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uievents.inc.php       2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/inc/class.uievents.inc.php       2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -243,6 +243,8 @@
                        }
 
                        $category = 
$this->cats->return_single($application->category_id);
+                       $config = CreateObject('phpgwapi.config', 
'eventplanner')->read();
+                       $booking_interval = !empty($config['booking_interval']) 
? $config['booking_interval'] : null;
 
                        $data = array(
                                'datatable_def' => $datatable_def,
@@ -249,6 +251,7 @@
                                'cancel_url' => self::link(array('menuaction' 
=> "{$this->currentapp}.uievents.index",)),
                                'application' => $application,
                                'category_name' => $category[0]['name'],
+                               'booking_interval' => $booking_interval,
                                'status_list' => array('options' => 
$this->get_status_options($application->status)),
                                'application_type_list' => 
$application_type_list,
                                'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),

Modified: trunk/eventplanner/inc/model/class.booking.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.booking.inc.php  2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/inc/model/class.booking.inc.php  2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -26,7 +26,6 @@
         * @subpackage booking
         * @version $Id: $
         */
-
        phpgw::import_class('eventplanner.bobooking');
 
        include_class('phpgwapi', 'model', 'inc/model/');
@@ -62,7 +61,6 @@
                        $created,
                        $secret,
                        $process_update;
-
                protected $field_of_responsibility_name = '.booking';
 
                public function __construct( int $id = null )
@@ -85,111 +83,111 @@
                {
                        return array(
                                self::STATUS_REGISTERED => lang('registered'),
-                               self::STATUS_PENDING    => lang('pending'),
+                               self::STATUS_PENDING => lang('pending'),
                                self::STATUS_REJECTED => lang('rejected'),
-                               self::STATUS_APPROVED   => lang('approved')
+                               self::STATUS_APPROVED => lang('approved')
                        );
                }
 
-               public static function get_fields($debug = true)
+               public static function get_fields( $debug = true )
                {
-                        $fields = array(
-                               'id' => array('action'=> PHPGW_ACL_READ,
+                       $fields = array(
+                               'id' => array('action' => PHPGW_ACL_READ,
                                        'type' => 'int',
                                        'label' => 'id',
-                                       'sortable'=> true,
+                                       'sortable' => true,
                                        'formatter' => 
'JqueryPortico.formatLink',
-                                       'public'        => true
-                                       ),
-                               'owner_id' => array('action'=> PHPGW_ACL_ADD,
+                                       'public' => true
+                               ),
+                               'owner_id' => array('action' => PHPGW_ACL_ADD,
                                        'type' => 'int',
                                        'required' => false
-                                       ),
-                               'active' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                               ),
+                               'active' => array('action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'int',
-                                       'public'        => true,
-                                       'history'       => true
-                                       ),
-                               'completed' => array('action'=>  PHPGW_ACL_EDIT,
+                                       'public' => true,
+                                       'history' => true
+                               ),
+                               'completed' => array('action' => PHPGW_ACL_EDIT,
                                        'type' => 'int',
-                                       'history'       => true
-                                       ),
-                               'cost' => array('action'=>  PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'history' => true
+                               ),
+                               'cost' => array('action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'decimal'
-                                       ),
-                               'from_' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                               ),
+                               'from_' => array('action' => PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'date',
-                                       'label' => 'from',
+                                       'label' => 'from',
                                        'history' => true,
                                        'required' => true,
-                                       'public'        => true
-                                       ),
-                               'to_' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'public' => true
+                               ),
+                               'to_' => array('action' => PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'date',
-                                       'label' => 'to',
+                                       'label' => 'to',
                                        'history' => true,
                                        'required' => true,
-                                       'public'        => true
+                                       'public' => true
                                ),
-                               'application_id' => array('action'=> 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                               'application_id' => array('action' => 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'int',
                                        'label' => 'application',
                                        'sortable' => true,
                                        'required' => true,
-                                       'public'        => true
-                                       ),
-                               'application_name' => array('action'=>  
PHPGW_ACL_READ,
+                                       'public' => true
+                               ),
+                               'application_name' => array('action' => 
PHPGW_ACL_READ,
                                        'type' => 'string',
                                        'query' => true,
                                        'label' => 'application',
-                                       'public'        => true,
+                                       'public' => true,
                                        'join' => array(
                                                'table' => 
'eventplanner_application',
                                                'fkey' => 'application_id',
                                                'key' => 'id',
                                                'column' => 'title'
-                                               )
-                                       ),
-                               'vendor_name' => array('action'=>  
PHPGW_ACL_READ,
+                                       )
+                               ),
+                               'vendor_name' => array('action' => 
PHPGW_ACL_READ,
                                        'type' => 'string',
                                        'query' => true,
                                        'label' => 'vendor',
-                                       'public'        => true,
+                                       'public' => true,
                                        'multiple_join' => array(
                                                'statement' => 'LEFT JOIN 
eventplanner_application ON eventplanner_application.id = 
eventplanner_booking.application_id'
-                                                                               
. ' LEFT JOIN eventplanner_vendor ON eventplanner_application.vendor_id = 
eventplanner_vendor.id',
+                                               . ' LEFT JOIN 
eventplanner_vendor ON eventplanner_application.vendor_id = 
eventplanner_vendor.id',
                                                'column' => 
'eventplanner_vendor.name'
-                                               )
-                                       ),
-                               'customer_id' => array('action'=> PHPGW_ACL_ADD 
| PHPGW_ACL_EDIT,
+                                       )
+                               ),
+                               'customer_id' => array('action' => 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'int',
                                        'label' => 'customer',
                                        'sortable' => true,
                                        'history' => true,
-                                       'public'        => true
-                                       ),
-                               'customer_name' => array('action'=>  
PHPGW_ACL_READ,
+                                       'public' => true
+                               ),
+                               'customer_name' => array('action' => 
PHPGW_ACL_READ,
                                        'type' => 'string',
                                        'query' => true,
                                        'label' => 'customer',
-                                       'public'        => true,
+                                       'public' => true,
                                        'join' => array(
                                                'table' => 
'eventplanner_customer',
                                                'fkey' => 'customer_id',
                                                'key' => 'id',
                                                'column' => 'name'
-                                               )
-                                       ),
+                                       )
+                               ),
                                'customer_contact_name' => array(
-                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'string',
                                        'required' => false,
                                        'query' => true,
                                        'label' => 'customer contact name',
                                        'history' => true,
-                                       ),
+                               ),
                                'customer_contact_email' => array(
-                                       'action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'action' => PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
                                        'type' => 'string',
                                        'required' => false,
                                        'query' => true,
@@ -196,26 +194,26 @@
                                        'sf_validator' => 
createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% 
is invalid')),
                                        'label' => 'customer contact email',
                                        'history' => true,
-                                       ),
+                               ),
                                'customer_contact_phone' => array(
-                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'string',
                                        'required' => false,
                                        'query' => true,
                                        'label' => 'customer contact phone',
                                        'history' => true,
-                                       ),
+                               ),
                                'location' => array(
-                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'string',
                                        'required' => false,
                                        'query' => true,
                                        'label' => 'location',
                                        'history' => true,
-                                       'public'        => true
-                                       ),
+                                       'public' => true
+                               ),
                                'comments' => array(
-                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'string',
                                        'manytomany' => array(
                                                'input_field' => 
'comment_input',
@@ -225,31 +223,30 @@
                                                'order' => array('sort' => 
'time', 'dir' => 'ASC')
                                        )),
                                'comment' => array(
-                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'action' => PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                        'type' => 'string',
                                        'related' => true,
-                                       ),
-                               'created' => array('action'=> PHPGW_ACL_READ,
+                               ),
+                               'created' => array('action' => PHPGW_ACL_READ,
                                        'type' => 'date',
                                        'label' => 'created',
                                        'sortable' => true,
-                                       ),
-                               'secret' => array('action'=> PHPGW_ACL_ADD,
+                               ),
+                               'secret' => array('action' => PHPGW_ACL_ADD,
                                        'type' => 'string',
                                        'label' => 'secret',
                                        'sortable' => false,
-                                       ),
-                               );
+                               ),
+                       );
 
-                       if($debug)
+                       if ($debug)
                        {
                                foreach ($fields as $field => $field_info)
                                {
-                                       
if(!property_exists('eventplanner_booking', $field))
+                                       if 
(!property_exists('eventplanner_booking', $field))
                                        {
-                                          
phpgwapi_cache::message_set('$'."{$field},", 'error');
+                                               phpgwapi_cache::message_set('$' 
. "{$field},", 'error');
                                        }
-
                                }
                        }
                        return $fields;
@@ -270,7 +267,7 @@
                                );
                        }
 
-                       if(!$entity->get_id())
+                       if (!$entity->get_id())
                        {
                                $entity->status = 
eventplanner_booking::STATUS_REGISTERED;
                                $entity->secret = self::generate_secret();
@@ -290,7 +287,6 @@
 
                        $entity->modified = time();
                        $entity->active = (int)$entity->active;
-
                }
 
                protected function doValidate( $entity, &$errors )
@@ -300,24 +296,70 @@
                        $params['filters']['active'] = 1;
                        $params['filters']['application_id'] = 
$entity->application_id;
 
-                       $bookings =  
eventplanner_sobooking::get_instance()->read($params);
+                       $bookings = 
eventplanner_sobooking::get_instance()->read($params);
 
                        foreach ($bookings['results'] as $booking)
                        {
-                               if($booking['id'] == $entity->get_id())
+                               if ($booking['id'] == $entity->get_id())
                                {
                                        continue;
                                }
 
-                               if(($entity->from_ > $booking['from_'] && 
$entity->from_ < $booking['to_'])
-                                       ||      ($entity->to_ > 
$booking['from_'] && $entity->to_ < $booking['to_']) )
+                               if (($entity->from_ > $booking['from_'] && 
$entity->from_ < $booking['to_']) || ($entity->to_ > $booking['from_'] && 
$entity->to_ < $booking['to_']))
                                {
                                        $errors['from_'] = lang('Time is 
already booked');
                                }
                        }
 
-                       if($entity->customer_id || $entity->process_update) // 
update
+                       $orig_customer_id = 0;
+                       if ($entity->get_id())
                        {
+                               $orig_booking = 
createObject('eventplanner.bobooking')->read_single($entity->get_id());
+                               $orig_customer_id = $orig_booking->customer_id;
+                       }
+
+                       $number_of_customer_bookings = 0;
+                       if ($entity->customer_id && $entity->customer_id != 
$orig_customer_id)
+                       {
+                               $config = CreateObject('phpgwapi.config', 
'eventplanner')->read();
+                               $booking_interval = 
!empty($config['booking_interval']) ? (int)$config['booking_interval'] : 0;
+                               $customer = 
createObject('eventplanner.bocustomer')->read_single($entity->customer_id);
+                               $max_events = (int)$customer->max_events;
+                               foreach ($bookings['results'] as $booking)
+                               {
+                                       $current_interval = 0;
+
+                                       if ($booking['customer_id'] == 
$entity->customer_id)
+                                       {
+                                               $current_interval = 
floor(abs(($booking['from_'] - $entity->from_)) / (60 * 60 * 24));
+                                       }
+
+                                       if ($booking_interval && 
$current_interval && $current_interval < $booking_interval)
+                                       {
+                                               $errors['booking_interval'] = 
lang('There is a minimum interval of %1 day(s)', $booking_interval);
+                                       }
+
+                                       $booking_year = date('Y', 
$booking['from_']);
+
+                                       if ($booking_year != date('Y', 
$entity->from_))
+                                       {
+                                               continue;
+                                       }
+
+                                       if ($booking['customer_id'] == 
$entity->customer_id)
+                                       {
+                                               $number_of_customer_bookings ++;
+                                       }
+                               }
+
+                               if ($max_events && $number_of_customer_bookings 
>= $max_events)
+                               {
+                                       $errors['num_granted_events_year'] = 
lang('maximum of granted events per year (%1) are reached', $max_events);
+                               }
+                       }
+
+                       if ($entity->customer_id || $entity->process_update) // 
update
+                       {
                                $test_total_tecords = 
(int)$bookings['total_records'];
                        }
                        else // new entry
@@ -325,16 +367,16 @@
                                $test_total_tecords = 
(int)$bookings['total_records'] + 1;
                        }
 
-                       if($test_total_tecords > 
(int)$application->num_granted_events)
+                       if ($test_total_tecords > 
(int)$application->num_granted_events)
                        {
                                $errors['num_granted_events'] = lang('maximum 
of granted events are reached');
                        }
 
-                       $date_start = date('Ymd',$application->date_start);
-                       $date_end = date('Ymd',$application->date_end);
-                       $from_ = date('Ymd',$entity->from_);
+                       $date_start = date('Ymd', $application->date_start);
+                       $date_end = date('Ymd', $application->date_end);
+                       $from_ = date('Ymd', $entity->from_);
 
-                       if($from_ < $date_start || $from_ > $date_end)
+                       if ($from_ < $date_start || $from_ > $date_end)
                        {
                                $errors['from_'] = lang('date is outside the 
scope');
                        }
@@ -355,8 +397,8 @@
                        return 
eventplanner_bobooking::get_instance()->store($this);
                }
 
-               public function read_single($id)
+               public function read_single( $id )
                {
                        return 
eventplanner_bobooking::get_instance()->read_single($id, true);
                }
-       }
+       }
\ No newline at end of file

Modified: trunk/eventplanner/inc/model/class.customer.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.customer.inc.php 2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/inc/model/class.customer.inc.php 2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -221,6 +221,13 @@
                                        'query' => true,
                                        'sf_validator' => 
createObject('booking.sfValidatorNorwegianOrganizationNumber', array(), 
array('invalid' => '%field% is invalid')),
                                        'label' => 'organization number'
+                                       ),
+                                       'max_events' => array(
+                                               'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                               'type' => 'int',
+                                               'required' => true,
+                                               'query' => false,
+                                               'label' => 'maximum number of 
events',
                                        )
                        );
 
@@ -245,14 +252,7 @@
                                                'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
                                                'type' => 'string',
                                                'related' => true,
-                                               ),
-                                       'max_events' => array(
-                                               'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
-                                               'type' => 'int',
-                                               'required' => true,
-                                               'query' => false,
-                                               'label' => 'maximum number of 
events',
-                                               ),
+                                               )
                                        );
 
                                foreach ($backend_fields as $key => $field_info)

Modified: trunk/eventplanner/setup/phpgw_no.lang
===================================================================
--- trunk/eventplanner/setup/phpgw_no.lang      2017-03-16 04:44:39 UTC (rev 
16438)
+++ trunk/eventplanner/setup/phpgw_no.lang      2017-03-16 10:24:44 UTC (rev 
16439)
@@ -111,7 +111,11 @@
 read   eventplanner    no      Les
 permission     eventplanner    no      Rettighet
 maximum number of events       eventplanner    no      Maksimum antall 
arrangement
+maximum of granted events per year (%1) are reached    eventplanner    no      
Maksimum antall arrangementer (%1) pr år er nådd
 number of users        eventplanner    no      Ca. antall brukere
 disconnect     eventplanner    no      Kople fra
 end date cannot be before start date   eventplanner    no      Siste dato kan 
ikke være før første dato
-Time is already booked eventplanner    no      Tiden er allerede booking
\ No newline at end of file
+Time is already booked eventplanner    no      Tiden er allerede booking
+booking interval       eventplanner    no      Booking intervall
+days   eventplanner    no      dager
+there is a minimum interval of %1 day(s)       eventplanner    no      Det er 
et minimumsintervall på %1 dag(er)
\ No newline at end of file

Modified: trunk/eventplanner/templates/base/config.tpl
===================================================================
--- trunk/eventplanner/templates/base/config.tpl        2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/templates/base/config.tpl        2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -14,6 +14,12 @@
                                </select>
                        </td>
                </tr>
+               <tr>
+                       <td>{lang_booking_interval}:</td>
+                       <td>
+                               <input type="number" 
name="newsettings[booking_interval]" value="{value_booking_interval}">
+                       </td>
+               </tr>
 
                <!-- END body -->
                <!-- BEGIN footer -->

Modified: trunk/eventplanner/templates/base/events.xsl
===================================================================
--- trunk/eventplanner/templates/base/events.xsl        2017-03-16 04:44:39 UTC 
(rev 16438)
+++ trunk/eventplanner/templates/base/events.xsl        2017-03-16 10:24:44 UTC 
(rev 16439)
@@ -66,6 +66,16 @@
                                                <xsl:value-of 
select="category_name"/>
                                        </div>
 
+                                       <xsl:if test="booking_interval != ''">
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'booking interval')"/>
+                                                       </label>
+                                                       <xsl:value-of 
select="booking_interval"/>
+                                                       <xsl:text> </xsl:text>
+                                                       <xsl:value-of 
select="php:function('lang', 'days')"/>
+                                               </div>
+                                       </xsl:if>
                                        
                                        <div class="pure-control-group">
                                                <label>




reply via email to

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