fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16083] rental: start implementing moveout


From: sigurdne
Subject: [Fmsystem-commits] [16083] rental: start implementing moveout
Date: Wed, 14 Dec 2016 15:02:56 +0000 (UTC)

Revision: 16083
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16083
Author:   sigurdne
Date:     2016-12-14 15:02:55 +0000 (Wed, 14 Dec 2016)
Log Message:
-----------
rental: start implementing moveout

Modified Paths:
--------------
    trunk/rental/inc/class.menu.inc.php
    trunk/rental/setup/phpgw_no.lang
    trunk/rental/setup/tables_update.inc.php

Added Paths:
-----------
    trunk/rental/inc/class.bomoveout.inc.php
    trunk/rental/inc/class.somoveout.inc.php
    trunk/rental/inc/class.uimoveout.inc.php
    trunk/rental/inc/model/class.moveout.inc.php
    trunk/rental/templates/base/moveout.xsl

Added: trunk/rental/inc/class.bomoveout.inc.php
===================================================================
--- trunk/rental/inc/class.bomoveout.inc.php                            (rev 0)
+++ trunk/rental/inc/class.bomoveout.inc.php    2016-12-14 15:02:55 UTC (rev 
16083)
@@ -0,0 +1,106 @@
+<?php
+       /**
+        * phpGroupWare - rental: 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 customer was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package rental
+        * @subpackage moveout
+        * @version $Id: $
+        */
+
+
+       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('rental.somoveout');
+
+       include_class('rental', 'moveout', 'inc/model/');
+
+       class rental_bomoveout extends eventplanner_bocommon
+       {
+               protected static
+                       $bo,
+                       $fields,
+                       $acl_location;
+
+               public function __construct()
+               {
+                       $this->fields = rental_moveout::get_fields();
+                       $this->acl_location = rental_moveout::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 rental_bomoveout();
+                       }
+                       return self::$bo;
+               }
+
+               public function store($object)
+               {
+                       $this->store_pre_commit($object);
+                       $ret = rental_somoveout::get_instance()->store($object);
+                       $this->store_post_commit($object);
+                       return $ret;
+               }
+
+               public function read($params)
+               {
+                       if(empty($params['filters']['active']))
+                       {
+                               $params['filters']['active'] = 1;
+                       }
+                       else
+                       {
+                               unset($params['filters']['active']);
+                       }
+                       $values =  
rental_somoveout::get_instance()->read($params);
+       //              $status_text = rental_moveout::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']);
+                       }
+                       return $values;
+               }
+
+               public function read_single($id, $return_object = true)
+               {
+                       if ($id)
+                       {
+                               $values = 
rental_somoveout::get_instance()->read_single($id, $return_object);
+                       }
+                       else
+                       {
+                               $values = new rental_moveout();
+                       }
+
+                       return $values;
+               }
+       }
\ No newline at end of file

Modified: trunk/rental/inc/class.menu.inc.php
===================================================================
--- trunk/rental/inc/class.menu.inc.php 2016-12-13 10:45:46 UTC (rev 16082)
+++ trunk/rental/inc/class.menu.inc.php 2016-12-14 15:02:55 UTC (rev 16083)
@@ -143,6 +143,11 @@
                        if(!$use_fellesdata)
                        {
                                $menus['navigation'] = 
array_reverse($menus['navigation'], true);
+                               $menus['navigation']['moveout'] = array(
+                                       'text' => lang('moveout'),
+                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uimoveout.index')),
+                                       'image' => array('rental', 
'text-x-generic'),
+                               );
                                $menus['navigation']['schedule'] = array(
                                        'text' => lang('schedule'),
                                        'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uicomposite.schedule')),
@@ -153,6 +158,7 @@
                                        'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uiapplication.index')),
                                        'image' => array('rental', 
'text-x-generic'),
                                );
+
                                $menus['navigation'] = 
array_reverse($menus['navigation'], true);
                        }
 

