fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [12040] Rental: optional composite standard, optional


From: Sigurd Nes
Subject: [Fmsystem-commits] [12040] Rental: optional composite standard, optional list of contract responsibility candidates, extra option of invoice excel-export
Date: Sun, 27 Jul 2014 11:21:49 +0000

Revision: 12040
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12040
Author:   sigurdne
Date:     2014-07-27 11:21:49 +0000 (Sun, 27 Jul 2014)
Log Message:
-----------
Rental: optional composite standard, optional list of contract responsibility 
candidates, extra option of invoice excel-export

Modified Paths:
--------------
    trunk/property/inc/class.sogeneric.inc.php
    trunk/rental/inc/class.menu.inc.php
    trunk/rental/inc/class.sobilling.inc.php
    trunk/rental/inc/class.socomposite.inc.php
    trunk/rental/inc/class.soprice_item.inc.php
    trunk/rental/inc/class.uibilling.inc.php
    trunk/rental/inc/class.uicomposite.inc.php
    trunk/rental/inc/class.uicontract.inc.php
    trunk/rental/inc/class.uiprice_item.inc.php
    trunk/rental/inc/model/class.agresso_lg04.inc.php
    trunk/rental/inc/model/class.composite.inc.php
    trunk/rental/inc/model/class.contract.inc.php
    trunk/rental/setup/phpgw_no.lang
    trunk/rental/setup/setup.inc.php
    trunk/rental/setup/tables_current.inc.php
    trunk/rental/setup/tables_update.inc.php
    trunk/rental/templates/base/billing.php
    trunk/rental/templates/base/composite.php
    trunk/rental/templates/base/contract.php

Modified: trunk/property/inc/class.sogeneric.inc.php
===================================================================
--- trunk/property/inc/class.sogeneric.inc.php  2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/property/inc/class.sogeneric.inc.php  2014-07-27 11:21:49 UTC (rev 
12040)
@@ -2746,8 +2746,62 @@
                                break;
 
 // END CONTROLLER TABLES
+// START RENTAL TABLES
+                               case 'composite_standard':
+                                       $info = array
+                                       (
+                                               'table'                         
=> 'rental_composite_standard',
+                                               'id'                            
=> array('name' => 'id', 'type' => 'int'),
+                                               'fields'                        
=> array
+                                               (
+                                                       array
+                                                       (
+                                                               'name' => 
'name',
+                                                               'descr' => 
lang('name'),
+                                                               'type' => 
'varchar'
+                                                       ),
+                                                       array
+                                                       (
+                                                               'name' => 
'factor',
+                                                               'descr' => 
lang('factor'),
+                                                               'type'          
=> 'numeric',
+                                                               'nullable'      
=> false,
+                                                               'size'          
=> 4,
+                                                               'sortable'      
=> true
+                                                       )
+                                               ),
+                                               'edit_msg'                      
=> lang('edit unit'),
+                                               'add_msg'                       
=> lang('add unit'),
+                                               'name'                          
=> lang('unit'),
+                                               'acl_app'                       
=> 'rental',
+                                               'acl_location'          => 
'.admin',
+                                               'menu_selection'        => 
'admin::rental::composite_standard'
+                                       );
+                               break;
+                               case 'responsibility_unit':
+                                       $info = array
+                                       (
+                                               'table'                         
=> 'rental_contract_responsibility_unit',
+                                               'id'                            
=> array('name' => 'id', 'type' => 'int'),
+                                               'fields'                        
=> array
+                                               (
+                                                       array
+                                                       (
+                                                               'name' => 
'name',
+                                                               'descr' => 
lang('name'),
+                                                               'type' => 
'varchar'
+                                                       ),
+                                               ),
+                                               'edit_msg'                      
=> lang('edit unit'),
+                                               'add_msg'                       
=> lang('add unit'),
+                                               'name'                          
=> lang('unit'),
+                                               'acl_app'                       
=> 'rental',
+                                               'acl_location'          => 
'.admin',
+                                               'menu_selection'        => 
'admin::rental::responsibility_unit'
+                                       );
+                               break;
+// END RENTAL TABLES
 
-
                        default:
                                $message =lang('ERROR: illegal type %1', $type);
                                phpgwapi_cache::message_set($message, 'error');

