fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7401] Merge 7387:7400 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [7401] Merge 7387:7400 from trunk
Date: Mon, 20 Jun 2011 06:30:26 +0000

Revision: 7401
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7401
Author:   sigurdne
Date:     2011-06-20 06:30:25 +0000 (Mon, 20 Jun 2011)
Log Message:
-----------
Merge 7387:7400 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
    
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
    
branches/Version-1_0-branch/activitycalendar/inc/class.uiorganization.inc.php
    branches/Version-1_0-branch/activitycalendar/js/activitycalendar/common.js
    branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
    branches/Version-1_0-branch/activitycalendar/templates/base/common.php
    
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
    branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang
    
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
    branches/Version-1_0-branch/frontend/inc/class.uifrontend.inc.php
    branches/Version-1_0-branch/frontend/inc/hook_config.inc.php
    branches/Version-1_0-branch/frontend/templates/base/config.tpl
    branches/Version-1_0-branch/property/inc/class.menu.inc.php
    branches/Version-1_0-branch/property/inc/class.soentity.inc.php
    branches/Version-1_0-branch/property/inc/class.uientity.inc.php
    branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
    branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
    
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
    branches/Version-1_0-branch/property/templates/base/attributes_form.xsl
    branches/Version-1_0-branch/property/templates/base/entity.xsl
    branches/Version-1_0-branch/property/templates/base/location.xsl

Added Paths:
-----------
    branches/Version-1_0-branch/activitycalendarfrontend/templates/base/css/
    branches/Version-1_0-branch/frontend/inc/class.uientity.inc.php
    branches/Version-1_0-branch/frontend/js/yahoo/entity.list.js
    branches/Version-1_0-branch/frontend/templates/base/entity.xsl
    branches/Version-1_0-branch/frontend/templates/base/entityview.xsl
    
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb

Removed Paths:
-------------
    branches/Version-1_0-branch/activitycalendarfrontend/templates/base/base.css

Property Changed:
----------------
    branches/Version-1_0-branch/


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php   
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.soactivity.inc.php   
2011-06-20 06:30:25 UTC (rev 7401)
@@ -344,11 +344,21 @@
                        
$activity->set_description($this->unmarshal($this->db->f('description'), 
'string'));
                        
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
                        
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
-                       
$activity->set_contact_person_1($this->unmarshal($this->db->f('contact_person_1'),
 'int'));
-                       
$activity->set_contact_person_2($this->unmarshal($this->db->f('contact_person_2'),
 'int'));
                        
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
 'int'));
                        
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
 'bool')));
                        
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
+                       
+                       if($activity->get_group_id() && 
$activity->get_group_id() > 0)
+                       {
+                               $contacts = 
activitycalendar_sogroup::get_instance()->get_contacts($activity->get_group_id());
+                               $activity->set_contact_persons($contacts);
+                       }
+                       else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
+                       {
+                               $contacts = 
activitycalendar_soorganization::get_instance()->get_contacts($activity->get_organization_id());
+                               $activity->set_contact_persons($contacts);
+                       }
+                       
                }
                return $activity;
        }
@@ -734,4 +744,220 @@
                }
                return $categories;
        }