Added: trunk/rental/inc/class.somoveout.inc.php
===================================================================
--- trunk/rental/inc/class.somoveout.inc.php                            (rev 0)
+++ trunk/rental/inc/class.somoveout.inc.php    2016-12-14 15:02:55 UTC (rev 
16083)
@@ -0,0 +1,116 @@
+<?php
+       /**
+        * phpGroupWare - rental: 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 rental
+        * @subpackage moveout
+        * @version $Id: $
+        */
+       phpgw::import_class('phpgwapi.socommon');
+
+       class rental_somoveout extends phpgwapi_socommon
+       {
+
+               protected static $so;
+
+               public function __construct()
+               {
+                       parent::__construct('rental_moveout', 
rental_moveout::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.socustomer');
+                       }
+                       return self::$so;
+               }
+
+
+               protected function populate( array $data )
+               {
+                       $object = new rental_moveout();
+                       foreach ($this->fields as $field => $field_info)
+                       {
+                               $object->set_field($field, $data[$field]);
+                       }
+
+                       return $object;
+               }
+
+               protected function update( $object )
+               {
+                       $this->db->transaction_begin();
+       //              $status_text = rental_moveout::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 ($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
+                                       (
+                                               'customer_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 
rental_moveout_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

Added: trunk/rental/inc/class.uimoveout.inc.php
===================================================================
--- trunk/rental/inc/class.uimoveout.inc.php                            (rev 0)
+++ trunk/rental/inc/class.uimoveout.inc.php    2016-12-14 15:02:55 UTC (rev 
16083)
@@ -0,0 +1,222 @@
+<?php
+       /**
+        * phpGroupWare - rental: 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 moveout was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
+        * @package rental
+        * @subpackage moveout
+        * @version $Id: $
+        */
+       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.datetime');
+
+       include_class('rental', 'moveout', 'inc/model/');
+
+       class rental_uimoveout extends eventplanner_uicommon
+       {
+
+               public $public_functions = array(
+                       'add' => true,
+                       'index' => true,
+                       'query' => true,
+                       'view' => true,
+                       'edit' => true,
+                       'save' => true,
+                       'get' => true
+               );
+               protected
+                       $fields,
+                       $permissions;
+
+               public function __construct()
+               {
+                       parent::__construct();
+                       self::set_active_menu('rental::moveout');
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('moveout');
+                       $this->bo = createObject('rental.bomoveout');
+                       $this->fields = rental_moveout::get_fields();
+                       $this->permissions = 
rental_moveout::get_instance()->get_permission_array();
+               }
+
+               public function index()
+               {
+                       $function_msg = lang('moveout');
+
+                       if (empty($this->permissions[PHPGW_ACL_READ]))
+                       {
+                               phpgw::no_access($function_msg);
+                       }
+
+                       if (phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query();
+                       }
+
+                       phpgwapi_jquery::load_widget('autocomplete');
+
+                       $data = array(
+                               'datatable_name' => $function_msg,
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                               )
+                                       )
+                               ),
+                               'datatable' => array(
+                                       'source' => self::link(array(
+                                               'menuaction' => 
'rental.uimoveout.index',
+                                               'phpgw_return_as' => 'json'
+                                       )),
+                                       'allrows' => true,
+                                       'new_item' => 
self::link(array('menuaction' => 'rental.uimoveout.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' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 'rental.uimoveout.view'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       $data['datatable']['actions'][] = array
+                               (
+                               'my_name' => 'edit',
+                               'text' => lang('edit'),
+                               'action' => 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                       'menuaction' => 'rental.uimoveout.edit'
+                               )),
+                               'parameters' => json_encode($parameters)
+                       );
+
+                       self::add_javascript('rental', 'rental', 
'moveout.index.js');
+                       phpgwapi_jquery::load_widget('numberformat');
+
+                       self::render_template_xsl('datatable_jquery', $data);
+               }
+
+               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']))
+                       {
+                               $moveout = $values['object'];
+                       }
+                       else
+                       {
+                               $id = !empty($values['id']) ? $values['id'] : 
phpgw::get_var('id', 'int');
+                               $moveout = $this->bo->read_single($id);
+                       }
+
+                       $tabs = array();
+                       $tabs['first_tab'] = array(
+                               'label' => lang('moveout'),
+                               'link' => '#first_tab'
+                       );
+
+
+                       $comments = (array)$moveout->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)
+                               )
+                       );
+
+                       $data = array(
+                               'datatable_def' => $datatable_def,
+                               'form_action' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uimoveout.save')),
+                               'cancel_url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'rental.uimoveout.index',)),
+                               'moveout' => $moveout,
+                               'mode' => $mode,
+                               'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+                               'value_active_tab' => $active_tab
+                       );
+                       phpgwapi_jquery::formvalidator_generate(array());
+                       self::add_javascript('rental', 'rental', 
'moveout.edit.js');
+                       self::render_template_xsl(array('moveout', 
'datatable_inline'), array($mode => $data));
+               }
+
+               /*
+                * Get the moveout with the id given in the http variable 'id'
+                */
+
+               public function get( $id = 0 )
+               {
+                       if (empty($this->permissions[PHPGW_ACL_ADD]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $id = !empty($id) ? $id : phpgw::get_var('id', 'int');
+
+                       $moveout = $this->bo->read_single($id)->toArray();
+
+                       unset($moveout['secret']);
+
+                       return $moveout;
+               }
+
+               public function save()
+               {
+                       parent::save();
+               }
+       }
\ No newline at end of file

Added: trunk/rental/inc/model/class.moveout.inc.php
===================================================================
--- trunk/rental/inc/model/class.moveout.inc.php                                
(rev 0)
+++ trunk/rental/inc/model/class.moveout.inc.php        2016-12-14 15:02:55 UTC 
(rev 16083)
@@ -0,0 +1,287 @@
+<?php
+       /**
+        * phpGroupWare - rental: 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 rental
+        * @subpackage moveout
+        * @version $Id: $
+        */
+
+       phpgw::import_class('rental.bomoveout');
+
+       include_class('phpgwapi', 'model', 'inc/model/');
+
+       class rental_moveout extends phpgwapi_model
+       {
+
+               const STATUS_REGISTERED = 1;
+               const STATUS_PENDING = 2;
+               const STATUS_REJECTED = 3;
+               const STATUS_APPROVED = 4;
+               const acl_location = '.moveout';
+
+               protected
+                       $id,
+                       $active,
+                       $category_id,
+                       $created,
+                       $modified,
+                       $secret,
+                       $name,
+                       $address_1,
+                       $address_2,
+                       $zip_code,
+                       $city,
+                       $moveout_organization_number,
+                       $contact_name,
+                       $contact_email,
+                       $contact_phone,
+                       $account_number,
+                       $description,
+                       $remark,
+       //              $moveout_identifier_type,
+       //              $moveout_ssn,
+
+                       $comments,
+                       $comment;
+
+               protected $field_of_responsibility_name = '.moveout';
+
+               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 rental_moveout();
+               }
+
+               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',
+                                       ),
+                               'active' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'int',
+                                       'history'       => true
+                                       ),
+                               'category_id' => array('action'=>  
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'int'
+                                       ),
+                               'created' => array('action'=> PHPGW_ACL_READ,
+                                       'type' => 'date',
+                                       'label' => 'created',
+                                       'sortable' => true,
+                                       ),
+                               'modified' => array('action'=> PHPGW_ACL_READ | 
PHPGW_ACL_EDIT,
+                                       'type' => 'date',
+                                       'label' => 'modified',
+                                       'sortable' => true,
+                                       ),
+                               'secret' => array('action'=> PHPGW_ACL_ADD,
+                                       'type' => 'string',
+                                       'label' => 'secret',
+                                       'sortable' => false,
+                                       ),
+                               'name' => array(
+                                       'action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'label' => 'name',
+                                       'required' => true,
+                                       'query' => true,
+                                       ),
+                               'address_1' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true
+                                       ),
+                               'address_2' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => false),
+                               'zip_code' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true),
+                               'city' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true),
+                               'account_number' => array('action'=> 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true),
+                               'description' => array('action'=> PHPGW_ACL_ADD 
| PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'label' => 'description',
+                                       'sortable' => false,
+                                       'required' => true
+                                       ),
+                               'remark' => array('action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'label' => 'description',
+                                       'sortable' => false,
+                                       ),
+                               'contact_name' => array(
+                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true,
+                                       'query' => true,
+                                       'label' => 'contact name',
+                                       ),
+                               'contact_email' => array(
+                                       'action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true,
+                                       'query' => true,
+                                       'sf_validator' => 
createObject('booking.sfValidatorEmail', array(), array('invalid' => '%field% 
is invalid')),
+                                       'label' => 'contact email',
+                                       ),
+                               'contact_phone' => array(
+                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true,
+                                       'query' => true,
+                                       'label' => 'contact phone',
+                                       ),
+/*                             'moveout_identifier_type' => array(
+                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true,
+                                       'label' => 'moveout_identifier_type',
+                                       ),
+                               'moveout_ssn' => array(
+                                       'action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => false,
+                                       'query' => true,
+                                       'sf_validator' => 
createObject('booking.sfValidatorNorwegianSSN', array('full_required' => 
false)),
+                                       'label' => 'moveout_ssn'
+                                       ),*/
+                               'moveout_organization_number' => array(
+                                       'action'=> PHPGW_ACL_READ | 
PHPGW_ACL_ADD | PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'required' => true,
+                                       'query' => true,
+                                       'sf_validator' => 
createObject('booking.sfValidatorNorwegianOrganizationNumber', array(), 
array('invalid' => '%field% is invalid')),
+                                       'label' => 'organization_number'
+                                       ),
+                               'comments' => array(
+                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'manytomany' => array(
+                                               'input_field' => 
'comment_input',
+                                               'table' => 
'rental_moveout_comment',
+                                               'key' => 'moveout_id',
+                                               'column' => array('time', 
'author', 'comment', 'type'),
+                                               'order' => array('sort' => 
'time', 'dir' => 'ASC')
+                                       )),
+                               'comment' => array(
+                                       'action'=> PHPGW_ACL_ADD | 
PHPGW_ACL_EDIT,
+                                       'type' => 'string',
+                                       'related' => true,
+                                       )
+                       );
+
+                       if($debug)
+                       {
+                               foreach ($fields as $field => $field_info)
+                               {
+                                       if(!property_exists('rental_moveout', 
$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 (!empty($entity->moveout_organization_number))
+                       {
+                               $entity->moveout_organization_number = 
str_replace(' ', '', $entity->moveout_organization_number);
+                       }
+
+                       $entity->modified = time();
+                       $entity->active = (int)$entity->active;
+
+                       if($entity->get_id())
+                       {
+                       }
+                       else
+                       {
+                               $entity->status = 
rental_moveout::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 rental_bomoveout::get_instance()->store($this);
+               }
+
+               public function read_single($id)
+               {
+                       return 
rental_bomoveout::get_instance()->read_single($id, true);
+               }
+       }

Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang    2016-12-13 10:45:46 UTC (rev 16082)
+++ trunk/rental/setup/phpgw_no.lang    2016-12-14 15:02:55 UTC (rev 16083)
@@ -640,4 +640,5 @@
 type   rental  no      Type
 custom price   rental  no      Taksering
 price type     rental  no      Pristype
-schedule       rental  no      Kalender
\ No newline at end of file
+schedule       rental  no      Kalender
+moveout        rental  no      Utflytting
\ No newline at end of file

Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php    2016-12-13 10:45:46 UTC (rev 
16082)
+++ trunk/rental/setup/tables_update.inc.php    2016-12-14 15:02:55 UTC (rev 
16083)
@@ -739,3 +739,18 @@
                        return $GLOBALS['setup_info']['rental']['currentver'];
                }
        }
+
+
+       $test[] = '0.1.0.31';
+       function rental_upgrade0_1_0_31()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+       //      $GLOBALS['phpgw']->locations->add('.moveout', 'Moveout', 
'rental', $allow_grant = true, $custom_tbl = false, $c_function = true);
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['rental']['currentver'] = 
'0.1.0.31';
+                       return $GLOBALS['setup_info']['rental']['currentver'];
+               }
+       }

