fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [6872] Create accounts based on contract parties in r


From: Yngve Espelid
Subject: [Fmsystem-commits] [6872] Create accounts based on contract parties in rental module, new logic to fetch rental properties basen on account usernames (email), new configuration elements on both rental and frontend, language updates, external contract view in frontend.
Date: Thu, 27 Jan 2011 14:51:20 +0000

Revision: 6872
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6872
Author:   yes
Date:     2011-01-27 14:51:20 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
Create accounts based on contract parties in rental module, new logic to fetch 
rental properties basen on account usernames (email), new configuration 
elements on both rental and frontend, language updates, external contract view 
in frontend.

Modified Paths:
--------------
    trunk/frontend/inc/class.borental.inc.php
    trunk/frontend/inc/class.uifrontend.inc.php
    trunk/frontend/setup/default_records.inc.php
    trunk/frontend/setup/phpgw_no.lang
    trunk/frontend/setup/setup.inc.php
    trunk/frontend/setup/tables_update.inc.php
    trunk/frontend/templates/base/config.tpl
    trunk/frontend/templates/base/contract.xsl
    trunk/frontend/templates/base/frontend.xsl
    trunk/rental/inc/class.soparty.inc.php
    trunk/rental/inc/class.uiparty.inc.php
    trunk/rental/inc/hook_settings.inc.php
    trunk/rental/inc/model/class.composite.inc.php
    trunk/rental/inc/model/class.property_location.inc.php
    trunk/rental/setup/phpgw_no.lang
    trunk/rental/templates/base/config.tpl
    trunk/rental/templates/base/party.php

Added Paths:
-----------
    trunk/frontend/help/NO/contact.odt
    trunk/frontend/inc/class.uicontract_ex.inc.php
    trunk/frontend/setup/nlsh/
    trunk/frontend/setup/nlsh/phpgw_no.lang
    trunk/rental/inc/hook_config.inc.php

Removed Paths:
-------------
    trunk/frontend/help/NO/contact_BKB.odt

Copied: trunk/frontend/help/NO/contact.odt (from rev 6840, 
trunk/frontend/help/NO/contact_BKB.odt)
===================================================================
(Binary files differ)


Property changes on: trunk/frontend/help/NO/contact.odt
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Deleted: trunk/frontend/help/NO/contact_BKB.odt
===================================================================
(Binary files differ)

Modified: trunk/frontend/inc/class.borental.inc.php
===================================================================
--- trunk/frontend/inc/class.borental.inc.php   2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/frontend/inc/class.borental.inc.php   2011-01-27 14:51:20 UTC (rev 
6872)
@@ -78,7 +78,7 @@
          *
          * @param integer $org_unit_ids
          */
-        public static function get_property_locations($org_unit_ids)
+        public static function get_property_locations($array)
         {
                
                $property_locations = array();
@@ -90,22 +90,28 @@
                $types = 
rental_socontract::get_instance()->get_fields_of_responsibility();
                        $location_id_internal = 
array_search('contract_type_internleie', $types);
                $location_id_in = array_search('contract_type_innleie', $types);
+               $location_id_ex = array_search('contract_type_eksternleie', 
$types);
                
-               foreach($org_unit_ids as $org_unit_id){
+               foreach($array as $row){
                        /*
              * 1. hent alle kontraktsparter som har org unit id (foreløpig 
bruker vi result_unit_number i rentalparty)
              * 2. hent alle kontrakter på kontraktspartene
              * 3. hent alle leieobjekt på kontraktene
              * 4. hent ut bygg-ider, location_code, fra leieobjektet
              */
-               
-                       if(!isset($org_unit_id['ORG_UNIT_ID']) || 
$org_unit_id['ORG_UNIT_ID'] == '')
+                       if(is_array($row))
                        {
-                               continue;
+                               if(!isset($row['ORG_UNIT_ID']) || 
$row['ORG_UNIT_ID'] == '')
+                               {
+                                       continue;
+                               }
+                               $parties = 
rental_soparty::get_instance()->get(null, null, null, null, null, null, 
array('org_unit_id' => $row['ORG_UNIT_ID']));
                        }
-                       
-                       $parties = rental_soparty::get_instance()->get(null, 
null, null, null, null, null, array('org_unit_id' => 
$org_unit_id['ORG_UNIT_ID']));
-                       
+                       else
+                       {
+                               $parties = 
rental_soparty::get_instance()->get(null, null, null, null, null, null, 
array('email' => $row));
+                       }
+               
                        $contracts = array();
                        $composites = array();
                        
@@ -134,8 +140,6 @@
                                                        $property_location = 
$unit->get_location();
                                                        
$property_locations[$property_location->get_location_code()] = 
$property_location;
                                                        
-                                                       
-                                                       
                                                        // Contract holders: 
contracts_per_location (internal) and contracts_in_per_location (in)
                                                        
                                                        // Internal contract 
should have impact on total price
@@ -173,6 +177,24 @@
                                                                }
                                                                
array_push($contracts_in_per_location[$property_location->get_location_code()], 
$contract);
                                                        }
+                                                       else 
if($contract->get_location_id() == $location_id_ex)
+                                                       {
+                                                               $total_price = 
rental_socontract_price_item::get_instance()->get_total_price($contract->get_id());
+                                                               
$contract->set_total_price($total_price);
+                                                               
+                                                               
if(!is_array($contracts_ex_per_location[$property_location->get_location_code()]))
+                                                               {
+                                                                       
$contracts_ex_per_location[$property_location->get_location_code()] = array();  
+                                                               }
+                                                               
array_push($contracts_ex_per_location[$property_location->get_location_code()], 
$contract);
+                                                               
+                                                               
if($contract->is_active())
+                                                               {
+                                                                       
$property_locations_active[$property_location->get_location_code()] = true;
+                                                                       
$rented_area_per_location[$property_location->get_location_code()] += 
$contract->get_rented_area();
+                                                                       
$rented_price_per_location[$property_location->get_location_code()] += 
$total_price;
+                                                               }
+                                                       }
                                                }                       
                                        }
                                }