Modified: trunk/rental/inc/class.menu.inc.php
===================================================================
--- trunk/rental/inc/class.menu.inc.php 2014-07-01 07:38:16 UTC (rev 12039)
+++ trunk/rental/inc/class.menu.inc.php 2014-07-27 11:21:49 UTC (rev 12040)
@@ -5,13 +5,13 @@
        {
                function get_menu()
                {
-                       $incoming_app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $incoming_app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'rental';
                        
                        $config = CreateObject('phpgwapi.config','rental');
                        $config->read();
-                       $use_fellesdata = 
$config->config_data['use_fellesdata'];
-
+                       $use_fellesdata = 
$config->config_data['use_fellesdata'];
+
                        $menus = array();
 
                        $menus['navbar'] = array
@@ -135,16 +135,26 @@
 
                        $menus['admin'] = array
                        (
-                               'index' => array
-                               (
-                                       'text'  => lang('Configuration'),
-                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index', 'appname' => 'rental') )
-                               ),
+                               'index' => array
+                               (
+                                       'text'  => lang('Configuration'),
+                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index', 'appname' => 'rental') )
+                               ),
                                'acl'   => array
                                (
                                        'text'  => lang('Configure Access 
Permissions'),
                                        'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'preferences.uiadmin_acl.list_acl', 'acl_app' => 'rental') )
                                ),
+                               'composite_standard'    => array
+                               (
+                                       'text'  => lang('composite standard'),
+                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uigeneric.index', 'type' => 'composite_standard', 'admin' => true) )
+                               ),
+                               'responsibility_unit'   => array
+                               (
+                                       'text'  => lang('responsibility'),
+                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uigeneric.index', 'type' => 'responsibility_unit', 'admin' => true) )
+                               ),
                                'import'        => array
                                (
                                        'text'  => lang('facilit_import'),
@@ -163,13 +173,13 @@
                        
                        $menus['preferences'] = array
                        (
-                               array
-                               (
-                                       'text'  => lang('Preferences'),
-                                       'url'   => 
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' => 
'rental', 'type'=> 'user') )
-                               ),
                                array
                                (
+                                       'text'  => lang('Preferences'),
+                                       'url'   => 
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' => 
'rental', 'type'=> 'user') )
+                               ),
+                               array
+                               (
                                'text'  => lang('Grant Access'),
                                'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'preferences.uiadmin_acl.list_acl', 'acl_app'=> 'rental'))
                                )
@@ -178,4 +188,4 @@
                        return $menus;
                }
        }
-?>
+?>

Modified: trunk/rental/inc/class.sobilling.inc.php
===================================================================
--- trunk/rental/inc/class.sobilling.inc.php    2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.sobilling.inc.php    2014-07-27 11:21:49 UTC (rev 
12040)
@@ -348,7 +348,7 @@
                 * 
                 * @param $billing_job
                 */
-               public function generate_export(&$billing_job, $excel_export = 
false)
+               public function generate_export(&$billing_job, 
$excel_export_type = false)
                {
                        $exportable = null;
                        switch($billing_job->get_export_format())
@@ -365,9 +365,9 @@
                        }
                        if($exportable != null)
                        {
-                               if($excel_export)
+                               if($excel_export_type)
                                {
-                                       $export_data = 
$exportable->get_contents_excel();
+                                       $export_data = 
$exportable->get_contents_excel($excel_export_type);
                                        //_debug_array($export_data[1]);
                                        return $export_data;
                                }

Modified: trunk/rental/inc/class.socomposite.inc.php
===================================================================
--- trunk/rental/inc/class.socomposite.inc.php  2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.socomposite.inc.php  2014-07-27 11:21:49 UTC (rev 
12040)
@@ -172,7 +172,7 @@
                                $cols = "rental_composite.id AS composite_id,";
                        }
                        $cols .= "rental_unit.id AS unit_id, 
rental_unit.location_code, rental_composite.name, 
rental_composite.has_custom_address, rental_composite.address_1, 
rental_composite.house_number, 
-                                         rental_composite.address_2, 
rental_composite.postcode, rental_composite.place, rental_composite.is_active, 
rental_composite.area, rental_composite.description, 
rental_composite.furnish_type_id, ";
+                                         rental_composite.address_2, 
rental_composite.postcode, rental_composite.place, rental_composite.is_active, 
rental_composite.area, rental_composite.description, 
rental_composite.furnish_type_id, rental_composite.standard_id, ";
                        $cols .= "rental_contract.id AS contract_id, 
rental_contract.date_start, rental_contract.date_end, 
rental_contract.old_contract_id, ";
                        $cols .= "
                        CASE WHEN 
@@ -214,7 +214,8 @@
                        
$composite->set_custom_postcode($this->unmarshal($this->db->f('postcode', 
true), 'string'));
                        
$composite->set_custom_place($this->unmarshal($this->db->f('place', true), 
'string'));
                        
$composite->set_area($this->unmarshal($this->db->f('area', true), 'float'));
-                       
$composite->set_furnish_type_id($this->unmarshal($this->db->f('furnish_type_id',
 true), 'int'));
+                       
$composite->set_furnish_type_id($this->unmarshal($this->db->f('furnish_type_id'),
 'int'));
