fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15831] more on eventplanner


From: sigurdne
Subject: [Fmsystem-commits] [15831] more on eventplanner
Date: Sun, 16 Oct 2016 15:26:33 +0000 (UTC)

Revision: 15831
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15831
Author:   sigurdne
Date:     2016-10-16 15:26:32 +0000 (Sun, 16 Oct 2016)
Log Message:
-----------
more on eventplanner

Modified Paths:
--------------
    trunk/eventplanner/inc/class.menu.inc.php
    trunk/eventplanner/inc/class.uiapplication.inc.php
    trunk/eventplanner/inc/model/class.application.inc.php
    trunk/eventplanner/setup/default_records.inc.php
    trunk/eventplanner/setup/tables_current.inc.php

Added Paths:
-----------
    trunk/eventplanner/inc/class.bovendor_report.inc.php
    trunk/eventplanner/inc/class.sovendor_report.inc.php
    trunk/eventplanner/inc/class.uivendor_report.inc.php
    trunk/eventplanner/inc/model/class.vendor_report.inc.php
    trunk/eventplanner/templates/base/vendor_report.xsl

Added: trunk/eventplanner/inc/class.bovendor_report.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bovendor_report.inc.php                        
        (rev 0)
+++ trunk/eventplanner/inc/class.bovendor_report.inc.php        2016-10-16 
15:26:32 UTC (rev 15831)
@@ -0,0 +1,115 @@
+<?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 vendor_report
+        * @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('eventplanner.bocommon');
+       phpgw::import_class('eventplanner.sovendor_report');
+
+       include_class('eventplanner', 'vendor_report', 'inc/model/');
+
+       class eventplanner_bovendor_report extends eventplanner_bocommon
+       {
+               protected static
+                       $bo,
+                       $fields,
+                       $acl_location;
+
+               public $cats;
+
+               public function __construct()
+               {
+                       $this->fields = 
eventplanner_vendor_report::get_fields();
+                       $this->acl_location = 
eventplanner_vendor_report::acl_location;
+                       $this->cats = CreateObject('phpgwapi.categories', -1, 
'eventplanner', $this->acl_location);
+                       $this->cats->supress_info = true;
+               }
+
+               /**
+                * 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_bovendor_report();
+                       }
+                       return self::$bo;
+               }
+
+               public function store($object)
+               {
+                       $this->store_pre_commit($object);
+                       $ret = 
eventplanner_sovendor_report::get_instance()->store($object);
+                       $this->store_post_commit($object);
+                       return $ret;
+               }
+
+               public function read($params)
+               {
+                       if (isset($params['filters']['category_id']) && 
$params['filters']['category_id'] > 0)
+                       {
+                               $category_id = 
$params['filters']['category_id'];
+                               $cat_list = $this->cats->return_sorted_array(0, 
false, '', '', '', false, $category_id, false);
+                               $cat_filter = array($category_id);
+                               foreach ($cat_list as $_category)
+                               {
+                                       $cat_filter[] = $_category['id'];
+                               }
+                               $params['filters']['category_id'] = $cat_filter;
+                       }
+
+                       $values =  
eventplanner_sovendor_report::get_instance()->read($params);
+                       $status_text = 
eventplanner_vendor_report::get_status_list();
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+                       foreach ($values['results'] as &$entry)
+                       {
+                               $entry['status'] = 
$status_text[$entry['status']];
+                               $entry['created'] = 
$GLOBALS['phpgw']->common->show_date($entry['created']);
+                               $entry['modified'] = 
$GLOBALS['phpgw']->common->show_date($entry['modified']);
+                               $entry['date_start'] = 
$GLOBALS['phpgw']->common->show_date($entry['date_start'], $dateformat);
+                               $entry['date_end'] = 
$GLOBALS['phpgw']->common->show_date($entry['date_end'], $dateformat);
+                               $entry['case_officer_id'] = 
$entry['case_officer_id'] ? 
$GLOBALS['phpgw']->accounts->get($entry['case_officer_id'])->__toString() : '';
+                       }
+                       return $values;
+               }
+
+               public function read_single($id, $return_object = true)
+               {
+                       if ($id)
+                       {
+                               $values = 
eventplanner_sovendor_report::get_instance()->read_single($id, $return_object);
+                       }
+                       else
+                       {
+                               $values = new eventplanner_vendor_report();
+                       }
+
+                       return $values;
+               }
+       }
\ No newline at end of file

Modified: trunk/eventplanner/inc/class.menu.inc.php
===================================================================
--- trunk/eventplanner/inc/class.menu.inc.php   2016-10-16 10:37:07 UTC (rev 
15830)
+++ trunk/eventplanner/inc/class.menu.inc.php   2016-10-16 15:26:32 UTC (rev 
15831)
@@ -102,6 +102,19 @@
                                                'text'  => lang('resource 
category'),
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'eventplanner.uigeneric.index', 'type' => 'resource_category') )
                                        ),
+                                       'custom_field_groups' => array
+                                               (
+                                               'text' => lang('custom field 
groups'),
+                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute_group',
+                                                       'appname' => 
'eventplanner', 'menu_selection' => 'admin::eventplanner::custom_field_groups'))
+                                       ),
+                                       'custom_fields' => array
+                                               (
+                                               'text' => lang('custom fields'),
+                                               'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute',
+                                                       'appname' => 
'eventplanner', 'menu_selection' => 'admin::eventplanner::custom_fields'))
+                                       ),
+
                                );
                        }
 

Added: trunk/eventplanner/inc/class.sovendor_report.inc.php
===================================================================
--- trunk/eventplanner/inc/class.sovendor_report.inc.php                        
        (rev 0)
+++ trunk/eventplanner/inc/class.sovendor_report.inc.php        2016-10-16 
15:26:32 UTC (rev 15831)
@@ -0,0 +1,139 @@
+<?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/ and Nordlandssykehuset
+        * @package eventplanner
+        * @subpackage vendor_report
+        * @version $Id: $
+        */
+       phpgw::import_class('phpgwapi.socommon');
+
+       class eventplanner_sovendor_report extends phpgwapi_socommon
+       {
+
+               protected static $so;
+
+               public function __construct()
+               {
+                       
parent::__construct('eventplanner_booking_vendor_report', 
eventplanner_vendor_report::get_fields());
+                       $this->acl_location = 
eventplanner_vendor_report::acl_location;
+                       $this->cats = CreateObject('phpgwapi.categories', -1, 
'eventplanner', $this->acl_location);
+                       $this->cats->supress_info = true;
+               }
+
+               /**
+                * 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.sovendor_report');
+                       }
+                       return self::$so;
+               }
+
+
+               protected function populate( array $data )
+               {
+                       $object = new eventplanner_vendor_report();
+                       foreach ($this->fields as $field => $field_info)
+                       {
+                               $object->set_field($field, $data[$field]);
+                       }
+
+                       return $object;
+               }
+
+               function get_category_name( $cat_id )
+               {
+                       static $category_name = array();
+
+                       if (!isset($category_name[$cat_id]))
+                       {
+                               $category = $this->cats->return_single($cat_id);
+                               $category_name[$cat_id] = $category[0]['name'];
+                       }
+                       return $category_name[$cat_id];
+               }
+
+               protected function update( $object )
+               {
+                       $this->db->transaction_begin();
+                       $status_text = 
eventplanner_vendor_report::get_status_list();
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+                       $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 'date_start':
+                                               case 'date_end':
+                                                       $old_value = 
$GLOBALS['phpgw']->common->show_date($old_value, $dateformat);
+                                                       $new_value = 
$GLOBALS['phpgw']->common->show_date($new_value, $dateformat);
+
+                                                       break;
+                                               case 'case_officer_id':
+                                                       $old_value = $old_value 
? $GLOBALS['phpgw']->accounts->get($old_value)->__toString() : '';
+                                                       $new_value = $new_value 
? $GLOBALS['phpgw']->accounts->get($new_value)->__toString() : '';
+                                                       break;
+                                               case 'category_id':
+                                                       $old_value = $old_value 
? $this->get_category_name($old_value) : '';
+                                                       $new_value = $new_value 
? $this->get_category_name($new_value) : '';
+                                                       break;
+                                               default:
+                                                       break;
+                                       }
+                                       $value_set = array
+                                       (
+                                               'vendor_report_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_vendor_report_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();
+               }
+
+       }
\ No newline at end of file

Modified: trunk/eventplanner/inc/class.uiapplication.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uiapplication.inc.php  2016-10-16 10:37:07 UTC 
(rev 15830)
+++ trunk/eventplanner/inc/class.uiapplication.inc.php  2016-10-16 15:26:32 UTC 
(rev 15831)
@@ -45,7 +45,6 @@
 
                protected
                        $fields,
-                       $composite_types,
                        $permissions;
 
                public function __construct()
@@ -55,7 +54,6 @@
                        $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('application');
                        $this->bo = createObject('eventplanner.boapplication');
                        $this->cats = & $this->bo->cats;
-                       $this->composite_types = 
eventplanner_application::get_composite_types();
                        $this->fields = eventplanner_application::get_fields();
                        $this->permissions = 
eventplanner_application::get_instance()->get_permission_array();
                }
@@ -237,12 +235,6 @@
                                'function' => "set_tab('demands')"
                        );
 
-                       $composite_types = array();
-                       foreach ($this->composite_types as $_key => $_value)
-                       {
-                               $composite_types[] = array('id' => $_key, 
'name' => $_value);
-                       }
-
                        $bocommon = CreateObject('property.bocommon');
 
                        $GLOBALS['phpgw']->jqcal->add_listener('date_start');

Added: trunk/eventplanner/inc/class.uivendor_report.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uivendor_report.inc.php                        
        (rev 0)
+++ trunk/eventplanner/inc/class.uivendor_report.inc.php        2016-10-16 
15:26:32 UTC (rev 15831)
@@ -0,0 +1,281 @@
+<?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/ and Nordlandssykehuset
+        * @package eventplanner
+        * @subpackage vendor_report
+        * @version $Id: $
+        */
+       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.datetime');
+
+       include_class('eventplanner', 'vendor_report', 'inc/model/');
+
+       class eventplanner_uivendor_report extends eventplanner_uicommon
+       {
+
+               public $public_functions = array(
+                       'add' => true,
+                       'index' => true,
+                       'query' => true,
+                       'view' => true,
+                       'edit' => true,
+                       'save' => true,
+               );
+
+               protected
+                       $fields,
+                       $permissions;
+
+               public function __construct()
+               {
+                       parent::__construct();
+                       self::set_active_menu('eventplanner::vendor_report');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('vendor_report');
+                       $this->bo = 
createObject('eventplanner.bovendor_report');
+                       $this->cats = & $this->bo->cats;
+                       $this->fields = 
eventplanner_vendor_report::get_fields();
+                       $this->permissions = 
eventplanner_vendor_report::get_instance()->get_permission_array();
+                       $this->custom_fields = 
eventplanner_vendor_report::get_instance()->get_custom_fields();
+               }
+
+               private function get_status_options( $selected = 0 )
+               {
+                       $status_options = array();
+                       $status_list = 
eventplanner_vendor_report::get_status_list();
+
+                       foreach ($status_list as $_key => $_value)
+                       {
+                               $status_options[] = array(
+                                       'id' => $_key,
+                                       'name' => $_value,
+                                       'selected' => $_key == $selected ? 1 : 0
+                               );
+                       }
+                       return $status_options;
+               }
+
+               private function _get_filters()
+               {
+                       $combos = array();
+                       $combos[] = array(
+                               'type' => 'autocomplete',
+                               'name' => 'vendor',
+                               'app' => 'eventplanner',
+                               'ui' => 'vendor',
+                               'label_attr' => 'name',
+                               'text' => lang('vendor') . ':',
+                               'requestGenerator' => 'requestWithVendorFilter'
+                       );
+
+                       $status_options = $this->get_status_options();
+                       array_unshift($status_options, array('id' => '','name' 
=> lang('all')));
+
+                       $combos[] = array(
+                               'type' => 'filter',
+                               'name' => 'filter_status',
+                               'extra' => '',
+                               'text' => lang('status'),
+                               'list' => $status_options
+                       );
+
+                       $categories = 
$this->cats->formatted_xslt_list(array('format' => 'filter',
+                                       'selected' => $this->cat_id, 'globals' 
=> true, 'use_acl' => $this->_category_acl));
+                       $default_value = array('cat_id' => '', 'name' => 
lang('no category'));
+                       array_unshift($categories['cat_list'], $default_value);
+
+                       $_categories = array();
+                       foreach ($categories['cat_list'] as $_category)
+                       {
+                               $_categories[] = array('id' => 
$_category['cat_id'], 'name' => $_category['name']);
+                       }
+
+                       $combos[] = array('type' => 'filter',
+                               'name' => 'filter_category_id',
+                               'extra' => '',
+                               'text' => lang('category'),
+                               'list' => $_categories
+                       );
+
+                       return $combos;
+
+               }
+               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('vendor_report');
+
+                       $data = array(
+                               'datatable_name' => $function_msg,
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                               )
+                                       )
+                               ),
+                               'datatable' => array(
+                                       'source' => self::link(array(
+                                               'menuaction' => 
'eventplanner.uivendor_report.index',
+                                               'phpgw_return_as' => 'json'
+                                       )),
+                                       'allrows' => true,
+                                       'new_item' => 
self::link(array('menuaction' => 'eventplanner.uivendor_report.add')),
+                                       'editor_action' => '',
+                                       'field' => parent::_get_fields()
+                               )
+                       );
+
+                       $filters = $this->_get_filters();
+
+                       foreach ($filters as $filter)
+                       {
+                               array_unshift($data['form']['toolbar']['item'], 
$filter);
+                       }
+
+                       $parameters = array(
+                               'parameter' => array(
+                                       array(
+                                               'name' => 'id',
+                                               'source' => 'id'
+                                       )
+                               )
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'view',
+                               'text' => lang('show'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 
'eventplanner.uivendor_report.view'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'edit',
+                               'text' => lang('edit'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 
'eventplanner.uivendor_report.edit'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       self::add_javascript('eventplanner', 'portico', 
'vendor_report.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']))
+                       {
+                               $vendor_report = $values['object'];
+                       }
+                       else
+                       {
+                               $id = !empty($values['id']) ? $values['id'] : 
phpgw::get_var('id', 'int');
+                               $vendor_report = $this->bo->read_single($id);
+                       }
+
+                       $custom_values = $vendor_report->json_representation;
+                       $custom_fields = 
createObject('booking.custom_fields','eventplanner');
+                       $fields = $this->custom_fields;
+                       foreach ($fields as $attrib_id => &$attrib)
+                       {
+                               $attrib['value'] = 
isset($custom_values[$attrib['name']]) ? $custom_values[$attrib['name']] : null;
+
+                               if (isset($attrib['choice']) && 
is_array($attrib['choice']) && $attrib['value'])
+                               {
+                                       foreach ($attrib['choice'] as &$choice)
+                                       {
+                                               if (is_array($attrib['value']))
+                                               {
+                                                       $choice['selected'] = 
in_array($choice['id'], $attrib['value']) ? 1 : 0;
+                                               }
+                                               else
+                                               {
+                                                       $choice['selected'] = 
$choice['id'] == $attrib['value'] ? 1 : 0;
+                                               }
+                                       }
+                               }
+                       }
+//                     _debug_array($fields);
+                       $organized_fields = 
$custom_fields->organize_fields(eventplanner_vendor_report::acl_location, 
$fields);
+
+                       $tabs = array();
+                       $tabs['first_tab'] = array(
+                               'label' => lang('vendor_report'),
+                               'link' => '#first_tab',
+                               'function' => "set_tab('first_tab')"
+                       );
+
+                       $data = array(
+                               'form_action' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'eventplanner.uivendor_report.save')),
+                               'cancel_url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'eventplanner.uivendor_report.index',)),
+                               'vendor_report' => $vendor_report,
+                               'status_list' => array('options' => 
$this->get_status_options($vendor_report->status)),
+                               'vendor_report_type_list' => 
$vendor_report_type_list,
+                               'mode' => $mode,
+                               'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+                               'value_active_tab' => $active_tab,
+                               'attributes_group' => $organized_fields,
+                       );
+                       phpgwapi_jquery::formvalidator_generate(array('date', 
'security', 'file'));
+                       phpgwapi_jquery::load_widget('autocomplete');
+                       self::add_javascript('eventplanner', 'portico', 
'vendor_report.edit.js');
+                       self::render_template_xsl(array('vendor_report', 
'datatable_inline', 'attributes_form'), array($mode => $data));
+               }
+
+               
+               public function save()
+               {
+                       parent::save();
+               }
+
+       }
\ No newline at end of file