@@ -181,6 +203,7 @@
                
                phpgwapi_cache::session_set('frontend', 
'contracts_per_location', $contracts_per_location);
                phpgwapi_cache::session_set('frontend', 
'contracts_in_per_location', $contracts_in_per_location);
+               phpgwapi_cache::session_set('frontend', 
'contracts_ex_per_location', $contracts_ex_per_location);
                phpgwapi_cache::session_set('frontend', 
'rented_area_per_location', $rented_area_per_location);
                phpgwapi_cache::session_set('frontend', 
'total_price_per_location', $rented_price_per_location);
                

Added: trunk/frontend/inc/class.uicontract_ex.inc.php
===================================================================
--- trunk/frontend/inc/class.uicontract_ex.inc.php                              
(rev 0)
+++ trunk/frontend/inc/class.uicontract_ex.inc.php      2011-01-27 14:51:20 UTC 
(rev 6872)
@@ -0,0 +1,15 @@
+<?php
+
+phpgw::import_class('frontend.uicontract');
+
+class frontend_uicontract_ex extends frontend_uicontract
+{
+       public function __construct()
+       {
+               $this->contract_state_identifier = "contract_state_ex";
+               $this->contracts_per_location_identifier = 
"contracts_ex_per_location";
+               $this->form_url = 
"index.php?menuaction=frontend.uicontract_ex.index";
+               
phpgwapi_cache::session_set('frontend','tab',$GLOBALS['phpgw']->locations->get_id('frontend','.rental.contract_ex'));
+               parent::__construct();
+       }
+}

Modified: trunk/frontend/inc/class.uifrontend.inc.php
===================================================================
--- trunk/frontend/inc/class.uifrontend.inc.php 2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/frontend/inc/class.uifrontend.inc.php 2011-01-27 14:51:20 UTC (rev 
6872)
@@ -53,6 +53,11 @@
                {
                        // This module uses XSLT templates
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+                       
+                       $config = CreateObject('phpgwapi.config','frontend');
+                       $config->read();
+                       $use_fellesdata = 
$config->config_data['use_fellesdata'];
+                       $logo_path = $config->config_data['logo_path'];
 
                        // Get the mode: in frame or full screen
                        $mode = phpgwapi_cache::session_get('frontend', 
'noframework');
@@ -68,6 +73,8 @@
                        
                        // Get header state
                        $this->header_state = 
phpgwapi_cache::session_get('frontend', 'header_state');
+                       $this->header_state['use_fellesdata'] = $use_fellesdata;
+                       $this->header_state['logo_path'] = $logo_path;
                        
                        // Get navigation parameters
                        $param_selected_location = phpgw::get_var('location');  
                // New location selected from locations list
@@ -146,28 +153,37 @@
                                $this->insert_links_on_header_state();
                        } 
                        /* No state, first visit after login, or refresh 
request*/
-                       else if(!isset($this->header_state) || isset($refresh))
+                       else if(!isset($this->header_state) || isset($refresh) 
|| !isset($this->header_state['locations']))
                        {
-                               //Specify organisational units
-                               $org_units = 
frontend_bofellesdata::get_instance()->get_result_units($GLOBALS['phpgw_info']['user']['account_lid']);
-                               
-                               //Merge with delegation units
-                               $delegation_org_ids = 
frontend_bofrontend::get_delegations($GLOBALS['phpgw_info']['user']['account_id']);
-                               if(count($delegation_org_ids) > 0)
+                               if($use_fellesdata)
                                {
-                                       $delegation_units = 
frontend_bofellesdata::get_instance()->populate_result_units($delegation_org_ids);
-                                       $org_units = 
array_merge($org_units,$delegation_units);
+                                       //Specify organisational units
+                                       $org_units = 
frontend_bofellesdata::get_instance()->get_result_units($GLOBALS['phpgw_info']['user']['account_lid']);
+                                       
+                                       //Merge with delegation units
+                                       $delegation_org_ids = 
frontend_bofrontend::get_delegations($GLOBALS['phpgw_info']['user']['account_id']);
+                                       if(count($delegation_org_ids) > 0)
+                                       {
+                                               $delegation_units = 
frontend_bofellesdata::get_instance()->populate_result_units($delegation_org_ids);
+                                               $org_units = 
array_merge($org_units,$delegation_units);
+                                       }
+                                       
+                                       //Update org units on header state
+                                       $this->header_state['org_unit'] = 
$org_units;
+                                       
$this->header_state['number_of_org_units'] = count($org_units);
+                                       
$this->header_state['selected_org_unit'] = 'all';
+                                       
+                                       //Update locations
+                                       $property_locations = 
frontend_borental::get_property_locations($org_units);
                                }
+                               else 
+                               {
+                                       //If no organisational database is in 
use: get rented properties based on username
+                                       $usernames[] = 
$GLOBALS['phpgw_info']['user']['account_lid'];
+                                       $property_locations = 
frontend_borental::get_property_locations($usernames);
+                               }
                                
-                               //Update org units on header state
-                               $this->header_state['org_unit'] = $org_units;
-                               $this->header_state['number_of_org_units'] = 
count($org_units);
-                               $this->header_state['selected_org_unit'] = 
'all';
-                               
-                               //Update locations
-                               $property_locations = 
frontend_borental::get_property_locations($org_units);
                                $property_locations_update = true;
-
                                $this->insert_links_on_header_state();
                                
                        }