Added: trunk/rental/templates/base/moveout.xsl
===================================================================
--- trunk/rental/templates/base/moveout.xsl                             (rev 0)
+++ trunk/rental/templates/base/moveout.xsl     2016-12-14 15:02:55 UTC (rev 
16083)
@@ -0,0 +1,299 @@
+
+<!-- $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="customer/id > 0">
+                                                       <div 
class="pure-control-group">
+                                                               <label>
+                                                                       
<xsl:value-of select="php:function('lang', 'id')"/>
+                                                               </label>
+                                                               <input 
type="hidden" name="id" value="{customer/id}"/>
+                                                               <xsl:value-of 
select="customer/id"/>
+                                                       </div>
+                                               </xsl:if>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'active')"/>
+                                                       </label>
+                                                       <input type="checkbox" 
name="active" id="active" value="1">
+                                                               <xsl:if 
test="customer/active = 1">
+                                                                       
<xsl:attribute name="checked" value="checked"/>
+                                                               </xsl:if>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <xsl:variable 
name="lang_category">
+                                                               <xsl:value-of 
select="php:function('lang', 'category')"/>
+                                                       </xsl:variable>
+                                                       <label>
+                                                               <xsl:value-of 
select="$lang_category"/>
+                                                       </label>
+                                                       <select 
name="category_id">
+                                                               <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="$lang_category"/>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="data-validation-error-msg">
+                                                                       
<xsl:value-of select="$lang_category"/>
+                                                               </xsl:attribute>
+                                                               
<xsl:apply-templates select="category_list/options"/>
+                                                       </select>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'name')"/>
+                                                       </label>
+                                                       <input type="text" 
name="name" value="{customer/name}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'name')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <xsl:variable 
name="lang_address_1">
+                                                               <xsl:value-of 
select="php:function('lang', 'address_1')"/>
+                                                       </xsl:variable>
+                                                       <xsl:variable 
name="lang_address_2">
+                                                               <xsl:value-of 
select="php:function('lang', 'address_2')"/>
+                                                       </xsl:variable>
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'address')"/>
+                                                       </label>
+                                                       <input type="text" 
name="address_1" value="{customer/address_1}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="$lang_address_1"/>
+                                                               </xsl:attribute>
+
+                                                       </input>
+                                                       <input type="text" 
name="address_2" value="{customer/address_2}">
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="$lang_address_2"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'postal_code_place')"/>
+                                                       </label>
+                                                       <input type="text" 
name="zip_code" value="{customer/zip_code}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'zip_code')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                                       <input type="text" 
name="city" value="{customer/city}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'city')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'customer_organization_number')"/>
+                                                       </label>
+                                                       <input type="text" 
id="lastname" name="customer_organization_number" 
value="{customer/customer_organization_number}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'customer_organization_number')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'contact name')"/>
+                                                       </label>
+                                                       <input type="text" 
name="contact_name" value="{customer/contact_name}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'contact_name')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'email')"/>
+                                                       </label>
+                                                       <input type="text" 
name="contact_email" id="contact_email" value="{customer/contact_email}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>email</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'email')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="valid_email = 1">
+                                                                       
<xsl:text> </xsl:text>
+                                                                       <a 
href="{link_create_user}">
+                                                                               
<xsl:value-of select="php:function('lang', 'create_user_based_on_email_link')"/>
+                                                                       </a>
+                                                               </xsl:when>
+                                                       </xsl:choose>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'contact phone')"/>
+                                                       </label>
+                                                       <input type="text" 
name="contact_phone" value="{customer/contact_phone}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'contact_phone')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'account_number')"/>
+                                                       </label>
+                                                       <input type="text" 
name="account_number" value="{customer/account_number}">
+                                                               <xsl:attribute 
name="data-validation">
+                                                                       
<xsl:text>required</xsl:text>
+                                                               </xsl:attribute>
+                                                               <xsl:attribute 
name="placeholder">
+                                                                       
<xsl:value-of select="php:function('lang', 'account_number')"/>
+                                                               </xsl:attribute>
+                                                       </input>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'description')"/>
+                                                       </label>
+                                                       <textarea cols="47" 
rows="7" name="description">
+                                                               <xsl:value-of 
select="customer/description"/>
+                                                       </textarea>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'remark')"/>
+                                                       </label>
+                                                       <textarea cols="47" 
rows="7" name="remark">
+                                                               <xsl:value-of 
select="customer/remark"/>
+                                                       </textarea>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'comment')"/>
+                                                       </label>
+                                                       <textarea cols="47" 
rows="7" name="comment">
+                                                               <xsl:value-of 
select="customer/comment"/>
+                                                       </textarea>
+                                               </div>
+                                               <div class="pure-control-group">
+                                                       <label>
+                                                               <xsl:value-of 
select="php:function('lang', 'details')"/>
+                                                       </label>
+                                                       <div 
class="pure-custom">
+                                                               <xsl:for-each 
select="datatable_def">
+                                                                       <xsl:if 
test="container = 'datatable-container_0'">
+                                                                               
<xsl:call-template name="table_setup">
+                                                                               
        <xsl:with-param name="container" select ='container'/>
+                                                                               
        <xsl:with-param name="requestUrl" select ='requestUrl'/>
+                                                                               
        <xsl:with-param name="ColumnDefs" select ='ColumnDefs'/>
+                                                                               
        <xsl:with-param name="data" select ='data'/>
+                                                                               
        <xsl:with-param name="config" select ='config'/>
+                                                                               
</xsl:call-template>
+                                                                       
</xsl:if>
+                                                               </xsl:for-each>
+                                                       </div>
+                                               </div>
+                                       </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]