+       function update_organization($org_info)
+       {
+               $name = $org_info['name'];
+               $orgid = (int)$org_info['orgid'];
+               $homepage = $org_info['homepage'];
+               $phone = $org_info['phone'];
+               $email = $org_info['email'];
+               $description = $org_info['description'];
+               $street = $org_info['street'];
+               $zip = $org_info['zip'];
+               if($zip && strlen($zip) > 5)
+               {
+                       $zip_code = substr($zip,0,4);
+                       $city = substr($zip, 5);
+               }
+               else
+               {
+                       $zip_code = '';
+                       $city = '';
+               }
+               $district = $org_info['district'];
+               $activity_id = $org_info['activity_id'];
+               $show_in_portal = 1; 
+               
+               $values = array(
+                       'name = ' . $this->marshal($name, 'string'),
+                       'homepage = ' . $this->marshal($homepage, 'string'),
+                       'phone = ' . $this->marshal($phone, 'string'),
+                       'email = ' . $this->marshal($email, 'string'),
+                       'description = ' . $this->marshal($description, 
'string'),
+                       'street = ' . $this->marshal($street, 'string'),
+                       'zip_code = ' . $this->marshal($zip_code, 'string'),
+                       'city = ' . $this->marshal($city, 'string'),
+                       'district = ' . $this->marshal($district),
+                       'activity_id = ' . $this->marshal($activity_id, 'int'),
+                       'show_in_portal = 1'
+               );
+               
+               $result = $this->db->query('UPDATE bb_organization SET ' . 
join(',', $values) . " WHERE id=$orgid", __LINE__,__FILE__);
+       }
+       function add_organization($org_info)
+       {
+               $name = $org_info['name'];
+               $orgnr = $org_info['orgnr'];
+               $homepage = $org_info['homepage'];
+               $phone = $org_info['phone'];
+               $email = $org_info['email'];
+               $description = $org_info['description'];
+               $street = $org_info['street'];
+               $zip = $org_info['zip'];
+               if($zip && strlen($zip) > 5)
+               {
+                       $zip_code = substr($zip,0,4);
+                       $city = substr($zip, 5);
+               }
+               else
+               {
+                       $zip_code = '';
+                       $city = '';
+               }
+               $district = $org_info['district'];
+               $activity_id = $org_info['activity_id'];
+               $show_in_portal = 1; 
+               
+               $columns[] = 'name';
+               $columns[] = 'homepage';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'description';
+               $columns[] = 'street';
+               $columns[] = 'zip_code';
+               $columns[] = 'city';
+               $columns[] = 'district';
+               $columns[] = 'organization_number';
+               $columns[] = 'activity_id';
+               $columns[] = 'show_in_portal';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$homepage}";
+               $values[] = "{$phone}";
+               $values[] = "{$email}";
+               $values[] = "{$description}";
+               $values[] = "{$street}";
+               $values[] = "{$zip_code}";
+               $values[] = "{$city}";
+               $values[] = "{$orgnr}";
+               $values[] = "{$district}";
+               $values[] = $activity_id;
+               $values[] = $show_in_portal;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_organization ({$cols}) VALUES ({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               if(isset($result))
+               {
+                       return $this->db->get_last_insert_id('bb_organization', 
'id');
+               }
+               else
+               {
+                       return 0;
+               }
+       }
+       
+       function add_group($group_info)
+       {
+               $name = $org_info['name'];
+               $orgid = $org_info['organization_id'];
+               $description = $org_info['description'];
+               $activity_id = $org_info['activity_id'];
+               $show_in_portal = 1; 
+               
+               $columns[] = 'name';
+               $columns[] = 'description';
+               $columns[] = 'organization_id';
+               $columns[] = 'activity_id';
+               $columns[] = 'show_in_portal';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$description}";
+               $values[] = "{$orgid}";
+               $values[] = $activity_id;
+               $values[] = $show_in_portal;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_group ({$cols}) VALUES ({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               if(isset($result))
+               {
+                       return $this->db->get_last_insert_id('bb_group', 'id');
+               }
+               else
+               {
+                       return 0;
+               }
+       }
+       
+       function delete_contact_persons($org_id)
+       {
+               if($org_id)
+               {
+                       $org = (int)$org_id;
+                       $sql = "DELETE FROM bb_organization_contact WHERE 
organization_id={$org}";
+                       $result = $this->db->query($sql, __LINE__, __FILE__);
+                       return isset($result);
+               }
+/*             else if($group_id)
+               {
+                       $group = (int)$group_id;
+                       $sql = "DELETE FROM bb_group_contact WHERE 
group_id={$group}";
+                       $result = $this->db->query($sql, __LINE__, __FILE__);
+                       return isset($result);
+               }*/
+       }
+       
+       function add_contact_person_org($contact)
+       {
+               $name = $contact2['name'];
+               $phone = $contact2['phone'];
+               $mail = $contact2['mail'];
+               $org_id = $contact2['org_id'];
+               $ssn = '';
+               
+               $columns[] = 'name';
+               $columns[] = 'ssn';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'organization_id';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$ssn}";
+               $values[] = "{$phone}";
+               $values[] = "{$mail}";
+               $values[] = $org_id;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_organization_contact ({$cols}) VALUES 
({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               return isset($result);
+       }
+       
+       function update_contact_person_org($contact)
+       {
+               
+       }
+       
+       function add_contact_person_group($contact)
+       {
+               $name = $contact2['name'];
+               $phone = $contact2['phone'];
+               $mail = $contact2['mail'];
+               $org_id = $contact2['group_id'];
+               
+               $columns[] = 'name';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'group_id';
+               $cols = implode(',',$columns);
+               
+               $values[] = "{$name}";
+               $values[] = "{$phone}";
+               $values[] = "{$mail}";
+               $values[] = $org_id;
+               $vals = implode(',',$values);
+               
+               $sql = "INSERT INTO bb_group_contact ({$cols}) VALUES 
({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               return isset($result);
+       }
+       
+       function update_contact_person_group($contact)
+       {
+               
+       }
 }

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php  
    2011-06-19 17:47:39 UTC (rev 7400)
+++ 
branches/Version-1_0-branch/activitycalendar/inc/class.socontactperson.inc.php  
    2011-06-20 06:30:25 UTC (rev 7401)
@@ -186,10 +186,10 @@
        {
                $result = "Ingen";
        if(isset($id)){
-               $q1="SELECT name FROM bb_group_contact WHERE id={$id}";
+               $q1="SELECT name, phone, email FROM bb_group_contact WHERE 
id={$id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
-                               $result = $this->db->f('name');
+                               $result = $this->db->f('name') . "<br/>" . 
$this->db->f('phone') . "<br/>" . $this->db->f('email');
                        }
        }
                return $result;
@@ -199,10 +199,10 @@
        {
                $result = "Ingen";
        if(isset($id)){
-               $q1="SELECT name FROM bb_organization_contact WHERE id={$id}";
+               $q1="SELECT name, phone, email FROM bb_organization_contact 
WHERE id={$id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
-                               $result = $this->db->f('name');
+                               $result = $this->db->f('name') . "<br/>" . 
$this->db->f('phone') . "<br/>" . $this->db->f('email');
                        }
        }
                return $result;
@@ -210,7 +210,7 @@
        
        function get_mailaddress_for_group_contact($contact_person_id)
        {
-               if(isset($contact_person_id)){
+               if($contact_person_id){
                $q1="SELECT email FROM bb_group_contact WHERE 
id={$contact_person_id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
@@ -222,8 +222,8 @@
        
        function get_mailaddress_for_org_contact($contact_person_id)
        {
-               if(isset($contact_person_id)){
-               $q1="SELECT email FROM bb_group_contact WHERE 
id={$contact_person_id}";
+               if($contact_person_id){
+               $q1="SELECT email FROM bb_organization_contact WHERE 
id={$contact_person_id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
                                $result = $this->db->f('email');

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php 
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uiactivities.inc.php 
2011-06-20 06:30:25 UTC (rev 7401)
@@ -41,6 +41,7 @@
        
        public function index()
        {
+               //$message = phpgw::get_var('message');
                $this->render('activity_list.php');
                
        }
@@ -308,17 +309,21 @@
        
        //var_dump($subject);
        //var_dump($body);
+       //var_dump($activity->get_organization_id() . " ; " . 
$activity->get_group_id());
        
-       
-       if($activity->get_group_id())
+       if($activity->get_group_id() && $activity->get_group_id() > 0)
        {
+               //$contact_person2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact2($activity>get_group_id());
                
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),
 $subject, $body);
        }
-       else if($activity->get_organization_id())
+       else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
        {
+               //$contact_person2 = 
activitycalendar_socontactperson::get_instance()->get_oup_contact2($activity>get_group_id());
                
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),
 $subject, $body);
        }
        
+       $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'activitycalendar.uiactivities.index', 'message' => 'E-post sendt'));
+       
     }
     
        function send_mailnotification_to_organization($contact_person_id, 
$subject, $body)
@@ -342,6 +347,8 @@
                
                $mailtoAddress = 
activitycalendar_socontactperson::get_instance()->get_mailaddress_for_org_contact($contact_person_id);
                //$mailtoAddress = "address@hidden";
+               
+               //var_dump($mailtoAddress);
 
                if (strlen($mailtoAddress) > 0) 
                {

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.uiorganization.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/inc/class.uiorganization.inc.php   
    2011-06-19 17:47:39 UTC (rev 7400)
+++ 
branches/Version-1_0-branch/activitycalendar/inc/class.uiorganization.inc.php   
    2011-06-20 06:30:25 UTC (rev 7401)
@@ -4,13 +4,15 @@
 phpgw::import_class('activitycalendar.sogroup');
 
 include_class('activitycalendar', 'organization', 'inc/model/');
+include_class('activitycalendar', 'group', 'inc/model/');
 
 class activitycalendar_uiorganization extends activitycalendar_uicommon
 {
        public $public_functions = array
        (
                'index'                         => true,
-               'query'                         => true
+               'query'                         => true,
+               'get_organization_groups' => true
        );
        
        public function __construct()
@@ -23,10 +25,36 @@
        
        public function index()
        {
+               if(phpgw::get_var('phpgw_return_as') == 'json') {
+                       return $this->index_json();
+               }
+                       
                $this->render('organization_list.php');
        }
        
+       public function index_json()
+       {
+               $organizations = 
activitycalendar_soorganization::get_instance()->get(); //get organizations
+               array_walk($organizations["results"], array($this, 
"_add_links"), "booking.uiorganization.show");
 
+               foreach($organizations["results"] as &$organization) {
+
+                       $contact = (isset($organization['contacts']) && 
isset($organization['contacts'][0])) ? $organization['contacts'][0] : null;
+
+                       if ($contact) {
+                               $organization += array(
+                                                       "primary_contact_name"  
=> ($contact["name"])  ? $contact["name"] : '',
+                                                       "primary_contact_phone" 
=> ($contact["phone"]) ? $contact["phone"] : '',
+                                                       "primary_contact_email" 
=> ($contact["email"]) ? $contact["email"] : '',
+                               );
+                       }
+               }
+
+               return $this->yui_results($organizations);
+       }
+       
+       
+
        /**
         * (non-PHPdoc)
         * @see rental/inc/rental_uicommon#query()
@@ -117,6 +145,43 @@
                
                return $this->yui_results($organization_data, 'total_records', 
'results');
        }
+       
+       public function get_organization_groups()
+       {
+               $GLOBALS['phpgw_info']['flags']['noheader'] = true; 
+               $GLOBALS['phpgw_info']['flags']['nofooter'] = true; 
+               $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+               
+               $org_id = phpgw::get_var('orgid');
+               $group_id = phpgw::get_var('groupid');
+               $returnHTML = "<option value='0'>Ingen gruppe valgt</option>";
+               if($org_id)
+               {
+                       $groups = 
activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, 
null, array('org_id' => $org_id));
+                       foreach ($groups as $group) {
+                               if(isset($group))
+                               {
+                                       //$res_g = $group->serialize();
+                                       $selected = "";
+                                       if($group_id && $group_id > 0)
+                                       {
+                                               $gr_id = (int)$group_id; 
+                                               if($gr_id == 
(int)$group->get_id())
+                                               {
+                                                       $selected_group = " 
selected";
+                                               }
+                                       }
+                                       $group_html[] = "<option value='" . 
$group->get_id() . "'". $selected_group . ">" . $group->get_name() . 
"</option>";
+                               }
+                       }
+                   $html = implode(' ' , $group_html);
+                   $returnHTML = $returnHTML . ' ' . $html;
+               }
+               
+               
+               return $returnHTML;
+               //return "<option>Ingen gruppe valgt</option>";
+       }
 
        /**
         * Public method. Called when a user wants to view information about a 
party.

Modified: 
branches/Version-1_0-branch/activitycalendar/js/activitycalendar/common.js
===================================================================
--- branches/Version-1_0-branch/activitycalendar/js/activitycalendar/common.js  
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/activitycalendar/js/activitycalendar/common.js  
2011-06-20 06:30:25 UTC (rev 7401)
@@ -257,3 +257,32 @@
         YAHOO.util.Dom.replaceClass(fieldname + "_edit", "showit", "hideit");
     }
 }
+
+/*
+YAHOO.activitycalendar.autocompleteHelper = function(url, field, hidden, 
container, label_attr) {
+       label_attr = label_attr || 'name';
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               fields: [label_attr, 'id']
+       };
+       myDataSource.maxCacheEntries = 5; 
+       console.log(myDataSource);
+       console.log(field);
+       console.log(container);
+       console.log(YAHOO.widget.AutoComplete);
+       var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
+       ac.queryQuestionMark = false;
+       ac.resultTypeList = false;
+       ac.forceSelection = true;
+       console.log(ac);
+       
+       ac.itemSelectEvent.subscribe(function(sType, aArgs) {
+               console.log(aArgs[2]);
+               YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
+       });
+       return ac;
+};
+*/
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/templates/base/activity.php    
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/activitycalendar/templates/base/activity.php    
2011-06-20 06:30:25 UTC (rev 7401)
@@ -5,6 +5,45 @@
        $contpers_so = activitycalendar_socontactperson::get_instance();
 ?>
 
+<script type="text/javascript">
+
+function get_available_groups()
+{
+       var org_id = document.getElementById('organization_id').value;
+       var group_select = document.getElementById('group_id');
+       //alert(group_select);
+<?php if($activity->get_group_id()){?>
+       url = 
"index.php?menuaction=activitycalendar.uiorganization.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id + "&amp;groupid=" + <?php echo $activity->get_group_id();?>;
+<?php }else{?>
+       url = 
"index.php?menuaction=activitycalendar.uiorganization.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
+<?php }?>
+       
+/*     $.ajax({url: url, 
+               success:  function(response) {
+                       $("#group_id").innerHTML = response;
+               }
+       });
+*/
+       var callback = {
+               success: function(response){
+                                       //alert("det funker");
+                                       group_select.innerHTML = 
JSON.parse(response.responseText);
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+YAHOO.util.Event.onDOMReady(function()
+{
+       get_available_groups();
+});
+
+</script>
+
 <div class="yui-content">
        <div id="details">
                <h1><img src="<?php echo ACTIVITYCALENDAR_IMAGE_PATH 
?>images/32x32/custom/contact.png" /><?php echo lang('activity') ?></h1>
@@ -42,7 +81,7 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="organization_id">
+                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
                                                        <option value="">Ingen 
organisasjon valgt</option>
                                                        <?php
                                                        foreach($organizations 
as $organization)
@@ -74,14 +113,8 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="group_id">
+                                               <select name="group_id" 
id="group_id">
                                                        <option value="0">Ingen 
gruppe valgt</option>
-                                                       <?php
-                                                       foreach($groups as 
$group)
-                                                       {
-                                                               echo "<option 
".($current_group_id == $group->get_id() ? 'selected="selected"' : "")." 
value=\"{$group->get_id()}\">".$group->get_name()."</option>";
-                                                       }
-                                                       ?>
                                                </select>
                                                <?php
                                        ?>

Modified: branches/Version-1_0-branch/activitycalendar/templates/base/common.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/templates/base/common.php      
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/activitycalendar/templates/base/common.php      
2011-06-20 06:30:25 UTC (rev 7401)
@@ -957,4 +957,29 @@
         return ret;
     });
 }
+/*
+YAHOO.activitycalendar.autocompleteHelper = function(url, field, hidden, 
container, label_attr) {
+       label_attr = label_attr || 'name';
+       var myDataSource = new YAHOO.util.DataSource(url);
+       myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
+       myDataSource.connXhrMode = "queueRequests";
+       myDataSource.responseSchema = {
+               resultsList: "ResultSet.Result",
+               fields: [label_attr, 'id']
+       };
+       myDataSource.maxCacheEntries = 5; 
+       console.log(myDataSource);
+       console.log(field);
+       console.log(container);
+       var ac = new YAHOO.widget.AutoComplete(field, container, myDataSource);
+       ac.queryQuestionMark = false;
+       ac.resultTypeList = false;
+       ac.forceSelection = true;
+       console.log(ac);
+       ac.itemSelectEvent.subscribe(function(sType, aArgs) {
+               YAHOO.util.Dom.get(hidden).value = aArgs[2].id;
+       });
+       return ac;
+};
+*/
 </script>

Modified: 
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
   2011-06-19 17:47:39 UTC (rev 7400)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
   2011-06-20 06:30:25 UTC (rev 7401)
@@ -1,8 +1,10 @@
 <?php
        phpgw::import_class('activitycalendar.uiactivities');
        phpgw::import_class('activitycalendar.soactivity');
+       phpgw::import_class('activitycalendar.sogroup');
        
        include_class('activitycalendar', 'activity', 'inc/model/');
+       include_class('activitycalendar', 'group', 'inc/model/');
 
        class activitycalendarfrontend_uiactivity extends 
activitycalendar_uiactivities
        {
@@ -11,7 +13,8 @@
                        'add'                   =>      true,
                        'edit'                  =>      true,
                        'view'                  =>      true,
-                       'index'                 =>      true
+                       'index'                 =>      true,
+                       'get_organization_groups'       =>      true
                );
                
                /**
@@ -47,6 +50,8 @@
 
                function edit()
                {
+                       $GLOBALS['phpgw']->js->validate_file( 'json', 'json', 
'phpgwapi' );
+
                        $id = intval(phpgw::get_var('id', 'GET'));
                        $action = phpgw::get_var('action', 'GET');
                        //var_dump($id);
@@ -122,7 +127,15 @@
                                        $district_array = 
phpgw::get_var('district');
                                        $activity->set_district(implode(",", 
$district_array));
                                        
$activity->set_office(phpgw::get_var('office'));
-                                       $activity->set_state($new_state);
+                                       if($action == 'new_activity')
+                                       {
+                                               $activity->set_state(1);
+                                               //$new_state=1;
+                                       }
+                                       else
+                                       {
+                                               
$activity->set_state($new_state);
+                                       }
                                        
$activity->set_category(phpgw::get_var('category'));
                                        $target_array = 
phpgw::get_var('target');
                                        $activity->set_target(implode(",", 
$target_array));
@@ -182,4 +195,41 @@
                        $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.add'));
                        //var_dump("inni index");
                }
+               
+               public function get_organization_groups()
+               {
+                       $GLOBALS['phpgw_info']['flags']['noheader'] = true; 
+                       $GLOBALS['phpgw_info']['flags']['nofooter'] = true; 
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+                       
+                       $org_id = phpgw::get_var('orgid');
+                       $group_id = phpgw::get_var('groupid');
+                       $returnHTML = "<option value='0'>Ingen gruppe 
valgt</option>";
+                       if($org_id)
+                       {
+                               $groups = 
activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, 
null, array('org_id' => $org_id));
+                               foreach ($groups as $group) {
+                                       if(isset($group))
+                                       {
+                                               //$res_g = $group->serialize();
+                                               $selected = "";
+                                               if($group_id && $group_id > 0)
+                                               {
+                                                       $gr_id = 
(int)$group_id; 
+                                                       if($gr_id == 
(int)$group->get_id())
+                                                       {
+                                                               $selected_group 
= " selected";
+                                                       }
+                                               }
+                                               $group_html[] = "<option 
value='" . $group->get_id() . "'". $selected_group . ">" . $group->get_name() . 
"</option>";
+                                       }
+                               }
+                           $html = implode(' ' , $group_html);
+                           $returnHTML = $returnHTML . ' ' . $html;
+                       }
+                       
+                       
+                       return $returnHTML;
+                       //return "<option>Ingen gruppe valgt</option>";
+               }
        }

Modified: 
branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang    
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/activitycalendarfrontend/setup/phpgw_no.lang    
2011-06-20 06:30:25 UTC (rev 7401)
@@ -44,6 +44,12 @@
 state_3        activitycalendarfrontend        no      Akseptert
 state_4        activitycalendarfrontend        no      Behandlet
 state_5        activitycalendarfrontend        no      Avvist
+new    activitycalendarfrontend        no      Ny
+accepted       activitycalendarfrontend        no      Akseptert
+rejected       activitycalendarfrontend        no      Avvist
+activity       activitycalendarfrontend        no      Aktivitet
+organization   activitycalendarfrontend        no      Organisasjon
+group  activitycalendarfrontend        no      Gruppe
 district       activitycalendarfrontend        no      Bydel
 title  activitycalendarfrontend        no      Tittel
 activity_helptext      activitycalendarfrontend        no      Før ny 
aktivitet kan registreres må du sjekke at organisasjon/gruppe finnes og er 
oppdatert, og at arena finnes og er oppdatert.
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
    2011-06-19 17:47:39 UTC (rev 7400)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
    2011-06-20 06:30:25 UTC (rev 7401)
@@ -5,9 +5,43 @@
        $contpers_so = activitycalendar_socontactperson::get_instance();
 ?>
 
+<script type="text/javascript">
+
+function get_available_groups()
+{
+       var org_id = document.getElementById('organization_id').value;
+       var group_select = document.getElementById('group_id');
+       //alert(group_select);
+<?php if($activity->get_group_id()){?>
+       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id + "&amp;groupid=" + <?php echo $activity->get_group_id();?>;
+<?php }else{?>
+       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
+<?php }?>
+       
+       var callback = {
+               success: function(response){
+                                       //alert("det funker");
+                                       group_select.innerHTML = 
JSON.parse(response.responseText);
+                                       //group_select.innerHTML = 
group_select.innerHTML;
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+YAHOO.util.Event.onDOMReady(function()
+{
+       get_available_groups();
+});
+
+</script>
+
 <div class="yui-content">
        <div id="details">
-               <h1><img src="<?php echo ACTIVITYCALENDAR_IMAGE_PATH 
?>images/32x32/custom/contact.png" /><?php echo lang('activity') ?></h1>
+               <h1><?php echo lang('activity') ?></h1>
                <h4><?php if($editable){echo lang('activity_helptext');}?></h4>
                <form action="#" method="post">
                        <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
@@ -42,7 +76,7 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="organization_id">
+                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
                                                        <option value="">Ingen 
organisasjon valgt</option>
                                                        <?php
                                                        foreach($organizations 
as $organization)
@@ -74,14 +108,8 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="group_id">
+                                               <select name="group_id" 
id="group_id">
                                                        <option value="0">Ingen 
gruppe valgt</option>
-                                                       <?php
-                                                       foreach($groups as 
$group)
-                                                       {
-                                                               echo "<option 
".($current_group_id == $group->get_id() ? 'selected="selected"' : "")." 
value=\"{$group->get_id()}\">".$group->get_name()."</option>";
-                                                       }
-                                                       ?>
                                                </select>
                                                <?php
                                        ?>

Deleted: 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/base.css
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/base.css    
    2011-06-19 17:47:39 UTC (rev 7400)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/base.css    
    2011-06-20 06:30:25 UTC (rev 7401)
@@ -1,243 +0,0 @@
address@hidden "UTF-8";
-
-dl.proplist,
-dl.proplist-col {
-    margin: 1em 0;
-    padding-left: 2em;
-}
-dl.proplist dt,
-dl.proplist-col dt { 
-    font-style: italic; 
-    font-weight: bolder; 
-    font-size: 90%; 
-    margin: .8em 0 .1em 0;
-}
-
-dl.proplist-col,
-dl.form-col {
-    width: 18em;
-    float: left;
-}
-
-
-table#header {
-       margin: 2em;
-       
-       }
-
-div#unit_selector {
-       
-}
-
-div#all_units_key_data {
-       padding-left: 2em;
-       }
-
-div#unit_image {
-       margin-left: 2em;
-       }
-
-div#unit_image img {
-       height:170px;
-}
-
-div.yui-navset {
-       padding-left: 2em;
-       padding-right: 2em;
-       }
-       
-div#contract_selector {
-       padding-left: 1em;
-       padding-top: 1em;
-       }
-       
-img.list_image {
-       margin-right: 5px;
-       float:left;
-       }
-
-a.list_image {
-       float:left;
-       display:inline;
-       }
-
-ol.list_image {
-       float: left;
-       }
-       
-ol.list_image li {
-       padding: 1px;
-}
-       
-dl#key_data  {
-       padding: 2px;
-       }
-       
-       
-dl#key_data dd {
-       padding-bottom: 1em;
-}
-
-table#key_data td {
-       padding-right: 1em;
-       padding: 5px;
-       }
-
-
-.user_menu {
-       list-style:none;
-       height: 100%;
-       padding: 2px;
-       border-style: none none none solid;
-       border-width: 1px;
-       border-color: grey;
-       padding-left: 5px;
-}
-
-.user_menu li {
-       margin: 13px;
-       }
-       
-#area_and_price {
-       list-style:none;
-       height: 100%;
-       padding: 2px;
-       padding-left: 5px;
-       float:right;
-       padding:0.5em 1em 0 0;
-}
-
-#area_and_price li {
-       margin: 13px;
-       }
-       
-#org_units {
-       list-style: none;
-       height: 100%;
-       padding: 2px;
-       padding-left: 5px;
-       float:right;
-       padding:0.5em 1em 0 0;
-}
-
-#org_units li {
-       margin: 13px;
-       }
-       
-#information {
-       list-style:none;
-       height: 100%;
-       padding: 2px;
-       padding-left: 5px;
-       float:right;
-       padding:0.5em 1em 0 0;
-}
-
-#information li {
-       margin: 13px;
-       }
-
-a.header_link {
-       text-decoration: none;
-       float: none;
-       }
-       
-#logo_holder {
-       border: 0 none;
-       font-family:Arial,sans-serif;
-font-size:65%;
-line-height:1.166;
-position: absolute;
-padding:2em;
-}
-
-em#bold {
-       font-weight: bold;
-       }
-
-div#header a {
-       float: none;
-}
-
-.yui-skin-sam .yui-navset .yui-nav, .yui-skin-sam .yui-navset .yui-navset-top 
.yui-nav {
-       border-color: #BF0005;
-       border-width:0 0 2px;
-       }
-       
-.yui-skin-sam .yui-navset .yui-content {
-       background: none repeat scroll 0 0 #F4F2ED;
-}
-
-.yui-skin-sam .yui-navset .yui-nav .selected a, .yui-skin-sam .yui-navset 
.yui-nav .selected a:focus, .yui-skin-sam .yui-navset .yui-nav .selected 
a:hover {
-       background:url("../../../../assets/skins/sam/sprite.png") repeat-x 
scroll left -1400px #2647A0;
-       }
-       
-div.tickets {
-       margin-top: 1em;
-       }
-
-em.select_header {
-       font-size: larger;
-       padding-top: 10px;
-       }
-
-#contract_price_and_area {
-       float: left;
-       margin: 1em 2em 0 0;
-}
-
-#contract_price_and_area li {
-               margin-bottom: 1em;
-       }
-
-#contract_essentials {
-       float: left;
-       margin: 1em 2em 0 2em;
-       }
-       
-#composites {
-       float: left;
-       margin: 1em 2em 0 2em;
-       }
-       
-       
-#comment {
-       float: left;
-       margin: 1em 2em 0 2em;
-       }
-       
-       #contract_essentials li {
-               margin-bottom: 1em;
-       }
-       
-#contract_parts {
-       float: left;
-       margin: 1em 2em 0 2em;
-       }
-       
-div.toolbar {
-background-color:#EEEEEE;
-border:1px solid #BBBBBB;
-float:left;
-width:100%;
-}
-
-div.toolbar_manual {
-background-color:#EEEEEE;
-border:1px solid #BBBBBB;
-float:left;
-width:100%;
-}
-
-.yui-pg-container {
-       white-space: normal;
-       }
-       
-li.ticket_detail {
-       padding: 5px;
-       margin-left: 5px;
-       }
-
-
-
-

Copied: branches/Version-1_0-branch/frontend/inc/class.uientity.inc.php (from 
rev 7400, trunk/frontend/inc/class.uientity.inc.php)
===================================================================
--- branches/Version-1_0-branch/frontend/inc/class.uientity.inc.php             
                (rev 0)
+++ branches/Version-1_0-branch/frontend/inc/class.uientity.inc.php     
2011-06-20 06:30:25 UTC (rev 7401)
@@ -0,0 +1,1158 @@
+<?php
+
+       /**
+        * Frontend : a simplified tool for end users.
+        *
+        * @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 Frontend
+        * @version $Id: class.uientity.inc.php 7224 2011-04-15 11:48:27Z 
sigurdne $
+        */
+
+       /*
+          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/>.
+       */
+
+       phpgw::import_class('frontend.uifrontend');
+
+       /**
+        * Helpdesk
+        *
+        * @package Frontend
+        */
+
+       class frontend_uientity extends frontend_uifrontend
+       {
+
+               public $public_functions = array
+               (
+                       'index'                 => true,
+                       'download'              => true,
+                       'view'                  => true,
+               );
+
+               public function __construct()
+               {
+                       $this->location_id                      = 
phpgw::get_var('location_id', 'int', 'REQUEST', 0);
+                       $location_info                          = 
$GLOBALS['phpgw']->locations->get_name($this->location_id);
+                       $this->acl_location                     = 
$location_info['location'];
+                       $location_arr                           = explode('.', 
$this->acl_location);
+
+                       $this->account                          = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->bo                                       = 
CreateObject('property.boentity',true);
+                       $this->bocommon                         = & 
$this->bo->bocommon;
+                       $this->soadmin_entity           = & 
$this->bo->soadmin_entity;
+
+                       $this->entity_id                        = 
isset($location_arr[2]) && $location_arr[2] ? $location_arr[2] :  
$this->bo->entity_id;
+                       $this->cat_id                           = 
isset($location_arr[3]) && $location_arr[3] ? $location_arr[3] :  
$this->bo->cat_id;
+
+                       $this->type                                     = 
$this->bo->type;
+                       $this->type_app                         = 
$this->bo->type_app;
+
+                       if(isset($location_arr[3]))
+                       {
+                               $this->bo->entity_id    = $this->entity_id;
+                               $this->bo->cat_id               = $this->cat_id;
+                               $this->acl_location             = 
".{$this->type}.$this->entity_id";
+                               if( $this->cat_id )
+                               {
+                                       $this->acl_location     .= 
".{$this->cat_id}";
+                               }
+                       }
+
+
+                       $this->acl                                      = & 
$GLOBALS['phpgw']->acl;                     
+                       $this->acl_read                         = 
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'property');
+                       $this->acl_add                          = 
$this->acl->check($this->acl_location, PHPGW_ACL_ADD, 'property');
+                       $this->acl_edit                         = 
$this->acl->check($this->acl_location, PHPGW_ACL_EDIT, 'property');
+                       $this->acl_delete                       = 
$this->acl->check($this->acl_location, PHPGW_ACL_DELETE, 'property');
+
+                       $this->start                            = 
$this->bo->start;
+                       $this->query                            = 
$this->bo->query;
+                       $this->sort                                     = 
$this->bo->sort;
+                       $this->order                            = 
$this->bo->order;
+                       $this->filter                           = 
$this->bo->filter;
+                       $this->part_of_town_id          = 
$this->bo->part_of_town_id;
+                       $this->district_id                      = 
$this->bo->district_id;
+                       $this->status                           = 
$this->bo->status;
+//                     $this->location_code            = 
$this->bo->location_code;
+                       $this->p_num                            = 
$this->bo->p_num;
+                       $this->category_dir                     = 
$this->bo->category_dir;
+                       
$GLOBALS['phpgw']->session->appsession('entity_id','property',$this->entity_id);
+                       $this->start_date                       = 
$this->bo->start_date;
+                       $this->end_date                         = 
$this->bo->end_date;
+                       $this->allrows                          = 
$this->bo->allrows;
+
+       
+                       
phpgwapi_cache::session_set('frontend','tab',$this->location_id);
+                       parent::__construct();
+                       $this->location_code = 
$this->header_state['selected_location'];
+                       $this->bo->location_code = $this->location_code;
+               }
+
+
+               function download()
+               {
+                       $GLOBALS['phpgw_info']['flags'][noheader] = true;
+                       $GLOBALS['phpgw_info']['flags'][nofooter] = true;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+
+                       $start_date     = urldecode($this->start_date);
+                       $end_date       = urldecode($this->end_date);
+
+                       $list = 
$this->bo->read(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'allrows'=>true,'start_date'=>$start_date,'end_date'=>$end_date,
 'type' => $this->type));
+                       $uicols = $this->bo->uicols;
+
+                       
$this->bocommon->download($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
+               }
+
+
+               public function index()
+               {
+                       $GLOBALS['phpgw_info']['apps']['manual']['section'] = 
'entity.index';
+                       $this->insert_links_on_header_state();
+
+                       if($this->entity_id && !$this->cat_id)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'frontend.uientity.index', 'entity_id'=>$this->entity_id, 'cat_id'=> 1, 'type' 
=> $this->type));
+                       }
+
+                       //redirect if no rights
+                       if(!$this->acl_read && $this->cat_id)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
+                       }
+
+                       $start_date     = urldecode($this->start_date);
+                       $end_date       = urldecode($this->end_date);
+                       $dry_run = false;
+                       $second_display = phpgw::get_var('second_display', 
'bool');
+
+//                     $this->save_sessiondata();
+
+                       //Preferencias sets
+                       
if(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['group_filters'])
 && $GLOBALS['phpgw_info']['user']['preferences']['property']['group_filters'] 
== 'yes')
+                       {
+                               $group_filters = 'select';
+                               
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field_grouped'));
+                       }
+                       else
+                       {
+                               $group_filters = 'filter';
+                               
$GLOBALS['phpgw']->xslttpl->add_file(array('search_field'));
+                       }
+                       $default_district       = 
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_district'])?$GLOBALS['phpgw_info']['user']['preferences']['property']['default_district']:'');
+
+                       if ($default_district && !$second_display && 
!$this->district_id)
+                       {
+                               $this->bo->district_id  = $default_district;
+                               $this->district_id              = 
$default_district;
+                       }
+
+                       $datatable = array();
+                       $values_combo_box = array();
+
+                       if($this->cat_id)
+                       {
+                               $category = 
$this->soadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+                       }
+
+                       //      enters the first time
+                       if( phpgw::get_var('phpgw_return_as') != 'json' )
+                       {
+
+                               $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                               'menuaction'                    
=> 'frontend.uientity.index',
+                                               'entity_id'                     
=> $this->entity_id,
+                                               'cat_id'                => 
$this->cat_id,
+                                               'type'                          
        => $this->type,
+                                               'district_id'                   
=> $this->district_id,
+                                               'p_num'                         
        => $this->p_num,
+                                               'location_id'   => 
$this->location_id
+                                       ));
+                               $datatable['config']['allow_allrows'] = true;
+
+                               $datatable['config']['base_java_url']   =       
"menuaction:'frontend.uientity.index',".
+                                       "second_display:1,".
+                                       "entity_id:'{$this->entity_id}',".
+                                       "cat_id:'{$this->cat_id}',".
+                                       "type:'{$this->type}',".
+                                       "district_id:'{$this->district_id}',".
+                                       "p_num:'{$this->p_num}',".
+                                       "location_id:'{$this->location_id}'";
+
+                               // this array "$arr_filter_hide" indicate what 
filters are hidden or not
+                               $arr_filter_hide = array();
+
+                               //// ---- DISTRICT filter----------------------
+                               if($this->cat_id)
+                               {
+                                       //this validation comes to previous 
versions
+                                       if (isset($category['location_level']) 
&& $category['location_level']>0)
+                                       {
+                                               $values_combo_box[1]    = 
$this->bocommon->select_district_list($group_filters,$this->district_id);
+                                               if(count($values_combo_box[1]))
+                                               {
+                                                       $default_value = array 
('id'=>'','name'=>lang('no district'));
+                                                       array_unshift 
($values_combo_box[1],$default_value);
+                                                       $arr_filter_hide[1] = 0;
+                                               }
+                                               else
+                                               {
+                                                       $arr_filter_hide[1] = 1;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $values_combo_box[1] = array();
+                                               $arr_filter_hide[1] = 1;
+                                       }
+                               }
+
+                               //// ---- USER filter----------------------
+                               $values_combo_box[2]  = 
$this->bocommon->get_user_list_right2($group_filters,4,$this->filter,$this->acl_location,array('all'),$default='all');
+
+                               if(count($values_combo_box[2]))
+                               {
+                                       $default_value = array 
('id'=>'','name'=>lang('no user'));
+                                       array_unshift 
($values_combo_box[2],$default_value);
+                                       $arr_filter_hide[2] = 0;
+                               }
+                               else
+                               {
+                                       $arr_filter_hide[2] = 1;
+                               }
+
+                               $values_combo_box[3]  = 
$this->bo->get_criteria_list($this->criteria_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no criteria'));
+                               array_unshift 
($values_combo_box[3],$default_value);
+
+                               $datatable['actions']['form'] = array
+                                       (
+                                               array
+                                               (
+                                                       'action'  => 
$GLOBALS['phpgw']->link('/index.php',
+                                                       array
+                                                       (
+                                                               'menuaction'    
        => 'frontend.uientity.index',
+                                                               
'second_display'        => $second_display,
+                                                               'entity_id'     
                => $this->entity_id,
+                                                               'cat_id'        
                => $this->cat_id,
+                                                               'type'          
                => $this->type,
+                                                               'location_id'   
        => $this->location_id
+                                                       )),
+                                                       'fields'  => array
+                                                       (
+                                                               'field' => array
+                                                               (
+                                                       /*              array
+                                                                       ( 
//boton       CATEGORY
+                                                                               
                        'id'   => 'btn_cat_id',
+                                                                               
                        'name' => 'cat_id',
+                                                                               
                        'value'=> lang('Category'),
+                                                                               
                        'type' => 'button',
+                                                                               
                        'style' => 'filter',
+                                                                               
                        'tab_index' => 1
+                                                                               
),
+                                                                       array
+                                                                       ( 
//boton       DISTINT
+                                                                               
'id'   => 'btn_district_id',
+                                                                               
'name' => 'district_id',
+                                                                               
'value'=> lang('District'),
+                                                                               
'type' => 'button',
+                                                                               
'style' => 'filter',
+                                                                               
'tab_index' => 2
+                                                                       ),
+                                                                       array
+                                                                       ( 
//boton       USER
+                                                                               
'id'   => 'btn_user_id',
+                                                                               
'name' => 'user_id',
+                                                                               
'value'=> lang('User'),
+                                                                               
'type' => 'button',
+                                                                               
'style' => 'filter',
+                                                                               
'tab_index' => 3
+                                                                       ),*/
+                                                                       array
+                                                                       ( 
//boton       search criteria
+                                                                               
'id' => 'btn_criteria_id',
+                                                                               
'name' => 'criteria_id',
+                                                                               
'value' => lang('search criteria'),
+                                                                               
'type' => 'button',
+                                                                               
'style' => 'filter',
+                                                                               
'tab_index' => 4
+                                                                       ),
+                                                                       array
+                                                                       (//for 
link "columns", next to Export button
+                                                                               
'type'=> 'link',
+                                                                               
'id'  => 'btn_columns',
+                                                                               
'url' => "Javascript:window.open('".$GLOBALS['phpgw']->link('/index.php',
+                                                                               
array
+                                                                               
(
+                                                                               
        'menuaction'    => 'property.uientity.columns',
+                                                                               
        'entity_id'             => $this->entity_id,
+                                                                               
        'cat_id'                => $this->cat_id,
+                                                                               
        'type'                  => $this->type
+                                                                               
))."','link','width=300,height=600,scrollbars=1')",
+                                                                               
'value' => lang('columns'),
+                                                                               
'tab_index' => 11
+                                                                       ),
+                                                                       array
+                                                                       (
+                                                                               
'type' => 'button',
+                                                                               
'id'   => 'btn_export',
+                                                                               
'value'=> lang('download'),
+                                                                               
'tab_index' => 10
+                                                                       ),
+                                                                       array
+                                                                       (
+                                                                               
'type' => 'button',
+                                                                               
'id'   => 'btn_new',
+                                                                               
'value'=> lang('add'),
+                                                                               
'tab_index' => 9
+                                                                       ),
+                                                                       array
+                                                                       ( 
//boton        SEARCH
+                                                                               
'id'   => 'btn_search',
+                                                                               
'name' => 'search',
+                                                                               
'value'=> lang('search'),
+                                                                               
'type' => 'button',
+                                                                               
'tab_index' => 8
+                                                                       ),
+                                                                       array
+                                                                       ( // 
TEXT IMPUT
+                                                                               
'name' => 'query',
+                                                                               
'id'   => 'txt_query',
+                                                                               
'value'=> $this->query,
+                                                                               
'type' => 'text',
+                                                                               
'size' => 28,
+                                                                               
'onkeypress' => 'return pulsar(event)',
+                                                                               
'tab_index' => 7
+                                                                       ),
+                                                                       array
+                                                                       (//for 
link "None",
+                                                                               
'type'=> 'label_date'
+                                                                       ),
+                                                                       array
+                                                                       ( 
//hidden end_date
+                                                                               
'type'  => 'hidden',
+                                                                               
'id'    => 'end_date',
+                                                                               
'name'  => 'end_date',
+                                                                               
'value' => $end_date
+                                                                       ),
+                                                                       array
+                                                                       ( 
//hidden start_date
+                                                                               
'type'  => 'hidden',
+                                                                               
'id'    => 'start_date',
+                                                                               
'name'  => 'start_date',
+                                                                               
'value' => $start_date
+                                                                       ),
+                                                                       array
+                                                                       (//for 
link "Date search",
+                                                                               
'type'=> 'link',
+                                                                               
'id'  => 'btn_data_search',
+                                                                               
'url' => "Javascript:window.open('".$GLOBALS['phpgw']->link('/index.php',
+                                                                               
array
+                                                                               
(
+                                                                               
        'menuaction' => 
'property.uiproject.date_search'))."','link','width=350,height=250')",
+                                                                               
        'value' => lang('Date search'),
+                                                                               
        'tab_index' => 6
+                                                                               
)),
+                                                               'hidden_value' 
=> array
+                                                               (
+                                                                       array
+                                                                       (
+                                                                               
'id'   => 'values_combo_box_0',
+                                                                               
'value'=> $this->bocommon->select2String($values_combo_box[0])
+                                                                       ),
+                                                                       array
+                                                                       (
+                                                                               
'id'    => 'values_combo_box_1',
+                                                                               
'value' => $this->bocommon->select2String($values_combo_box[1])
+                                                                       ),
+                                                                       array
+                                                                       (
+                                                                               
'id' => 'values_combo_box_2',
+                                                                               
'value' => $this->bocommon->select2String($values_combo_box[2])
+                                                                       ),
+                                                                       array
+                                                                       (
+                                                                               
'id' => 'values_combo_box_3',
+                                                                               
'value' => $this->bocommon->select2String($values_combo_box[3])
+                                                                       ),
+                                                               )
+                                                       )));
+
+                               $custom = 
createObject('phpgwapi.custom_fields');
+                               $attrib_data = 
$custom->find($this->type_app[$this->type],".{$this->type}.{$this->entity_id}.{$this->cat_id}",
 0, '','','',true, true);
+
+                               $button_def[] = "oMenuButton_0";
+               //              $button_def[] = "oMenuButton_1";
+               //              $button_def[] = "oMenuButton_2";
+                               $button_def[] = "oMenuButton_3";
+                               $code_inner[] = "{order:0, 
var_URL:'cat_id',name:'btn_cat_id',style:'genericbutton',dependiente:[]}";
+               //              $code_inner[] = "{order:1, 
var_URL:'district_id',name:'btn_district_id',style:'genericbutton',dependiente:[]}";
+               //              $code_inner[] = "{order:2, 
var_URL:'filter',name:'btn_user_id',style:'genericbutton',dependiente:[]}";
+                               $code_inner[] = "{order:3, 
var_URL:'criteria_id',name:'btn_criteria_id',style:'genericbutton',dependiente:[]}";
+
+
+                               if($attrib_data)
+                               {
+                                       $i = 4;
+                                       foreach ( $attrib_data as $attrib )
+                                       {
+                                               if($attrib['datatype'] == 'LB' 
|| $attrib['datatype'] == 'CH' || $attrib['datatype'] == 'R')
+                                               {
+                                                       
$datatable['actions']['form'][0]['fields']['field'][] = array
+                                                       (
+                                                               'id' => 
"btn_{$attrib['column_name']}",
+                                                               'name' => 
$attrib['column_name'],
+                                                               'value' => 
$attrib['input_text'],
+                                                               'type' => 
'button',
+                                                               'style' => 
'filter',
+                                                               'tab_index' => 
$i
+                                                       );
+
+                                                       $button_def[] = 
"oMenuButton_{$i}"; 
+                                                       $code_inner[] = 
"{order:{$i}, 
var_URL:'{$attrib['column_name']}',name:'btn_{$attrib['column_name']}',style:'genericbutton',dependiente:[]}";
+
+                                                       $values_combo_box[$i][] 
 = array
+                                                       (
+                                                               'id'    => '',
+                                                               'name'  => 
$attrib['input_text'],
+                                                       );
+
+
+                                                       
foreach($attrib['choice'] as $choice)
+                                                       {
+                                                               
$values_combo_box[$i][]  = array
+                                                               (
+                                                                       'id'    
=> $choice['id'],
+                                                                       'name'  
=> htmlspecialchars($choice['value'], ENT_QUOTES, 'UTF-8'),
+                                                               );
+                                                       }
+
+                                                       
$datatable['actions']['form'][0]['fields']['hidden_value'][] = array
+                                                       (
+                                                               'id'    => 
"values_combo_box_{$i}",
+                                                               'value' => 
$this->bocommon->select2String($values_combo_box[$i])                           
                     
+                                                       );
+                                                       $i++;
+                                               }
+                                       }
+                               }
+
+                               $code = 'var ' . implode(',', $button_def)  . 
";\n";
+                               $code .= 'var selectsButtons = [' . "\n" . 
implode(",\n",$code_inner) . "\n];";
+
+                               $GLOBALS['phpgw']->js->add_code('', $code);
+
+                               //      eliminates those empty filters
+                               $eliminate = 0;
+                               foreach( $arr_filter_hide as $key => $value )
+                               {
+                                       if ($value)
+                                       {
+                                               //eliminates the respective 
entry in $datatable..['field']
+                                               
array_splice($datatable['actions']['form'][0]['fields']['field'],$eliminate, 1);
+                                       }
+                                       else
+                                       {
+                                               $eliminate++;
+                                       }
+                               }
+
+                               // sets for initial ordering
+                               $this->sort = "ASC";
+                               $this->order = "num";
+//                             $dry_run = true;
+                       }
+
+                       $entity_list = array();
+
+                       $entity_list = 
$this->bo->read(array('start_date'=>$start_date,'end_date'=>$end_date, 
'dry_run' => $dry_run));
+
+                       $uicols = $this->bo->uicols;
+
+                       $content = array();
+                       $j=0;
+                       if (isset($entity_list) && is_array($entity_list))
+                       {
+                               foreach($entity_list as $entity_entry)
+                               {
+                                       for 
($i=0;$i<count($uicols['name']);$i++)
+                                       {
+                                               
if($uicols['input_type'][$i]!='hidden')
+                                               {
+                                                       
if(isset($entity_entry['query_location'][$uicols['name'][$i]]))
+                                                       {
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['name']                     = 
$uicols['name'][$i];
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['statustext']               = 
lang('search');
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['value']                    = 
$entity_entry[$uicols['name'][$i]];
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['format']                   = 
'link';
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['java_link']                = true;
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['link']                             
= $entity_entry['query_location'][$uicols['name'][$i]];
+                                                       }
+                                                       else
+                                                       {
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['value']                    = 
$entity_entry[$uicols['name'][$i]];
+                                                               
//$datatable['rows']['row'][$j]['column'][$i]['value']                  = $i;
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['name']                     = 
$uicols['name'][$i];
+                                                               
//$datatable['rows']['row'][$j]['column'][$i]['lookup']                 = 
$lookup;
+                                                               
$datatable['rows']['row'][$j]['column'][$i]['align']                    = 
isset($uicols['align'][$i])?$uicols['align'][$i]:'center';
+
+                                                               
if(isset($uicols['datatype']) && isset($uicols['datatype'][$i]) && 
$uicols['datatype'][$i]=='link' && $entity_entry[$uicols['name'][$i]])
+                                                               {
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['format']           = 'link';
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['value']            = lang('link');
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['link']                     = 
$entity_entry[$uicols['name'][$i]];
+                                                                       
$datatable['rows']['row'][$j]['column'][$i]['target']      = '_blank';
+                                                               }
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       
$datatable['rows']['row'][$j]['column'][$i]['name']                     = 
$uicols['name'][$i];
+                                                       
$datatable['rows']['row'][$j]['column'][$i]['value']                    = 
$entity_entry[$uicols['name'][$i]];
+                                               }
+                                               
$datatable['rows']['row'][$j]['hidden'][$i]['value']                            
= $entity_entry[$uicols['name'][$i]];
+                                               
$datatable['rows']['row'][$j]['hidden'][$i]['name']                             
        = $uicols['name'][$i];
+                                       }
+
+                                       $j++;
+                               }
+                       }
+
+                       //indica que de la fila seleccionada escogera de la 
columna "id" el valor "id". Para agregarlo al URL
+                       $parameters = array
+                               (
+                                       'parameter' => array
+                                       (
+                                               array
+                                               (
+                                                       'name'          => 'id',
+                                                       'source'        => 'id'
+                                               ),
+                                       )
+                               );
+
+                       $parameters2 = array
+                               (
+                                       'parameter' => array
+                                       (
+                                               array
+                                               (
+                                                       'name'          => 
'location_code',
+                                                       'source'        => 
'location_code'
+                                               ),
+                                               array
+                                               (
+                                                       'name'          => 
'origin_id',
+                                                       'source'        => 'id'
+                                               ),
+                                               array
+                                               (
+                                                       'name'          => 
'p_num',
+                                                       'source'        => 'id'
+                                               ),
+                                       )
+                               );
+
+                       if($this->acl_read)
+                       {
+                               $datatable['rowactions']['action'][] = array
+                                       (
+                                               'my_name'               => 
'view',
+                                               'text'                  => 
lang('view'),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'    => 
'frontend.uientity.view',
+                                                       'entity_id'             
=> $this->entity_id,
+                                                       'cat_id'                
=> $this->cat_id,
+                                                       'type'                  
=> $this->type
+                                               )),
+                                               'parameters'                    
=> $parameters
+                                       );
+                       }
+                       if($this->acl_edit)
+                       {
+                               $datatable['rowactions']['action'][] = array
+                                       (
+                                               'my_name'               => 
'edit',
+                                               'text'                  => 
lang('edit'),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'    => 
'frontend.uientity.edit',
+                                                       'entity_id'             
=> $this->entity_id,
+                                                       'cat_id'                
=> $this->cat_id,
+                                                       'type'                  
=> $this->type
+                                               )),
+                                               'parameters'                    
=> $parameters
+                                       );
+                       }
+
+                       if(     $category['start_ticket'])
+                       {
+                               $datatable['rowactions']['action'][] = array
+                                       (
+                                               'my_name'               => 
'edit',
+                                               'text'                  => 
lang('start ticket'),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'            
=> 'frontend.uihelpdesk.add_ticket',
+                                                       'noframework'           
=> 1,
+                                                       'target'                
        => '_lightbox'
+                                               )),
+                                               'parameters'                    
=> $parameters2
+                                       );
+                       }
+
+                       $jasper = execMethod('property.sojasper.read', 
array('location_id' => 
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], 
$this->acl_location)));
+
+                       foreach ($jasper as $report)
+                       {
+                               $datatable['rowactions']['action'][] = array
+                                       (
+                                               'my_name'               => 
'edit',
+                                               'text'                  => 
lang('open JasperReport %1 in new window', $report['title']),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'    => 
'property.uijasper.view',
+                                                       'jasper_id'             
        => $report['id'],
+                                                       'target'                
=> '_blank'
+                                               )),
+                                               'parameters'                    
=> $parameters
+                                       );
+                       }
+
+/*
+                       if($this->acl_delete)
+                       {
+                               $datatable['rowactions']['action'][] = array
+                                       (
+                                               'my_name'               => 
'delete',
+                                               'text'                  => 
lang('delete'),
+                                               'confirm_msg'   => lang('do you 
really want to delete this entry'),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'    => 
'frontend.uientity.delete',
+                                                       'entity_id'             
=> $this->entity_id,
+                                                       'cat_id'                
=> $this->cat_id,
+                                                       'type'                  
=> $this->type
+                                               )),
+                                               'parameters'    => $parameters
+                                       );
+                       }
+
+
+                       if($this->acl_add)
+                       {
+                               $datatable['rowactions']['action'][] = array
+                                       (
+                                               'my_name'               => 
'add',
+                                               'text'                  => 
lang('add'),
+                                               'action'                => 
$GLOBALS['phpgw']->link('/index.php',array
+                                               (
+                                                       'menuaction'    => 
'frontend.uientity.edit',
+                                                       'entity_id'             
=> $this->entity_id,
+                                                       'cat_id'                
=> $this->cat_id,
+                                                       'type'                  
=> $this->type
+                                               ))
+                                       );
+                       }
+*/
+                       unset($parameters);
+
+                       //$uicols_count indicates the number of columns to 
display in actuall option-menu. this variable was set in $this->bo->read()
+                       $link = $GLOBALS['phpgw']->link(
+                                       '/index.php',
+                                       array('menuaction'      => 
'frontend.uientity.view'));
+                       $datatable['exchange_values'] = "document.location = 
'{$link}&id=' + data.getData().id + '&location_id={$this->location_id}';";
+
+
+                       $uicols_count   = count($uicols['descr']);
+
+                       //Columns Order
+                       for ($i=0;$i<$uicols_count;$i++)
+                       {
+                               //all colums should be have formatter
+                               
$datatable['headers']['header'][$i]['formatter'] = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
+
+                               if($uicols['input_type'][$i]!='hidden')
+                               {
+                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
+                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
+                                       
$datatable['headers']['header'][$i]['visible']                  = true;
+                                       
$datatable['headers']['header'][$i]['format']                   = 
$this->bocommon->translate_datatype_format($uicols['datatype'][$i]);
+                                       
$datatable['headers']['header'][$i]['sortable']                 = 
$uicols['sortable'][$i];;
+                                       
$datatable['headers']['header'][$i]['sort_field']               = 
$uicols['name'][$i];
+                                       
//$datatable['headers']['header'][$i]['formatter']              = 
$uicols['formatter'][$i];
+                                       //according to stable bruch this 
columns is not SORTABLE'
+                                       $denied = array('merknad');//$denied = 
array('merknad','account_lid');
+                                       //if not include
+                                       if(in_array ($uicols['name'][$i], 
$denied))
+                                       {
+                                               
$datatable['headers']['header'][$i]['sortable']         = false;
+                                       }
+                                       else 
if(isset($uicols['cols_return_extra'][$i]) && 
($uicols['cols_return_extra'][$i]!='T' || 
$uicols['cols_return_extra'][$i]!='CH'))
+                                       {
+                                               
$datatable['headers']['header'][$i]['sortable']         = true;
+                                       }
+
+                               }
+                               else
+                               {
+                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
+                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
+                                       
$datatable['headers']['header'][$i]['visible']                  = false;
+                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
+                                       
$datatable['headers']['header'][$i]['format']                   = 'hidden';
+                               }
+                       }
+
+                       // path for property.js
+                       $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property.js";
+
+                       // Pagination and sort values
+                       $datatable['pagination']['records_start']       = 
(int)$this->bo->start;
+                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+
+                       if($dry_run)
+                       {
+                               $datatable['pagination']['records_returned'] = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];           
         