@@ -225,6 +241,7 @@
 
                                
phpgwapi_cache::session_clear('frontend','contract_state');
                                
phpgwapi_cache::session_clear('frontend','contract_state_in');
+                               
phpgwapi_cache::session_clear('frontend','contract_state_ex');
                        }
                        /* Store the header state on the session*/
                        $bomessenger = CreateObject('messenger.bomessenger');
@@ -317,7 +334,7 @@
                                 (
                                        'menuaction'=> 'manual.uimanual.help',
                                        'app' => 
$GLOBALS['phpgw_info']['flags']['currentapp'],
-                                       'section' => 'contact_BKB'
+                                       'section' => 'contact'
                                 )) . "','700','600')";
                 
                        $folder_url = "javascript:openwindow('"

Modified: trunk/frontend/setup/default_records.inc.php
===================================================================
--- trunk/frontend/setup/default_records.inc.php        2011-01-27 13:16:00 UTC 
(rev 6871)
+++ trunk/frontend/setup/default_records.inc.php        2011-01-27 14:51:20 UTC 
(rev 6872)
@@ -11,7 +11,6 @@
        $GLOBALS['phpgw']->locations->add('.', 'top', 'frontend', false);
        $GLOBALS['phpgw']->locations->add('.ticket', 'helpdesk', 'frontend', 
false);
        $GLOBALS['phpgw']->locations->add('.rental.contract', 
'contract_internal', 'frontend', false);
-       
$GLOBALS['phpgw']->locations->add('.rental.contract_in','contract_in','frontend',
 false);
        $GLOBALS['phpgw']->locations->add('.document.drawings', 'drawings', 
'frontend', false);
        $GLOBALS['phpgw']->locations->add('.document.pictures', 'pictures', 
'frontend', false);
        $GLOBALS['phpgw']->locations->add('.property.maintenance', 
'maintenance', 'frontend', false);

Added: trunk/frontend/setup/nlsh/phpgw_no.lang
===================================================================
--- trunk/frontend/setup/nlsh/phpgw_no.lang                             (rev 0)
+++ trunk/frontend/setup/nlsh/phpgw_no.lang     2011-01-27 14:51:20 UTC (rev 
6872)
@@ -0,0 +1,11 @@
+contact_BKB    frontend        no      Kontakt
+email_create_account_title     frontend        no      BKBygg systemtilgang
+email_create_account_message   frontend        no      Systemmelding fra 
Nordlandssykehuset til %1 %2:<br/>Det er opprettet en tilgang for deg i 
Nordlandssykehuset<br/><br/>Du får tilgang til systemet via kommunens 
intranett.<br/>Under verktøy i høyre kolonne, velg 
Nordlandssykehuset.<br/>Brukerveiledning finner du i systemet, ved å velge 
"Hjelp" i toppmenyen.<br/>Har du spørsmål send en e-post til Nordlandssykehuset 
brukerstøtte.<br/>
+email_remove_delegate_title    frontend        no      BKBygg systemtilgang
+email_remove_delegate_message  frontend        no      Systemmelding fra 
Nordlandssykehuset til %1 %2:<br/>Din tilgang til Nordlandssykehuset på vegne 
av %3 %4 er slettet.<br/>Har du spørsmål send en e-post til Nordlandssykehuset 
brukerstøtte.<br/>
+email_add_delegate_title       frontend        no      BKBygg systemtilgang
+email_add_delegate_message     frontend        no      Systemmelding fra 
Nordlandssykehust til %1 %2:<br/>%3 %4 har gitt deg tilgang til 
Nordlandssykehust for følgende resultatenhet:<br/>%5<br/><br/>Du får tilgang 
til systemet via kommunens intranett.<br/>Under verktøy i høyre kolonne, velg 
Nordlandssykehuset.<br/>Brukerveiledning finner du i systemet, ved å velge 
"Hjelp" i toppmenyen.<br/>Har du spørsmål send en e-post til Nordlandssykehuset 
brukerstøtte.<br/>
+send_contract_message  frontend        no      Send melding til 
Nordlandssykehuset angående kontrakten
+total_area_internal    frontend        no      Totalt areal
+total_price_internal   frontend        no      Total pris
+folder frontend        no      Informasjon
\ No newline at end of file

Modified: trunk/frontend/setup/phpgw_no.lang
===================================================================
--- trunk/frontend/setup/phpgw_no.lang  2011-01-27 13:16:00 UTC (rev 6871)
+++ trunk/frontend/setup/phpgw_no.lang  2011-01-27 14:51:20 UTC (rev 6872)
@@ -7,6 +7,7 @@
 services       frontend        no      Tjenester
 contract       frontend        no      Kontrakter
 contract_in    frontend        no      Innleiekontrakter
+contract_ex    frontend        no      Eksternleiekontrakter
 helpdesk       frontend        no      Melding om avvik
 subject        frontend        no      Meldingstittel
 entry_date     frontend        no      Dato

Modified: trunk/frontend/setup/setup.inc.php
===================================================================
--- trunk/frontend/setup/setup.inc.php  2011-01-27 13:16:00 UTC (rev 6871)
+++ trunk/frontend/setup/setup.inc.php  2011-01-27 14:51:20 UTC (rev 6872)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['frontend']['name'] = 'frontend';
-       $setup_info['frontend']['version'] = '0.2';
+       $setup_info['frontend']['version'] = '0.4';
        $setup_info['frontend']['app_order'] = 9;
 //     $setup_info['frontend']['tables'] = array();
        $setup_info['frontend']['enable'] = 1;