+                       
$composite->set_standard_id($this->unmarshal($this->db->f('standard_id'), 
'int'));
                }
                // Location code
                $location_code = $this->unmarshal($this->db->f('location_code', 
true), 'string');
@@ -353,6 +354,7 @@
             'object_type_id = '.$composite->get_object_type_id(),
             'area = ' . $this->marshal($composite->get_area(), 'float'),
                        'furnish_type_id = '.$composite->get_furnish_type_id(),
+                       'standard_id = '.$composite->get_standard_id(),
                );
 
                $result = $this->db->query('UPDATE rental_composite SET ' . 
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
@@ -370,7 +372,7 @@
        public function add(&$composite)
        {
                // Build a db-friendly array of the composite object
-               $cols = array('name', 'description', 'has_custom_address', 
'address_1', 'address_2', 'house_number', 'postcode', 'place', 
'object_type_id', 'area', 'furnish_type_id');
+               $cols = array('name', 'description', 'has_custom_address', 
'address_1', 'address_2', 'house_number', 'postcode', 'place', 
'object_type_id', 'area', 'furnish_type_id', 'standard_id');
                $values = array(
                        "'".$composite->get_name()."'",
                        "'".$composite->get_description()."'",
@@ -382,7 +384,8 @@
                        "'".$composite->get_custom_place()."'",
             $composite->get_object_type_id(),
             $this->marshal($composite->get_area(), 'float'),
-            $composite->get_furnish_type_id()
+            $composite->get_furnish_type_id(),
+            $composite->get_standard_id()
                );
 
                $query ="INSERT INTO rental_composite (" . join(',', $cols) . 
") VALUES (" . join(',', $values) . ")";

Modified: trunk/rental/inc/class.soprice_item.inc.php
===================================================================
--- trunk/rental/inc/class.soprice_item.inc.php 2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.soprice_item.inc.php 2014-07-27 11:21:49 UTC (rev 
12040)
@@ -334,8 +334,9 @@
         * @param $price_item   the price item to add
         * @return true if successful, false otherwise
         */
-       function add_price_item($contract_id, $price_item_id)
+       function add_price_item($contract_id, $price_item_id,$factor)
        {
+               $factor = $factor ? (float) $factor : 1;
                $price_item = $this->get_single($price_item_id);
                $contract = 
rental_socontract::get_instance()->get_single($contract_id);
                $rented_area = 0;
@@ -345,7 +346,7 @@
                        if($rented_area == ''){
                                $rented_area = 0;
                        }
-                       $total_price = ($rented_area * 
$price_item->get_price());
+                       $total_price = ($rented_area * $price_item->get_price() 
* $factor);
                        //var_dump($total_price, $rented_area, 
$price_item->get_price());
                }
                if($price_item)
@@ -357,7 +358,7 @@
                                str_replace(',','.',$rented_area),
                                "'" . $price_item->get_agresso_id() . "'",
                                $price_item->is_area() ? 'true' : 'false',
-                               str_replace(',','.',$price_item->get_price()),
+                               (str_replace(',','.',$price_item->get_price()) 
* $factor),
                                str_replace(',','.',$total_price)
                        );
                        $q = "INSERT INTO rental_contract_price_item 
(price_item_id, contract_id, title, area, agresso_id, is_area, price, 
total_price) VALUES (" . join(',', $values) . ")";

