[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16490] more on eventplanner
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16490] more on eventplanner |
Date: |
Tue, 28 Mar 2017 09:54:48 -0400 (EDT) |
Revision: 16490
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16490
Author: sigurdne
Date: 2017-03-28 09:54:48 -0400 (Tue, 28 Mar 2017)
Log Message:
-----------
more on eventplanner
Modified Paths:
--------------
trunk/eventplanner/inc/class.bobooking.inc.php
trunk/eventplanner/inc/class.bopermission.inc.php
trunk/eventplanner/inc/class.sobooking.inc.php
trunk/eventplanner/inc/class.sopermission.inc.php
trunk/eventplanner/inc/class.uiapplication.inc.php
trunk/eventplanner/inc/class.uibooking.inc.php
trunk/eventplanner/inc/class.uicustomer.inc.php
trunk/eventplanner/inc/class.uicustomer_report.inc.php
trunk/eventplanner/inc/class.uipermission.inc.php
trunk/eventplanner/inc/class.uivendor.inc.php
trunk/eventplanner/inc/model/class.booking.inc.php
trunk/eventplanner/inc/model/class.customer.inc.php
trunk/eventplanner/js/portico/application.edit.js
trunk/eventplanner/setup/default_records.inc.php
trunk/eventplanner/setup/phpgw_no.lang
trunk/eventplanner/setup/setup.inc.php
trunk/eventplanner/setup/tables_current.inc.php
trunk/eventplanner/setup/tables_update.inc.php
trunk/eventplanner/templates/base/booking.xsl
trunk/eventplannerfrontend/js/portico/application.edit.js
trunk/eventplannerfrontend/setup/default_records.inc.php
trunk/eventplannerfrontend/templates/base/booking.xsl
Added Paths:
-----------
trunk/eventplanner/inc/class.bocalendar.inc.php
trunk/eventplanner/inc/class.socalendar.inc.php
trunk/eventplanner/inc/class.uicalendar.inc.php
trunk/eventplanner/inc/model/class.calendar.inc.php
trunk/eventplannerfrontend/inc/class.uicalendar.inc.php
Modified: trunk/eventplanner/inc/class.bobooking.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bobooking.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.bobooking.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -60,8 +60,19 @@
public function store($object)
{
+ $save_last_booking = false;
+ if(!$object->get_id())
+ {
+ $save_last_booking = true;
+ }
+
$this->store_pre_commit($object);
$ret =
eventplanner_sobooking::get_instance()->store($object);
+ if($ret && $save_last_booking)
+ {
+ phpgwapi_cache::system_set('eventplanner',
"last_booking{$object->customer_id}", time());
+ }
+
$this->store_post_commit($object);
return $ret;
}
@@ -104,8 +115,13 @@
return $values;
}
- public function update_active_status( $ids, $action )
+ public function get_booking_id_from_calendar( $calendar_id )
{
+ return
eventplanner_sobooking::get_instance()->get_booking_id_from_calendar($calendar_id);
+ }
+
+/* public function update_active_status( $ids, $action )
+ {
if($action == 'enable' && $ids)
{
$_ids = array();
@@ -175,20 +191,5 @@
return
eventplanner_sobooking::get_instance()->update_active_status($_ids, $action);
}
-
- public function update_schedule( $id, $from_ )
- {
- $booking =
eventplanner_sobooking::get_instance()->read_single($id, true);
- $booking->from_ = $from_;
- $booking->customer_id = $booking->customer_id ?
$booking->customer_id : '';//foreigns key
- $booking->process_update = true;
-
- if($booking->validate())
- {
- return $booking->store();
- }
- return false;
- }
-
-
+*/
}
\ No newline at end of file
Added: trunk/eventplanner/inc/class.bocalendar.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bocalendar.inc.php
(rev 0)
+++ trunk/eventplanner/inc/class.bocalendar.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -0,0 +1,192 @@
+<?php
+ /**
+ * phpGroupWare
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License v2 or later
+ * @internal
+ * @package eventplanner
+ * @subpackage calendar
+ * @version $Id:$
+ */
+
+ /*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ phpgw::import_class('phpgwapi.bocommon');
+ phpgw::import_class('eventplanner.socalendar');
+
+ include_class('eventplanner', 'calendar', 'inc/model/');
+
+ class eventplanner_bocalendar extends phpgwapi_bocommon
+ {
+ protected static
+ $bo,
+ $fields,
+ $acl_location;
+
+ public function __construct()
+ {
+ $this->fields = eventplanner_calendar::get_fields();
+ $this->acl_location =
eventplanner_calendar::acl_location;
+ }
+
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public static function get_instance()
+ {
+ if (self::$bo == null)
+ {
+ self::$bo = new eventplanner_bocalendar();
+ }
+ return self::$bo;
+ }
+
+ public function store($object)
+ {
+ $this->store_pre_commit($object);
+ $ret =
eventplanner_socalendar::get_instance()->store($object);
+ $this->store_post_commit($object);
+ return $ret;
+ }
+
+ public function read($params)
+ {
+ $status_text = array(lang('inactive'), lang('active'));
+ if(empty($params['filters']['active']))
+ {
+ $params['filters']['active'] = 1;
+ }
+ else
+ {
+ unset($params['filters']['active']);
+ }
+ $values =
eventplanner_socalendar::get_instance()->read($params);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ foreach ($values['results'] as &$entry)
+ {
+ $entry['created'] =
$GLOBALS['phpgw']->common->show_date($entry['created']);
+ $entry['modified'] =
$GLOBALS['phpgw']->common->show_date($entry['modified']);
+ $entry['from_'] =
$GLOBALS['phpgw']->common->show_date($entry['from_']);
+ $entry['to_'] =
$GLOBALS['phpgw']->common->show_date($entry['to_']);
+ $entry['status'] =
$status_text[$entry['active']];
+ }
+ return $values;
+ }
+
+ public function read_single($id, $return_object = true)
+ {
+ if ($id)
+ {
+ $values =
eventplanner_socalendar::get_instance()->read_single($id, $return_object);
+ }
+ else
+ {
+ $values = new eventplanner_calendar();
+ }
+
+ return $values;
+ }
+
+ public function update_active_status( $ids, $action )
+ {
+ if($action == 'enable' && $ids)
+ {
+ $_ids = array();
+ $application_id =
eventplanner_socalendar::get_instance()->read_single($ids[0],
true)->application_id;
+
+ $application =
createObject('eventplanner.boapplication')->read_single($application_id);
+ $params = array();
+ $params['filters']['active'] = 1;
+ $params['filters']['application_id'] =
$application_id;
+
+ $calendars =
eventplanner_socalendar::get_instance()->read($params);
+
+ $existing_calendar_ids = array();
+ foreach ($calendars['results'] as $calendar)
+ {
+ $existing_calendar_ids[] =
$calendar['id'];
+ }
+
+ $number_of_active =
(int)$calendars['total_records'];
+ $limit = (int)$application->num_granted_events;
+
+ $error = false;
+ foreach ($ids as $id)
+ {
+ if(in_array($id,
$existing_calendar_ids) )
+ {
+ continue;
+ }
+ if($limit > $number_of_active)
+ {
+ $_ids[] = $id;
+ $number_of_active ++;
+ }
+ else
+ {
+ $error = true;
+ $message = lang('maximum of
granted events are reached');
+
phpgwapi_cache::message_set($message, 'error');
+ break;
+ }
+ }
+ if($ids && !$_ids && !$error)
+ {
+ return true;
+ }
+ }
+ else if ($action == 'delete' && $ids)
+ {
+ foreach ($ids as $id)
+ {
+ $booking_id =
createObject('eventplanner.bobooking')->get_booking_id_from_calendar($id);
+ $booking =
eventplanner_sobooking::get_instance()->read_single($booking_id, true);
+ if(!$booking->customer_id)
+ {
+ $_ids[] = $id;
+ }
+ else
+ {
+ $message = lang('can not delete
calendar with customer');
+
phpgwapi_cache::message_set($message, 'error');
+ }
+ }
+ }
+ else
+ {
+ $_ids = $ids;
+ }
+
+ return
eventplanner_socalendar::get_instance()->update_active_status($_ids, $action);
+ }
+
+ public function update_schedule( $id, $from_ )
+ {
+ $calendar =
eventplanner_socalendar::get_instance()->read_single($id, true);
+ $calendar->from_ = $from_;
+ $calendar->process_update = true;
+
+ if($calendar->validate())
+ {
+ return $calendar->store();
+ }
+ return false;
+ }
+ }
\ No newline at end of file
Modified: trunk/eventplanner/inc/class.bopermission.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bopermission.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.bopermission.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -120,4 +120,9 @@
return $values;
}
+
+ public function delete( $id )
+ {
+ return
eventplanner_sopermission::get_instance()->delete($id);
+ }
}
\ No newline at end of file
Modified: trunk/eventplanner/inc/class.sobooking.inc.php
===================================================================
--- trunk/eventplanner/inc/class.sobooking.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.sobooking.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -36,6 +36,8 @@
public function __construct()
{
parent::__construct('eventplanner_booking',
eventplanner_booking::get_fields());
+ $this->acl_location =
eventplanner_booking::acl_location;
+ $this->use_acl = true;
}
/**
@@ -52,7 +54,38 @@
return self::$so;
}
+ function get_acl_condition( )
+ {
+ if($this->relaxe_acl)
+ {
+ return;
+ }
+ $acl_condition = parent::get_acl_condition();
+
+ $sql = "SELECT object_id, permission FROM
eventplanner_permission WHERE subject_id = {$this->account}";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $object_ids = array(-1);
+ while ($this->db->next_record())
+ {
+ $permission = $this->db->f('permission');
+ if($permission & PHPGW_ACL_READ)
+ {
+ $object_ids[] =
$this->db->f('object_id');
+ }
+ }
+
+ if($acl_condition)
+ {
+ return '(' . $acl_condition . ' OR
eventplanner_booking.customer_id IN (' . implode(',', $object_ids) . '))';
+ }
+ else
+ {
+ return 'eventplanner_booking.customer_id IN ('
. implode(',', $object_ids) . ')';
+ }
+
+ }
+
protected function populate( array $data )
{
$object = new eventplanner_booking();
@@ -76,11 +109,6 @@
protected function update_history( $object, $fields )
{
- // $status_text = eventplanner_booking::get_status_list();
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $lang_active = lang('active');
- $lang_inactive = lang('inactive');
-
$original =
$this->read_single($object->get_id());//returned as array()
foreach ($fields as $field => $params)
{
@@ -89,29 +117,6 @@
if (!empty($params['history']) && $new_value &&
$old_value && ($new_value != $old_value))
{
$label = !empty($params['label']) ?
lang($params['label']) : $field;
- switch ($field)
- {
- case 'status':
- $old_value =
$status_text[$old_value];
- $new_value =
$status_text[$new_value];
- break;
- case 'active':
- $old_value = $old_value
? $lang_active : $lang_inactive;
- $new_value = $new_value
? $lang_active : $lang_inactive;
- break;
- case 'from_':
- case 'to_':
- if(($old_value +
phpgwapi_datetime::user_timezone()) == $new_value)
- {
- continue;
- }
-
- $old_value =
$GLOBALS['phpgw']->common->show_date($old_value);
- $new_value =
$GLOBALS['phpgw']->common->show_date($new_value);
- break;
- default:
- break;
- }
$value_set = array
(
'booking_id' =>
$object->get_id(),
@@ -128,51 +133,11 @@
}
}
- public function update_active_status($ids, $action )
+ public function get_booking_id_from_calendar( $calendar_id )
{
- if(!$ids || !is_array($ids))
- {
- return;
- }
-
- switch ($action)
- {
- case 'disable':
- $sql = "UPDATE eventplanner_booking SET
active = 0";
- $where = 'WHERE';
-
- break;
- case 'enable':
- $sql = "UPDATE eventplanner_booking SET
active = 1";
- $where = 'WHERE';
- break;
-
- case 'delete':
- $sql = "DELETE FROM
eventplanner_booking WHERE customer_id IS NULL";
- $where = 'AND';
- break;
-
- case 'disconnect':
- $sql = "UPDATE eventplanner_booking SET"
- . " customer_id = NULL,"
- . " customer_contact_name = NULL,"
- . " customer_contact_email = NULL,"
- . " customer_contact_phone = NULL,"
- . " location = NULL";
- $where = 'WHERE';
- break;
-
- default:
- throw new Exception("action {$action}
not supported");
- break;
- }
-
- $sql .= " {$where} id IN(". implode(',', $ids) . ')';
- $this->db->transaction_begin();
-
+ $sql = "SELECT id FROM eventplanner_booking WHERE
calendar_id = " . (int) $calendar_id;
$this->db->query($sql,__LINE__,__FILE__);
-
-
- return $this->db->transaction_commit();
+ $this->db->next_record();
+ return (int) $this->db->f('id');
}
}
\ No newline at end of file
Added: trunk/eventplanner/inc/class.socalendar.inc.php
===================================================================
--- trunk/eventplanner/inc/class.socalendar.inc.php
(rev 0)
+++ trunk/eventplanner/inc/class.socalendar.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -0,0 +1,172 @@
+<?php
+ /**
+ * phpGroupWare - property: a part of a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package eventplanner
+ * @subpackage calendar
+ * @version $Id: $
+ */
+ phpgw::import_class('phpgwapi.socommon');
+
+ class eventplanner_socalendar extends phpgwapi_socommon
+ {
+
+ protected static $so;
+
+ public function __construct()
+ {
+ parent::__construct('eventplanner_calendar',
eventplanner_calendar::get_fields());
+ }
+
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public static function get_instance()
+ {
+ if (self::$so == null)
+ {
+ self::$so =
CreateObject('eventplanner.socalendar');
+ }
+ return self::$so;
+ }
+
+
+ protected function populate( array $data )
+ {
+ $object = new eventplanner_calendar();
+ foreach ($this->fields as $field => $field_info)
+ {
+ $object->set_field($field, $data[$field]);
+ }
+
+ return $object;
+ }
+
+ protected function update( $object )
+ {
+ $this->db->transaction_begin();
+ $this->update_history($object, $this->fields);
+
+ parent::update($object);
+
+ return $this->db->transaction_commit();
+ }
+
+ protected function update_history( $object, $fields )
+ {
+ // $status_text = eventplanner_calendar::get_status_list();
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $lang_active = lang('active');
+ $lang_inactive = lang('inactive');
+
+ $original =
$this->read_single($object->get_id());//returned as array()
+ foreach ($fields as $field => $params)
+ {
+ $new_value = $object->$field;
+ $old_value = $original[$field];
+ if (!empty($params['history']) && $new_value &&
$old_value && ($new_value != $old_value))
+ {
+ $label = !empty($params['label']) ?
lang($params['label']) : $field;
+ switch ($field)
+ {
+ case 'status':
+ $old_value =
$status_text[$old_value];
+ $new_value =
$status_text[$new_value];
+ break;
+ case 'active':
+ $old_value = $old_value
? $lang_active : $lang_inactive;
+ $new_value = $new_value
? $lang_active : $lang_inactive;
+ break;
+ case 'from_':
+ case 'to_':
+ if(($old_value +
phpgwapi_datetime::user_timezone()) == $new_value)
+ {
+ continue;
+ }
+
+ $old_value =
$GLOBALS['phpgw']->common->show_date($old_value);
+ $new_value =
$GLOBALS['phpgw']->common->show_date($new_value);
+ break;
+ default:
+ break;
+ }
+ $value_set = array
+ (
+ 'calendar_id' =>
$object->get_id(),
+ 'time' => time(),
+ 'author' =>
$GLOBALS['phpgw_info']['user']['fullname'],
+ 'comment' => $label . '::
' . lang('old value') . ': ' . $this->db->db_addslashes($old_value) . ', '
.lang('new value') . ': ' . $this->db->db_addslashes($new_value),
+ 'type' => 'history',
+ );
+
+ $this->db->query( 'INSERT INTO
eventplanner_calendar_comment (' . implode( ',', array_keys( $value_set ) )
. ') VALUES ('
+ . $this->db->validate_insert(
array_values( $value_set ) ) . ')',__LINE__,__FILE__);
+ }
+
+ }
+ }
+
+ public function update_active_status($ids, $action )
+ {
+ if(!$ids || !is_array($ids))
+ {
+ return;
+ }
+
+ switch ($action)
+ {
+ case 'disable':
+ $sql = "UPDATE eventplanner_calendar
SET active = 0";
+ $where = 'WHERE';
+
+ break;
+ case 'enable':
+ $sql = "UPDATE eventplanner_calendar
SET active = 1";
+ $where = 'WHERE';
+ break;
+
+ case 'delete':
+ $sql = "DELETE FROM
eventplanner_calendar WHERE customer_id IS NULL";
+ $where = 'AND';
+ break;
+
+ case 'disconnect':
+ $sql = "DELETE FROM
eventplanner_booking WHERE calendar_id IN(". implode(',', $ids) . ')';
+ return
$this->db->query($sql,__LINE__,__FILE__);
+
+ default:
+ throw new Exception("action {$action}
not supported");
+ break;
+ }
+
+ $sql .= " {$where} id IN(". implode(',', $ids) . ')';
+ $this->db->transaction_begin();
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+
+ return $this->db->transaction_commit();
+ }
+ }
\ No newline at end of file
Modified: trunk/eventplanner/inc/class.sopermission.inc.php
===================================================================
--- trunk/eventplanner/inc/class.sopermission.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.sopermission.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -66,51 +66,12 @@
protected function update( $object )
{
- $this->db->transaction_begin();
- // $status_text =
eventplanner_permission::get_status_list();
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $lang_active = lang('active');
- $lang_inactive = lang('inactive');
+ return parent::update($object);
+ }
- $original =
$this->read_single($object->get_id());//returned as array()
- foreach ($this->fields as $field => $params)
- {
- $new_value = $object->$field;
- $old_value = $original[$field];
- if (!empty($params['history']) && ($new_value
!= $old_value))
- {
- $label = !empty($params['label']) ?
lang($params['label']) : $field;
- switch ($field)
- {
- case 'status':
- $old_value =
$status_text[$old_value];
- $new_value =
$status_text[$new_value];
- break;
- case 'active':
- $old_value = $old_value
? $lang_active : $lang_inactive;
- $new_value = $new_value
? $lang_active : $lang_inactive;
- break;
- default:
- break;
- }
- $value_set = array
- (
- 'permission_id' =>
$object->get_id(),
- 'time' => time(),
- 'author' =>
$GLOBALS['phpgw_info']['user']['fullname'],
- 'comment' => $label . '::
' . lang('old value') . ': ' . $this->db->db_addslashes($old_value) . ', '
.lang('new value') . ': ' . $this->db->db_addslashes($new_value),
- 'type' => 'history',
- );
-
- $this->db->query( 'INSERT INTO
eventplanner_permission_comment (' . implode( ',', array_keys( $value_set ) )
. ') VALUES ('
- . $this->db->validate_insert(
array_values( $value_set ) ) . ')',__LINE__,__FILE__);
- }
-
- }
-
- parent::update($object);
-
- return $this->db->transaction_commit();
+ public function delete( $id )
+ {
+ return $this->db->query( 'DELETE FROM
eventplanner_permission WHERE id=' . (int) $id ,__LINE__,__FILE__);
}
}
\ No newline at end of file
Modified: trunk/eventplanner/inc/class.uiapplication.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uiapplication.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.uiapplication.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -175,7 +175,7 @@
)
);
- $data['datatable']['actions'][] = array
+/* $data['datatable']['actions'][] = array
(
'my_name' => 'view',
'text' => lang('show'),
@@ -185,7 +185,7 @@
)),
'parameters' => json_encode($parameters)
);
-
+*/
$data['datatable']['actions'][] = array
(
'my_name' => 'edit',
@@ -315,7 +315,7 @@
'type' => 'custom',
'className' => 'add',
'custom_code' => "
- add_booking();"
+ add_schedule();"
),
array('my_name' => 'select_all'),
array('my_name' => 'select_none'),
@@ -358,9 +358,10 @@
$datatable_def[] = array(
'container' => 'datatable-container_1',
- 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
"{$this->currentapp}.uibooking.query_relaxed",
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
"{$this->currentapp}.uicalendar.query_relaxed",
'filter_application_id' => $id,
'filter_active' => 1,
+ 'redirect' => 'booking',
'phpgw_return_as' => 'json'))),
'tabletools' => $tabletools,
'ColumnDefs' => $dates_def,
Modified: trunk/eventplanner/inc/class.uibooking.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uibooking.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.uibooking.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -44,8 +44,6 @@
'edit' => true,
'save' => true,
'save_ajax' => true,
- 'update_active_status' => true,
- 'update_schedule' => true
);
protected
$fields,
@@ -125,7 +123,7 @@
)
);
- $data['datatable']['actions'][] = array
+/* $data['datatable']['actions'][] = array
(
'my_name' => 'view',
'text' => lang('show'),
@@ -135,7 +133,7 @@
)),
'parameters' => json_encode($parameters)
);
-
+*/
$data['datatable']['actions'][] = array
(
'my_name' => 'edit',
@@ -172,9 +170,19 @@
else
{
$id = !empty($values['id']) ? $values['id'] :
phpgw::get_var('id', 'int');
+ $calendar_id = phpgw::get_var('calendar_id',
'int');
+ if(!$id && $calendar_id)
+ {
+ $id =
$this->bo->get_booking_id_from_calendar($calendar_id);
+ }
$booking = $this->bo->read_single($id);
}
+ if(!$calendar_id)
+ {
+ $calendar_id = $booking->calendar_id;
+ }
+
$tabs = array();
$tabs['first_tab'] = array(
'label' => lang('booking'),
@@ -279,13 +287,9 @@
)
);
- $application =
createObject('eventplanner.boapplication')->read_single($booking->application_id,
true, $relaxe_acl = true);
+ $calendar =
createObject('eventplanner.bocalendar')->read_single($calendar_id, true,
$relaxe_acl = true);
-// $GLOBALS['phpgw']->jqcal2->add_listener('from_',
'datetime', $booking->from_, array(
-// 'min_date' => date('Y/m/d',
$application->date_start),
-// 'max_date' => date('Y/m/d',
$application->date_end)
-// )
-// );
+ $application =
createObject('eventplanner.boapplication')->read_single($calendar->application_id,
true, $relaxe_acl = true);
$application_type_list =
execMethod('eventplanner.bogeneric.get_list', array('type' =>
'application_type'));
$types = (array)$application->types;
@@ -304,22 +308,24 @@
}
}
-
-
-
- $application_url = self::link(array('menuaction' =>
"{$this->currentapp}.uiapplication.edit", 'id' => $booking->application_id));
+ $application_url = self::link(array('menuaction' =>
"{$this->currentapp}.uiapplication.edit", 'id' => $calendar->application_id));
$lang_application = lang('application');
if($this->currentapp == 'eventplannerfrontend')
{
- $application_url =
self::link(array('menuaction' => "{$this->currentapp}.uievents.edit", 'id' =>
$booking->application_id));
+ $application_url =
self::link(array('menuaction' => "{$this->currentapp}.uievents.edit", 'id' =>
$calendar->application_id));
$lang_application = lang('event');
}
+ if($booking->customer_id && !$booking->customer_name)
+ {
+ $booking->customer_name =
createObject('eventplanner.bocustomer')->read_single($booking->customer_id)->name;
+ }
$data = array(
'datatable_def' => $datatable_def,
- 'form_action' => self::link(array('menuaction'
=> "{$this->currentapp}.uibooking.save")),
+ 'form_action' => self::link(array('menuaction'
=> "{$this->currentapp}.uibooking.save", 'calendar_id' => $calendar_id)),
'cancel_url' => self::link(array('menuaction'
=> "{$this->currentapp}.uibooking.index",)),
+ 'calendar' =>$calendar,
'booking' => $booking,
'application' => $application,
'application_type_list' =>
$application_type_list,
@@ -346,53 +352,4 @@
{
return parent::save(true);
}
-
- public function update_active_status()
- {
- $ids = phpgw::get_var('ids', 'int');
- $action = phpgw::get_var('action', 'string');
-
- if ($this->bo->update_active_status($ids, $action))
- {
- return array(
- 'status_kode' => 'ok',
- 'status' => lang('ok'),
- 'msg' => lang('messages_saved_form')
- );
- }
- else
- {
- $messages = phpgwapi_cache::message_get(true);
- return array(
- 'status_kode' => 'error',
- 'status' => lang('error'),
- 'msg' => $messages ? $messages :
lang('did not validate')
- );
- }
- }
-
- public function update_schedule( )
- {
- $id = phpgw::get_var('id', 'int');
- $from_ = phpgw::get_var('from_', 'date');
- if ($this->bo->update_schedule($id, $from_))
- {
- return array(
- 'status_kode' => 'ok',
- 'status' => lang('ok'),
- 'msg' => lang('messages_saved_form')
- );
- }
- else
- {
- $messages = phpgwapi_cache::message_get(true);
- return array
- (
- 'status_kode' => 'error',
- 'status' => lang('error'),
- 'msg' => $messages ? $messages :
lang('did not validate')
- );
- }
-
- }
}
\ No newline at end of file
Added: trunk/eventplanner/inc/class.uicalendar.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uicalendar.inc.php
(rev 0)
+++ trunk/eventplanner/inc/class.uicalendar.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -0,0 +1,420 @@
+<?php
+ /**
+ * phpGroupWare - eventplanner: a part of a Facilities Management
System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this calendar was funded by
http://www.bergen.kommune.no/
+ * @package eventplanner
+ * @subpackage calendar
+ * @version $Id: $
+ */
+ phpgw::import_class('phpgwapi.uicommon');
+ phpgw::import_class('phpgwapi.datetime');
+
+ include_class('eventplanner', 'calendar', 'inc/model/');
+
+ class eventplanner_uicalendar extends phpgwapi_uicommon
+ {
+
+ public $public_functions = array(
+ 'add' => true,
+ 'index' => true,
+ 'query' => true,
+ 'query_relaxed'=> true,
+ 'get_list'=> true,
+ 'view' => true,
+ 'edit' => true,
+ 'save' => true,
+ 'save_ajax' => true,
+ 'update_active_status' => true,
+ 'update_schedule' => true
+ );
+ protected
+ $fields,
+ $permissions,
+ $currentapp;
+
+ public function __construct()
+ {
+ parent::__construct();
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('calendar');
+ $this->bo = createObject('eventplanner.bocalendar');
+ $this->fields = eventplanner_calendar::get_fields();
+ $this->permissions =
eventplanner_calendar::get_instance()->get_permission_array();
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ self::set_active_menu("{$this->currentapp}::calendar");
+ }
+
+ public function index()
+ {
+ if (empty($this->permissions[PHPGW_ACL_READ]))
+ {
+ phpgw::no_access();
+ }
+
+ if (phpgw::get_var('phpgw_return_as') == 'json')
+ {
+ return $this->query();
+ }
+
+ phpgwapi_jquery::load_widget('autocomplete');
+
+ $function_msg = lang('calendar');
+
+ $data = array(
+ 'datatable_name' => $function_msg,
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array(
+ 'type' =>
'autocomplete',
+ 'name' =>
'application',
+ 'app' =>
$this->currentapp,
+ 'ui' =>
'application',
+ 'function' =>
'get_list',
+ 'label_attr' =>
'title',
+ 'text' =>
lang('application') . ':',
+
'requestGenerator' => 'requestWithApplicationFilter'
+ ),
+ array(
+ 'type' =>
'checkbox',
+ 'name' =>
'filter_active',
+ 'text' =>
lang('showall'),
+ 'value' => 1,
+ 'checked' => 1,
+ )
+ )
+ )
+ ),
+ 'datatable' => array(
+ 'source' => self::link(array(
+ 'menuaction' =>
"{$this->currentapp}.uicalendar.index",
+ 'phpgw_return_as' => 'json'
+ )),
+ 'allrows' => true,
+ // 'new_item' =>
self::link(array('menuaction' => 'eventplanner.uicalendar.add')),
+ 'editor_action' => '',
+ 'field' => parent::_get_fields()
+ )
+ );
+
+ $parameters = array(
+ 'parameter' => array(
+ array(
+ 'name' => 'id',
+ 'source' => 'id'
+ )
+ )
+ );
+
+/* $data['datatable']['actions'][] = array
+ (
+ 'my_name' => 'view',
+ 'text' => lang('show'),
+ 'action' => self::link(array
+ (
+ 'menuaction' =>
"{$this->currentapp}.uicalendar.view"
+ )),
+ 'parameters' => json_encode($parameters)
+ );
+*/
+ $data['datatable']['actions'][] = array
+ (
+ 'my_name' => 'edit',
+ 'text' => lang('edit'),
+ 'action' => self::link(array
+ (
+ 'menuaction' =>
"{$this->currentapp}.uicalendar.edit"
+ )),
+ 'parameters' => json_encode($parameters)
+ );
+
+ self::add_javascript($this->currentapp, 'portico',
'calendar.index.js');
+ phpgwapi_jquery::load_widget('numberformat');
+
+ self::render_template_xsl('datatable_jquery', $data);
+ }
+ /*
+ * Edit the price item with the id given in the http variable
'id'
+ */
+
+ public function edit( $values = array(), $mode = 'edit' )
+ {
+ $active_tab = !empty($values['active_tab']) ?
$values['active_tab'] : phpgw::get_var('active_tab', 'string', 'REQUEST',
'first_tab');
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('edit');
+ if (empty($this->permissions[PHPGW_ACL_ADD]))
+ {
+ phpgw::no_access();
+ }
+
+ if (!empty($values['object']))
+ {
+ $calendar = $values['object'];
+ }
+ else
+ {
+ $id = !empty($values['id']) ? $values['id'] :
phpgw::get_var('id', 'int');
+ $calendar = $this->bo->read_single($id);
+ }
+
+ $tabs = array();
+ $tabs['first_tab'] = array(
+ 'label' => lang('calendar'),
+ 'link' => '#first_tab',
+ 'function' => "set_tab('first_tab')"
+ );
+ $tabs['reports'] = array(
+ 'label' => lang('reports'),
+ 'link' => '#reports',
+ 'function' => "set_tab('reports')"
+ );
+
+ $bocommon = CreateObject('property.bocommon');
+
+ $comments = (array)$calendar->comments;
+ foreach ($comments as $key => &$comment)
+ {
+ $comment['value_count'] = $key +1;
+ $comment['value_date'] =
$GLOBALS['phpgw']->common->show_date($comment['time']);
+ }
+
+ $comments_def = array(
+ array('key' => 'value_count', 'label' => '#',
'sortable' => true, 'resizeable' => true),
+ array('key' => 'value_date', 'label' =>
lang('Date'), 'sortable' => true, 'resizeable' => true),
+ array('key' => 'author', 'label' =>
lang('User'), 'sortable' => true, 'resizeable' => true),
+ array('key' => 'comment', 'label' =>
lang('Note'), 'sortable' => true, 'resizeable' => true)
+ );
+
+ $datatable_def[] = array(
+ 'container' => 'datatable-container_0',
+ 'requestUrl' => "''",
+ 'ColumnDefs' => $comments_def,
+ 'data' => json_encode($comments),
+ 'config' => array(
+ array('disableFilter' => true),
+ array('disablePagination' => true)
+ )
+ );
+
+ $vendor_report_def = array(
+ array('key' => 'id', 'label' => lang('id'),
'sortable' => true, 'resizeable' => true,'formatter' =>
'JqueryPortico.formatLink'),
+ array('key' => 'created', 'label' =>
lang('Date'), 'sortable' => true, 'resizeable' => true),
+ );
+
+ $vendor_report = array();
+
+ $tabletools = array(
+ array(
+ 'my_name' => 'add',
+ 'text' => lang('add'),
+ 'type' => 'custom',
+ 'className' => 'add',
+ 'custom_code' => "
+
add_report('vendor');"
+ )
+ );
+
+ $datatable_def[] = array(
+ 'container' => 'datatable-container_1',
+ 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
"{$this->currentapp}.uivendor_report.query",
+ 'filter_calendar_id' => $id,
+ 'filter_active' => 1,
+ 'phpgw_return_as' => 'json'))),
+ 'ColumnDefs' => $vendor_report_def,
+ 'data' => json_encode($vendor_report),
+ 'tabletools' => $tabletools,
+ 'config' => array(
+ array('disableFilter' => true),
+ array('disablePagination' => true)
+ )
+ );
+
+ $customer_report_def = array(
+ array('key' => 'id', 'label' => lang('id'),
'sortable' => true, 'resizeable' => true,'formatter' =>
'JqueryPortico.formatLink'),
+ array('key' => 'created', 'label' =>
lang('Date'), 'sortable' => true, 'resizeable' => true),
+ );
+
+ $customer_report = array();
+ $tabletools = array(
+ array(
+ 'my_name' => 'add',
+ 'text' => lang('add'),
+ 'type' => 'custom',
+ 'className' => 'add',
+ 'custom_code' => "
+
add_report('customer');"
+ )
+ );
+ $datatable_def[] = array(
+ 'container' => 'datatable-container_2',
+// 'requestUrl' =>
json_encode(self::link(array('menuaction' =>
"{$this->currentapp}.uicustomer_report.query",
+// 'filter_calendar_id' => $id,
+// 'filter_active' => 1,
+// 'phpgw_return_as' => 'json'))),
+ 'requestUrl' => "''",
+ 'ColumnDefs' => $customer_report_def,
+ 'data' => json_encode($customer_report),
+ 'tabletools' => $tabletools,
+ 'config' => array(
+ array('disableFilter' => true),
+ array('disablePagination' => true)
+ )
+ );
+
+ $application =
createObject('eventplanner.boapplication')->read_single($calendar->application_id,
true, $relaxe_acl = true);
+
+// $GLOBALS['phpgw']->jqcal2->add_listener('from_',
'datetime', $calendar->from_, array(
+// 'min_date' => date('Y/m/d',
$application->date_start),
+// 'max_date' => date('Y/m/d',
$application->date_end)
+// )
+// );
+
+ $application_type_list =
execMethod('eventplanner.bogeneric.get_list', array('type' =>
'application_type'));
+ $types = (array)$application->types;
+ if($types)
+ {
+ foreach ($application_type_list as
&$application_type)
+ {
+ foreach ($types as $type)
+ {
+ if((!empty($type['type_id']) &&
$type['type_id'] == $application_type['id']) || ($type ==
$application_type['id']))
+ {
+
$application_type['selected'] = 1;
+ break;
+ }
+ }
+ }
+ }
+
+
+
+
+ $application_url = self::link(array('menuaction' =>
"{$this->currentapp}.uiapplication.edit", 'id' => $calendar->application_id));
+ $lang_application = lang('application');
+ if($this->currentapp == 'eventplannerfrontend')
+ {
+ $application_url =
self::link(array('menuaction' => "{$this->currentapp}.uievents.edit", 'id' =>
$calendar->application_id));
+ $lang_application = lang('event');
+ }
+
+
+ $data = array(
+ 'datatable_def' => $datatable_def,
+ 'form_action' => self::link(array('menuaction'
=> "{$this->currentapp}.uicalendar.save")),
+ 'cancel_url' => self::link(array('menuaction'
=> "{$this->currentapp}.uicalendar.index",)),
+ 'calendar' => $calendar,
+ 'application' => $application,
+ 'application_type_list' =>
$application_type_list,
+ 'new_customer_url' =>
self::link(array('menuaction' => "{$this->currentapp}.uicustomer.add")),
+ 'application_url' => $application_url,
+ 'lang_application' => $lang_application,
+ 'customer_url' => self::link(array('menuaction'
=> "{$this->currentapp}.uicustomer.edit", 'id' => $calendar->customer_id)),
+ 'mode' => $mode,
+ 'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+ 'value_active_tab' => $active_tab
+ );
+ phpgwapi_jquery::formvalidator_generate(array());
+ self::add_javascript($this->currentapp, 'portico',
'calendar.edit.js');
+ phpgwapi_jquery::load_widget('autocomplete');
+ self::render_template_xsl(array('calendar',
'datatable_inline'), array($mode => $data));
+ }
+
+ public function save()
+ {
+ parent::save();
+ }
+
+ public function save_ajax()
+ {
+ return parent::save(true);
+ }
+
+ public function update_active_status()
+ {
+ $ids = phpgw::get_var('ids', 'int');
+ $action = phpgw::get_var('action', 'string');
+
+ if ($this->bo->update_active_status($ids, $action))
+ {
+ return array(
+ 'status_kode' => 'ok',
+ 'status' => lang('ok'),
+ 'msg' => lang('messages_saved_form')
+ );
+ }
+ else
+ {
+ $messages = phpgwapi_cache::message_get(true);
+ return array(
+ 'status_kode' => 'error',
+ 'status' => lang('error'),
+ 'msg' => $messages ? $messages :
lang('did not validate')
+ );
+ }
+ }
+
+ public function update_schedule( )
+ {
+ $id = phpgw::get_var('id', 'int');
+ $from_ = phpgw::get_var('from_', 'date');
+ if ($this->bo->update_schedule($id, $from_))
+ {
+ return array(
+ 'status_kode' => 'ok',
+ 'status' => lang('ok'),
+ 'msg' => lang('messages_saved_form')
+ );
+ }
+ else
+ {
+ $messages = phpgwapi_cache::message_get(true);
+ return array
+ (
+ 'status_kode' => 'error',
+ 'status' => lang('error'),
+ 'msg' => $messages ? $messages :
lang('did not validate')
+ );
+ }
+
+ }
+
+ public function query()
+ {
+ $params = $this->bo->build_default_read_params();
+ $values = $this->bo->read($params);
+ $redirect = phpgw::get_var('redirect');
+ if($redirect == 'booking')
+ {
+ array_walk($values["results"], array($this,
"_add_links2"), "{$this->currentapp}.uibooking.edit");
+ }
+ else
+ {
+ array_walk($values["results"], array($this,
"_add_links"), "{$this->currentapp}.uicalendar.edit");
+ }
+ return $this->jquery_results($values);
+ }
+
+ public function _add_links2( &$value, $key, $data )
+ {
+ $link_array = array('menuaction' => $data,
'calendar_id' => $value['id']);
+ $value['link'] = self::link($link_array);
+ }
+ }
\ No newline at end of file
Modified: trunk/eventplanner/inc/class.uicustomer.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uicustomer.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.uicustomer.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -139,7 +139,7 @@
)
);
- $data['datatable']['actions'][] = array
+/* $data['datatable']['actions'][] = array
(
'my_name' => 'view',
'text' => lang('show'),
@@ -149,7 +149,7 @@
)),
'parameters' => json_encode($parameters)
);
-
+*/
$data['datatable']['actions'][] = array
(
'my_name' => 'edit',
Modified: trunk/eventplanner/inc/class.uicustomer_report.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uicustomer_report.inc.php 2017-03-27
06:35:15 UTC (rev 16489)
+++ trunk/eventplanner/inc/class.uicustomer_report.inc.php 2017-03-28
13:54:48 UTC (rev 16490)
@@ -131,7 +131,7 @@
)
);
- $data['datatable']['actions'][] = array
+/* $data['datatable']['actions'][] = array
(
'my_name' => 'view',
'text' => lang('show'),
@@ -141,7 +141,7 @@
)),
'parameters' => json_encode($parameters)
);
-
+*/
$data['datatable']['actions'][] = array
(
'my_name' => 'edit',
Modified: trunk/eventplanner/inc/class.uipermission.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uipermission.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.uipermission.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -41,7 +41,8 @@
'view' => true,
'edit' => true,
'save' => true,
- 'object' => true
+ 'object' => true,
+ 'delete' => true
);
protected
@@ -136,6 +137,23 @@
'parameters' => json_encode($parameters)
);
+ if (!empty($this->permissions[PHPGW_ACL_ADD]))
+ {
+ $data['datatable']['actions'][] = array
+ (
+ 'my_name' => 'delete',
+ 'statustext' => lang('delete entry'),
+ 'text' => lang('delete'),
+ 'confirm_msg' => lang('do you really
want to delete this entry'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php', array
+ (
+ 'menuaction' =>
'eventplanner.uipermission.delete'
+ )),
+ 'parameters' => json_encode($parameters)
+ );
+
+ }
+
self::add_javascript('eventplanner', 'portico',
'permission.index.js');
phpgwapi_jquery::load_widget('numberformat');
@@ -142,6 +160,23 @@
self::render_template_xsl('datatable_jquery', $data);
}
+ function delete()
+ {
+ if (empty($this->permissions[PHPGW_ACL_DELETE]))
+ {
+ phpgw::no_access();
+ }
+
+ $id = phpgw::get_var('id', 'int');
+ if ($this->bo->delete($id))
+ {
+ return lang('entry %1 has been deleted', $id);
+ }
+ else
+ {
+ return lang('delete failed');
+ }
+ }
/*
* Edit the price item with the id given in the http variable
'id'
*/
Modified: trunk/eventplanner/inc/class.uivendor.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uivendor.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/class.uivendor.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -140,7 +140,7 @@
)
);
- $data['datatable']['actions'][] = array
+/* $data['datatable']['actions'][] = array
(
'my_name' => 'view',
'text' => lang('show'),
@@ -150,7 +150,7 @@
)),
'parameters' => json_encode($parameters)
);
-
+*/
$data['datatable']['actions'][] = array
(
'my_name' => 'edit',
Modified: trunk/eventplanner/inc/model/class.booking.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.booking.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/model/class.booking.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -37,7 +37,7 @@
const STATUS_PENDING = 2;
const STATUS_REJECTED = 3;
const STATUS_APPROVED = 4;
- const acl_location = '.booking';
+ const acl_location = '.customer';
protected
$id,
@@ -47,8 +47,7 @@
$cost,
$from_,
$to_,
- $application_id,
- $application_name,
+ $calendar_id,
$vendor_name,
$customer_id,
$customer_name,
@@ -61,7 +60,7 @@
$created,
$secret,
$process_update;
- protected $field_of_responsibility_name = '.booking';
+ protected $field_of_responsibility_name = '.customer';
public function __construct( int $id = null )
{
@@ -99,55 +98,54 @@
'formatter' =>
'JqueryPortico.formatLink',
'public' => true
),
- 'owner_id' => array('action' => PHPGW_ACL_ADD,
+ 'calendar_id' => array('action' =>
PHPGW_ACL_ADD,
'type' => 'int',
'required' => false
),
- 'active' => array('action' => PHPGW_ACL_ADD |
PHPGW_ACL_EDIT,
+ 'owner_id' => array('action' => PHPGW_ACL_ADD,
'type' => 'int',
- 'public' => true,
- 'history' => true
+ 'required' => false
),
- 'completed' => array('action' => PHPGW_ACL_EDIT,
- 'type' => 'int',
- '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,
- 'type' => 'date',
+ 'from_' => array('action' => PHPGW_ACL_READ,
+ 'type' => 'string',
+ 'query' => true,
'label' => 'from',
- 'history' => true,
- 'required' => true,
- 'public' => true
+ 'public' => true,
+ 'join' => array(
+ 'table' =>
'eventplanner_calendar',
+ 'fkey' => 'calendar_id',
+ 'key' => 'id',
+ 'column' => 'from_'
+ )
),
- 'to_' => array('action' => PHPGW_ACL_READ |
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
- 'type' => 'date',
+ 'to_' => array('action' => PHPGW_ACL_READ,
+ 'type' => 'string',
+ 'query' => true,
'label' => 'to',
- 'history' => true,
- 'required' => true,
- 'public' => true
+ 'public' => true,
+ 'join' => array(
+ 'table' =>
'eventplanner_calendar',
+ 'fkey' => 'calendar_id',
+ 'key' => 'id',
+ 'column' => 'to_'
+ )
),
- '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,
+ 'active' => array('action' => PHPGW_ACL_READ,
'type' => 'string',
'query' => true,
- 'label' => 'application',
+ 'label' => 'active',
'public' => true,
'join' => array(
- 'table' =>
'eventplanner_application',
- 'fkey' => 'application_id',
+ 'table' =>
'eventplanner_calendar',
+ 'fkey' => 'calendar_id',
'key' => 'id',
- 'column' => 'title'
+ 'column' => 'active'
)
),
+ 'completed' => array('action' => PHPGW_ACL_EDIT,
+ 'type' => 'int',
+ 'history' => true
+ ),
'vendor_name' => array('action' =>
PHPGW_ACL_READ,
'type' => 'string',
'query' => true,
@@ -154,8 +152,9 @@
'label' => 'vendor',
'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',
+ 'statement' => ' JOIN
eventplanner_calendar ON eventplanner_calendar.id =
eventplanner_booking.calendar_id'
+ . ' JOIN
eventplanner_application ON eventplanner_application.id =
eventplanner_calendar.application_id'
+ . ' JOIN eventplanner_vendor ON
eventplanner_application.vendor_id = eventplanner_vendor.id',
'column' =>
'eventplanner_vendor.name'
)
),
@@ -291,26 +290,12 @@
protected function doValidate( $entity, &$errors )
{
- $application =
createObject('eventplanner.boapplication')->read_single($entity->application_id);
$params = array();
$params['filters']['active'] = 1;
- $params['filters']['application_id'] =
$entity->application_id;
+ $params['filters']['customer_id'] =
$entity->customer_id;
$bookings =
eventplanner_sobooking::get_instance()->read($params);
- foreach ($bookings['results'] as $booking)
- {
- if ($booking['id'] == $entity->get_id())
- {
- continue;
- }
-
- if (($entity->from_ > $booking['from_'] &&
$entity->from_ < $booking['to_']) || ($entity->to_ > $booking['from_'] &&
$entity->to_ < $booking['to_']))
- {
- $errors['from_'] = lang('Time is
already booked');
- }
- }
-
$orig_customer_id = 0;
if ($entity->get_id())
{
@@ -318,27 +303,24 @@
$orig_customer_id = $orig_booking->customer_id;
}
- $number_of_customer_bookings = 0;
+ $test_total_tecords = 0;
if ($entity->customer_id && $entity->customer_id !=
$orig_customer_id)
{
+ $last_booking =
(int)phpgwapi_cache::system_get('eventplanner',
"last_booking{$entity->customer_id}");
$config = CreateObject('phpgwapi.config',
'eventplanner')->read();
$booking_interval =
!empty($config['booking_interval']) ? (int)$config['booking_interval'] : 0;
+
+ $current_interval = floor((time() -
$last_booking ) / (60 * 60));
+
+ if ($last_booking && $booking_interval &&
$current_interval < $booking_interval)
+ {
+ $errors['booking_interval'] =
lang('There is a minimum interval of %1 hours', $booking_interval);
+ }
+
$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_))
@@ -345,41 +327,22 @@
{
continue;
}
+ $test_total_tecords ++;
+ }
- if ($booking['customer_id'] ==
$entity->customer_id)
- {
- $number_of_customer_bookings ++;
- }
+ if ($entity->customer_id ||
$entity->process_update) // update
+ {
}
+ else // new entry
+ {
+ $test_total_tecords ++;
+ }
- if ($max_events && $number_of_customer_bookings
>= $max_events)
+ if ($test_total_tecords > (int)$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
- {
- $test_total_tecords =
(int)$bookings['total_records'] + 1;
- }
-
- 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_);
-
- if ($from_ < $date_start || $from_ > $date_end)
- {
- $errors['from_'] = lang('date is outside the
scope');
- }
}
protected function generate_secret( $length = 10 )
Added: trunk/eventplanner/inc/model/class.calendar.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.calendar.inc.php
(rev 0)
+++ trunk/eventplanner/inc/model/class.calendar.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -0,0 +1,308 @@
+<?php
+ /**
+ * phpGroupWare - eventplanner: a part of a Facilities Management
System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package eventplanner
+ * @subpackage calendar
+ * @version $Id: $
+ */
+ phpgw::import_class('eventplanner.bocalendar');
+
+ include_class('phpgwapi', 'model', 'inc/model/');
+
+ class eventplanner_calendar extends phpgwapi_model
+ {
+
+ const STATUS_REGISTERED = 1;
+ const STATUS_PENDING = 2;
+ const STATUS_REJECTED = 3;
+ const STATUS_APPROVED = 4;
+ const acl_location = '.calendar';
+
+ protected
+ $id,
+ $owner_id,
+ $active,
+ $completed,
+ $cost,
+ $from_,
+ $to_,
+ $application_id,
+ $application_name,
+ $vendor_name,
+ $customer_id,
+ $customer_name,
+ $customer_contact_name,
+ $customer_contact_email,
+ $customer_contact_phone,
+ $location,
+ $comments,
+ $comment,
+ $created,
+ $secret,
+ $process_update;
+ protected $field_of_responsibility_name = '.calendar';
+
+ public function __construct( int $id = null )
+ {
+ parent::__construct((int)$id);
+ $this->field_of_responsibility_name =
self::acl_location;
+ }
+
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public static function get_instance()
+ {
+ return new eventplanner_calendar();
+ }
+
+ public static function get_status_list()
+ {
+ return array(
+ self::STATUS_REGISTERED => lang('registered'),
+ self::STATUS_PENDING => lang('pending'),
+ self::STATUS_REJECTED => lang('rejected'),
+ self::STATUS_APPROVED => lang('approved')
+ );
+ }
+
+ public static function get_fields( $debug = true )
+ {
+ $fields = array(
+ 'id' => array('action' => PHPGW_ACL_READ,
+ 'type' => 'int',
+ 'label' => 'id',
+ 'sortable' => true,
+ 'formatter' =>
'JqueryPortico.formatLink',
+ 'public' => true
+ ),
+ 'owner_id' => array('action' => PHPGW_ACL_ADD,
+ 'type' => 'int',
+ 'required' => false
+ ),
+ 'active' => array('action' => PHPGW_ACL_ADD |
PHPGW_ACL_EDIT,
+ 'type' => 'int',
+ 'public' => true,
+ 'history' => true
+ ),
+ 'completed' => array('action' => PHPGW_ACL_EDIT,
+ 'type' => 'int',
+ '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,
+ 'type' => 'date',
+ 'label' => 'from',
+ 'history' => true,
+ 'required' => true,
+ 'public' => true
+ ),
+ 'to_' => array('action' => PHPGW_ACL_READ |
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+ 'type' => 'date',
+ 'label' => 'to',
+ 'history' => true,
+ 'required' => true,
+ 'public' => true
+ ),
+ '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,
+ 'type' => 'string',
+ 'query' => true,
+ 'label' => 'application',
+ 'public' => true,
+ 'join' => array(
+ 'table' =>
'eventplanner_application',
+ 'fkey' => 'application_id',
+ 'key' => 'id',
+ 'column' => 'title'
+ )
+ ),
+ 'location' => array('action' => PHPGW_ACL_READ,
+ 'type' => 'string',
+ 'query' => true,
+ 'label' => 'location',
+ 'public' => true,
+ 'join' => array(
+ 'table' =>
'eventplanner_booking',
+ 'fkey' => 'id',
+ 'key' => 'calendar_id',
+ 'column' => 'location'
+ )
+ ),
+ 'vendor_name' => array('action' =>
PHPGW_ACL_READ,
+ 'type' => 'string',
+ 'query' => true,
+ 'label' => 'vendor',
+ 'public' => true,
+ 'multiple_join' => array(
+ 'statement' => 'LEFT JOIN
eventplanner_application ON eventplanner_application.id =
eventplanner_calendar.application_id'
+ . ' LEFT JOIN
eventplanner_vendor ON eventplanner_application.vendor_id =
eventplanner_vendor.id',
+ 'column' =>
'eventplanner_vendor.name'
+ )
+ ),
+ 'customer_name' => array('action' =>
PHPGW_ACL_READ,
+ 'type' => 'string',
+ 'query' => true,
+ 'label' => 'customer',
+ 'public' => true,
+ 'multiple_join' => array(
+ 'statement' => 'LEFT JOIN
eventplanner_booking ON eventplanner_booking.calendar_id =
eventplanner_calendar.id'
+ . ' LEFT JOIN
eventplanner_customer ON eventplanner_booking.customer_id =
eventplanner_customer.id',
+ 'column' =>
'eventplanner_customer.name'
+ )
+ ),
+ 'created' => array('action' => PHPGW_ACL_READ,
+ 'type' => 'date',
+ 'label' => 'created',
+ 'sortable' => true,
+ )
+ );
+
+ if ($debug)
+ {
+ foreach ($fields as $field => $field_info)
+ {
+ if
(!property_exists('eventplanner_calendar', $field))
+ {
+ phpgwapi_cache::message_set('$'
. "{$field},", 'error');
+ }
+ }
+ }
+ return $fields;
+ }
+
+ /**
+ * Implement in subclasses to perform actions on entity before
validation
+ */
+ protected function preValidate( &$entity )
+ {
+ if (!empty($entity->comment))
+ {
+ $entity->comment_input = array(
+ 'time' => time(),
+ 'author' =>
$GLOBALS['phpgw_info']['user']['fullname'],
+ 'comment' => $entity->comment,
+ 'type' => 'comment'
+ );
+ }
+
+ if (!$entity->get_id())
+ {
+ $entity->status =
eventplanner_calendar::STATUS_REGISTERED;
+ $entity->secret = self::generate_secret();
+ $entity->owner_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+ if (empty($entity->completed))
+ {
+ $entity->completed = 0;
+ }
+
+ if (!empty($entity->application_id))
+ {
+ $application =
createObject('eventplanner.boapplication')->read_single($entity->application_id,
true, $relaxe_acl = true);
+ $entity->to_ = $entity->from_ +
((int)$application->timespan * 60);
+ }
+
+ $entity->modified = time();
+ $entity->active = (int)$entity->active;
+ }
+
+ protected function doValidate( $entity, &$errors )
+ {
+ $application =
createObject('eventplanner.boapplication')->read_single($entity->application_id);
+ $params = array();
+ $params['filters']['active'] = 1;
+ $params['filters']['application_id'] =
$entity->application_id;
+
+ $calendars =
eventplanner_socalendar::get_instance()->read($params);
+
+ foreach ($calendars['results'] as $calendar)
+ {
+ if ($calendar['id'] == $entity->get_id())
+ {
+ continue;
+ }
+
+ if (($entity->from_ > $calendar['from_'] &&
$entity->from_ < $calendar['to_']) || ($entity->to_ > $calendar['from_'] &&
$entity->to_ < $calendar['to_']))
+ {
+ $errors['from_'] = lang('Time is
already booked');
+ }
+ }
+
+
+ if ($entity->get_id()) // update
+ {
+ $test_total_tecords =
(int)$calendars['total_records'];
+ }
+ else // new entry
+ {
+ $test_total_tecords =
(int)$calendars['total_records'] + 1;
+ }
+
+ 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_);
+
+ if ($from_ < $date_start || $from_ > $date_end)
+ {
+ $errors['from_'] = lang('date is outside the
scope');
+ }
+ }
+
+ protected function generate_secret( $length = 10 )
+ {
+ return substr(base64_encode(rand(1000000000,
9999999999)), 0, $length);
+ }
+
+ public function serialize()
+ {
+ return self::toArray();
+ }
+
+ public function store()
+ {
+ return
eventplanner_bocalendar::get_instance()->store($this);
+ }
+
+ public function read_single( $id )
+ {
+ return
eventplanner_bocalendar::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-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/inc/model/class.customer.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -114,12 +114,12 @@
'category_id' => array('action'=>
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
'type' => 'int'
),
- 'created' => array('action'=> PHPGW_ACL_READ,
+/* 'created' => array('action'=> PHPGW_ACL_READ,
'type' => 'date',
'label' => 'created',
'sortable' => true,
- ),
- 'modified' => array('action'=> PHPGW_ACL_READ |
PHPGW_ACL_EDIT,
+ ),*/
+ 'modified' => array('action'=> PHPGW_ACL_EDIT,
'type' => 'date',
'label' => 'modified',
'sortable' => true,
Modified: trunk/eventplanner/js/portico/application.edit.js
===================================================================
--- trunk/eventplanner/js/portico/application.edit.js 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/js/portico/application.edit.js 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -260,7 +260,7 @@
$("#stage_size").val(total_size);
}
-add_booking = function ()
+add_schedule = function ()
{
var from_ = $("#from_").val();
if (!from_)
@@ -269,7 +269,7 @@
}
oArgs = {
- menuaction: 'eventplanner.uibooking.save_ajax',
+ menuaction: 'eventplanner.uicalendar.save_ajax',
application_id: $("#application_id").val()
};
@@ -319,7 +319,7 @@
{
return;
}
- oArgs = {menuaction: 'eventplanner.uibooking.update_schedule'};
+ oArgs = {menuaction: 'eventplanner.uicalendar.update_schedule'};
var requestUrl = phpGWLink('index.php', oArgs, true);
var htmlString = '';
@@ -364,7 +364,7 @@
$("#receipt").html("");
if (action === 'add')
{
- add_booking();
+ add_schedule();
return;
}
@@ -400,7 +400,7 @@
{
var data = {"ids": ids, "action": action, from_:
$("#from_").val()};
- oArgs = {menuaction:
'eventplanner.uibooking.update_active_status'};
+ oArgs = {menuaction:
'eventplanner.uicalendar.update_active_status'};
var requestUrl = phpGWLink('index.php', oArgs, true);
Modified: trunk/eventplanner/setup/default_records.inc.php
===================================================================
--- trunk/eventplanner/setup/default_records.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/setup/default_records.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -20,6 +20,7 @@
$GLOBALS['phpgw']->locations->add('.events', 'events', 'eventplanner',
$allow_grant = true, $custom_tbl = '', $c_function = true);
$GLOBALS['phpgw']->locations->add('.customer', 'customer',
'eventplanner', $allow_grant = true, $custom_tbl = '', $c_function = true);
$GLOBALS['phpgw']->locations->add('.vendor', 'vendor', 'eventplanner',
$allow_grant = true, $custom_tbl = '', $c_function = true);
+ $GLOBALS['phpgw']->locations->add('.calendar', 'calendar',
'eventplanner', $allow_grant = true);
$GLOBALS['phpgw']->locations->add('.booking', 'booking',
'eventplanner', $allow_grant = true, $custom_tbl = '', $c_function = true);
$GLOBALS['phpgw']->locations->add('.vendor_report', 'vendor_report',
'eventplanner', $allow_grant = true, $custom_tbl = '', $c_function = true,
$c_attrib = true);
$GLOBALS['phpgw']->locations->add('.customer_report',
'customer_report', 'eventplanner', $allow_grant = true, $custom_tbl = '',
$c_function = true, $c_attrib = true);
Modified: trunk/eventplanner/setup/phpgw_no.lang
===================================================================
--- trunk/eventplanner/setup/phpgw_no.lang 2017-03-27 06:35:15 UTC (rev
16489)
+++ trunk/eventplanner/setup/phpgw_no.lang 2017-03-28 13:54:48 UTC (rev
16490)
@@ -32,6 +32,7 @@
contact name eventplanner no Navn kontaktperson
contact email eventplanner no Epost kontaktperson
contact phone eventplanner no Tlf. kontaktperson
+contact email 2 eventplanner no Epost 2
case officer eventplanner no Saksbehandler
active eventplanner no Aktiv
inactive eventplanner no Inaktiv
@@ -118,4 +119,4 @@
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
+there is a minimum interval of %1 hours eventplanner no Det er
et minimumsintervall på %1 time(r)
\ No newline at end of file
Modified: trunk/eventplanner/setup/setup.inc.php
===================================================================
--- trunk/eventplanner/setup/setup.inc.php 2017-03-27 06:35:15 UTC (rev
16489)
+++ trunk/eventplanner/setup/setup.inc.php 2017-03-28 13:54:48 UTC (rev
16490)
@@ -11,7 +11,7 @@
* @version $Id: setup.inc.php 14728 2016-02-11 22:28:46Z sigurdne $
*/
$setup_info['eventplanner']['name'] = 'eventplanner';
- $setup_info['eventplanner']['version'] = '0.9.18.007';
+ $setup_info['eventplanner']['version'] = '0.9.18.008';
$setup_info['eventplanner']['app_order'] = 20;
$setup_info['eventplanner']['enable'] = 1;
$setup_info['eventplanner']['app_group'] = 'office';
@@ -55,6 +55,8 @@
'eventplanner_application_type',
'eventplanner_application',
'eventplanner_application_comment',
+ 'eventplanner_calendar',
+ 'eventplanner_calendar_comment',
'eventplanner_booking',
'eventplanner_booking_comment',
'eventplanner_booking_cost',
Modified: trunk/eventplanner/setup/tables_current.inc.php
===================================================================
--- trunk/eventplanner/setup/tables_current.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/setup/tables_current.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -50,7 +50,7 @@
'eventplanner_vendor_category' =>
array('category_id' => 'id'),
),
'ix' => array(),
- 'uc' => array()
+ 'uc' => array('organization_number')
),
'eventplanner_vendor_comment' => array(
'fd' => array(
@@ -229,16 +229,61 @@
'ix' => array(),
'uc' => array()
),
- 'eventplanner_booking' => array(
+ 'eventplanner_calendar' => array(
'fd' => array(
'id' => array('type' => 'auto', 'nullable' =>
False),
- 'customer_id' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ 'application_id' => array('type' => 'int',
'precision' => 4, 'nullable' => True),
+ // 'customer_id' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
'from_' => array('type' => 'int', 'precision'
=> '8', 'nullable' => False),
'to_' => array('type' => 'int', 'precision' =>
'8', 'nullable' => False),
'active' => array('type' => 'int', 'precision'
=> 4, 'nullable' => False, 'default' => '1'),
'completed' => array('type' => 'int',
'precision' => 4, 'nullable' => False,'default' => '0'),
'cost' => array('type' => 'decimal',
'precision' => 20, 'scale' => 2, 'nullable' => True,'default' => '0.00'),
- 'application_id' => array('type' => 'int',
'precision' => 4, 'nullable' => True),
+ // 'customer_contact_name' => array('type' =>
'text', 'nullable' => True),
+ // 'customer_contact_email' => array('type' =>
'text', 'nullable' => True),
+ // 'customer_contact_phone' => array('type' =>
'text', 'nullable' => True),
+ // 'location' => array('type' => 'text',
'nullable' => True),
+ // 'reminder' => array('type' => 'int',
'precision' => 4, 'nullable' => False, 'default' => '0'),
+ // 'secret' => array('type' => 'text', 'nullable'
=> False),
+ // 'sms_total' => array('type' => 'int',
'precision' => 4, 'nullable' => True),
+ 'owner_id' => array('type' => 'int',
'precision' => '4', 'nullable' => False),
+ 'public' => array('type' => 'int', 'precision'
=> '2', 'nullable' => True),
+ 'created' => array('type' => 'int', 'precision'
=> '8', 'nullable' => False, 'default' => 'current_timestamp'),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ // 'eventplanner_customer' => array('customer_id'
=> 'id'),
+ 'eventplanner_application' =>
array('application_id' => 'id'),
+ ),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'eventplanner_calendar_comment' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'nullable' =>
False),
+ 'calendar_id' => array('type' => 'int',
'precision' => '4', 'nullable' => False),
+ 'time' => array('type' => 'int', 'precision' =>
'8', 'nullable' => False),
+ 'author' => array('type' => 'text', 'nullable'
=> False),
+ 'comment' => array('type' => 'text', 'nullable'
=> False),
+ 'type' => array('type' => 'varchar',
'precision' => '20', 'nullable' => false,'default' => 'comment'),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'eventplanner_calendar' => array('calendar_id'
=> 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'eventplanner_booking' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'nullable' =>
False),
+ 'calendar_id' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ 'customer_id' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+// 'from_' => array('type' => 'int', 'precision'
=> '8', 'nullable' => False),
+// 'to_' => array('type' => 'int', 'precision' =>
'8', 'nullable' => False),
+// 'active' => array('type' => 'int', 'precision'
=> 4, 'nullable' => False, 'default' => '1'),
+ 'completed' => array('type' => 'int',
'precision' => 4, 'nullable' => False,'default' => '0'),
+// 'cost' => array('type' => 'decimal',
'precision' => 20, 'scale' => 2, 'nullable' => True,'default' => '0.00'),
+// 'application_id' => array('type' => 'int',
'precision' => 4, 'nullable' => True),
'customer_contact_name' => array('type' =>
'text', 'nullable' => True),
'customer_contact_email' => array('type' =>
'text', 'nullable' => True),
'customer_contact_phone' => array('type' =>
'text', 'nullable' => True),
@@ -252,8 +297,8 @@
),
'pk' => array('id'),
'fk' => array(
+ 'eventplanner_calendar' => array('calendar_id'
=> 'id'),
'eventplanner_customer' => array('customer_id'
=> 'id'),
- 'eventplanner_application' =>
array('application_id' => 'id'),
),
'ix' => array(),
'uc' => array()
Modified: trunk/eventplanner/setup/tables_update.inc.php
===================================================================
--- trunk/eventplanner/setup/tables_update.inc.php 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/setup/tables_update.inc.php 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -224,3 +224,134 @@
}
return $GLOBALS['setup_info']['eventplanner']['currentver'];
}
+
+ $test[] = '0.9.18.007';
+ function eventplanner_upgrade0_9_18_007()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw']->locations->add('.calendar', 'calendar',
'eventplanner', $allow_grant = true);
+ $GLOBALS['phpgw']->locations->add('.calendar', 'calendar',
'eventplannerfrontend', $allow_grant = true);
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable(
+ 'eventplanner_calendar', array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto',
'nullable' => False),
+ 'application_id' => array('type' =>
'int', 'precision' => 4, 'nullable' => True),
+ 'from_' => array('type' => 'int',
'precision' => '8', 'nullable' => False),
+ 'to_' => array('type' => 'int',
'precision' => '8', 'nullable' => False),
+ 'active' => array('type' => 'int',
'precision' => 4, 'nullable' => False, 'default' => '1'),
+ 'completed' => array('type' => 'int',
'precision' => 4, 'nullable' => False,'default' => '0'),
+ 'cost' => array('type' => 'decimal',
'precision' => 20, 'scale' => 2, 'nullable' => True,'default' => '0.00'),
+ 'owner_id' => array('type' => 'int',
'precision' => '4', 'nullable' => False),
+ 'public' => array('type' => 'int',
'precision' => '2', 'nullable' => True),
+ 'created' => array('type' => 'int',
'precision' => '8', 'nullable' => False, 'default' => 'current_timestamp'),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'eventplanner_application' =>
array('application_id' => 'id'),
+ ),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable(
+ 'eventplanner_calendar_comment', array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto',
'nullable' => False),
+ 'calendar_id' => array('type' => 'int',
'precision' => '4', 'nullable' => False),
+ 'time' => array('type' => 'int',
'precision' => '8', 'nullable' => False),
+ 'author' => array('type' => 'text',
'nullable' => False),
+ 'comment' => array('type' => 'text',
'nullable' => False),
+ 'type' => array('type' => 'varchar',
'precision' => '20', 'nullable' => false,'default' => 'comment'),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'eventplanner_calendar' =>
array('calendar_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ));
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('eventplanner_booking', 'calendar_id',
+ array
+ (
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => true
+ )
+ );
+
+ $sql = "SELECT * FROM eventplanner_booking";
+ $GLOBALS['phpgw_setup']->oProc->query($sql, __LINE__, __FILE__);
+
+ $calendars = array();
+ while($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $calendars[] = array(
+ 'id' =>
$GLOBALS['phpgw_setup']->oProc->f('id'),
+ 'application_id' =>
$GLOBALS['phpgw_setup']->oProc->f('application_id'),
+ 'customer_id' =>
$GLOBALS['phpgw_setup']->oProc->f('customer_id'),
+ 'from_' =>
$GLOBALS['phpgw_setup']->oProc->f('from_'),
+ 'to_' =>
$GLOBALS['phpgw_setup']->oProc->f('to_'),
+ 'active' =>
$GLOBALS['phpgw_setup']->oProc->f('active'),
+ 'completed' =>
$GLOBALS['phpgw_setup']->oProc->f('completed'),
+ 'cost' =>
$GLOBALS['phpgw_setup']->oProc->f('cost'),
+ 'customer_contact_name' =>
$GLOBALS['phpgw_setup']->oProc->f('customer_contact_name'),
+ 'customer_contact_email' =>
$GLOBALS['phpgw_setup']->oProc->f('customer_contact_email'),
+ 'customer_contact_phone' =>
$GLOBALS['phpgw_setup']->oProc->f('customer_contact_phone'),
+ 'location' =>
$GLOBALS['phpgw_setup']->oProc->f('location'),
+ 'reminder' =>
$GLOBALS['phpgw_setup']->oProc->f('reminder'),
+ 'secret' =>
$GLOBALS['phpgw_setup']->oProc->f('secret'),
+ 'sms_total' =>
$GLOBALS['phpgw_setup']->oProc->f('sms_total'),
+ 'owner_id' =>
$GLOBALS['phpgw_setup']->oProc->f('owner_id'),
+ 'public' =>
$GLOBALS['phpgw_setup']->oProc->f('public'),
+ 'created' =>
$GLOBALS['phpgw_setup']->oProc->f('created')
+ );
+ }
+
+ $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM
eventplanner_booking WHERE customer_id IS NULL", __LINE__, __FILE__);
+
+ foreach ($calendars as $calendar)
+ {
+ $value_set = array(
+ 'application_id' => $calendar['application_id'],
+ 'from_' => $calendar['from_'],
+ 'to_' => $calendar['to_'],
+ 'active' => $calendar['active'],
+ 'completed' => $calendar['completed'],
+ 'cost' => $calendar['cost'],
+ 'owner_id' => $calendar['owner_id'],
+ 'public' => $calendar['public'],
+ 'created' => $calendar['created'],
+ );
+
+ $GLOBALS['phpgw_setup']->oProc->query('INSERT INTO
eventplanner_calendar (' . implode(',', array_keys($value_set)) . ') VALUES ('
. $GLOBALS['phpgw_setup']->oProc->validate_insert(array_values($value_set)) .
')');
+ $calendar_id =
(int)$GLOBALS['phpgw_setup']->oProc->m_odb->get_last_insert_id('eventplanner_calendar',
'id');
+ $GLOBALS['phpgw_setup']->oProc->query("UPDATE
eventplanner_booking SET calendar_id = {$calendar_id}"
+ . " WHERE id = {$calendar['id']}", __LINE__, __FILE__);
+
+ }
+
+ $GLOBALS['phpgw_setup']->oProc->query("ALTER TABLE
eventplanner_booking DROP CONSTRAINT eventplanner_booking_application_id_fkey",
__LINE__, __FILE__);
+
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('eventplanner_booking', array(),
'from_');
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('eventplanner_booking', array(),
'to_');
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('eventplanner_booking', array(),
'cost');
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('eventplanner_booking', array(),
'application_id');
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('eventplanner_booking', array(),
'active');
+
+
+ $sql = "ALTER TABLE public.eventplanner_booking"
+ . " ADD CONSTRAINT
eventplanner_booking_calendar_id_fkey FOREIGN KEY (calendar_id)"
+ . " REFERENCES eventplanner_calendar (id) MATCH SIMPLE"
+ . " ON UPDATE NO ACTION ON DELETE NO ACTION";
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql, __LINE__, __FILE__);
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['eventplanner']['currentver'] =
'0.9.18.008';
+ }
+ return $GLOBALS['setup_info']['eventplanner']['currentver'];
+ }
Modified: trunk/eventplanner/templates/base/booking.xsl
===================================================================
--- trunk/eventplanner/templates/base/booking.xsl 2017-03-27 06:35:15 UTC
(rev 16489)
+++ trunk/eventplanner/templates/base/booking.xsl 2017-03-28 13:54:48 UTC
(rev 16490)
@@ -76,6 +76,7 @@
</div>
<input type="hidden" id="active_tab"
name="active_tab" value="{value_active_tab}"/>
<div id="first_tab">
+ <input type="hidden" name="calendar_id"
value="{calendar/id}"/>
<xsl:if test="booking/id > 0">
<div class="pure-control-group">
<label>
@@ -82,7 +83,6 @@
<xsl:value-of
select="php:function('lang', 'id')"/>
</label>
<input type="hidden"
id="booking_id" name="id" value="{booking/id}"/>
- <input type="hidden"
name="application_id" value="{booking/application_id}"/>
<xsl:value-of
select="booking/id"/>
</div>
</xsl:if>
@@ -103,7 +103,7 @@
</a>
</label>
- <xsl:value-of
select="booking/application_name"/>
+ <xsl:value-of
select="calendar/application_name"/>
</div>
<div class="pure-control-group">
@@ -274,7 +274,7 @@
<xsl:value-of
select="php:function('lang', 'active')"/>
</label>
<input type="checkbox"
name="active" id="active" value="1" readonly="readonly">
- <xsl:if
test="booking/active = 1">
+ <xsl:if
test="calendar/active = 1">
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
</input>
@@ -284,7 +284,7 @@
<xsl:value-of
select="php:function('lang', 'completed')"/>
</label>
<input type="checkbox"
name="completed" id="completed" value="1">
- <xsl:if
test="booking/completed = 1">
+ <xsl:if
test="calendar/completed = 1">
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
</input>
@@ -298,9 +298,9 @@
<xsl:value-of
select="$lang_from"/>
</label>
<input type="text"
id="from_" name="from_" size="16" readonly="readonly">
- <xsl:if
test="booking/from_ != 0 and booking/from_ != ''">
+ <xsl:if
test="calendar/from_ != 0 and calendar/from_ != ''">
<xsl:attribute name="value">
-
<xsl:value-of select="php:function('show_date', number(booking/from_),
$date_format)"/>
+
<xsl:value-of select="php:function('show_date', number(calendar/from_),
$date_format)"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute
name="data-validation">
@@ -322,7 +322,7 @@
<label>
<xsl:value-of
select="php:function('lang', 'to')"/>
</label>
- <xsl:value-of
select="php:function('show_date', number(booking/to_), $date_format)"/>
+ <xsl:value-of
select="php:function('show_date', number(calendar/to_), $date_format)"/>
</div>
<div class="pure-control-group">
@@ -463,7 +463,7 @@
<xsl:variable name="cancel_url">
<xsl:value-of select="cancel_url"/>
</xsl:variable>
- <input type="button" class="pure-button
pure-button-primary" name="cancel" value="{lang_cancel}"
onMouseout="window.status='';return true;" onClick="window.location =
'{cancel_url}';"/>
+ <input type="button" class="pure-button
pure-button-primary" name="cancel" value="{lang_cancel}"
onClick="window.location = '{cancel_url}';"/>
</div>
</form>
</div>
Added: trunk/eventplannerfrontend/inc/class.uicalendar.inc.php
===================================================================
--- trunk/eventplannerfrontend/inc/class.uicalendar.inc.php
(rev 0)
+++ trunk/eventplannerfrontend/inc/class.uicalendar.inc.php 2017-03-28
13:54:48 UTC (rev 16490)
@@ -0,0 +1,47 @@
+<?php
+ phpgw::import_class('eventplanner.uicalendar');
+ include_class('eventplanner', 'application', 'inc/model/');
+ class eventplannerfrontend_uicalendar extends eventplanner_uicalendar
+ {
+
+ public function __construct()
+ {
+ $GLOBALS['phpgw']->translation->add_app('eventplanner');
+ parent::__construct();
+ }
+
+ public function query()
+ {
+ $params = $this->bo->build_default_read_params();
+ $params['filters']['status'] =
eventplanner_application::STATUS_APPROVED;
+ $values = $this->bo->read($params);
+ array_walk($values["results"], array($this,
"_add_links"), "eventplannerfrontend.uicalendar.edit");
+
+ return $this->jquery_results($values);
+ }
+
+ public function query_relaxed()
+ {
+ $params = $this->bo->build_default_read_params();
+ $params['relaxe_acl'] = true;
+ $params['filters']['status'] =
eventplanner_application::STATUS_APPROVED;
+ $values = $this->bo->read($params);
+ $redirect = phpgw::get_var('redirect');
+ if($redirect == 'booking')
+ {
+ array_walk($values["results"], array($this,
"_add_links2"), "{$this->currentapp}.uibooking.edit");
+ }
+ else
+ {
+ array_walk($values["results"], array($this,
"_add_links"), "{$this->currentapp}.uicalendar.edit");
+ }
+
+ return $this->jquery_results($values);
+ }
+
+ public function edit()
+ {
+ parent::edit();
+ }
+
+ }
Modified: trunk/eventplannerfrontend/js/portico/application.edit.js
===================================================================
--- trunk/eventplannerfrontend/js/portico/application.edit.js 2017-03-27
06:35:15 UTC (rev 16489)
+++ trunk/eventplannerfrontend/js/portico/application.edit.js 2017-03-28
13:54:48 UTC (rev 16490)
@@ -260,7 +260,7 @@
$("#stage_size").val(total_size);
}
-add_booking = function ()
+add_schedule = function ()
{
var from_ = $("#from_").val();
if (!from_)
@@ -269,7 +269,7 @@
}
oArgs = {
- menuaction: 'eventplannerfrontend.uibooking.save_ajax',
+ menuaction: 'eventplannerfrontend.uicalendar.save_ajax',
application_id: $("#application_id").val()
};
@@ -319,7 +319,7 @@
{
return;
}
- oArgs = {menuaction: 'eventplannerfrontend.uibooking.update_schedule'};
+ oArgs = {menuaction: 'eventplannerfrontend.uicalendar.update_schedule'};
var requestUrl = phpGWLink('eventplannerfrontend/', oArgs, true);
var htmlString = '';
@@ -355,7 +355,7 @@
$("#receipt").html("");
if (action === 'add')
{
- add_booking();
+ add_schedule();
return;
}
@@ -391,7 +391,7 @@
{
var data = {"ids": ids, "action": action, from_:
$("#from_").val()};
- oArgs = {menuaction:
'eventplannerfrontend.uibooking.update_active_status'};
+ oArgs = {menuaction:
'eventplannerfrontend.uicalendar.update_active_status'};
var requestUrl = phpGWLink('eventplannerfrontend/', oArgs,
true);
Modified: trunk/eventplannerfrontend/setup/default_records.inc.php
===================================================================
--- trunk/eventplannerfrontend/setup/default_records.inc.php 2017-03-27
06:35:15 UTC (rev 16489)
+++ trunk/eventplannerfrontend/setup/default_records.inc.php 2017-03-28
13:54:48 UTC (rev 16490)
@@ -5,6 +5,7 @@
$GLOBALS['phpgw']->locations->add('.events', 'events',
'eventplannerfrontend', $allow_grant = true, $custom_tbl = '', $c_function =
true);
$GLOBALS['phpgw']->locations->add('.customer', 'customer',
'eventplannerfrontend', $allow_grant = true, $custom_tbl = '', $c_function =
true);
$GLOBALS['phpgw']->locations->add('.vendor', 'vendor',
'eventplannerfrontend', $allow_grant = true, $custom_tbl = '', $c_function =
true);
+ $GLOBALS['phpgw']->locations->add('.calendar', 'calendar',
'eventplannerfrontend', $allow_grant = true);
$GLOBALS['phpgw']->locations->add('.booking', 'booking',
'eventplannerfrontend', $allow_grant = true, $custom_tbl = '', $c_function =
true);
$GLOBALS['phpgw']->locations->add('.vendor_report', 'vendor_report',
'eventplannerfrontend', $allow_grant = true, $custom_tbl = '', $c_function =
true);
$GLOBALS['phpgw']->locations->add('.customer_report',
'customer_report', 'eventplannerfrontend', $allow_grant = true, $custom_tbl =
'', $c_function = true);
Modified: trunk/eventplannerfrontend/templates/base/booking.xsl
===================================================================
--- trunk/eventplannerfrontend/templates/base/booking.xsl 2017-03-27
06:35:15 UTC (rev 16489)
+++ trunk/eventplannerfrontend/templates/base/booking.xsl 2017-03-28
13:54:48 UTC (rev 16490)
@@ -103,7 +103,7 @@
</a>
</label>
- <xsl:value-of
select="booking/application_name"/>
+ <xsl:value-of
select="calendar/application_name"/>
</div>
<div class="pure-control-group">
@@ -274,7 +274,7 @@
<xsl:value-of
select="php:function('lang', 'active')"/>
</label>
<input type="checkbox"
name="active" id="active" value="1" readonly="readonly">
- <xsl:if
test="booking/active = 1">
+ <xsl:if
test="calendar/active = 1">
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
</input>
@@ -284,7 +284,7 @@
<xsl:value-of
select="php:function('lang', 'completed')"/>
</label>
<input type="checkbox"
name="completed" id="completed" value="1">
- <xsl:if
test="booking/completed = 1">
+ <xsl:if
test="calendar/completed = 1">
<xsl:attribute name="checked" value="checked"/>
</xsl:if>
</input>
@@ -298,9 +298,9 @@
<xsl:value-of
select="$lang_from"/>
</label>
<input type="text"
id="from_" name="from_" size="16" readonly="readonly">
- <xsl:if
test="booking/from_ != 0 and booking/from_ != ''">
+ <xsl:if
test="calendar/from_ != 0 and calendar/from_ != ''">
<xsl:attribute name="value">
-
<xsl:value-of select="php:function('show_date', number(booking/from_),
$date_format)"/>
+
<xsl:value-of select="php:function('show_date', number(calendar/from_),
$date_format)"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute
name="data-validation">
@@ -322,7 +322,7 @@
<label>
<xsl:value-of
select="php:function('lang', 'to')"/>
</label>
- <xsl:value-of
select="php:function('show_date', number(booking/to_), $date_format)"/>
+ <xsl:value-of
select="php:function('show_date', number(calendar/to_), $date_format)"/>
</div>
<div class="pure-control-group">
@@ -463,7 +463,7 @@
<xsl:variable name="cancel_url">
<xsl:value-of select="cancel_url"/>
</xsl:variable>
- <input type="button" class="pure-button
pure-button-primary" name="cancel" value="{lang_cancel}"
onMouseout="window.status='';return true;" onClick="window.location =
'{cancel_url}';"/>
+ <input type="button" class="pure-button
pure-button-primary" name="cancel" value="{lang_cancel}"
onClick="window.location = '{cancel_url}';"/>
</div>
</form>
</div>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16490] more on eventplanner,
sigurdne <=