@@ -29,6 +29,11 @@
                'appname' => 'rental',
                'versions' => array('0.1.0')
        );
+       
+       $setup_info['frontend']['depends'][] = array(
+               'appname' => 'messenger',
+               'versions' => array('0.9.17.500')
+       );
 
        /* The hooks this app includes, needed for hooks registration */
        $setup_info['frontend']['hooks'] = array

Modified: trunk/frontend/setup/tables_update.inc.php
===================================================================
--- trunk/frontend/setup/tables_update.inc.php  2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/frontend/setup/tables_update.inc.php  2011-01-27 14:51:20 UTC (rev 
6872)
@@ -12,7 +12,7 @@
        */
 
        /**
-       * Update frontend version from 0.1 to 0.9.17.500
+       * Update frontend version from 0.1 to 0.2
        * Add locations as placeholders for functions and menues
        * 
        */
@@ -32,13 +32,33 @@
 
                if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
                {
-                       $GLOBALS['setup_info']['frontend']['currentver'] = 
'0.9.17.500';
+                       $GLOBALS['setup_info']['frontend']['currentver'] = 
'0.2';
                        return $GLOBALS['setup_info']['frontend']['currentver'];
                }
        }
        
+       /**
+       * Update frontend version from 0.1 to 0.2
+       * Add new location as placeholders for functions and menues
+       * 
+       */
        $test[] = '0.2';
        function frontend_upgrade0_2()
        {
                
$GLOBALS['phpgw']->locations->add('.rental.contract_in','contract_in','frontend',
 false);
+               $GLOBALS['setup_info']['frontend']['currentver'] = '0.3';
+               return $GLOBALS['setup_info']['frontend']['currentver'];
        }
+       
+       /**
+       * Update frontend version from 0.2 to 0.3
+       * Add new location as placeholders for functions and menues
+       * 
+       */
+       $test[] = '0.3';
+       function frontend_upgrade0_3()
+       {
+               
$GLOBALS['phpgw']->locations->add('.rental.contract_ex','contract_ex','frontend',
 false);
+               $GLOBALS['setup_info']['frontend']['currentver'] = '0.4';
+               return $GLOBALS['setup_info']['frontend']['currentver'];
+       }

Modified: trunk/frontend/templates/base/config.tpl
===================================================================
--- trunk/frontend/templates/base/config.tpl    2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/frontend/templates/base/config.tpl    2011-01-27 14:51:20 UTC (rev 
6872)
@@ -74,7 +74,16 @@
                <tr class="row_off">
                        <td>{lang_delegate_limit}:</td>
                        <td><input name="newsettings[delegate_limit]" 
value="{value_delegate_limit}"></td>
-               </tr>           
+               </tr>
+               <tr class="row_off">
+                       <td>{lang_use_fellesdata}:</td>
+                       <td>
+                               <select name="newsettings[use_fellesdata]">
+                                       <option value="" 
{selected_use_fellesdata_}>NO</option>
+                                       <option value="1" 
{selected_use_fellesdata_1}>YES</option>
+                               </select>
+                       </td>
+               </tr>   
                <tr class="row_on">
                        <td colspan="2">&nbsp;<b>{lang_external_db}</b></td>
                </tr>
@@ -124,6 +133,13 @@
                        <td>{lang_email_contract_messages}:</td>
                        <td><input name="newsettings[email_contract_messages]" 
value="{value_email_contract_messages}"></td>
                </tr>
+               <tr class="row_on">
+                       <td colspan="2">&nbsp;<b>{lang_logo_settings}</b></td>
+               </tr>
+               <tr class="row_on">
+                       <td>{lang_logo_contract_messages}:</td>
+                       <td><input name="newsettings[logo_path]" 
value="{value_logo_path}"></td>
+               </tr>
 <!-- END body -->
 <!-- BEGIN footer -->
                <tr class="th">

Modified: trunk/frontend/templates/base/contract.xsl
===================================================================
--- trunk/frontend/templates/base/contract.xsl  2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/frontend/templates/base/contract.xsl  2011-01-27 14:51:20 UTC (rev 
6872)
@@ -130,7 +130,7 @@
                                                                                
                <li>
                                                                                
                        <dl style="padding-left: 1em;">
                                                                                
                                <dt style="float: left;"><img 
src="frontend/templates/base/images/16x16/house.png" class="list_image" /></dt>
-                                                                               
                                <dd>
+                                                                               
                                <dd><br/>
                                                                                
                                        <xsl:if test="normalize-space(address)">
                                                                                
                                                <xsl:value-of select="address" 
disable-output-escaping="yes"/>
                                                                                
                                        </xsl:if>

Modified: trunk/frontend/templates/base/frontend.xsl
===================================================================
--- trunk/frontend/templates/base/frontend.xsl  2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/frontend/templates/base/frontend.xsl  2011-01-27 14:51:20 UTC (rev 
6872)
@@ -3,7 +3,7 @@
        <div id="header">
                <div id="login-bar">
                        <ul class="user_menu">
-                               <li><em><img 
src="frontend/templates/base/images/16x16/user_red.png"  class="list_image" 
/></em><xsl:value-of select="name_of_user"/></li>
+                               <li><em><img 
src="frontend/templates/base/images/16x16/user_red.png"  class="list_image" 
/></em><xsl:value-of select="name_of_user"/> | <a 
href="http://portico/pe/preferences/changepassword.php";>Bytt passord</a></li>
                                <li><a 
href="index.php?menuaction=frontend.uimessages.index" 
class="list_image"><em><img 
src="frontend/templates/base/images/16x16/email.png" 
class="list_image"/></em><xsl:value-of select="new_messages"/></a></li>
                                <li>
                                        <a href="logout.php"  