Modified: trunk/rental/inc/class.uibilling.inc.php
===================================================================
--- trunk/rental/inc/class.uibilling.inc.php    2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.uibilling.inc.php    2014-07-27 11:21:49 UTC (rev 
12040)
@@ -652,9 +652,9 @@
                     }
                     else
                     {
-                       $billing_job = 
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
-                        $billing_info_array = 
rental_sobilling_info::get_instance()->get(null, null, null, null, null, null, 
array('billing_id' => phpgw::get_var('id')));
-
+                                               $billing_job = 
rental_sobilling::get_instance()->get_single((int)phpgw::get_var('id'));
+                                               $billing_info_array = 
rental_sobilling_info::get_instance()->get(null, null, null, null, null, null, 
array('billing_id' => phpgw::get_var('id')));
+                                               $type = phpgw::get_var('type', 
'string', 'GET', 'bk');
                         if($billing_job == null) // Not found
                         {
                                 $errorMsgs[] = lang('Could not find specified 
billing job.');
@@ -675,7 +675,7 @@
                             $billing_job->set_year($year);
                             $billing_job->set_month($month);
                             
-                            $list = 
rental_sobilling::get_instance()->generate_export($billing_job, true);
+                            $list = 
rental_sobilling::get_instance()->generate_export($billing_job, $type);
                             //_debug_array($list[0]);
                             /*foreach ($list as $l)
                             {

Modified: trunk/rental/inc/class.uicomposite.inc.php
===================================================================
--- trunk/rental/inc/class.uicomposite.inc.php  2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.uicomposite.inc.php  2014-07-27 11:21:49 UTC (rev 
12040)
@@ -348,6 +348,7 @@
                                        
$composite->set_is_active(phpgw::get_var('is_active') == 'on' ? true : false);
                                        
$composite->set_description(phpgw::get_var('description'));
                                        
$composite->set_furnish_type_id(phpgw::get_var('furnish_type_id'));
+                                       
$composite->set_standard_id(phpgw::get_var('composite_standard_id','int'));
 
                                        
if(rental_socomposite::get_instance()->store($composite))
                                        {

Modified: trunk/rental/inc/class.uicontract.inc.php
===================================================================
--- trunk/rental/inc/class.uicontract.inc.php   2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.uicontract.inc.php   2014-07-27 11:21:49 UTC (rev 
12040)
@@ -839,11 +839,12 @@
                {
                        $contract_id = (int)phpgw::get_var('contract_id');
                        $price_item_id = (int)phpgw::get_var('price_item_id');
+                       $factor =  phpgw::get_var('factor','float');
                        $so_contract = rental_socontract::get_instance();
                        $contract = $so_contract->get_single($contract_id);
                        if($contract->has_permission(PHPGW_ACL_EDIT))
                        {
-                               return 
rental_soprice_item::get_instance()->add_price_item($contract_id, 
$price_item_id);
+                               return 
rental_soprice_item::get_instance()->add_price_item($contract_id, 
$price_item_id, $factor);
                        }
                        return false;
                }

Modified: trunk/rental/inc/class.uiprice_item.inc.php
===================================================================
--- trunk/rental/inc/class.uiprice_item.inc.php 2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/inc/class.uiprice_item.inc.php 2014-07-27 11:21:49 UTC (rev 
12040)
@@ -289,6 +289,17 @@
                                        $value['ajax'][] = true;
                                        $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uicontract.add_price_item', 'price_item_id' => $value['id'], 
'contract_id' => $contract_id)));
                                        $value['labels'][] = lang('add');
+
+                                       $sogeneric                      = 
CreateObject('property.sogeneric','composite_standard');
+                                       $composite_standards = 
$sogeneric->read(array('allrows' => true));
+                                       foreach($composite_standards as 
$composite_standard)
+                                       {
+                                               $value['ajax'][] = true;
+                                               $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uicontract.add_price_item', 'price_item_id' => $value['id'], 
'contract_id' => $contract_id, 'factor' => $composite_standard['factor'])));
+                                               $value['labels'][] = 
lang('add') . " {$composite_standard['name']}";
+                                       }
+
+       //FIXME: Add actions for composite standard factors
                                }
                                break;
                        default:

Modified: trunk/rental/inc/model/class.agresso_lg04.inc.php
===================================================================
--- trunk/rental/inc/model/class.agresso_lg04.inc.php   2014-07-01 07:38:16 UTC 
(rev 12039)
+++ trunk/rental/inc/model/class.agresso_lg04.inc.php   2014-07-27 11:21:49 UTC 
(rev 12040)
@@ -46,11 +46,11 @@
                        return $contents;
                }
 
-               public function get_contents_excel()
+               public function get_contents_excel($excel_export_type)
                {
                        if($this->orders == null) // Data hasn't been created 
yet
                        {
-                               $this->run_excel_export();
+                               $this->run_excel_export($excel_export_type);
                        }
                        return $this->orders;
                }
@@ -167,8 +167,21 @@
                        return $so_invoice->transaction_commit();
                }
 
-               protected function run_excel_export()
+               protected function run_excel_export($excel_export_type)
                {
+                       switch($excel_export_type)
+                       {
+                               case 'bk':
+                                       $get_order_excel = 'get_order_excel_bk';
+                                       break;
+                               case 'nlsh':
+                                       $get_order_excel = 
'get_order_excel_nlsh';
+                                       break;
+
+                               default:
+                                       $get_order_excel = 'get_order_excel_bk';
+                                       break;
+                       }
                        $this->orders            = array();
                        $decimal_separator       = 
isset($GLOBALS['phpgw_info']['user']['preferences']['rental']['decimal_separator'])
 ? $GLOBALS['phpgw_info']['user']['preferences']['rental']['decimal_separator'] 
: ',';
                        $thousands_separator = 
isset($GLOBALS['phpgw_info']['user']['preferences']['rental']['thousands_separator'])
 ? 
$GLOBALS['phpgw_info']['user']['preferences']['rental']['thousands_separator'] 
: '.';
@@ -210,7 +223,7 @@
                                        $serialized_party        = 
$invoice->get_party()->serialize();
                                        $party_name                      = 
$serialized_party['name'];
 
-                                       $this->orders[] = 
$this->get_order_excel(
+                                       $this->orders[] = 
$this->$get_order_excel(
                                        $invoice->get_header(), 
$invoice->get_party()->get_identifier(), $party_name, $invoice->get_id(), 
$this->billing_job->get_year(), $this->billing_job->get_month(), 
$invoice->get_account_out(), $data, $invoice->get_responsibility_id(), 
$invoice->get_service_id(), $building_location_code, 
$invoice->get_project_id(), $composite_name, $invoice->get_reference(), 
$price_item_counter
                                        );
                                        $price_item_counter++;
@@ -405,7 +418,7 @@
                 * Builds one single order of the excel file.
                 * 
                 */
-               protected function get_order_excel($header, $party_id, 
$party_name, $order_id, $bill_year, $bill_month, $account, $product_item, 
$responsibility, $service, $building, $project, $text, $client_ref, $counter)
+               protected function get_order_excel_bk($header, $party_id, 
$party_name, $order_id, $bill_year, $bill_month, $account, $product_item, 
$responsibility, $service, $building, $project, $text, $client_ref, $counter)
                {
 
                        //$order_id = $order_id + 39500000;
@@ -444,6 +457,49 @@
                        return str_replace(array("\n", "\r"), '', $order);
                }
 
+               protected function get_order_excel_nlsh($header, $party_id, 
$party_name, $order_id, $bill_year, $bill_month, $account, $product_item, 
$responsibility, $service, $building, $project, $text, $client_ref, $counter)
+               {
+
+                       //$order_id = $order_id + 39500000;
+                       // XXX: Which charsets do Agresso accept/expect? Do we 
need to something regarding padding and UTF-8?
+                       //$order = array();
+
+                       $item_counter    = $counter;
+                       $order                   = array
+                       (
+                               'Kontraktstype'                         => 
'Kontraktstype',//FIXME
+                               'Art/konto inntektsside' => $account,
+                               'Art/konto utgiftsside' => 'Art/konto 
utgiftsside',//FIXME
+                               'client_ref'                     => $client_ref,
+                               'header'                                 => 
utf8_decode($header),
+                               'bill_year'                              => 
$bill_year,
+                               'bill_month'                     => $bill_month,
+                               'Ansvar'                                 => 
'BKBPE',//FIXME
+                               'Ansvar2'                                => 
'BKBPE',//FIXME
+                               'Party'                                  => 
$party_id,
+                               'name'                                   => 
$party_name,
+                               'amount'                                 => 
$this->get_formatted_amount_excel($product_item['amount']),
+//                        'amount' => 
$this->get_formatted_amount($product_items[0]['amount']),
+                               'article description'    => 
utf8_decode($product_item['article_description']),
+                               'article_code'                   => 
$product_item['article_code'],
+                               'batch_id'                               => 
"BKBPE{$this->date_str}",
+                               'client'                                 => 
'BY',
+                               'responsibility'                 => 
$responsibility,
+                               'service'                                => 
$service,
+                               'project'                                => 
$project,
+                               'counter'                                => 
++$item_counter,
+                               'bill_year'                              => 
$bill_year,
+                               'bill_month'                     => $bill_month,
+                               'batch_id'                               => 
"BKBPE{$this->date_str}",
+                               'client'                                 => 
'BY',
+                               'item_counter'                   => 
$item_counter,
+                               'text'                                   => 
utf8_decode($text),
+                               'Kommentar'                             => 
'Kommentar',//FIXME
+                       );
+
+                       return str_replace(array("\n", "\r"), '', $order);
+               }
+
                protected function get_formatted_amount($amount)
                {
                        $amount = round($amount, 2) * 100;

Modified: trunk/rental/inc/model/class.composite.inc.php
===================================================================
--- trunk/rental/inc/model/class.composite.inc.php      2014-07-01 07:38:16 UTC 
(rev 12039)
+++ trunk/rental/inc/model/class.composite.inc.php      2014-07-27 11:21:49 UTC 
(rev 12040)
@@ -23,6 +23,7 @@
         protected $area;
         protected $status;
         protected $furnish_type_id;
+        protected $standard_id;
                
                protected $units;
                protected $contracts;
@@ -269,7 +270,7 @@
                public function get_furnish_type_id() {
             return (int) $this->furnish_type_id;
         }
-        
+      
                public function get_furnish_type() {
                        
                        $furnish_types = $this->get_furnish_types();
@@ -289,6 +290,30 @@
                return self::$furnish_types_arr;
        }
 
+               public function set_standard_id($standard_id)
+               {
+//                     _debug_array($standard_id);die();
+                       $this->standard_id = (int)$standard_id;
+        }
+
+               public function get_standard_id()
+               {
+            return (int) $this->standard_id;
+        }
+
+               /**
+                * Fetch composite standards on the form array(array('id' => 1, 
'name' => 'some text', 'selected' => 1|0))
+                * @return array
+                */
+               public function get_standards($selected)
+               {
+                       if( $composite_standards = 
execMethod('property.bogeneric.get_list',array('type' => 'composite_standard', 
'selected' => $selected)))
+                       {
+                               array_unshift ($composite_standards,array('id' 
=> '', 'name' => lang('none')));
+                       }
+                       return $composite_standards;
+        }
+
         public function set_area($area) {
             $this->area = $area;
         }

Modified: trunk/rental/inc/model/class.contract.inc.php
===================================================================
--- trunk/rental/inc/model/class.contract.inc.php       2014-07-01 07:38:16 UTC 
(rev 12039)
+++ trunk/rental/inc/model/class.contract.inc.php       2014-07-27 11:21:49 UTC 
(rev 12040)
@@ -1085,6 +1085,19 @@
                        return false;
                }
 
+               /**
+                * Fetch responsibility candidates on the form array(array('id' 
=> 1, 'name' => 'some text', 'selected' => 1|0))
+                * @return array
+                */
+               public function get_responsibility_arr($selected)
+               {
+                       if( $responsibility_arr = 
execMethod('property.bogeneric.get_list',array('type' => 'responsibility_unit', 
'selected' => $selected)))
+                       {
+                               array_unshift ($responsibility_arr,array('id' 
=> '', 'name' => lang('none')));
+                       }
+                       return $responsibility_arr;
+        }
+
                public function set_rented_area($rented_area)
                {
                        $this->rented_area = $rented_area;

Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang    2014-07-01 07:38:16 UTC (rev 12039)
+++ trunk/rental/setup/phpgw_no.lang    2014-07-27 11:21:49 UTC (rev 12040)
@@ -101,6 +101,8 @@
 composite_back rental  no      Leieobjektsliste
 composite_has_contract rental  no      Leieobjekt med aktive kontrakter
 composite_has_no_contract      rental  no      Leieobjekt uten aktive 
kontrakter
+composite standard     rental  no      Leieobjekt standard
+factor common  no      Faktor
 contract       rental  no      Kontrakt
 contract_back  rental  no      Kontraktsliste
 contract_id    rental  no      Kontraktsnummer

Modified: trunk/rental/setup/setup.inc.php
===================================================================
--- trunk/rental/setup/setup.inc.php    2014-07-01 07:38:16 UTC (rev 12039)
+++ trunk/rental/setup/setup.inc.php    2014-07-27 11:21:49 UTC (rev 12040)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['rental']['name'] = 'rental';               // Module 
identifier
-       $setup_info['rental']['version'] = '0.1.0.17';  // Current module 
version
+       $setup_info['rental']['version'] = '0.1.0.18';  // Current module 
version
        $setup_info['rental']['app_order'] = 51;                // (?)
        $setup_info['rental']['tables'] = array(
                'rental_party',                                         // All 
contract participants, tenants etc.
@@ -8,7 +8,9 @@
                'rental_contract_composite',            // Connection between 
contracts and composites
                'rental_contract_party',                        // Connection 
between tenants and contracts
                'rental_composite',                                     // 
Rental object, an aggregation of rental units
+               'rental_composite_standard',            // Optional standard 
clsasses
                'rental_contract_price_item',           // Price items from the 
price book tied to a contract
+               'rental_contract_responsibility_unit',  // optional list of 
candidates
                'rental_billing',                                       // 
Contains information about the job creating invoices
                'rental_invoice',                                       // 
Contract invoices
                'rental_invoice_price_item',            // Price items from the 
contract tied to a past invoice

Modified: trunk/rental/setup/tables_current.inc.php
===================================================================
--- trunk/rental/setup/tables_current.inc.php   2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/setup/tables_current.inc.php   2014-07-27 11:21:49 UTC (rev 
12040)
@@ -28,13 +28,25 @@
                                        'has_custom_address' => array('type' => 
'bool','nullable' => false,'default' => 'false'),
                     'object_type_id' =>     array('type' => 'int', 'precision' 
=> 2, 'nullable' => true, 'default' => null),
                     'area' =>               array('type' => 'decimal', 
'precision' => '20','scale' => '2', 'nullable' => true),
-                                       'furnish_type_id' =>    array('type' => 
'int', 'precision' => 4, 'nullable' => true)
+                                       'furnish_type_id' =>    array('type' => 
'int', 'precision' => 4, 'nullable' => true),
+                                       'standard_id' =>        array('type' => 
'int', 'precision' => 4, 'nullable' => true)
                                ),
                                'pk' => array('id'),
                                'fk' => array(),
                                'ix' => array(),
                                'uc' => array()
                ),
+               'rental_composite_standard' => array(
+                               'fd' => array(
+                                       'id' =>                                 
array('type' => 'int', 'precision' => 4, 'nullable' => false),
+                                       'name' =>                               
array('type' => 'varchar','precision' => '255','nullable' => false),
+                    'factor' =>               array('type' => 'decimal', 
'precision' => '20','scale' => '2', 'nullable' => true),
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+               ),
                'rental_unit' => array(
                                'fd' => array(
                                        'id'                    => array('type' 
=> 'auto', 'nullable' => false),
@@ -70,6 +82,17 @@
                        'ix' => array(),
                        'uc' => array()
                ),
+               'rental_contract_responsibility_unit' => array(
+                               'fd' => array(
+                                       'id' =>                                 
array('type' => 'int', 'precision' => 4, 'nullable' => false),
+                                       'name' =>                               
array('type' => 'varchar','precision' => '255','nullable' => false)
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+               ),
+
                // Describes different billing terms like 'Monthly', 'Yearly', 
etc.
                'rental_billing_term' => array(
                        'fd' => array(

Modified: trunk/rental/setup/tables_update.inc.php
===================================================================
--- trunk/rental/setup/tables_update.inc.php    2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/setup/tables_update.inc.php    2014-07-27 11:21:49 UTC (rev 
12040)
@@ -297,3 +297,47 @@
                $GLOBALS['setup_info']['rental']['currentver'] = '0.1.0.17';
                return $GLOBALS['setup_info']['rental']['currentver'];
        }
+
+
+       $test[] = '0.1.0.17';
+       function rental_upgrade0_1_0_17()
+       {
+               $GLOBALS['phpgw']->locations->add('.admin', 'Admin section', 
'rental');
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('rental_composite','standard_id',array(
+                       'type' => 'int',
+                       'precision' => 4,
+                       'nullable' => 'True'
+               ));
+
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'rental_composite_standard', array(
+                               'fd' => array(
+                                       'id' => array('type' => 
'int','precision' => '4','nullable' => false),
+                                       'name' => array('type' => 
'varchar','precision' => '255','nullable' => false),
+                    'factor' => array('type' => 'decimal', 'precision' => 
'20','scale' => '2', 'nullable' => true),
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->CreateTable(
+                       'rental_contract_responsibility_unit', array(
+                               'fd' => array(
+                                       'id' => array('type' => 
'int','precision' => '4','nullable' => false),
+                                       'name' => array('type' => 
'varchar','precision' => '255','nullable' => false)
+                               ),
+                               'pk' => array('id'),
+                               'fk' => array(),
+                               'ix' => array(),
+                               'uc' => array()
+                       )
+               );
+
+               $GLOBALS['setup_info']['rental']['currentver'] = '0.1.0.18';
+               return $GLOBALS['setup_info']['rental']['currentver'];
+       }
+

Modified: trunk/rental/templates/base/billing.php
===================================================================
--- trunk/rental/templates/base/billing.php     2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/templates/base/billing.php     2014-07-27 11:21:49 UTC (rev 
12040)
@@ -107,7 +107,8 @@
                        {
                                ?>
                                <a href="<?php echo $download_link ?>"><?php 
echo lang('Download export') ?></a><br />
-                <a href="<?php echo $download_link . '&amp;toExcel=true' 
?>">Last ned eksportfil i Excel-format</a>
+                <a href="<?php echo $download_link . 
'&amp;toExcel=true&amp;type=bk' ?>"><?php echo lang('Download Excel export') . 
' BK'?></a><br />
+                <a href="<?php echo $download_link . 
'&amp;toExcel=true&amp;type=nlsh' ?>">Last ned eksportfil i Excel-format 
NLSH</a>
                                <?php
                                if(!$billing_job->is_commited())
                                {

Modified: trunk/rental/templates/base/composite.php
===================================================================
--- trunk/rental/templates/base/composite.php   2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/templates/base/composite.php   2014-07-27 11:21:49 UTC (rev 
12040)
@@ -73,6 +73,47 @@
                                                ?>
                                        </dd>
                                        <dt>
+                                               <!-- composite standard  -->
+                                               <label 
for="composite_standard_id"><?php echo lang('composite standard') ?></label>
+                                                       <?php
+                                                               
$cur_standard_id = $composite->get_standard_id();
+
+                                                               
$composite_standard_arr = $composite->get_standards($cur_standard_id);
+
+                                                       // Edit composite
+                                                       if ($editable && 
$composite_standard_arr)
+                                                       {
+                                                               ?>
+                                                               <select 
name="composite_standard_id">
+                                                               <?php
+                                                                       
foreach($composite_standard_arr as $composite_standard)
+                                                                       {
+                                                                               
echo "<option ".($composite_standard['selected'] == 1 ? 'selected="selected"' : 
"")." 
value=\"{$composite_standard['id']}\">{$composite_standard['name']}</option>";
+                                                                       }
+                                                               ?>
+                                                               </select>
+                                                       <?php
+                                                       // View composite
+                                                       }
+                                                       else 
if($composite_standard_arr)
+                                                       {
+                                                               
$composite_standard_name = '';
+                                                               
foreach($composite_standard_arr as $composite_standard)
+                                                               {
+                                                                       if 
($composite_standard['selected'] == 1)
+                                                                       {
+                                                                               
$composite_standard_name = $composite_standard['name'];
+                                                                               
break;
+                                                                       }
+                                                               }
+
+                                                               ?>
+                                                                       <input 
type="text" id="composite_standard_id" value='<?php echo 
$composite_standard_name; ?>' disabled="disabled" />
+                                                               <?php
+
+                                                       } ?>
+                                       </dt>
+                                       <dt>
                                                <!-- Furnish status  -->
                                                <label 
for="furnish_type_id"><?php echo lang('furnish_type') ?></label>
                                                        <?php
@@ -82,21 +123,21 @@
                                                        // Edit composite
                                                        if ($editable) { ?>
                                                                <select 
name="furnish_type_id">
-                                                               <?php 
+                                                               <?php
                                                                        
foreach($furnish_types_arr as $id => $title){
                                                                                
if($cur_furnish_type_id == $id)
                                                                                
        echo "<option selected='true' value='$id'>" . $title . "</option>";
-                                                                               
else 
+                                                                               
else
                                                                                
        echo "<option value='$id'>" . $title . "</option>";
                                                                        }
                                                                ?>
-                                                               </select>       
                
-                                                       <?php 
+                                                               </select>
+                                                       <?php
                                                        // View composite
                                                        }else{ ?>
                                                                <input 
type="text" id="furnish_type_id" value='<?php echo 
$furnish_types_arr[$cur_furnish_type_id]; ?>' disabled="disabled" />
                                                        <?php } ?>
-                                       </dt>   
+                                       </dt>
                                        <?php if ($editable) { // Only show 
custom address fields if we're in edit mode ?>
                                        <dt>
                                                <label 
for="has_custom_address"><?php echo lang('has_custom_address') ?></label>

Modified: trunk/rental/templates/base/contract.php
===================================================================
--- trunk/rental/templates/base/contract.php    2014-07-01 07:38:16 UTC (rev 
12039)
+++ trunk/rental/templates/base/contract.php    2014-07-27 11:21:49 UTC (rev 
12040)
@@ -491,10 +491,30 @@
                                        </dt>
                                        <dd>
                                                <?php
-                                               if ($editable) {
-                                               ?>
-                                                       <input type="text" 
name="responsibility_id" id="responsibility_id" value="<?php echo 
$contract->get_responsibility_id(); ?>"/>
-                                               <?php
+                                               if ($editable)
+                                               {
+                                                       $cur_responsibility_id 
= $contract->get_responsibility_id();
+                                                       
$contract_responsibility_arr = 
$contract->get_responsibility_arr($cur_responsibility_id);
+
+                                                       
if($contract_responsibility_arr)
+                                                       {
+                                                               ?>
+                                                               <select 
name="responsibility_id">
+                                                               <?php
+                                                                       
foreach($contract_responsibility_arr as $contract_responsibility)
+                                                                       {
+                                                                               
echo "<option ".($contract_responsibility['selected'] == 1 ? 
'selected="selected"' : "")." 
value=\"{$contract_responsibility['id']}\">{$contract_responsibility['name']}</option>";
+                                                                       }
+                                                               ?>
+                                                               </select>
+                                                               <?php
+                                                       }
+                                                       else
+                                                       {
+                                                       ?>
+                                                               <input 
type="text" name="responsibility_id" id="responsibility_id" value="<?php echo 
$contract->get_responsibility_id(); ?>"/>
+                                                       <?php
+                                                       }
                                                }
                                                else
                                                {
@@ -556,7 +576,7 @@
                                                        $cid = 
$contract->get_id();
                                                        if(!isset($cid) || $cid 
<= 0)
                                                        {
-                                                               echo '';
+                                                               echo 
rental_socontract::get_instance()->get_default_account($contract->get_location_id(),
 false);
                                                        }
                                                        else
                                                        {




reply via email to

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