+                       }
+                       else
+                       {
+                               $datatable['pagination']['records_returned']= 
count($entity_list);
+                       }
+
+                       $datatable['pagination']['records_total']       = 
$this->bo->total_records;
+
+                       $datatable['sorting']['order']  = 
phpgw::get_var('order', 'string'); // Column
+                       $datatable['sorting']['sort']   = 
phpgw::get_var('sort', 'string'); // ASC / DESC
+
+                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
+                       {
+                               $datatable['sorting']['order']                  
= 'id'; // name key Column in myColumnDef
+                               $datatable['sorting']['sort']                   
= 'desc'; // ASC / DESC
+                       }
+                       else
+                       {
+                               $datatable['sorting']['order']                  
= phpgw::get_var('order', 'string'); // name of column of Database
+                               $datatable['sorting']['sort']                   
= phpgw::get_var('sort', 'string'); // ASC / DESC
+                       }
+
+
+                       //-BEGIN----------------------------- JSON CODE 
------------------------------
+
+                       //values for Pagination
+                       $json = array
+                               (
+                                       'recordsReturned'       => 
$datatable['pagination']['records_returned'],
+                                       'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
+                                       'startIndex'            => 
$datatable['pagination']['records_start'],
+                                       'sort'                          => 
$datatable['sorting']['order'],
+                                       'dir'                           => 
$datatable['sorting']['sort'],
+                                       'records'                       => 
array()
+                               );
+
+                       // values for datatable
+                       if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row']))
+                       {
+                               foreach( $datatable['rows']['row'] as $row )
+                               {
+                                       $json_row = array();
+                                       foreach( $row['column'] as $column)
+                                       {
+                                               if(isset($column['format']) && 
$column['format']== "link" && $column['java_link']==true)
+                                               {
+                                                       
$json_row[$column['name']] = "<a href='#' id='".$column['link']."' 
onclick='javascript:filter_data(this.id);'>" .$column['value']."</a>";
+                                               }
+                                               else 
if(isset($column['format']) && $column['format']== "link")
+                                               {
+                                                       
$json_row[$column['name']] = "<a href='".$column['link']."' target='_blank'>" 
.$column['value']."</a>";
+                                               }
+                                               else
+                                               {
+                                                       
$json_row[$column['name']] = $column['value'];
+                                               }
+                                       }
+                                       $json['records'][] = $json_row;
+                               }
+                       }
+
+                       //---no exits depended filters
+                       $json['hidden']['dependent'][] = array ( );
+
+                       // checks right in datatable
+                       if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
+                       {
+                               $json ['rights'] = 
$datatable['rowactions']['action'];
+                       }
+
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       {
+                               return $json;
+                       }
+
+
+                       $datatable['json_data'] = json_encode($json);
+                       //-END------------------- JSON CODE 
----------------------
+
+                       // Prepare template variables and process XSLT
+                       $template_vars = array();
+                       $template_vars['datatable'] = $datatable;
+//                     
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
+//                     $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
+
+                       if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
+                       {
+                               $GLOBALS['phpgw']->css = 
createObject('phpgwapi.css');
+                       }
+
+
+                       $appname = lang('entity');
+
+                       phpgwapi_yui::load_widget('dragdrop');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('menu');
+                       phpgwapi_yui::load_widget('connection');
+                       //// cramirez: necesary for include a partucular js
+                       phpgwapi_yui::load_widget('loader');
+                       //cramirez: necesary for use opener . Avoid error JS
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('paginator');
+                       //FIXME this one is only needed when $lookup==true - so 
there is probably an error
+                       phpgwapi_yui::load_widget('animation');
+
+                       // Prepare CSS Style
+                       $GLOBALS['phpgw']->css->validate_file('datatable');
+                       $GLOBALS['phpgw']->css->validate_file('property');
+                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
+                       //Title of Page
+                       if($this->entity_id && $this->cat_id)
+                       {
+                               $entity    = 
$this->soadmin_entity->read_single($this->entity_id,false);
+                               $appname          = $entity['name'];
+                               $category        = 
$this->soadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+                               $function_msg = 'list ' . $category['name'];
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->type_app[$this->type]) . ' - ' . $appname . ': ' . $function_msg;
+                       }
+
+                       // Prepare YUI Library
+
+
+                       $GLOBALS['phpgw']->js->validate_file('yahoo', 
'entity.list' , 'frontend');
+
+                       $msglog = 
phpgwapi_cache::session_get('frontend','msgbox');
+                       phpgwapi_cache::session_clear('frontend','msgbox');
+                       
+                       $data = array(
+                               'header'                => $this->header_state,
+                               'tabs'                  => $this->tabs,
+                               'entity'                => array('datatable' => 
$datatable, 'msgbox_data' => 
$GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog))),
+                               'lightbox_name' => lang('add ticket')
+                       );
+
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 
'entity', 'datatable'));
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('app_data' => $data));
+               }
+
+
+
+               private function cmp($a, $b)
+               {
+                       $timea = explode('/', $a['date']);
+                       $timeb = explode('/', $b['date']);
+                       $year_and_maybe_time_a = explode(' - ', $timea[2]);
+                       $year_and_maybe_time_b = explode(' - ', $timeb[2]);
+                       $time_of_day_a = explode(':', 
$year_and_maybe_time_a[1]);
+                       $time_of_day_b = explode(':', 
$year_and_maybe_time_b[1]);
+
+                       $timestamp_a = mktime($time_of_day_a[0], 
$time_of_day_a[1], 0, $timea[1], $timea[0], $year_and_maybe_time_a[0]);
+                       $timestamp_b = mktime($time_of_day_b[0], 
$time_of_day_b[1], 0, $timeb[1], $timeb[0], $year_and_maybe_time_b[0]);
+
+                       if($timestamp_a < $timestamp_b)
+                       {
+                               return 1;
+                       }
+
+                       return -1;
+               }
+
+
+               public function view()
+               {
+                       $GLOBALS['phpgw']->translation->add_app('property');
+                       $bo     = CreateObject('property.botts');
+                       $entityid = phpgw::get_var('id');
+                       $entity = $bo->read_single($entityid);
+
+                       $assignedto = $entity['assignedto'];
+                       if(isset($assignedto) && $assignedto != '')
+                       {
+                               $assignedto_account = 
$GLOBALS['phpgw']->accounts->get($assignedto);
+                               //var_dump($assignedto_account);
+                               if($assignedto_account)
+                               {
+                                       $entity['assigned_to_name'] = 
$assignedto_account->__toString();
+                               }
+                       }
+                       
+                       $contact_id = $entity['contact_id'];
+                       if(isset($contact_id) && $contact_id != '')
+                       {
+                               $contacts                                       
                = CreateObject('phpgwapi.contacts');
+                               $contact_data                                   
        = $contacts->read_single_entry($contact_id, 
array('fn','tel_work','email'));
+                               $entity['value_contact_name']           = 
$contact_data[0]['fn'];
+                               $entity['value_contact_email']          = 
$contact_data[0]['email'];
+                               $entity['value_contact_tel']            = 
$contact_data[0]['tel_work'];
+                       }       
+                               
+                       $vendor_id = $entity['vendor_id'];
+                       if(isset($vendor_id) && $vendor_id != '')
+                       {
+                               $contacts       = 
CreateObject('property.sogeneric');
+                               $contacts->get_location_info('vendor',false);
+
+                               $custom                 = 
createObject('property.custom_fields');
+                               $vendor_data['attributes'] = 
$custom->find('property','.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
+
+                               $vendor_data    = 
$contacts->read_single(array('id' => $vendor_id),$vendor_data);
+
+                               if(is_array($vendor_data))
+                               {
+                                       foreach($vendor_data['attributes'] as 
$attribute)
+                                       {
+                                               
if($attribute['name']=='org_name')
+                                               {
+                                                       
$entity['value_vendor_name']=$attribute['value'];
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+
+                       $notes = $bo->read_additional_notes($entityid);
+                       //$history = $bo->read_record_history($entityid);
+
+                       $entityhistory = array();
+
+                       foreach($notes as $note)
+                       {
+                               if($note['value_publish'])
+                               {
+                                       $entityhistory[] = array(
+                                               'date' => $note['value_date'],
+                                               'user' => $note['value_user'],
+                                               'note' => $note['value_note']
+                                       );
+                               }
+                       }
+
+
+                       usort($entityhistory, array($this, "cmp"));
+
+
+                       $i=0;
+                       foreach($entityhistory as $foo)
+                       {
+                               $entityhistory2['record'.$i] = $foo;
+                               $i++;
+                       }
+
+                       $msglog = 
phpgwapi_cache::session_get('frontend','msgbox');
+                       phpgwapi_cache::session_clear('frontend','msgbox');
+                       
+                       $data = array(
+                               'header'                => $this->header_state,
+                               'msgbox_data'   => isset($msglog) ? 
$GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog))
 : array(),
+                               'tabs'                  => $this->tabs,
+                               'entityinfo'    => array(
+                                       'entitylist'    => 
$GLOBALS['phpgw']->link('/index.php',
+                                                                       array
+                                                                       (
+                                                                               
'menuaction'            => 'frontend.uientity.index',
+                                                                               
'location_id'           => $this->location_id
+                                                                       )),
+
+                                       'entity'        => $entity,
+                                       'entityhistory' => $entityhistory2)
+                       );
+
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('frontend', 
'entityview'));
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('app_data' => $data));
+               }
+
+
+               public function add_ticket()
+               {
+                       $bo     = CreateObject('property.botts',true);
+                       $boloc  = CreateObject('property.bolocation',true);
+
+                       $location_details = 
$boloc->read_single($this->location_code, array('noattrib' => true));
+
+                       $values         = phpgw::get_var('values');
+                       $missingfields  = false;
+                       $msglog         = array();
+
+                       // Read default assign-to-group from config
+                       $config = CreateObject('phpgwapi.config', 'frontend');
+                       $config->read();
+                       $default_cat = $config->config_data['tts_default_cat'] 
? $config->config_data['tts_default_cat'] : 0;
+                                       
+                       if(!$default_cat)
+                       {
+                               throw new Exception('Default category is not 
set in config');
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
+
+                       if(isset($values['save']))
+                       {
+                               foreach($values as $key => $value)
+                               {
+                                       if(empty($value) && $key !== 'file')
+                                       {
+                                               $missingfields = true;
+                                       }
+                               }
+
+                               if(!$missingfields && !phpgw::get_var('added'))
+                               {
+                                       $location  = array
+                                       (
+                                               'loc1'  => 
$location_details['loc1'],
+                                               'loc2'  => 
$location_details['loc2']
+                                       );
+
+                                       $assignedto = 
execMethod('property.boresponsible.get_responsible', array('location' => 
$location, 'cat_id' => $default_cat));
+
+                                       if(!$assignedto)
+                                       {
+                                               $default_group = 
$config->config_data['tts_default_group'];
+                                       }
+                                       else
+                                       {
+                                               $default_group = 0;
+                                       }
+
+                                       $ticket = array(
+                                               'origin'    => null,
+                                               'origin_id' => null,
+                                               'cat_id'    => 
$values['cat_id'],
+                                               'group_id'  => ($default_group 
? $default_group : null),
+                                               'assignedto'=> $assignedto,
+                                               'priority'  => 3,
+                                               'status'    => 'O', // O = Open
+                                               'subject'   => $values['title'],
+                                               'details'   => 
$values['locationdesc'].":\n\n".$values['description'],
+                                               'apply'     => lang('Apply'),
+                                               'contact_id'=> 0,
+                                               'location'  => $location,
+                                               'street_name'   => 
$location_details['street_name'],
+                                               'street_number' => 
$location_details['street_number'],
+                                               'location_name' => 
$location_details['loc1_name'],
+                                               //'locationdesc'  => 
$values['locationdesc']
+                                       );
+
+                                       $result = $bo->add($ticket);
+                                       if($result['message'][0]['msg'] != null 
&& $result['id'] > 0)
+                                       {
+                                               $msglog['message'][] = 
array('msg' => lang('Ticket added'));
+                                               $noform = true;
+
+
+                                               // Files
+                                               $values['file_name'] = 
@str_replace(' ','_',$_FILES['file']['name']);
+                                               if($values['file_name'] && 
$msglog['id'])
+                                               {
+                                                       $bofiles = 
CreateObject('property.bofiles');
+                                                       $to_file = 
$bofiles->fakebase . '/fmticket/' . $msglog['id'] . '/' . $values['file_name'];
+
+                                                       
if($bofiles->vfs->file_exists(array(
+                                                               'string' => 
$to_file,
+                                                               'relatives' => 
array(RELATIVE_NONE)
+                                                       )))
+                                                       {
+                                                               
$msglog['error'][] = array('msg'=>lang('This file already exists !'));
+                                                       }
+                                                       else
+                                                       {
+                                                               
$bofiles->create_document_dir("fmticket/{$result['id']}");
+                                                               
$bofiles->vfs->override_acl = 1;
+
+                                                               
if(!$bofiles->vfs->cp(array (
+                                                               'from'  => 
$_FILES['file']['tmp_name'],
+                                                               'to'    => 
$to_file,
+                                                               'relatives'     
=> array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+                                                               {
+                                                                       
$msglog['error'][] = array('msg' => lang('Failed to upload file!'));
+                                                               }
+                                                               
$bofiles->vfs->override_acl = 0;
+                                                       }
+                                               }
+
+                                               $redirect = true;
+                                               
phpgwapi_cache::session_set('frontend', 'msgbox', $msglog);
+                                               // /Files
+                                       }
+                               }
+                               else
+                               {
+                                       $msglog['error'][] = 
array('msg'=>lang('Missing field(s)'));
+                               }
+                       }
+
+
+                       $tts_frontend_cat_selected = 
$config->config_data['tts_frontend_cat'] ? 
$config->config_data['tts_frontend_cat'] : array();
+
+                       $cats   = CreateObject('phpgwapi.categories', -1, 
'property', '.ticket');
+                       $cats->supress_info = true;
+                       $categories = $cats->return_sorted_array(0, false, '', 
'', '', true, '', false);
+
+                       $category_list = array();
+                       foreach ( $categories as $category)
+                       {
+                               if ( in_array($category['id'], 
$tts_frontend_cat_selected))
+                               {
+                                       $category_list[] = array
+                                       (
+                                               'id'            => 
$category['id'],
+                                               'name'          => 
$category['name'],
+                                               'selected'      => 
$category['id'] == $default_cat ? 1 : 0
+                                       ); 
+                               }
+                       }
+
+                       $data = array(
+                               'redirect'                      => 
isset($redirect) ? $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'frontend.uientity.index')) : null,
+                               'msgbox_data'           => 
$GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($msglog)),
+                               'form_action'           => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction' => 
'frontend.uientity.add_ticket', 'noframework' => '1')),
+                               'title'                 => $values['title'],
+                               'locationdesc'          => 
$values['locationdesc'],
+                               'description'           => 
$values['description'],
+                               'noform'                => $noform,
+                               'category_list'         => $category_list
+                       );
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('frontend','helpdesk'));
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('add_ticket' => $data));
+               }
+
+       }