class="header_link"><em><img 
src="frontend/templates/base/images/16x16/door_out.png" 
class="list_image"/></em><xsl:value-of select="php:function('lang', 
'logout')"/></a> 
@@ -26,61 +26,72 @@
                                <li><em><img 
src="frontend/templates/base/images/16x16/coins.png" 
class="list_image"/></em><xsl:value-of select="php:function('lang', 
'total_price_internal')"/>: <xsl:value-of select="total_price"/></li>
                        </ul>
                        </div>
-                       <div id="org_units">
-                       <ul>
-                               <li>
-                                       <em>
-                                               <img 
src="frontend/templates/base/images/16x16/chart_organisation.png"  
class="list_image" />
-                                       </em>
-                                       <xsl:value-of 
select="php:function('lang', 'organisational_units')"/> 
-                                       (<xsl:value-of 
select="number_of_org_units"/>)
-                                       <a 
href="index.php?menuaction=frontend.uihelpdesk.index&amp;refresh=true" 
class="list_image">
-                                               <img 
src="frontend/templates/base/images/16x16/page_refresh.png" class="list_image"/>
-                                       </a>
-                               </li>
-                               <li>
-                                       <form 
action="index.php?menuaction=frontend.uihelpdesk.index" method="post">
-                                               <select size="3" 
onchange="this.form.submit()" name="org_unit_id">
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="selected_org_unit = 'all'">
-                                                                       <option 
value="all" selected="selected"><xsl:value-of select="php:function('lang', 
'all_organisational_units')"/></option>
-                                                                       
<xsl:for-each select="org_unit">
-                                                                               
<xsl:sort select="ORG_NAME"/>
-                                                                               
<option value="{ORG_UNIT_ID}"><xsl:value-of select="ORG_NAME"/></option>
-                                                                       
</xsl:for-each>
-                                                               </xsl:when>
-                                                               <xsl:otherwise>
-                                                                       <option 
value="all"><xsl:value-of select="php:function('lang', 
'all_organisational_units')"/></option>
-                                                                       
<xsl:for-each select="org_unit">
-                                                                               
<xsl:sort select="ORG_NAME"/>
-                                                                               
<xsl:choose>
-                                                                               
                <xsl:when test="ORG_UNIT_ID = //header/selected_org_unit">
-                                                                               
                        <option value="{ORG_UNIT_ID}" 
selected="selected"><xsl:value-of select="ORG_NAME"/></option>
-                                                                               
                </xsl:when>
-                                                                               
                <xsl:otherwise>
-                                                                               
                        <option value="{ORG_UNIT_ID}"><xsl:value-of 
select="ORG_NAME"/></option>
-                                                                               
                </xsl:otherwise>
-                                                                               
        </xsl:choose>
-                                                                       
</xsl:for-each>
-                                                               </xsl:otherwise>
-                                                               
-                                                       </xsl:choose> 
-                                               </select>
-                                       </form>
-                               </li>
-                       </ul>
-                       </div>
+                       <xsl:choose>
+                       <xsl:when test="use_fellesdata = 1">
+                                       <div id="org_units">
+                                       <ul>
+                                               <li>
+                                                       <em>
+                                                               <img 
src="frontend/templates/base/images/16x16/chart_organisation.png"  
class="list_image" />
+                                                       </em>
+                                                       <xsl:value-of 
select="php:function('lang', 'organisational_units')"/> 
+                                                       (<xsl:value-of 
select="number_of_org_units"/>)
+                                                       <a 
href="index.php?menuaction=frontend.uihelpdesk.index&amp;refresh=true" 
class="list_image">
+                                                               <img 
src="frontend/templates/base/images/16x16/page_refresh.png" class="list_image"/>
+                                                       </a>
+                                               </li>
+                                               <li>
+                                                       <form 
action="index.php?menuaction=frontend.uihelpdesk.index" method="post">
+                                                               <select 
size="3" onchange="this.form.submit()" name="org_unit_id">
+                                                                       
<xsl:choose>
+                                                                               
<xsl:when test="selected_org_unit = 'all'">
+                                                                               
        <option value="all" selected="selected"><xsl:value-of 
select="php:function('lang', 'all_organisational_units')"/></option>
+                                                                               
        <xsl:for-each select="org_unit">
+                                                                               
                <xsl:sort select="ORG_NAME"/>
+                                                                               
                <option value="{ORG_UNIT_ID}"><xsl:value-of 
select="ORG_NAME"/></option>
+                                                                               
        </xsl:for-each>
+                                                                               
</xsl:when>
+                                                                               
<xsl:otherwise>
+                                                                               
        <option value="all"><xsl:value-of select="php:function('lang', 
'all_organisational_units')"/></option>
+                                                                               
        <xsl:for-each select="org_unit">
+                                                                               
                <xsl:sort select="ORG_NAME"/>
+                                                                               
                <xsl:choose>
+                                                                               
                                <xsl:when test="ORG_UNIT_ID = 
//header/selected_org_unit">
+                                                                               
                                        <option value="{ORG_UNIT_ID}" 
selected="selected"><xsl:value-of select="ORG_NAME"/></option>
+                                                                               
                                </xsl:when>
+                                                                               
                                <xsl:otherwise>
+                                                                               
                                        <option 
value="{ORG_UNIT_ID}"><xsl:value-of select="ORG_NAME"/></option>
+                                                                               
                                </xsl:otherwise>
+                                                                               
                        </xsl:choose>
+                                                                               
        </xsl:for-each>
+                                                                               
</xsl:otherwise>
+                                                                               
+                                                                       
</xsl:choose> 
+                                                               </select>
+                                                       </form>
+                                               </li>
+                                       </ul>
+                                       </div>
+                               </xsl:when>
+                       </xsl:choose>
                        <div id="logo_holder">