Modified: trunk/eventplanner/inc/model/class.application.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.application.inc.php      2016-10-16 
10:37:07 UTC (rev 15830)
+++ trunk/eventplanner/inc/model/class.application.inc.php      2016-10-16 
15:26:32 UTC (rev 15831)
@@ -109,10 +109,6 @@
                        return new eventplanner_application();
                }
 
-               public static function get_composite_types()
-               {
-                       return array(1 => 'Hybel', 2 => 'Leilighet');
-               }
                public static function get_status_list()
                {
                        return array(

Added: trunk/eventplanner/inc/model/class.vendor_report.inc.php
===================================================================
--- trunk/eventplanner/inc/model/class.vendor_report.inc.php                    
        (rev 0)
+++ trunk/eventplanner/inc/model/class.vendor_report.inc.php    2016-10-16 
15:26:32 UTC (rev 15831)
@@ -0,0 +1,181 @@
+<?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 vendor_report
+        * @version $Id: $
+        */
+
+       phpgw::import_class('eventplanner.bovendor_report');
+
+       include_class('phpgwapi', 'model', 'inc/model/');
+
+       class eventplanner_vendor_report extends phpgwapi_model
+       {
+
+               const STATUS_REGISTERED = 1;
+               const STATUS_PENDING = 2;
+               const STATUS_REJECTED = 3;
+               const STATUS_APPROVED = 4;
+               const acl_location = '.vendor_report';
+
+               protected
+                       $id,
+                       $created,
+                       $json_representation;
+
+               static $custom_fields = array();
+
+               protected $field_of_responsibility_name = '.vendor_report';
+
+               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_vendor_report();
+               }
+
+               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 function set_custom_fields()
+               {
+                       $this->custom_fields = 
$GLOBALS['phpgw']->custom_fields->find('eventplanner', self::acl_location, 0, 
'', 'ASC', 'attrib_sort', true, true);
+               }
+
+               public function get_custom_fields()
+               {
+                       if(! $this->custom_fields)
+                       {
+                               $this->set_custom_fields();
+                       }
+                       return $this->custom_fields;
+               }
+
+               public function get_organized_fields()
+               {
+                       if(! $this->custom_fields)
+                       {
+                               $this->custom_fields = 
createObject('booking.custom_fields', 
'eventplanner')->get_organized_fields(self::acl_location);
+                       }
+                       return $this->custom_fields;
+               }
+
+
+               public static function get_fields($debug = true)
+               {
+                        $fields = array(
+                               'id' => array('action'=> PHPGW_ACL_READ,
+                                       'type' => 'int',
+                                       'label' => 'id',
+                                       'sortable'=> true,
+                                       'formatter' => 
'JqueryPortico.formatLink',
+                                       ),
+                               'created' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD,
+                                       'type' => 'date',
+                                       'label' => 'created',
+                                       'sortable' => true,
+                                       ),
+                               'json_representation' => array('action'=> 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'jsonb',
+                                       'sortable' => false,
+                                       ),
+                       );
+
+                       if($debug)
+                       {
+                               foreach ($fields as $field => $field_info)
+                               {
+                                       
if(!property_exists('eventplanner_vendor_report', $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'
+                               );
+                       }
+                       $entity->modified = time();
+                       $entity->active = (int)$entity->active;
+
+                       if(!$entity->get_id())
+                       {
+                               $entity->created = time();
+                               $entity->owner_id = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                               $entity->status = 
eventplanner_vendor_report::STATUS_REGISTERED;
+                               $entity->secret = self::generate_secret();
+                       }
+               }
+
+               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_bovendor_report::get_instance()->store($this);
+               }
+
+               public function read_single($id)
+               {
+                       return 
eventplanner_bovendor_report::get_instance()->read_single($id, true);
+               }
+       }

Modified: trunk/eventplanner/setup/default_records.inc.php
===================================================================
--- trunk/eventplanner/setup/default_records.inc.php    2016-10-16 10:37:07 UTC 
(rev 15830)
+++ trunk/eventplanner/setup/default_records.inc.php    2016-10-16 15:26:32 UTC 
(rev 15831)
@@ -15,12 +15,12 @@
         * @package eventplanner
         */
        $GLOBALS['phpgw']->locations->add('.', 'Tom', 'eventplanner');
-       $GLOBALS['phpgw']->locations->add('.admin', 'admin', 'eventplanner', 
$allow_grant = true, $custom_tbl = 'eventplanner_application', $c_function = 
true);
-       $GLOBALS['phpgw']->locations->add('.application', 'application', 
'eventplanner', $allow_grant = true, $custom_tbl = 'eventplanner_application', 
$c_function = true);
-       $GLOBALS['phpgw']->locations->add('.resource', 'resource', 
'eventplanner', $allow_grant = true, $custom_tbl = 'eventplanner_resource', 
$c_function = true);
-       $GLOBALS['phpgw']->locations->add('.customer', 'customer', 
'eventplanner', $allow_grant = true, $custom_tbl = 'eventplanner_resource', 
$c_function = true);
-       $GLOBALS['phpgw']->locations->add('.vendor', 'vendor', 'eventplanner', 
$allow_grant = true, $custom_tbl = 'eventplanner_resource', $c_function = true);
-       $GLOBALS['phpgw']->locations->add('.booking', 'booking', 
'eventplanner', $allow_grant = true, $custom_tbl = 'eventplanner_resource', 
$c_function = true);
-       $GLOBALS['phpgw']->locations->add('.vendor_report', 'vendor_report', 
'eventplanner', $allow_grant = true, $custom_tbl = 'eventplanner_resource', 
$c_function = true);
-       $GLOBALS['phpgw']->locations->add('.customer_report', 
'customer_report', 'eventplanner', $allow_grant = true, $custom_tbl = 
'eventplanner_resource', $c_function = true);
+       $GLOBALS['phpgw']->locations->add('.admin', 'admin', 'eventplanner');
+       $GLOBALS['phpgw']->locations->add('.application', 'application', 
'eventplanner', $allow_grant = true, $custom_tbl = '', $c_function = true);
+       $GLOBALS['phpgw']->locations->add('.resource', 'resource', 
'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('.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);
+       $GLOBALS['phpgw']->locations->add('.customer_report', 
'customer_report', 'eventplanner', $allow_grant = true, $custom_tbl = '', 
$c_function = true);
 

Modified: trunk/eventplanner/setup/tables_current.inc.php
===================================================================
--- trunk/eventplanner/setup/tables_current.inc.php     2016-10-16 10:37:07 UTC 
(rev 15830)
+++ trunk/eventplanner/setup/tables_current.inc.php     2016-10-16 15:26:32 UTC 
(rev 15831)
@@ -338,9 +338,9 @@
                        'fd' => array(
                                'id' => array('type' => 'auto', 'nullable' => 
False),
                                'booking_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => False),
-                               'time' => array('type' => 'int', 'precision' => 
'8', 'nullable' => False, 'default' => 'current_timestamp'),
-                               'author' => array('type' => 'text', 'nullable' 
=> False),
-                               'comment' => array('type' => 'text', 'nullable' 
=> False),
+                               'created' => array('type' => 'int', 'precision' 
=> '8',  'nullable' => False, 'default' => 'current_timestamp'),
+//                             'author' => array('type' => 'text', 'nullable' 
=> False),
+                               'json_representation' => array('type' => 
'jsonb', 'nullable' => true),
                        ),
                        'pk' => array('id'),
                        'fk' => array(
@@ -352,9 +352,9 @@
                        'fd' => array(
                                'id' => array('type' => 'auto', 'nullable' => 
False),
                                'booking_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => False),
-                               'time' => array('type' => 'int', 'precision' => 
'8', 'nullable' => False, 'default' => 'current_timestamp'),
-                               'author' => array('type' => 'text', 'nullable' 
=> False),
-                               'comment' => array('type' => 'text', 'nullable' 
=> False),
+                               'created' => array('type' => 'int', 'precision' 
=> '8',  'nullable' => False, 'default' => 'current_timestamp'),
+//                             'author' => array('type' => 'text', 'nullable' 
=> False),
+                               'json_representation' => array('type' => 
'jsonb', 'nullable' => true),
                        ),
                        'pk' => array('id'),
                        'fk' => array(

Added: trunk/eventplanner/templates/base/vendor_report.xsl
===================================================================
--- trunk/eventplanner/templates/base/vendor_report.xsl                         
(rev 0)
+++ trunk/eventplanner/templates/base/vendor_report.xsl 2016-10-16 15:26:32 UTC 
(rev 15831)
@@ -0,0 +1,97 @@
+
+<!-- $Id: price_item.xsl 12604 2015-01-15 17:06:11Z nelson224 $ -->
+<xsl:template match="data">
+       <xsl:choose>
+               <xsl:when test="edit">
+                       <xsl:apply-templates select="edit" />
+               </xsl:when>
+               <xsl:when test="view">
+                       <xsl:apply-templates select="view" />
+               </xsl:when>
+       </xsl:choose>
+
+</xsl:template>
+
+<!-- add / edit  -->
+<xsl:template xmlns:php="http://php.net/xsl"; match="edit">
+       <xsl:variable name="date_format">
+               <xsl:value-of select="php:function('get_phpgw_info', 
'user|preferences|common|dateformat')" />
+       </xsl:variable>
+       <xsl:variable name="form_action">
+               <xsl:value-of select="form_action"/>
+       </xsl:variable>
+       <xsl:variable name="mode">
+               <xsl:value-of select="mode"/>
+       </xsl:variable>
+
+       <div>
+               <script type="text/javascript">
+                       var lang = <xsl:value-of 
select="php:function('js_lang', 'Name or company is required')"/>;
+               </script>
+               <form id="form" name="form" method="post" 
action="{$form_action}" class="pure-form pure-form-aligned">
+                       <div id="tab-content">
+                               <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
+                               <input type="hidden" id="active_tab" 
name="active_tab" value="{value_active_tab}"/>
+                               <div id="first_tab">
+                                       <fieldset>
+                                               <xsl:if test="vendor/id > 0">
+                                                       <div 
class="pure-control-group">
+                                                               <label>
+                                                                       
<xsl:value-of select="php:function('lang', 'id')"/>
+                                                               </label>
+                                                               <input 
type="hidden" name="id" value="{vendor/id}"/>
+                                                               <xsl:value-of 
select="vendor/id"/>
+                                                       </div>
+                                               </xsl:if>
+                                               <xsl:apply-templates 
select="attributes_group/attributes"/>
+
+                                       </fieldset>
+                               </div>
+                       </div>
+                       <div class="proplist-col">
+                               <input type="submit" class="pure-button 
pure-button-primary" name="save">
+                                       <xsl:attribute name="value">
+                                               <xsl:value-of 
select="php:function('lang', 'save')"/>
+                                       </xsl:attribute>
+                               </input>
+                               <xsl:variable name="cancel_url">
+                                       <xsl:value-of select="cancel_url"/>
+                               </xsl:variable>
+                               <input type="button" class="pure-button 
pure-button-primary" name="cancel" onClick="window.location = '{cancel_url}';">
+                                       <xsl:attribute name="value">
+                                               <xsl:value-of 
select="php:function('lang', 'cancel')"/>
+                                       </xsl:attribute>
+                               </input>
+                       </div>
+               </form>
+       </div>
+</xsl:template>
+
+<xsl:template match="options">
+       <option value="{id}">
+               <xsl:if test="selected != 0">
+                       <xsl:attribute name="selected" value="selected"/>
+               </xsl:if>
+               <xsl:value-of disable-output-escaping="yes" select="name"/>
+       </option>
+</xsl:template>
+
+
+<xsl:template xmlns:php="http://php.net/xsl"; match="view">
+       <div>
+               <form id="form" name="form" method="post" action="" 
class="pure-form pure-form-aligned">
+                       <div id="tab-content">
+                               <xsl:value-of disable-output-escaping="yes" 
select="tabs"/>
+                               <div id="showing">
+
+                               </div>
+                       </div>
+                       <div class="proplist-col">
+                               <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}';"/>
+                       </div>
+               </form>
+       </div>
+</xsl:template>




reply via email to

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