Modified: branches/Version-1_0-branch/frontend/inc/class.uifrontend.inc.php
===================================================================
--- branches/Version-1_0-branch/frontend/inc/class.uifrontend.inc.php   
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/frontend/inc/class.uifrontend.inc.php   
2011-06-20 06:30:25 UTC (rev 7401)
@@ -54,10 +54,10 @@
                        // 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'];
+                       $this->config   = 
CreateObject('phpgwapi.config','frontend');
+                       $this->config->read();
+                       $use_fellesdata = 
$this->config->config_data['use_fellesdata'];
+                       $logo_path = $this->config->config_data['logo_path'];
 
                        // Get the mode: in frame or full screen
                        $mode = phpgwapi_cache::session_get('frontend', 
'noframework');
@@ -281,8 +281,33 @@
                                                'link'  => 
$GLOBALS['phpgw']->link('/',array('menuaction' => "frontend.ui{$name}.index", 
'type'=>$location_id, 'noframework' => $noframework))
                                        );
                                }
+                               unset($location);
                        }
                        
+
+                       // this one is for generic entitysupport from the app 
'property'
+                       $entity_frontend = 
isset($this->config->config_data['entity_frontend']) && 
$this->config->config_data['entity_frontend'] ? 
$this->config->config_data['entity_frontend'] : array();
+
+                       if($entity_frontend)
+                       {
+                               $entity                 = 
CreateObject('property.soadmin_entity');
+                       }
+
+                       foreach ($entity_frontend as $location)
+                       {
+                               if ( $GLOBALS['phpgw']->acl->check($location, 
PHPGW_ACL_READ, 'property') )
+                               {
+                                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', $location);
+                                       $location_arr = explode('.', $location);
+                                       
+                                       $category = 
$entity->read_single_category($location_arr[2], $location_arr[3]);
+                                       $tabs[$location_id] = array(
+                                               'label' => $category['name'],
+                                               'link'  => 
$GLOBALS['phpgw']->link('/',array('menuaction' => "frontend.uientity.index", 
'location_id' => $location_id, 'noframework' => $noframework))
+                                       );
+                               }
+                       }
+
                        $extra_tabs = phpgwapi_cache::session_get('frontend', 
'extra_tabs');
                        
                        if(isset($extra_tabs))