-                               <img 
src="https://www.bergen.kommune.no/internet/htdocs/images/logo.gif"/>
+                               <img src="{logo_path}"/>
                        </div>
                </div>
     </div>
-       <table id="header">     
+       <table id="header">
                <xsl:choose>
                        <xsl:when test="number_of_locations = 0">
                                <tr valign="top">
                                        <td>
                                                <label>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="use_fellesdata != 1">
+                                                                       <a 
href="index.php?menuaction=frontend.uihelpdesk.index&amp;refresh=true" 
class="list_image">
+                                                                               
                                <img 
src="frontend/templates/base/images/16x16/page_refresh.png" class="list_image"/>
+                                                                               
                        </a>
+                                                                 </xsl:when>
+                                                       </xsl:choose>
                                                        <img 
src="frontend/templates/base/images/32x32/house.png" class="list_image"/>
                                                        <em 
class="select_header"><xsl:value-of select="php:function('lang', 
'no_buildings')"/></em>
                                                </label>
@@ -93,6 +104,13 @@
                                                <div id="unit_selector">
                                                        <form 
action="index.php?menuaction=frontend.uihelpdesk.index" method="post">
                                                                <label>
+                                                                       
<xsl:choose>
+                                                                               
<xsl:when test="use_fellesdata != 1">
+                                                                               
        <a 
href="index.php?menuaction=frontend.uihelpdesk.index&amp;refresh=true" 
class="list_image">
+                                                                               
                                                <img 
src="frontend/templates/base/images/16x16/page_refresh.png" class="list_image"/>
+                                                                               
                                        </a>
+                                                                               
  </xsl:when>
+                                                                       
</xsl:choose>
                                                                        <img 
src="frontend/templates/base/images/32x32/house.png" class="list_image"/>
                                                                        <em 
class="select_header"><xsl:value-of select="php:function('lang', 
'select_unit')"/></em>
                                                                </label>

Modified: trunk/rental/inc/class.soparty.inc.php
===================================================================
--- trunk/rental/inc/class.soparty.inc.php      2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/rental/inc/class.soparty.inc.php      2011-01-27 14:51:20 UTC (rev 
6872)
@@ -159,6 +159,14 @@
                                $filter_clauses[] = "party.org_enhet_id = 
{$org_unit_id}";
                        }
                }
+               
+               if(isset($filters['email'])){
+                       $email = $this->marshal($filters['email'],'string');
+                       if(isset($email))
+                       {
+                               $filter_clauses[] = "party.email = {$email}";
+                       }
+               }
 
                if(isset($filters['sync']))
                {

Modified: trunk/rental/inc/class.uiparty.inc.php
===================================================================
--- trunk/rental/inc/class.uiparty.inc.php      2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/rental/inc/class.uiparty.inc.php      2011-01-27 14:51:20 UTC (rev 
6872)
@@ -21,7 +21,8 @@
                        'download_agresso'      => true,
                        'sync'                          => true,
                        'update_all_org_enhet_id'       => true,
-                       'syncronize_party'      => true
+                       'syncronize_party'      => true,
+                       'create_user_based_on_email' => true
        );
 
        public function __construct()
@@ -487,5 +488,110 @@
                        }
                }
        }
+       
+       /**
+        * Function to create Portico Estate users based on email, first- and 
lastname on contract parties.
+        */
+       public function create_user_based_on_email()
+       {       
+               //Get the party identifier from the reuest
+               $party_id = phpgw::get_var('id');
+               
+               //Access control: only executive officers and administrators 
can create such accounts
+               if(($this->isExecutiveOfficer() || $this->isAdministrator()))
+               {
+                       if(isset($party_id) && $party_id > 0)
+                       {
+                               //Load the party from the database
+                               $party = 
rental_soparty::get_instance()->get_single($party_id);
+                               $email = $party->get_email();
+                               
+                               //Validate the email
+                               $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
+                               if(!$validator->check_email_address($email))
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uiparty.edit','id' => $party_id, 'error' => 
lang('error_create_user_based_on_email_not_valid_address')));
+                               }
+                               if ($GLOBALS['phpgw']->accounts->exists($email) 
)
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uiparty.edit','id' => $party_id, 'error' => 
lang('error_create_user_based_on_email_account_exist')));
+                               }
+                               
+                               //Read group configuration
+                               $config = 
CreateObject('phpgwapi.config','rental');
+                               $config->read();
+                               $renter_group = 
$config->config_data['create_user_based_on_email_group'];
+                               
+                               //Get namae and generate password
+                               $first_name = $party->get_first_name();
+                               $last_name = $party->get_last_name();
+                               $passwd = 
$GLOBALS['phpgw']->common->randomstring(6)."ABab1!"; 
+                               
+                               
+                               try {
+                                       //Create account which never expires
+                                       $account                        = new 
phpgwapi_user();
+                                       $account->lid           = $email;
+                                       $account->firstname     = $first_name;
+                                       $account->lastname      = $last_name;
+                                       $account->passwd        = $passwd;
+                                       $account->enabled       = true;
+                                       $account->expires       = -1;
+                                       $frontend_account       = 
$GLOBALS['phpgw']->accounts->create($account, array($renter_group), array(), 
array('frontend'));
+                                       
+                                       //Specify the accounts access to 
modules 
+                                       $aclobj =& $GLOBALS['phpgw']->acl;
+                                       
$aclobj->set_account_id($frontend_account, true);
+                                       $aclobj->add('frontend', '.', 1);
+                                       $aclobj->add('frontend', 'run', 1);
+                                       $aclobj->add('manual', '.', 1);
+                                       $aclobj->add('manual', 'run', 1);
+                                       $aclobj->add('preferences', 
'changepassword',1);
+                                       $aclobj->add('preferences', '.',1);
+                                       $aclobj->add('preferences', 'run',1);
+                                       $aclobj->save_repository();
+                                       
+                                       //Set the default module for the account
+                                       $preferences = 
createObject('phpgwapi.preferences', $frontend_account);
+                                       
$preferences->add('common','default_app','frontend');
+                                       $preferences->save_repository();
+                               
+                               } catch (Exception $e) {
+                                       //Redirect with error message if 
something goes wrong
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uiparty.edit','id' => $party_id, 'error' => $e->getMessage()));
+                               }
+               
+                               if 
(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server'] )
+                               {
+                                       if (!is_object($GLOBALS['phpgw']->send))
+                                       {
+                                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                                       }
+                                       
+                                       //Get addresses from module 
configuration
+                                       $from = 
$config->config_data['from_email_setting'];
+                                       $address = 
$config->config_data['http_address_for_external_users'];
+                                       
+                                       // Define email content
+                                       $title = 
lang('email_create_user_based_on_email_title');
+                                       $message = 
lang('email_create_user_based_on_email_message',$first_name,$last_name,$passwd, 
$address);
+                               
+                                       //Send email
+                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email',$email,$title,
+                                                stripslashes(nl2br($message)), 
'', '', '',
+                                                $from , 'System message',
+                                                'html', '', array() , false);
+                                       
+                                       //Redirect with sucess message if 
receipt is ok
+                                       if($rcpt)
+                                       {
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uiparty.edit','id' => $party_id, 'message' => 
lang('success_create_user_based_on_email')));
+                                       }
+                               }
+                       }       
+               }
+               //Redirect to edit mode with error message if user reaches this 
point.
+               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'rental.uiparty.edit','id' => $party_id, 'error' => 
lang('error_create_user_based_on_email')));
+       }
 }
 ?>

