[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15214] rental: prepare for application handling
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15214] rental: prepare for application handling |
Date: |
Sun, 29 May 2016 17:18:53 +0000 (UTC) |
Revision: 15214
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15214
Author: sigurdne
Date: 2016-05-29 17:18:53 +0000 (Sun, 29 May 2016)
Log Message:
-----------
rental: prepare for application handling
Modified Paths:
--------------
trunk/rental/inc/class.menu.inc.php
trunk/rental/setup/phpgw_no.lang
Added Paths:
-----------
trunk/rental/inc/class.soapplication.inc.php
trunk/rental/inc/class.uiapplication.inc.php
trunk/rental/inc/model/class.application.inc.php
trunk/rental/js/rental/application.index.js
trunk/rental/templates/base/application.xsl
Modified: trunk/rental/inc/class.menu.inc.php
===================================================================
--- trunk/rental/inc/class.menu.inc.php 2016-05-29 17:17:01 UTC (rev 15213)
+++ trunk/rental/inc/class.menu.inc.php 2016-05-29 17:18:53 UTC (rev 15214)
@@ -118,6 +118,11 @@
$menus['navigation'] = array
(
+ 'application' => array(
+ 'text' => lang('application'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'rental.uiapplication.index')),
+ 'image' => array('rental',
'text-x-generic'),
+ ),
'contracts' => array
(
'text' => lang('contracts'),
Added: trunk/rental/inc/class.soapplication.inc.php
===================================================================
--- trunk/rental/inc/class.soapplication.inc.php
(rev 0)
+++ trunk/rental/inc/class.soapplication.inc.php 2016-05-29 17:18:53 UTC
(rev 15214)
@@ -0,0 +1,299 @@
+<?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 rental
+ * @subpackage application
+ * @version $Id: $
+ */
+
+ class rental_soapplication
+ {
+
+ protected $db;
+ protected $like;
+ protected $join;
+ protected $left_join;
+ protected $sort_field;
+ protected $skip_limit_query;
+ protected static $so;
+
+ public function __construct()
+ {
+ $this->db = & $GLOBALS['phpgw']->db;
+ $this->like = & $this->db->like;
+ $this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
+ $this->sort_field = null;
+ $this->skip_limit_query = null;
+ }
+
+ /**
+ * Begin transaction
+ *
+ * @return integer|bool current transaction id
+ */
+ public function transaction_begin()
+ {
+ return $this->db->transaction_begin();
+ }
+
+ /**
+ * Complete the transaction
+ *
+ * @return bool True if sucessful, False if fails
+ */
+ public function transaction_commit()
+ {
+ return $this->db->transaction_commit();
+ }
+
+ /**
+ * Rollback the current transaction
+ *
+ * @return bool True if sucessful, False if fails
+ */
+ public function transaction_abort()
+ {
+ return $this->db->transaction_abort();
+ }
+
+ /**
+ * Marshal values according to type
+ * @param $value the value
+ * @param $type the type of value
+ * @return database value
+ */
+ protected function marshal( $value, $type )
+ {
+ if ($value === null)
+ {
+ return 'NULL';
+ }
+ else if ($type == 'int')
+ {
+ if ($value == '')
+ {
+ return 'NULL';
+ }
+ return intval($value);
+ }
+ else if ($type == 'float')
+ {
+ return str_replace(',', '.', $value);
+ }
+ else if ($type == 'field')
+ {
+ return $this->db->db_addslashes($value);
+ }
+ return "'" . $this->db->db_addslashes($value) . "'";
+ }
+
+ /**
+ * Unmarchal database values according to type
+ * @param $value the field value
+ * @param $type a string dictating value type
+ * @return the php value
+ */
+ protected function unmarshal( $value, $type )
+ {
+ if ($type == 'bool')
+ {
+ return (bool)$value;
+ }
+ elseif ($type == 'int')
+ {
+ return (int)$value;
+ }
+ elseif ($value === null || $value == 'NULL')
+ {
+ return null;
+ }
+ elseif ($type == 'float')
+ {
+ return floatval($value);
+ }
+ return $value;
+ }
+
+ /**
+ * Get the count of the specified query. Query must return a
signel column
+ * called count.
+ *
+ * @param $sql the sql query
+ * @return the count value
+ */
+ protected function get_query_count( $sql )
+ {
+ $result = $this->db->query($sql);
+ if ($result && $this->db->next_record())
+ {
+ return $this->unmarshal($this->db->f('count',
true), 'int');
+ }
+ }
+
+ /**
+ * Implementing classes must return an instance of itself.
+ *
+ * @return the class instance.
+ */
+ public static function get_instance()
+ {
+ if (self::$so == null)
+ {
+ self::$so =
CreateObject('rental.soapplication');
+ }
+ return self::$so;
+
+ }
+
+ /**
+ * Convenience method for getting one single object. Calls
get() with the
+ * specified id as a filter.
+ *
+ * @param $id int with id of object to return.
+ * @return object with the specified id, null if not found.
+ */
+ public function get_single( int $id )
+ {
+ $objects = $this->get(0, 0, '', false, '', '',
array($this->get_id_field_name() => $id));
+ if (count($objects) > 0)
+ {
+ $keys = array_keys($objects);
+ return $objects[$keys[0]];
+ }
+ return null;
+ }
+
+ /**
+ * Method for retrieving the db-object (security "forgotten")
+ */
+ public function get_db()
+ {
+ return $this->db;
+ }
+
+ /**
+ * Method for retreiving objects.
+ *
+ * @param $start_index int with index of first object.
+ * @param $num_of_objects int with max number of objects to
return.
+ * @param $sort_field string representing the object field to
sort on.
+ * @param $ascending bool true for ascending sort on sort
field, false
+ * for descending.
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @return array of objects. May return an empty
+ * array, never null. The array keys are the respective index
numbers.
+ */
+ public function get( int $start_index, int $num_of_objects,
string $sort_field, bool $ascending, string $search_for, string $search_type,
array $filters )
+ {
+ $results = array(); // Array to store result objects
+
+ return $results;
+ }
+
+ /**
+ * Returns count of matching objects.
+ *
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @return int with object count.
+ */
+ public function get_count( string $search_for, string
$search_type, array $filters )
+ {
+ return $this->get_query_count($this->get_query('',
false, $search_for, $search_type, $filters, true));
+ }
+
+ /**
+ * Implementing classes must return the name of the field used
in the query
+ * returned from get_query().
+ *
+ * @return string with name of id field.
+ */
+ protected function get_id_field_name()
+ {
+
+ }
+
+ /**
+ * Returns SQL for retrieving matching objects or object count.
+ *
+ * @param $start_index int with index of first object.
+ * @param $num_of_objects int with max number of objects to
return.
+ * @param $sort_field string representing the object field to
sort on.
+ * @param $ascending bool true for ascending sort on sort
field, false
+ * for descending.
+ * @param $search_for string with free text search query.
+ * @param $search_type string with the query type.
+ * @param $filters array with key => value of filters.
+ * @param $return_count bool telling to return only the count
of the
+ * matching objects, or the objects themself.
+ * @return string with SQL.
+ */
+ protected function get_query( string $sort_field, bool
$ascending, string $search_for, string $search_type, array $filters, bool
$return_count )
+ {
+
+ }
+
+ protected function populate( int $object_id, &$object )
+ {
+
+ }
+
+ protected function add( &$object )
+ {
+
+ }
+
+ protected function update( $object )
+ {
+
+ }
+
+ /**
+ * Store the object in the database. If the object has no ID
it is assumed to be new and
+ * inserted for the first time. The object is then updated
with the new insert id.
+ */
+ public function store( &$object )
+ {
+ if ($object->validates())
+ {
+ if ($object->get_id() > 0)
+ {
+ // We can assume this composite came
from the database since it has an ID. Update the existing row
+ return $this->update($object);
+ }
+ else
+ {
+ // This object does not have an ID, so
will be saved as a new DB row
+ return $this->add($object);
+ }
+ }
+
+ // The object did not validate
+ return false;
+ }
+ }
\ No newline at end of file
Added: trunk/rental/inc/class.uiapplication.inc.php
===================================================================
--- trunk/rental/inc/class.uiapplication.inc.php
(rev 0)
+++ trunk/rental/inc/class.uiapplication.inc.php 2016-05-29 17:18:53 UTC
(rev 15214)
@@ -0,0 +1,465 @@
+<?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 rental
+ * @subpackage application
+ * @version $Id: $
+ */
+
+ phpgw::import_class('rental.uicommon');
+ phpgw::import_class('rental.soapplication');
+
+ include_class('rental', 'application', 'inc/model/');
+
+ class rental_uiapplication extends rental_uicommon
+ {
+
+ public $public_functions = array
+ (
+ 'add' => true,
+ 'index' => true,
+ 'query' => true,
+ 'view' => true,
+ 'edit' => true,
+ 'save' => true,
+ 'set_value' => true,
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+ self::set_active_menu('rental::application');
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('application');
+ }
+
+ public function index()
+ {
+ if (!$this->isExecutiveOfficer())
+ {
+ phpgw::no_access();
+ }
+
+ if (phpgw::get_var('phpgw_return_as') == 'json')
+ {
+ return $this->query();
+ }
+
+ phpgwapi_jquery::load_widget('autocomplete');
+
+ $types_options = array();
+ $types_options[] = array(
+ 'id' => 1,
+ 'name' => 'registrert'
+ );
+ $types_options[] = array(
+ 'id' => 2,
+ 'name' => 'under behandling'
+ );
+ $types_options[] = array(
+ 'id' => 3,
+ 'name' => 'avvist'
+ );
+ $types_options[] = array(
+ 'id' => 3,
+ 'name' => 'godkjent'
+ );
+
+ $function_msg = lang('application');
+
+ $data = array(
+ 'datatable_name' => $function_msg,
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array(
+ 'type' =>
'filter',
+ 'name' =>
'responsibility_id',
+ 'text' =>
lang('status'),
+ 'list' =>
$types_options
+ ),
+ array('type' =>
'autocomplete',
+ 'name' =>
'dimb',
+ 'app' =>
'property',
+ 'ui' =>
'generic',
+
'label_attr'=>'descr',
+ // 'show_id'=>
true,
+ 'text' =>
lang('dimb') . ':',
+
'requestGenerator' => 'requestWithDimbFilter',
+ ),
+ )
+ )
+ ),
+ 'datatable' => array(
+ 'source' => self::link(array(
+ 'menuaction' =>
'rental.uiapplication.index',
+ 'phpgw_return_as' => 'json'
+ )),
+ 'allrows' => true,
+ 'new_item' =>
self::link(array('menuaction' => 'rental.uiapplication.add')),
+ 'editor_action' => '',
+ 'field' => array(
+ array(
+ 'key' => 'title',
+ 'label' => lang('name'),
+ 'className' => '',
+ 'sortable' => true,
+ 'hidden' => false
+ ),
+ array(
+ 'key' => 'is_area',
+ 'label' => 'Avdeling',
+ 'className' => '',
+ 'sortable' => true,
+ 'hidden' => false
+ ),
+ array(
+ 'key' => 'status',
+ 'label' =>
lang('status'),
+ 'className' => '',
+ 'sortable' => true,
+ 'hidden' => false
+ ),
+ array(
+ 'key' => 'assignedto',
+ 'label' =>
'saksbehandler',
+ 'className' => '',
+ 'sortable' => true,
+ 'hidden' => false
+ ),
+ array(
+ 'key' => 'type',
+ 'label' => lang('type'),
+ 'className' => '',
+ 'sortable' => false,
+ 'hidden' => false
+ )
+ )
+ )
+ );
+
+ $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.uiapplication.view'
+ )),
+ 'parameters' => json_encode($parameters)
+ );
+
+ $data['datatable']['actions'][] = array
+ (
+ 'my_name' => 'edit',
+ 'text' => lang('edit'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php', array
+ (
+ 'menuaction' =>
'rental.uiapplication.edit'
+ )),
+ 'parameters' => json_encode($parameters)
+ );
+
+ $code = <<<JS
+ var thousandsSeparator =
'$this->thousandsSeparator';
+ var decimalSeparator =
'$this->decimalSeparator';
+ var decimalPlaces = '$this->decimalPlaces';
+ var currency_suffix = '$this->currency_suffix';
+JS;
+
+ $GLOBALS['phpgw']->js->add_code('', $code);
+
+ self::add_javascript('rental', 'rental',
'application.index.js');
+ phpgwapi_jquery::load_widget('numberformat');
+
+ self::render_template_xsl('datatable_jquery', $data);
+ }
+ /*
+ * View the price item with the id given in the http variable
'id'
+ */
+
+ public function view()
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('view');
+
+ if (!self::isExecutiveOfficer())
+ {
+ phpgw::no_access();
+ }
+
+ $this->edit(array(), 'view');
+ }
+ /*
+ * Edit the price item with the id given in the http variable
'id'
+ */
+
+ public function edit( $values = array(), $mode = 'edit' )
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' .
lang('edit');
+ if (!self::isExecutiveOfficer())
+ {
+ phpgw::no_access();
+ }
+
+ $responsibility_id =
phpgw::get_var('responsibility_id');
+ $application_id = phpgw::get_var('id', 'int');
+
+ if (!empty($values['application_id']))
+ {
+ $application_id = $values['application_id'];
+ }
+
+ if (!empty($application_id))
+ {
+ $application =
rental_application::get($application_id);
+ }
+ else
+ {
+ $title = phpgw::get_var('application_title');
+
+ $application = new rental_application();
+ $application->set_title($title);
+//
$application->set_responsibility_id($responsibility_id);
+// $application->set_price_type_id(1); // defaults
to year
+ }
+
+ // $responsibility_title =
($application->get_responsibility_title()) ?
$application->get_responsibility_title() :
rental_socontract::get_instance()->get_responsibility_title($responsibility_id);
+
+ $link_save = array(
+ 'menuaction' => 'rental.uiapplication.save'
+ );
+
+ $link_index = array(
+ 'menuaction' => 'rental.uiapplication.index',
+ );
+
+ $tabs = array();
+ $tabs['showing'] = array('label' =>
lang('application'), 'link' => '#showing');
+ $active_tab = 'showing';
+
+// $current_price_type_id =
$application->get_price_type_id();
+ $types_options = array();
+// foreach ($application->get_price_types() as
$price_type_id => $price_type_title)
+// {
+// $selected = ($current_price_type_id ==
$price_type_id) ? 1 : 0;
+// $types_options[] = array('id' =>
$price_type_id, 'name' => lang($price_type_title),
+// 'selected' => $selected);
+// }
+
+ $data = array(
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php', $link_save),
+ 'cancel_url' =>
$GLOBALS['phpgw']->link('/index.php', $link_index),
+ 'lang_save' => lang('save'),
+ 'lang_cancel' => lang('cancel'),
+// 'lang_current_price_type' =>
lang($application->get_price_type_title()),
+// 'lang_adjustable_text' =>
$application->get_adjustable_text(),
+// 'lang_standard_text' =>
$application->get_standard_text(),
+// 'value_title' => $application->get_title(),
+// 'value_field_of_responsibility' =>
lang($responsibility_title),
+// 'value_agresso_id' =>
$application->get_agresso_id(),
+// 'is_area' => ($application->is_area()) ? 1 : 0,
+// 'list_type' => array('options' =>
$types_options),
+// 'value_price' => $application->get_price(),
+// 'value_price_formatted' =>
number_format($application->get_price(), $this->decimalPlaces,
$this->decimalSeparator, $this->thousandsSeparator) . ' ' .
$this->currency_suffix,
+// 'has_active_contract' =>
(rental_soapplication::get_instance()->has_active_contract($application->get_id()))
? 1 : 0,
+// 'is_inactive' => ($application->is_inactive())
? 1 : 0,
+// 'is_adjustable' =>
($application->is_adjustable()) ? 1 : 0,
+// 'is_standard' => ($application->is_standard())
? 1 : 0,
+ 'application_id' => $application->get_id(),
+// 'responsibility_id' => $responsibility_id,
+ 'mode' => $mode,
+ 'tabs' =>
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
+ 'validator' =>
phpgwapi_jquery::formvalidator_generate(array('location',
+ 'date',
+ 'security', 'file'))
+ );
+
+ self::render_template_xsl(array('application'),
array($mode => $data));
+ }
+ /*
+ * To be removed
+ * Add a new price item to the database. Requires only a title.
+ */
+
+ public function add()
+ {
+ if (!self::isExecutiveOfficer())
+ {
+ phpgw::no_access();
+ }
+
+ $this->edit();
+ }
+
+ public function save()
+ {
+ $application_id = phpgw::get_var('id', 'int');
+
+ if (!empty($application_id))
+ {
+ $application =
rental_application::get($application_id);
+ }
+ else
+ {
+ $title = phpgw::get_var('application_title');
+ $responsibility_id =
phpgw::get_var('responsibility_id');
+ $application = new rental_application();
+ $application->set_title($title);
+
$application->set_responsibility_id($responsibility_id);
+ $application->set_price_type_id(1); // defaults
to year
+ }
+
+ $application->set_title(phpgw::get_var('title'));
+
$application->set_agresso_id(phpgw::get_var('agresso_id'));
+ $application->set_is_area(phpgw::get_var('is_area') ==
'true' ? true : false);
+
$application->set_is_inactive(phpgw::get_var('is_inactive') == 'on' ? true :
false);
+
$application->set_is_adjustable(phpgw::get_var('is_adjustable') == 'on' ? true
: false);
+ $application->set_standard(phpgw::get_var('standard')
== 'on' ? true : false);
+ $application->set_price(phpgw::get_var('price'));
+
$application->set_price_type_id(phpgw::get_var('price_type_id', 'int'));
+ if ($application->get_agresso_id() == null)
+ {
+
phpgwapi_cache::message_set(lang('missing_agresso_id'), 'error');
+ }
+ else
+ {
+ if
(rental_soapplication::get_instance()->store($application))
+ {
+
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
+ $application_id =
$application->get_id();
+ }
+ else
+ {
+
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
+ }
+ }
+ $this->edit(array('application_id' => $application_id));
+ }
+
+ public function set_value()
+ {
+ if (!self::isExecutiveOfficer())
+ {
+ return;
+ }
+
+ $field_name = phpgw::get_var('field_name');
+ $value = phpgw::get_var('value');
+ $id = phpgw::get_var('id');
+
+ switch ($field_name)
+ {
+ case 'count':
+ $value = (int) $value;
+ break;
+ case 'price':
+ $value =
trim(str_replace(array($this->currency_suffix, " "), '', $value));
+ break;
+ case 'date_start':
+ case 'date_end':
+ $value =
phpgwapi_datetime::date_to_timestamp(phpgw::get_var('value'));
+ break;
+ default:
+ $value = phpgw::get_var('value');
+ break;
+ }
+
+ $application =
rental_socontract_application::get_instance()->get_single($id);
+ $application->set_field($field_name, $value);
+ $result =
rental_socontract_application::get_instance()->store($application);
+
+ $message = array();
+ if ($result)
+ {
+ $message['message'][] = array('msg' =>
lang('data has been saved'));
+ }
+ else
+ {
+ $message['error'][] = array('msg' => lang('data
has not been saved'));
+ }
+
+ return $message;
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @see rental/inc/rental_uicommon#query()
+ */
+ public function query()
+ {
+
+ if
($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
+ {
+ $user_rows_per_page =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $user_rows_per_page = 10;
+ }
+
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
+ $start_index = phpgw::get_var('start', 'int',
'REQUEST', 0);
+ $num_of_objects = (phpgw::get_var('length', 'int') <=
0) ? $user_rows_per_page : phpgw::get_var('length', 'int');
+ $sort_field = ($columns[$order[0]['column']]['data']) ?
$columns[$order[0]['column']]['data'] : 'agresso_id';
+ $sort_ascending = ($order[0]['dir'] == 'desc') ? false
: true;
+
+ $search_for = '';
+ $search_type = '';
+
+
+ $filters = array();
+ $result_objects =
rental_soapplication::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $object_count =
0;//rental_soapplication::get_instance()->get_count($search_for, $search_type,
$filters);
+
+ // Create an empty row set
+ $rows = array();
+ foreach ($result_objects as $record)
+ {
+ if (isset($record))
+ {
+ // ... add a serialized record
+ $rows[] = $record->serialize();
+ }
+ }
+
+
+ $result_data = array('results' => $rows);
+ $result_data['total_records'] = $object_count;
+ $result_data['draw'] = $draw;
+
+ return $this->jquery_results($result_data);
+ }
+
+ }
\ No newline at end of file
Added: trunk/rental/inc/model/class.application.inc.php
===================================================================
--- trunk/rental/inc/model/class.application.inc.php
(rev 0)
+++ trunk/rental/inc/model/class.application.inc.php 2016-05-29 17:18:53 UTC
(rev 15214)
@@ -0,0 +1,127 @@
+<?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 rental
+ * @subpackage application
+ * @version $Id: $
+ */
+ include_class('rental', 'model', 'inc/model/');
+
+ class rental_application extends rental_model
+ {
+
+ protected $title;
+ protected $description;
+ protected $name;
+ protected $type;
+ protected $type_id;
+ protected $contract_id;
+ protected $party_id;
+
+ public function __construct( int $id = null )
+ {
+ parent::__construct((int)$id);
+ }
+
+ public function set_title( $title )
+ {
+ $this->title = $title;
+ }
+
+ public function get_title()
+ {
+ return $this->title;
+ }
+
+ public function set_description( $description )
+ {
+ $this->description = $description;
+ }
+
+ public function get_description()
+ {
+ return $this->description;
+ }
+
+ public function set_name( $name )
+ {
+ $this->name = $name;
+ }
+
+ public function get_name()
+ {
+ return $this->name;
+ }
+
+ public function set_type( $type )
+ {
+ $this->type = $type;
+ }
+
+ public function get_type()
+ {
+ return $this->type;
+ }
+
+ public function set_type_id( $type_id )
+ {
+ $this->type_id = $type_id;
+ }
+
+ public function get_type_id()
+ {
+ return $this->type_id;
+ }
+
+ public function set_contract_id( $contract_id )
+ {
+ $this->contract_id = $contract_id;
+ }
+
+ public function get_contract_id()
+ {
+ return $this->contract_id;
+ }
+
+ public function set_party_id( $party_id )
+ {
+ $this->party_id = $party_id;
+ }
+
+ public function get_party_id()
+ {
+ return $this->party_id;
+ }
+
+ public function serialize()
+ {
+ return array(
+ 'id' => $this->get_id(),
+ 'title' => $this->get_title(),
+ 'description' => $this->get_description(),
+ 'name' => $this->get_name(),
+ 'type' => lang($this->get_type())
+ );
+ }
+ }
\ No newline at end of file
Added: trunk/rental/js/rental/application.index.js
===================================================================
--- trunk/rental/js/rental/application.index.js (rev 0)
+++ trunk/rental/js/rental/application.index.js 2016-05-29 17:18:53 UTC (rev
15214)
@@ -0,0 +1,4 @@
+function requestWithDimbFilter(request)
+{
+ return request + '&type=dimb&type_id=0';
+}
Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang 2016-05-29 17:17:01 UTC (rev 15213)
+++ trunk/rental/setup/phpgw_no.lang 2016-05-29 17:18:53 UTC (rev 15214)
@@ -619,4 +619,6 @@
Name or company is required rental no Navn på person ELLER navn på
foretak er obligatorisk
simulation rental no Simulering
credits rental no Kreditering
-override adjustment start rental no Overstyr sist regulert
\ No newline at end of file
+override adjustment start rental no Overstyr sist regulert
+application rental no søknad
+dimb rental no Ansvarssted
\ No newline at end of file
Added: trunk/rental/templates/base/application.xsl
===================================================================
--- trunk/rental/templates/base/application.xsl (rev 0)
+++ trunk/rental/templates/base/application.xsl 2016-05-29 17:18:53 UTC (rev
15214)
@@ -0,0 +1,305 @@
+
+<!-- $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:when test="adjustment_price">
+ <xsl:apply-templates select="adjustment_price" />
+
+ </xsl:when>
+ </xsl:choose>
+
+</xsl:template>
+
+<!-- add / edit -->
+<xsl:template xmlns:php="http://php.net/xsl" match="edit">
+ <div>
+ <xsl:variable name="form_action">
+ <xsl:value-of select="form_action"/>
+ </xsl:variable>
+
+ <xsl:value-of select="validator"/>
+
+ <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"/>
+ <div id="showing">
+ <!--fieldset>
+ <input type="hidden" name="id"
value="{price_item_id}"/>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'title')"/>
+ </label>
+ <input type="text"
name="title" id="title" value="{value_title}">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
+ </input>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'field_of_responsibility')"/>
+ </label>
+ <xsl:choose>
+ <xsl:when
test="price_item_id = 0 or price_item_id = ''">
+ <input
type="hidden" name="responsibility_id" id="responsibility_id"
value="{responsibility_id}"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:value-of
select="value_field_of_responsibility"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'agresso_id')"/>
+ </label>
+ <input type="text"
name="agresso_id" id="agresso_id" value="{value_agresso_id}">
+ <xsl:attribute
name="data-validation">
+
<xsl:text>required</xsl:text>
+ </xsl:attribute>
+ </input>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_area')"/>
+ </label>
+ <div
class="pure-custom">
+ <div>
+ <input
type="radio" name="is_area" value="true">
+
<xsl:if test="is_area = 1">
+
<xsl:attribute name="checked" value="checked"/>
+
</xsl:if>
+
</input>
+
<xsl:value-of select="php:function('lang', 'calculate_price_per_area')"/>
+ </div>
+ <div>
+ <input
type="radio" name="is_area" value="false">
+
<xsl:if test="is_area = 0">
+
<xsl:attribute name="checked" value="checked"/>
+
</xsl:if>
+ </input>
+
<xsl:value-of select="php:function('lang', 'calculate_price_apiece')"/>
+ </div>
+ </div>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'type')"/>
+ </label>
+ <select
id="price_type_id" name="price_type_id">
+
<xsl:apply-templates select="list_type/options"/>
+ </select>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'price')"/>
+ </label>
+ <input type="text"
name="price" id="price" value="{value_price}"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_inactive')"/>
+ </label>
+ <input type="checkbox"
name="is_inactive" id="is_inactive">
+ <xsl:if
test="is_inactive = 1">
+
<xsl:attribute name="checked" value="checked"/>
+ </xsl:if>
+ <xsl:if
test="has_active_contract = 1">
+
<xsl:attribute name="disabled" value="disabled"/>
+ </xsl:if>
+ </input>
+ <xsl:if
test="has_active_contract = 1">
+ <xsl:value-of
select="lang_price_element_in_use"/>
+ </xsl:if>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_adjustable')"/>
+ </label>
+ <input type="checkbox"
name="is_adjustable" id="is_adjustable">
+ <xsl:if
test="is_adjustable = 1">
+
<xsl:attribute name="checked" value="checked"/>
+ </xsl:if>
+ </input>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_standard')"/>
+ </label>
+ <input type="checkbox"
name="is_standard" id="is_standard">
+ <xsl:if
test="is_standard = 1">
+
<xsl:attribute name="checked" value="checked"/>
+ </xsl:if>
+ </input>
+ </div>
+ </fieldset-->
+ </div>
+ </div>
+ <div class="proplist-col">
+ <input type="submit" class="pure-button
pure-button-primary" name="save" value="{lang_save}"
onMouseout="window.status='';return true;"/>
+ <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>
+
+<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">
+ <!--fieldset>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'title')"/>
+ </label>
+ <xsl:value-of
select="value_title"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'field_of_responsibility')"/>
+ </label>
+ <xsl:value-of
select="value_field_of_responsibility"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'agresso_id')"/>
+ </label>
+ <xsl:value-of
select="value_agresso_id"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_area')"/>
+ </label>
+ <div
class="pure-custom">
+ <div>
+ <input
type="radio" name="is_area" value="true" disabled="disabled">
+
<xsl:if test="is_area = 1">
+
<xsl:attribute name="checked" value="checked"/>
+
</xsl:if>
+
</input>
+
<xsl:value-of select="php:function('lang', 'calculate_price_per_area')"/>
+ </div>
+ <div>
+ <input
type="radio" name="is_area" value="false" disabled="disabled">
+
<xsl:if test="is_area = 0">
+
<xsl:attribute name="checked" value="checked"/>
+
</xsl:if>
+
</input>
+
<xsl:value-of select="php:function('lang', 'calculate_price_apiece')"/>
+ </div>
+ </div>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'type')"/>
+ </label>
+ <xsl:value-of
select="lang_current_price_type"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'price')"/>
+ </label>
+ <xsl:value-of
select="value_price_formatted"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_inactive')"/>
+ </label>
+ <input type="checkbox"
name="is_inactive" id="is_inactive" disabled="disabled">
+ <xsl:if
test="is_inactive = 1">
+
<xsl:attribute name="checked" value="checked"/>
+ </xsl:if>
+ </input>
+ <xsl:if
test="has_active_contract = 1">
+ <xsl:value-of
select="lang_price_element_in_use"/>
+ </xsl:if>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_adjustable')"/>
+ </label>
+ <xsl:value-of
select="lang_adjustable_text"/>
+ </div>
+ <div class="pure-control-group">
+ <label>
+ <xsl:value-of
select="php:function('lang', 'is_standard')"/>
+ </label>
+ <xsl:value-of
select="lang_standard_text"/>
+ </div>
+ </fieldset-->
+ </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>
+
+
+<xsl:template name="top-toolbar">
+ <div class="toolbar-container">
+ <div class="pure-g">
+ <div class="pure-u-1">
+ <div>
+ <xsl:value-of
select="php:function('lang', 'manual_adjust_price_item_select')"/>
+ <select id="price_item_id"
name="price_item_id">
+ <xsl:apply-templates
select="list_type/options"/>
+ </select>
+ <xsl:value-of
select="php:function('lang', 'price')"/>
+ <input type="text"
id="ctrl_adjust_price_item_price" name="ctrl_adjust_price_item_price"/>
+ <xsl:variable name="lang_adjust_price">
+ <xsl:value-of
select="php:function('lang', 'adjust_price')"/>
+ </xsl:variable>
+ <input type="button" class="pure-button
pure-button-primary" name="adjust_price" value="{$lang_adjust_price}"
onClick="onAdjust_price()"/>
+ </div>
+ </div>
+ </div>
+ </div>
+</xsl:template>
+
+<xsl:template xmlns:php="http://php.net/xsl" match="adjustment_price">
+ <xsl:call-template name="jquery_phpgw_i18n"/>
+ <h3>
+ <xsl:value-of select="php:function('lang',
'manual_adjust_price_item')"/>
+ </h3>
+ <div>
+ <xsl:call-template name="top-toolbar" />
+ <br/>
+ <div id="showing">
+ <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="tabletools" select ='tabletools' />
+ <xsl:with-param name="data"
select ='data' />
+ <xsl:with-param name="config"
select ='config' />
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
+ </div>
+ </div>
+</xsl:template>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15214] rental: prepare for application handling,
sigurdne <=