@@ -446,9 +471,7 @@
                        $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
 
-                       $config = CreateObject('phpgwapi.config','frontend');
-                       $config->read();
-                       $doc_type = 
$config->config_data['picture_building_cat'] ? 
$config->config_data['picture_building_cat'] : 'profilbilder';
+                       $doc_type = 
$this->config->config_data['picture_building_cat'] ? 
$this->config->config_data['picture_building_cat'] : 'profilbilder';
 
                        // Get object id from params or use 'dummy'
                        $location_code = phpgw::get_var('loc_code') ? 
phpgw::get_var('loc_code') : 'dummy';

Modified: branches/Version-1_0-branch/frontend/inc/hook_config.inc.php
===================================================================
--- branches/Version-1_0-branch/frontend/inc/hook_config.inc.php        
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/frontend/inc/hook_config.inc.php        
2011-06-20 06:30:25 UTC (rev 7401)
@@ -218,3 +218,37 @@
                }
                return $out;
        }
+       /**
+       * Get HTML checkbox with categories that are candidates for frontend 
documents cat
+       *
+       * @param $config
+       * @return string options for selectbox
+       */
+       function entity_frontend($config)
+       {
+               $entity                 = 
CreateObject('property.soadmin_entity');
+               $entity_list    = $entity->read(array('allrows' => true));
+               $entity_frontend_selected = isset($config['entity_frontend']) ? 
$config['entity_frontend'] : array();
+               $out = '';
+               foreach($entity_list as $entry)
+               {
+                       $out .=  <<<HTML
+                               <tr><td><input type="checkbox" disabled 
="disabled" name="entity_{$entry['id']}" value="entity_{$entry['id']}" 
{$checked}><label><b>{$entry['name']}</b></label></td></tr>
+HTML;
+                       $categories = 
$entity->read_category_tree2($entry['id']);
+                       
+                       foreach ($categories as $category)
+                       {
+                               $checked = '';
+                               if ( 
in_array(".entity.{$entry['id']}.{$category['id']}", $entity_frontend_selected))
+                               {
+                                       $checked = ' checked';
+                               }
+
+                               $out .=  <<<HTML
+                                       <tr><td><input type="checkbox" 
name="newsettings[entity_frontend][]" 
value=".entity.{$entry['id']}.{$category['id']}" 
{$checked}><label>{$category['name']}</label></td></tr>
+HTML;
+                       }
+               }
+               return $out;
+       }