Added: trunk/rental/inc/hook_config.inc.php
===================================================================
--- trunk/rental/inc/hook_config.inc.php                                (rev 0)
+++ trunk/rental/inc/hook_config.inc.php        2011-01-27 14:51:20 UTC (rev 
6872)
@@ -0,0 +1,49 @@
+<?php
+       /**
+       * Rental - configuration hook
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 2010 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @package phpgroupware
+       * @subpackage Frontend
+       * @category hooks
+       * @version $Id: hook_config.inc.php 4237 2009-11-27 23:17:21Z sigurd $
+       */
+
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU General Public License as published by
+          the Free Software Foundation, either version 2 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       function create_user_based_on_email_group($config)
+       {
+               $groups = $GLOBALS['phpgw']->accounts->get_list('groups');
+               $group_assigned = 
isset($config['create_user_based_on_email_group']) ? 
$config['create_user_based_on_email_group'] : '';
+
+               $out = '<option value="">' . lang('none selected') . 
'</option>' . "\n";
+
+               foreach ( $groups as $group => $label)
+               {
+                       $selected = '';
+                       if ( $group_assigned == $group )
+                       {
+                               $selected = ' selected';
+                       }
+
+                       $out .=  <<<HTML
+                               <option 
value="{$group}"{$selected}>{$label}</option>
+HTML;
+               }
+               return $out;
+       }
\ No newline at end of file