Copied: branches/Version-1_0-branch/frontend/js/yahoo/entity.list.js (from rev 
7400, trunk/frontend/js/yahoo/entity.list.js)
===================================================================
--- branches/Version-1_0-branch/frontend/js/yahoo/entity.list.js                
                (rev 0)
+++ branches/Version-1_0-branch/frontend/js/yahoo/entity.list.js        
2011-06-20 06:30:25 UTC (rev 7401)
@@ -0,0 +1,142 @@
+//--------------------------------------------------------
+// Declaration of location.index vars
+//--------------------------------------------------------
+       //define SelectButton
+/*
+       var oMenuButton_0, oMenuButton_1, oMenuButton_2, oMenuButton_3, 
oMenuButton_4;
+       var selectsButtons = [
+       {order:0, var_URL:'cat_id',             name:'btn_cat_id',              
style:'categorybutton', dependiente:''},
+       {order:1, var_URL:'district_id',name:'btn_district_id', 
style:'districtbutton', dependiente:''},
+       {order:2, var_URL:'status',             name:'btn_status_id',   
style:'statusbutton',   dependiente:''},
+       {order:3, var_URL:'filter',             name:'btn_user_id',             
style:'userIdbutton',   dependiente:''},
+       {order:4, var_URL:'criteria_id', 
name:'btn_criteria_id',style:'criteriabutton',dependiente:''}
+       ]
+*/
+       // define buttons
+       var oNormalButton_0, oNormalButton_1, oNormalButton_2;
+       var normalButtons = [
+       {order:0, name:'btn_search',funct:"onSearchClick"},
+       {order:1, name:'btn_new',       funct:"onNewClick"},
+       {order:2, name:'btn_export',funct:"onDownloadClick"}
+       ]
+
+    var toolTips = [
+    {name:'btn_export', title:'download', description:'Download table to your 
browser',ColumnDescription:''}
+    ]
+
+       // define Text buttons
+       var textImput = [
+       {order:0, name:'query', id:'txt_query'}
+       ]
+
+       // define the hidden column in datatable
+       var config_values = {
+       date_search : 1 //if search has link "Data search"
+       }
+
+       var linktoolTips =[
+       {name:'btn_columns', title:'columns', description:'Choose columns'},
+       {name:'btn_data_search', title:'Data search', description:'Narrow the 
search by dates'}
+       ]
+
+
+/****************************************************************************************/
+       this.particular_setting = function()
+       {
+               if(flag_particular_setting=='init')
+               {
+                       //category
+/*
+                       index = 
locate_in_array_options(0,"value",path_values.cat_id);
+                       if(index)
+                       {
+                               oMenuButton_0.set("label", ("<em>" + 
array_options[0][index][1] + "</em>"));
+                       }
+*/
+                       //district
+                       index = 
locate_in_array_options(1,"value",path_values.district_id);
+                       if(index)
+                       {
+                               oMenuButton_1.set("label", ("<em>" + 
array_options[1][index][1] + "</em>"));
+                       }
+
+                       //status
+                       index = 
locate_in_array_options(2,"value",path_values.status);
+                       if(index)
+                       {
+                               oMenuButton_2.set("label", ("<em>" + 
array_options[2][index][1] + "</em>"));
+                       }
+
+                       //filter
+                       index = 
locate_in_array_options(3,"value",path_values.filter);
+                       if(index)
+                       {
+                               oMenuButton_3.set("label", ("<em>" + 
array_options[3][index][1] + "</em>"));
+                       }
+
+                       //district
+                       index = 
locate_in_array_options(4,"value",path_values.criteria_id);
+                       if(index)
+                       {
+                               oMenuButton_4.set("label", ("<em>" + 
array_options[4][index][1] + "</em>"));
+                       }
+
+                       //eliminate "no category" option because is necesary 
have a category in the  PHP query
+       //              delete oMenuButton_0.getMenu().itemData[0];
+                       //correcting it. now look for value 
+       //              index = 
locate_in_array_options(0,"value",path_values.cat_id);
+                       //only change LABEL, because value (cat_id) is include 
un URL (PHP use redirect)
+       //              oMenuButton_0.set("label", ("<em>" + 
array_options[0][index][1] + "</em>"));
+       //              oMenuButton_0.focus();
+                       YAHOO.util.Dom.get(textImput[0].id).focus();
+               }
+               else if(flag_particular_setting=='update')
+               {
+                       //nothing
+               }
+
+       }
+
+
+       this.showlightbox = function(sUrl)
+       {
+               var onDialogShow = function(e, args, o)
+               {
+                       var frame = document.createElement('iframe');
+                       frame.src = sUrl;
+                       frame.width = "100%";
+                       frame.height = "460";
+                       o.setBody(frame);
+               };
+               lightbox.showEvent.subscribe(onDialogShow, lightbox);
+               lightbox.show();
+       }
+
+
+/****************************************************************************************/
+
+       this.myParticularRenderEvent = function()
+       {
+       //don't delete it
+       }
+
+/****************************************************************************************/
+       YAHOO.util.Event.addListener(window, "load", function()
+       {
+               //avoid render buttons html
+       YAHOO.util.Dom.getElementsByClassName('toolbar','div')[0].style.display 
= 'none';
+               var loader = new YAHOO.util.YUILoader();
+               loader.addModule({
+                       name: "anyone", //module name; must be unique
+                       type: "js", //can be "js" or "css"
+                   fullpath: property_js //'property_js' have the path for 
property.js, is render in HTML
+                   });
+
+               loader.require("anyone");
+
+               //Insert JSON utility on the page
+
+           loader.insert();
+
+
+       });

Modified: branches/Version-1_0-branch/frontend/templates/base/config.tpl
===================================================================
--- branches/Version-1_0-branch/frontend/templates/base/config.tpl      
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/frontend/templates/base/config.tpl      
2011-06-20 06:30:25 UTC (rev 7401)
@@ -82,6 +82,16 @@
                        </td>
                </tr>
                <tr class="row_on">
+                       <td>{lang_entity_frontend}:</td>
+                       <td>
+               <!--to be able to blank the setting - need an empty value-->
+               <input type = 'hidden' name="newsettings[entity_frontend][]" 
value="">
+                    <table>
+{hook_entity_frontend}
+                        </table>
+                       </td>
+               </tr>
+               <tr class="row_on">
                        <td>{lang_document_valid_types}(comma separated list of 
valid filetypes):</td>
                        <td><input name="newsettings[document_valid_types]" 
value="{value_document_valid_types}"></td>
                </tr>

Copied: branches/Version-1_0-branch/frontend/templates/base/entity.xsl (from 
rev 7400, trunk/frontend/templates/base/entity.xsl)
===================================================================
--- branches/Version-1_0-branch/frontend/templates/base/entity.xsl              
                (rev 0)
+++ branches/Version-1_0-branch/frontend/templates/base/entity.xsl      
2011-06-20 06:30:25 UTC (rev 7401)
@@ -0,0 +1,143 @@
+<!-- $Id: helpdesk.xsl 6663 2010-12-09 10:45:28Z sigurdne $ -->
+<xsl:template match="entity" xmlns:php="http://php.net/xsl";>
+    <xsl:variable name="form_action"><xsl:value-of 
select="form_action"/></xsl:variable>
+    <div class="yui-navset" id="ticket_tabview">
+        <xsl:value-of disable-output-escaping="yes" select="tabs" />
+        <div class="yui-content">
+               <xsl:choose>
+                               <xsl:when 
test="normalize-space(//header/selected_location) != ''">
+                                       <div class="toolbar-container">
+                               <div class="toolbar">
+                                   <xsl:apply-templates 
select="datatable/actions" />  
+                               </div>
+                           </div>
+                           <div class="tickets">
+                               <table cellpadding="2" cellspacing="2" 
width="95%" align="center">
+                                               <xsl:choose>
+                                                   <xsl:when test="msgbox_data 
!= ''">
+                                                       <tr>
+                                                           <td align="left" 
colspan="3">
+                                                               
<xsl:call-template name="msgbox"/>
+                                                           </td>
+                                                       </tr>
+                                                   </xsl:when>
+                                               </xsl:choose>
+                                           </table>
+                               <xsl:apply-templates select="datatable" />
+                           </div>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <div class="tickets">
+                               <xsl:value-of select="php:function('lang', 
'no_buildings')"/>
+                           </div>
+                               </xsl:otherwise>
+                       </xsl:choose>
+            
+        </div>
+    </div>
+
+</xsl:template>
+
+<xsl:template match="lightbox_name" xmlns:php="http://php.net/xsl";>
+</xsl:template>
+
+<xsl:template match="add_ticket" xmlns:php="http://php.net/xsl";>
+       <xsl:choose>
+        <xsl:when test="normalize-space(redirect) != ''">
+            <script>
+               window.parent.location = '<xsl:value-of select="redirect"/>';
+               window.close();
+            </script>
+        </xsl:when>
+    </xsl:choose>
+    <h2>Ny skademelding</h2>
+    <form ENCTYPE="multipart/form-data" name="form" method="post" 
action="{form_action}">
+        <table cellpadding="0" cellspacing="0" width="100%">
+            <xsl:choose>
+                <xsl:when test="msgbox_data != ''">
+                    <tr>
+                        <td align="left" colspan="2">
+                            <xsl:call-template name="msgbox"/>
+                        </td>
+                    </tr>
+                </xsl:when>
+            </xsl:choose>
+
+
+            <xsl:if test="noform != 1">
+                <tr>
+                    <td class="th_text" valign="top">
+                        <xsl:value-of select="php:function('lang', 
'category')" />
+                    </td>
+                    <td class="th_text" valign="top">
+                                               <select name="values[cat_id]" >
+                                                       <xsl:attribute 
name="title">
+                                                               <xsl:value-of 
select="php:function('lang', 'category')" />
+                                                       </xsl:attribute>
+                                                       <xsl:apply-templates 
select="category_list"/>
+                                               </select>                       
+                    </td>
+                </tr>
+                <tr>
+                    <td class="th_text" valign="top">
+                        <xsl:value-of select="php:function('lang', 'subject')" 
/>
+                    </td>
+                    <td class="th_text" valign="top">
+                        <input type="text" name="values[title]" 
value="{title}"/>
+                    </td>
+                </tr>
+
+                <tr>
+                    <td class="th_text" valign="top">
+                        <xsl:value-of select="php:function('lang', 
'locationdesc')" />
+                    </td>
+                    <td class="th_text" valign="top">
+                        <input type="text" name="values[locationdesc]" 
value="{locationdesc}"/>
+                    </td>
+                </tr>
+
+                <tr>
+                    <td valign="top">
+                        <xsl:value-of select="php:function('lang', 
'description')" />
+                    </td>
+                    <td>
+                        <textarea cols="60" rows="10" 
name="values[description]" wrap="virtual" onMouseout="window.status='';return 
true;">
+                            <xsl:value-of select="description"/>
+                        </textarea>
+                    </td>
+                </tr>
+
+                <tr>
+                    <td valign="top">
+                        <xsl:value-of select="php:function('lang', 'file')" />
+                    </td>
+                    <td>
+                        <input type="file" name="file" size="50">
+                            <xsl:attribute name="title">
+                                <xsl:value-of select="php:function('lang', 
'file')" />
+                            </xsl:attribute>
+                        </input>
+                    </td>
+                </tr>
+
+                <tr height="50">
+                    <td>
+                        <xsl:variable name="lang_send"><xsl:value-of 
select="php:function('lang', 'send')" /></xsl:variable>
+                        <input type="submit" name="values[save]" 
value="{$lang_send}" title='{$lang_send}'/>
+                    </td>
+                </tr>
+            </xsl:if>
+        </table>
+    </form>
+</xsl:template>
+
+<xsl:template match="category_list">
+       <option value="{id}">
+               <xsl:if test="selected != 0">
+                       <xsl:attribute name="selected" value="selected" />
+               </xsl:if>
+               <xsl:value-of disable-output-escaping="yes" select="name"/>
+       </option>
+</xsl:template>
+
+

Copied: branches/Version-1_0-branch/frontend/templates/base/entityview.xsl 
(from rev 7400, trunk/frontend/templates/base/entityview.xsl)
===================================================================
--- branches/Version-1_0-branch/frontend/templates/base/entityview.xsl          
                (rev 0)
+++ branches/Version-1_0-branch/frontend/templates/base/entityview.xsl  
2011-06-20 06:30:25 UTC (rev 7401)
@@ -0,0 +1,84 @@
+<xsl:template match="entityinfo" xmlns:php="http://php.net/xsl";>
+       
+    <table cellpadding="2" cellspacing="2" width="95%" align="center">
+        <xsl:choose>
+            <xsl:when test="msgbox_data != ''">
+                <tr>
+                    <td align="left" colspan="3">
+                        <xsl:call-template name="msgbox"/>
+                    </td>
+                </tr>
+            </xsl:when>
+        </xsl:choose>
+    </table>
+
+    <div class="yui-navset" id="entity_tabview">
+        <div class="yui-content">
+               <div id="entityinfo">
+                       <ul style="margin: 2em;">
+                               <li style="margin-bottom: 1em;">
+                                       <a href="{entitylist}"> &lt;&lt; 
<xsl:value-of select="php:function('lang', 'show_all_entities')"/></a>
+                               </li>
+                               <li>
+                                       <ul>
+                                               <li style="margin-bottom: 5px;">
+                                                       <img 
src="frontend/templates/base/images/16x16/comment.png" class="list_image"/> 
<strong><xsl:value-of select="entity/subject"/></strong>
+                                               </li>
+                                               <li class="entity_detail">
+                                                       <img 
src="frontend/templates/base/images/16x16/clock_edit.png" class="list_image"/> 
<xsl:value-of select="php:function('lang', 'entry_date')"/> <xsl:value-of 
select="entity/entry_date"/><xsl:value-of select="php:function('lang', 
'of')"/><xsl:value-of select="entity/user_name"/>
+                                               </li>
+                                               <li class="entity_detail">
+                                                       <img 
src="frontend/templates/base/images/16x16/timeline_marker.png" 
class="list_image"/> <xsl:value-of select="php:function('lang', 'status')"/>: 
<xsl:value-of select="entity/status_name"/>
+                                               </li>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="entity/value_vendor_name">
+                                                               <li 
class="entity_detail">
+                                                                       <img 
src="frontend/templates/base/images/16x16/user_suit.png" class="list_image"/> 
<xsl:value-of select="php:function('lang', 'vendor')"/>: <xsl:value-of 
select="entity/value_vendor_name"/>
+                                                               </li>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="entity/assigned_to_name">
+                                                               <li 
class="entity_detail">
+                                                                       <img 
src="frontend/templates/base/images/16x16/user_red.png" class="list_image"/> 
<xsl:value-of select="php:function('lang', 'assigned_to')"/>: <xsl:value-of 
select="entity/assigned_to_name"/>
+                                                               </li>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="entity/value_contact_name">
+                                                               <li 
class="entity_detail">
+                                                                       <img 
src="frontend/templates/base/images/16x16/user_green.png" class="list_image"/> 
<xsl:value-of select="php:function('lang', 'contact')"/>: <xsl:value-of 
select="entity/value_contact_name"/>
+                                                                       
Telefon: <xsl:value-of select="entity/value_contact_tel"/> 
+                                                                       E-post: 
<xsl:value-of select="entity/value_contact_email"/>
+                                                               </li>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="entity/publish_note = 1">
+                                                               <li 
class="entity_detail">
+                                                                       <img 
src="frontend/templates/base/images/16x16/page_white_edit.png" 
class="list_image"/><xsl:value-of select="php:function('lang', 'message')"/>: 
<xsl:value-of select="entity/details"/>
+                                                               </li>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                               <li class="entity_detail">
+                                                       <img 
src="frontend/templates/base/images/16x16/comments.png" class="list_image"/> 
<xsl:value-of select="php:function('lang', 'comments')"/>:<br/>
+                                                       <hr/>
+                                                       <ul>
+                                                               <xsl:for-each 
select="entityhistory/*[starts-with(name(), 'record')]">
+                                                               <li  
class="entity_detail">
+                                                                       <img 
src="frontend/templates/base/images/16x16/page_white_edit.png" 
class="list_image"/> <xsl:value-of select="date"/> - 
+                                                                       <img 
src="frontend/templates/base/images/16x16/user_gray.png" class="list_image"/> 
<xsl:value-of select="user"/><br/>
+                                                                       <p 
style="padding: 10px;"><xsl:value-of select="note"/></p>
+                                                               </li>
+                                                           </xsl:for-each>
+                                               </ul>
+                                               </li>
+                                       </ul>
+                               </li>
+                       </ul>
+               </div>
+        </div>
+    </div>
+</xsl:template>
+
+

Modified: branches/Version-1_0-branch/property/inc/class.menu.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.menu.inc.php 2011-06-19 
17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/inc/class.menu.inc.php 2011-06-20 
06:30:25 UTC (rev 7401)
@@ -559,12 +559,19 @@
                                        }
                                }
 
-                               $children['tenant'] = array
+                               $config = 
CreateObject('phpgwapi.config','property');
+                               $config->read();
+                               
+                               
if(!isset($config->config_data['suppress_tenant']) || 
!$config->config_data['suppress_tenant'])
+                               {
+                                       $children['tenant'] = array
                                        (
                                                'url'   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uilocation.index', 'lookup_tenant' => 1, 'type_id' => 
$soadmin_location->read_config_single('tenant_id'))),
                                                'text'  => lang('Tenant'),
                                                'image' => array('property', 
'location_tenant')
                                        );
+                               }
+                               
                                $children['gabnr'] = array
                                        (
                                                'url'   =>      
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uigab.index')),

Modified: branches/Version-1_0-branch/property/inc/class.soentity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2011-06-20 06:30:25 UTC (rev 7401)
@@ -342,9 +342,10 @@
                        $where= 'WHERE';
                        $filtermethod = '';
 
-                       $GLOBALS['phpgw']->config->read();
-                       
if(isset($GLOBALS['phpgw']->config->config_data['acl_at_location'])
-                               && 
$GLOBALS['phpgw']->config->config_data['acl_at_location']
+                       $_config        = 
CreateObject('phpgwapi.config','property');
+                       $_config->read();
+                       if(isset($_config->config_data['acl_at_location'])
+                               && $_config->config_data['acl_at_location']
                                && $category['location_level'] > 0)
                        {
                                $access_location = 
$this->bocommon->get_location_list(PHPGW_ACL_READ);
@@ -352,6 +353,8 @@
                                $where= 'AND';
                        }
 
+                       unset($_config);
+
                        if ($filter=='all')
                        {
                                if (is_array($grants))
@@ -595,8 +598,8 @@
 
                function read_single($data,$values = array())
                {
-                       $entity_id      = (int)$data['entity_id'];
-                       $cat_id         = (int)$data['cat_id'];
+                       $entity_id      = isset($data['entity_id']) && 
$data['entity_id'] ? (int)$data['entity_id'] : $this->entity_id;
+                       $cat_id         = isset($data['cat_id']) && 
$data['cat_id'] ? (int)$data['cat_id'] : $this->cat_id;
                        $id                     = (int)$data['id'];
                        $num            = isset($data['num']) && $data['num'] ? 
$data['num'] : '';
                        $table = "fm_{$this->type}_{$entity_id}_{$cat_id}";

Modified: branches/Version-1_0-branch/property/inc/class.uientity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uientity.inc.php     
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/inc/class.uientity.inc.php     
2011-06-20 06:30:25 UTC (rev 7401)
@@ -332,14 +332,19 @@
                function index()
                {
                        //redirect. If selected the title of module.
-                       if($this->entity_id == 1 && !$this->cat_id)
+                       if($this->entity_id && !$this->cat_id)
                        {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uientity.index', 'entity_id'=>1, 'cat_id'=> 1, 'type' => 
$this->type));
+                               $categories = 
$this->soadmin_entity->read_category(array('entity_id' => $this->entity_id));
+                               foreach($categories as $category)
+                               {
+                                       
if($this->acl->check(".{$this->type}.$this->entity_id.{$category['id']}", 
PHPGW_ACL_READ, $this->type_app[$this->type]))
+                                       {
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uientity.index', 'entity_id'=>$this->entity_id, 'cat_id'=> 
$category['id'], 'type' => $this->type));
+                                       }
+                               }
+                               unset($categories);
+                               unset($category);
                        }
-                       elseif($this->entity_id == 2 && !$this->cat_id)
-                       {
-                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uientity.index', 'entity_id'=>2, 'cat_id'=> 1, 'type' => 
$this->type));
-                       }
 
                        //redirect if no rights
                        if(!$this->acl_read && $this->cat_id)
@@ -945,6 +950,7 @@
                                        
$datatable['headers']['header'][$i]['visible']                  = true;
                                        
$datatable['headers']['header'][$i]['format']                   = 
$this->bocommon->translate_datatype_format($uicols['datatype'][$i]);
                                        
$datatable['headers']['header'][$i]['sortable']                 = 
$uicols['sortable'][$i];;
+                                       
$datatable['headers']['header'][$i]['sort_field']               = 
$uicols['name'][$i];
                                        