Modified: trunk/rental/inc/hook_settings.inc.php
===================================================================
--- trunk/rental/inc/hook_settings.inc.php      2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/rental/inc/hook_settings.inc.php      2011-01-27 14:51:20 UTC (rev 
6872)
@@ -35,4 +35,4 @@
        create_input_box('Decimal separator','decimal_separator', 'As in "." or 
","');
        create_input_box('responsibility','responsibility', '6 characters');
        create_input_box('project_id','project_id', '1-6 characters');
-
+       
\ No newline at end of file

Modified: trunk/rental/inc/model/class.composite.inc.php
===================================================================
--- trunk/rental/inc/model/class.composite.inc.php      2011-01-27 13:16:00 UTC 
(rev 6871)
+++ trunk/rental/inc/model/class.composite.inc.php      2011-01-27 14:51:20 UTC 
(rev 6872)
@@ -233,10 +233,19 @@
                        foreach($this->get_units() as $unit) // Runs through 
all of the composites units
                        {
                                $location = $unit->get_location();
+                               
                                if($location != null) // There is an underlying 
property location
                                {
-                                       $addresses .= 
$location->get_address_1() . "<br>\n";
-                                       $location_codes .= 
$location->get_location_code() . "<br>\n";
+                                       $address = $location->get_address_1();
+                                       if(isset($address) && $address != '')
+                                       {
+                                               $addresses .= $address . 
"<br>\n";
+                                       }
+                                       else
+                                       {
+                                               $addresses .= 
$location->get_concat_name() . "<br/>\n";
+                                       }
+                                       $location_codes .= 
$location->get_location_code() . "<br/>\n";
                                        $gab_ids .= $location->get_gab_id() . 
"<br>\n";
                                }
                        }

Modified: trunk/rental/inc/model/class.property_location.inc.php
===================================================================
--- trunk/rental/inc/model/class.property_location.inc.php      2011-01-27 
13:16:00 UTC (rev 6871)
+++ trunk/rental/inc/model/class.property_location.inc.php      2011-01-27 
14:51:20 UTC (rev 6872)
@@ -60,6 +60,18 @@
 
        public function get_area_net(){ return $this->area_net; }
        
+       public function get_concat_name()
+       {
+               if(count($this->names) > 0)
+               {
+                       return implode(', ',$this->names);      
+               }
+               else
+               {
+                       return '';
+               }
+       }
+       
        public function serialize()
        {
                $result = array();              

Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang    2011-01-27 13:16:00 UTC (rev 6871)
+++ trunk/rental/setup/phpgw_no.lang    2011-01-27 14:51:20 UTC (rev 6872)
@@ -153,6 +153,8 @@
 create_contract_contract_type_eksternleie      rental  no      Opprett 
eksternleiekontrakt
 create_contract_contract_type_innleie  rental  no      Opprett innleiekontrakt
 create_contract_contract_type_internleie       rental  no      Opprett 
internleiekontrakt
+create_user_based_on_email_link        rental  no      Opprett bruker basert 
på e-post
+create user based on email group       rental  no      Velg gruppe nye brukere 
blir innmeldt i
 cs15_export    rental  no      Kundefil
 currency decimal places        rental  no      Antall desimaler for valuta
 currency prefix        rental  no      Valuta prefix
@@ -188,8 +190,13 @@
 edit   rental  no      Redigér
 elements_pr_page       rental  no      elementer per side
 elements       rental  no      Elementer
-email  renal   no      E-post
+email  rental  no      E-post
+email_create_user_based_on_email_title rental  no      Tilgang til Portico 
Estate
+email_create_user_based_on_email_message       rental  no      Hei %1 
%2:<br/>Det er opprettet en tilgang for deg i Portico 
Estate<br/><br/>Brukernavnet er e-posten din<br/>Passordet er 
%3<br/><br/>Systemet kan nås på adressen %4
 ended  rental  no      Avsluttet
+error_create_user_based_on_email       rental  no      En feil oppstod under 
opprettelse av bruker
+error_create_user_based_on_email_account_exist rental  no      En konto med 
denne e-posten som brukernavn eksisterer allerede
+error_create_user_based_on_email_not_valid_address     rental  no      Kan 
ikke opprette kontoen pga av e-postadressen ikke er gyldig
 error_no_contract_or_party     rental  no      Ingen kontrakt eller 
kontraktspart å utføre handlingen på
 events rental  no      Hendelser
 every_second_week      rental  no      Hver 14. dag
@@ -222,6 +229,7 @@
 f_new_price_item       rental  no      Nytt priselement
 f_new_rc       rental  no      Nytt leieobjekt
 from   rental  no      Fra
+from email setting     rental  no      E-post adresse systemmeldinger (Fra)
 frontpage_was_reset    rental  no      Oppsettet på forsiden ble nullstilt
 frontpage_reset_setup  rental  no      Nullstill oppsett 
 f_select_columns       rental  no      Velg kolonner
@@ -234,6 +242,7 @@
 hidden_for_pick        rental  no      skjult
 has_custom_address     rental  no      Er adressen overstyrt?
 house_number   rental  no      Husnummer
+http address for external users        rental  no      HTTP adresse for 
eksterne brukere
 id     rental  no      ID
 Identifier     rental  no      Identifikator
 import_log_messages    rental  no      Import log
@@ -492,6 +501,7 @@
 status_unknown rental  no      Ukjent status
 status rental  no      Status
 Success        rental  no      Suksess
+success_create_user_based_on_email     rental  no      En brukerkonto ble 
opprettet og en e-post ble sendt til brukeren
 sum    rental  no      Sum
 sync   rental  no      Synkroniser
 sync_identifier        rental  no      Kun identifikator

Modified: trunk/rental/templates/base/config.tpl
===================================================================
--- trunk/rental/templates/base/config.tpl      2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/rental/templates/base/config.tpl      2011-01-27 14:51:20 UTC (rev 
6872)
@@ -36,7 +36,23 @@
                        <td>{lang_billing_time_limit}:</td>
                        <td><input name="newsettings[billing_time_limit]" 
value="{value_billing_time_limit}"></td>
                </tr>
+               <tr class="row_on">
+                       <td>{lang_from_email_setting}:</td>
+                       <td><input name="newsettings[from_email_setting]" 
value="{value_from_email_setting}"></td>
+               </tr>
                <tr class="row_off">
+                       <td>{lang_http_address_for_external_users}:</td>
+                       <td><input 
name="newsettings[http_address_for_external_users]" 
value="{value_http_address_for_external_users}"></td>
+               </tr>
+               <tr class="row_on">
+                       <td>{lang_create_user_based_on_email_group}:</td>
+                       <td>
+                        <select 
name="newsettings[create_user_based_on_email_group]">
+{hook_create_user_based_on_email_group}
+                        </select>
+                       </td>
+               </tr>
+               <tr class="row_off">
                        <td>{lang_use_fellesdata}:</td>
                        <td>
                                <select name="newsettings[use_fellesdata]">

Modified: trunk/rental/templates/base/party.php
===================================================================
--- trunk/rental/templates/base/party.php       2011-01-27 13:16:00 UTC (rev 
6871)
+++ trunk/rental/templates/base/party.php       2011-01-27 14:51:20 UTC (rev 
6872)
@@ -266,6 +266,12 @@
                                                ?>
                                                        <input type="text" 
name="email" id="email" value="<?php echo $party->get_email() ?>" />
                                                <?php
+                                                       $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
+                                                       $email = 
$party->get_email();
+                                                       
if($validator->check_email_address($email) && 
!$GLOBALS['phpgw']->accounts->exists($email))
+                                                       {
+                                                               ?><br/><a 
href="?menuaction=rental.uiparty.create_user_based_on_email&id=<?php echo 
$party->get_id() ?>"><?php echo lang('create_user_based_on_email_link') ?></a> 
<?php        
+                                                       }
                                                }
                                                else
                                                {




reply via email to

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