//$datatable['headers']['header'][$i]['formatter']              = 
$uicols['formatter'][$i];
                                        //according to stable bruch this 
columns is not SORTABLE'
                                        $denied = array('merknad');//$denied = 
array('merknad','account_lid');
@@ -952,12 +958,10 @@
                                        if(in_array ($uicols['name'][$i], 
$denied))
                                        {
                                                
$datatable['headers']['header'][$i]['sortable']         = false;
-                                               
$datatable['headers']['header'][$i]['sort_field']       = $uicols['name'][$i];
                                        }
                                        else 
if(isset($uicols['cols_return_extra'][$i]) && 
($uicols['cols_return_extra'][$i]!='T' || 
$uicols['cols_return_extra'][$i]!='CH'))
                                        {
                                                
$datatable['headers']['header'][$i]['sortable']         = true;
-                                               
$datatable['headers']['header'][$i]['sort_field']       = $uicols['name'][$i];
                                        }
 
                                }
@@ -966,7 +970,7 @@
                                        
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
                                        
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
                                        
$datatable['headers']['header'][$i]['visible']                  = false;
-                                       
$datatable['headers']['header'][$i]['sortable']          = false;
+                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
                                        
$datatable['headers']['header'][$i]['format']                   = 'hidden';
                                }
                        }
@@ -1476,7 +1480,10 @@
                        {
                                $_no_link = 
(int)$category['location_link_level'] + 2;
                        }
-                       if($entity['location_form'] )
+
+                       $location_data = array();
+
+                       if($entity['location_form'] && 
$category['location_level'] > 0)
                        {
                                
$location_data=$bolocation->initiate_ui_location(array
                                        (
@@ -1615,10 +1622,11 @@
                                $location = 
".{$this->type}.{$this->entity_id}.{$this->cat_id}";
                                $attributes_groups = 
$this->bo->get_attribute_groups($location, $values['attributes']);
 
+                               $attributes_general = array();
                                $attributes = array();
                                foreach ($attributes_groups as $group)
                                {
-                                       if(isset($group['attributes']))
+                                       if(isset($group['attributes']) && 
(isset($group['group_sort']) || !$location_data))
                                        {
                                                $_tab_name = str_replace(' ', 
'_', $group['name']);
                                                $active_tab = $active_tab ? 
$active_tab : $_tab_name;
@@ -1627,6 +1635,10 @@
                                                $attributes[] = $group;
                                                unset($_tab_name);
                                        }
+                                       else if(isset($group['attributes']) && 
!isset($group['group_sort']) && $location_data)
+                                       {
+                                               $attributes_general = 
array_merge($attributes_general,$group['attributes']);
+                                       }
                                }
                                unset($attributes_groups);
 
@@ -1961,6 +1973,7 @@
                                        'category_name'                         
        => $category['name'],
                                        'msgbox_data'                           
        => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                        'attributes_group'                      
        => $attributes,
+                                       'attributes_general'                    
=> array('attributes' => $attributes_general),
                                        'lookup_functions'                      
        => isset($values['lookup_functions'])?$values['lookup_functions']:'',
                                        'lang_none'                             
                => lang('None'),
                                        'location_data'                         
        => $location_data,

Modified: branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiimport.inc.php     
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/inc/class.uiimport.inc.php     
2011-06-20 06:30:25 UTC (rev 7401)
@@ -32,6 +32,7 @@
                {
                        set_time_limit(10000); //Set the time limit for this 
request oto 3000 seconds
                        $this->account          = 
(int)$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->db           = & $GLOBALS['phpgw']->db;
                }
                
 
@@ -225,8 +226,7 @@
                        $this->messages[] = "Read 'import_all.csv' file in " . 
(time() - $start_time) . " seconds";
                        $this->messages[] = "'importfile.csv' contained " . 
count($datalines) . " lines";
                        
-                       $this->db           = & $GLOBALS['phpgw']->db;
-       
+
                        $ok = true;
                        $_ok = false;
                        $this->db->transaction_begin();

Modified: branches/Version-1_0-branch/property/inc/class.uilocation.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uilocation.inc.php   
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/inc/class.uilocation.inc.php   
2011-06-20 06:30:25 UTC (rev 7401)
@@ -2006,6 +2006,9 @@
 
                        //_debug_array($attributes_values);
 
+                       $_config                = 
CreateObject('phpgwapi.config','property');
+                       $_config->read();
+
                        $insert_record['extra'][]                               
                = 'cat_id';
 
                        $config_count=count($config);
@@ -2023,8 +2026,11 @@
 
                                        
if($config[$j]['column_name']=='tenant_id')
                                        {
-                                               $edit_tenant=true;
-                                               $insert_record['extra'][]       
= 'tenant_id';
+                                               
if(!isset($_config->config_data['suppress_tenant']) || 
!$_config->config_data['suppress_tenant'])
+                                               {
+                                                       $edit_tenant=true;
+                                                       
$insert_record['extra'][]       = 'tenant_id';
+                                               }
                                        }
 
                                        
if($config[$j]['column_name']=='part_of_town_id')
@@ -2127,17 +2133,23 @@
 
                                $location = ".location.{$type_id}";
                                $attributes_groups = 
$this->bo->get_attribute_groups($location, $values['attributes']);
-                               //_debug_array($attributes_groups);die();
+//     _debug_array($attributes_groups);die();
 
+                               $attributes_general = array();
                                $attributes = array();
                                foreach ($attributes_groups as $group)
                                {
-                                       if(isset($group['attributes']))
+                                       if(isset($group['attributes']) && 
isset($group['group_sort']))
                                        {
                                                $tabs[str_replace(' ', '_', 
$group['name'])] = array('label' => $group['name'], 'link' => '#' . 
str_replace(' ', '_', $group['name']));
                                                $group['link'] = str_replace(' 
', '_', $group['name']);
                                                $attributes[] = $group;
                                        }
+                                       else if(isset($group['attributes']) && 
!isset($group['group_sort']))
+                                       {
+                                               $attributes_general = 
array_merge($attributes_general,$group['attributes']);
+                                       }
+
                                }
                                unset($attributes_groups);
                                unset($values['attributes']);
@@ -2185,8 +2197,6 @@
                                        $documents = json_encode($documents);   
                        
                                }
 
-                               $_config                = 
CreateObject('phpgwapi.config','property');
-                               $_config->read();
                                $_dirname = '';
 
                                $_files_maxlevel = 0;
@@ -2414,6 +2424,7 @@
                                'lang_owner_statustext'                 => 
(isset($lang_owner_statustext)?$lang_owner_statustext:''),
                                'additional_fields'                             
=> $additional_fields,
                                'attributes_group'                              
=> $attributes,
+                               'attributes_general'                    => 
array('attributes' => $attributes_general),
 //                             'attributes_values'                             
=> $values['attributes'],
                                'lookup_functions'                              
=> isset($values['lookup_functions'])?$values['lookup_functions']:'',
                                'lang_none'                                     
        => lang('None'),

Copied: 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
 (from rev 7400, 
trunk/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb)
===================================================================
--- 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
                          (rev 0)
+++ 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bilde_bkb
  2011-06-20 06:30:25 UTC (rev 7401)
@@ -0,0 +1,106 @@
+<?php
+       class import_conversion
+       {
+               protected $bofiles;
+               protected $db;
+               public $messages = array();
+               public $warnings = array();
+               public $errors = array();
+               protected $dir = '/opt/kunst/001';
+               protected $entity_id = 4;
+               protected $cat_id = 1;
+
+
+               public function __construct()
+               {
+                       set_time_limit(10000); //Set the time limit for this 
request
+                       $this->account          = 
(int)$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->db           = & $GLOBALS['phpgw']->db;
+                       $this->bofiles          = 
CreateObject('property.bofiles');
+                       $this->category_dir = 
"entity_{$this->entity_id}_{$this->cat_id}";
+                       $this->soentity         = 
CreateObject('property.soentity',$this->entity_id,$this->cat_id);
+               }
+
+               public function add($data)
+               {
+//                     $debug = true;
+                       $error = false;
+//_debug_array($data);
+
+                       $values = $this->soentity->read_single(array('id' => 
$data[0] ));
+
+                       if(isset($values['location_code']))
+                       {
+                               $filename = sprintf('%05s',$data[1]);
+                               $from_file      = 
"{$this->dir}/{$filename}.jpg";
+                               if(!is_file($from_file))
+                               {
+                                       $this->errors[] ="'Missing file: 
{$from_file}";                         
+                               }                               
+                               
+                               $location = explode('-', 
$values['location_code']);
+
+                               $to_file        = 
"{$this->bofiles->fakebase}/{$this->category_dir}/{$location[0]}/{$data[0]}/{$filename}.jpg";
+
+                               if ($this->bofiles->vfs->file_exists(array
+                                       (
+                                               'string' => $to_file,
+                                               'relatives' => 
Array(RELATIVE_NONE)
+                                       )))
+                               {
+                                       $this->errors[] ="This file already 
exists: {$to_file}";
+                               }
+                               else if (!$debug)
+                               {
+                                       
$this->bofiles->create_document_dir("{$this->category_dir}/{$location[0]}/{$data[0]}");
+                                       $this->bofiles->vfs->override_acl = 1;
+
+                                       if(!$this->bofiles->vfs->cp (array (
+                                               'from'  => $from_file,
+                                               'to'    => $to_file,
+                                               'relatives'     => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))))
+                                       {
+                                               $this->errors[] ="'Failed to 
upload file: {$to_file}";
+                                       }
+                                       else
+                                       {
+                                               $this->messages[] = 
"Successfully imported file: Title ({$filename}.jpg)";                          
            
+                                       }
+                                       $this->bofiles->vfs->override_acl = 0;
+                               }
+
+//                             _debug_array($to_file);
+                       }
+
+                       return true;
+               }
+
+
+               /**
+                * Convert from the locale encoding to UTF-8 encoding and 
escape single quotes
+                * 
+                * @param string $value The value to convert
+                * @return string
+                */
+               protected function decode($value)
+               {
+                       $converted = mb_convert_encoding($value, 'UTF-8');
+                       if ($this->is_null(trim($converted)))
+                       {
+                               return null;
+                       }
+                       return stripslashes($converted);
+               }
+               
+               /**
+                * Test a value for null according to several formats that can 
exist in the export.
+                * Returns true if the value is null according to these rules, 
false otherwise.
+                * 
+                * @param string $value The value to test
+                * @return bool
+                */
+               protected function is_null($value)
+               {
+                       return ((trim($value) == "") || ($data == "<NULL>") || 
($data == "''"));
+               }
+       }

Modified: 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
===================================================================
--- 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
        2011-06-19 17:47:39 UTC (rev 7400)
+++ 
branches/Version-1_0-branch/property/inc/import/default/cvs_import_kunstoversikt_bkb
        2011-06-20 06:30:25 UTC (rev 7401)
@@ -19,6 +19,16 @@
                        $error = false;
                        $table = 'fm_entity_4_1';
                        $byggid = $this->decode($data[0]);
+                       if(!$byggid)
+                       {
+                               $this->errors[] = "Mangler objekt, hopper over: 
{$data[1]}";
+                               return true;
+                       }
+                       if(substr($byggid,0,1) == 'B')
+                       {
+                               $this->warnings[] = "BBB-objekt, hopper over: 
{$byggid}";
+                               return true;
+                       }
                        $location_code = substr($byggid,0,4) . '-0' . 
substr($byggid,-1);
 //_debug_array($location_code);
                        $location_data = 
execMethod('property.solocation.read_single', $location_code );
@@ -44,12 +54,19 @@
                        }
 
                        $id = (int)$data[2];
+                       
+                       $this->db->query("SELECT id FROM {$table} WHERE id = 
{$id}",__LINE__,__FILE__);
+                       if($this->db->next_record())
+                       {
+                               $this->errors[] = "ID finnes fra før: {$id}";
+                               return true;
+                       }
 
                        $this->messages[] = "Dagens dato er lagt inn som 
registreringsdato for {$id}  (mangler info)";
                        $entry_date = time();
 
-_debug_array($entry_date_info);
-_debug_array($entry_date);
+//_debug_array($entry_date_info);
+//_debug_array($entry_date);
                        $value_set = array();
 
                        $value_set['id']                                        
= $id;

Modified: 
branches/Version-1_0-branch/property/templates/base/attributes_form.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/attributes_form.xsl     
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/templates/base/attributes_form.xsl     
2011-06-20 06:30:25 UTC (rev 7401)
@@ -8,14 +8,13 @@
                <xsl:for-each select="attributes_group" >
                        <div id="{link}">
                                <table cellpadding="2" cellspacing="2" 
width="100%" align="center" border="0">
-                                       <xsl:call-template name="attributes"/>
+                                       <xsl:apply-templates 
select="attributes"/>
                                </table>
                        </div>
                </xsl:for-each>
        </xsl:template>
 
-       <xsl:template name="attributes">
-               <xsl:for-each select="attributes" >
+       <xsl:template match="attributes">
                        <xsl:variable name="statustext"><xsl:value-of 
select="statustext"/></xsl:variable>
                        <tr>
                                <td align="left" width="19%" valign="top" 
title="{$statustext}">
@@ -387,7 +386,6 @@
                                        </xsl:choose>
                                </td>
                        </tr>
-               </xsl:for-each>
        </xsl:template>
 
        <xsl:template name="choice">

Modified: branches/Version-1_0-branch/property/templates/base/entity.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/entity.xsl      
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/templates/base/entity.xsl      
2011-06-20 06:30:25 UTC (rev 7401)
@@ -212,6 +212,7 @@
                                                                                
        <xsl:call-template name="location_view"/>
                                                                                
</xsl:otherwise>
                                                                        
</xsl:choose>
+                                                                       
<xsl:apply-templates select="attributes_general/attributes"/>
                                                                </table>
                                                        </div>
                                                </xsl:when>

Modified: branches/Version-1_0-branch/property/templates/base/location.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/location.xsl    
2011-06-19 17:47:39 UTC (rev 7400)
+++ branches/Version-1_0-branch/property/templates/base/location.xsl    
2011-06-20 06:30:25 UTC (rev 7401)
@@ -459,7 +459,7 @@
                                                                        </tr>
                                                                </xsl:when>
                                                        </xsl:choose>
-
+                                                       <xsl:apply-templates 
select="attributes_general/attributes"/>
                                                </table>
                                        </div>
 




reply via email to

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