fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8125] Merge 8109:8124 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [8125] Merge 8109:8124 from trunk
Date: Thu, 17 Nov 2011 18:21:10 +0000

Revision: 8125
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8125
Author:   sigurdne
Date:     2011-11-17 18:21:09 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Merge 8109:8124 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
    branches/Version-1_0-branch/activitycalendar/inc/model/class.arena.inc.php
    branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
    branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
    
branches/Version-1_0-branch/activitycalendar/templates/base/arena_list_partial.php
    branches/Version-1_0-branch/activitycalendar/templates/base/group.php
    
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
    
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
    branches/Version-1_0-branch/bim/setup/setup.inc.php
    branches/Version-1_0-branch/bim/setup/tables_update.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php
    
branches/Version-1_0-branch/controller/inc/class.socontrol_group_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
    
branches/Version-1_0-branch/controller/inc/class.uilocation_check_list.inc.php
    branches/Version-1_0-branch/controller/js/controller/custom_ui.js
    
branches/Version-1_0-branch/controller/templates/base/choose_control_items.xsl
    branches/Version-1_0-branch/controller/templates/base/control_groups.xsl
    branches/Version-1_0-branch/controller/templates/base/control_tabs.xsl
    branches/Version-1_0-branch/controller/templates/base/css/base.css
    branches/Version-1_0-branch/property/inc/class.boentity.inc.php
    branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php
    branches/Version-1_0-branch/property/inc/class.soentity.inc.php
    branches/Version-1_0-branch/property/inc/cron/default/catch_ppc.php
    branches/Version-1_0-branch/property/templates/base/admin_entity.xsl
    branches/Version-1_0-branch/rental/inc/class.uiparty.inc.php

Added Paths:
-----------
    
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_edit.php
    
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php

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,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108
   + 
/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,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php     
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/activitycalendar/inc/class.uiimport.inc.php     
2011-11-17 18:21:09 UTC (rev 8125)
@@ -212,6 +212,7 @@
                                unset($activity_persons);
                                unset($activity_description);
                                unset($org_info);
+                               unset($group_info);
                                unset($contact_person);
                                unset($contact1);
                                unset($contact2);

Modified: 
branches/Version-1_0-branch/activitycalendar/inc/model/class.arena.inc.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/inc/model/class.arena.inc.php  
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/activitycalendar/inc/model/class.arena.inc.php  
2011-11-17 18:21:09 UTC (rev 8125)
@@ -88,9 +88,8 @@
                        return array(
                                'id' => $this->get_id(),
                                'arena_name' => $this->get_arena_name(),
-                               'internal_arena_id' => 
activitycalendar_soarena::get_instance()->get_building_name($this->get_internal_arena_id()),
                                'address' => $this->get_address(),
-                               'active' => $this->is_active()
+                               'active' => 
($this->is_active())?'Aktiv':'Inaktiv'
                        );
                }
        }

Modified: branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang    
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/activitycalendar/setup/phpgw_no.lang    
2011-11-17 18:21:09 UTC (rev 8125)
@@ -332,8 +332,8 @@
 date_end       activitycalendar        no      Sluttdato
 special_adaptation     activitycalendar        no      Spesielt tilpasset for 
utviklingshemmede
 target activitycalendar        no      Målgruppe
-contact_person_1       activitycalendar        no      Kontaktperson 1
-contact_person_2       activitycalendar        no      Kontaktperson 2
+contact_person_1       activitycalendar        no      Kontaktperson 1 (Navn, 
e-post)
+contact_person_2       activitycalendar        no      Kontaktperson 2 (Navn, 
e-post)
 Activities     activitycalendar        no      Aktiviteter
 activities     activitycalendar        no      Aktiviteter
 Arena  activitycalendar        no      Arena
@@ -372,7 +372,7 @@
 state_5        activitycalendar        no      Avvist
 activity_import        activitycalendar        no      Importer aktiviteter
 office activitycalendar        no      Hovedansvarlig kulturkontor
-activity_helptext      activitycalendar        no      Før ny aktivitet kan 
registreres må du sjekke at organisasjon/gruppe finnes og er oppdatert, og at 
arena finnes og er oppdatert.
+activity_helptext      activitycalendar        no      Aktivitetsoversikten 
henter kontaktinformasjon og beskrivelse fra bookingmodulen.<br/>Før ny 
aktivitet kan registreres må du sjekke at organisasjon/gruppe finnes og er 
oppdatert,<br/>og at arena finnes og er oppdatert. Feltet vis i portal skal 
være satt til JA, i organisasjonsregisteret og evt. lag/gruppe. For nye 
aktiviteter vil dette bli satt automatisk.
 mail_subject_update    activitycalendar        no      Melding om oppdatering 
av aktivitet
 mail_body_update       activitycalendar        no      Du må oppdatere 
informasjonen som er registrert på aktivitet %1 . Bruk følgende lenke for å gå 
inn på aktiviteten: %2
 mail_body_state_3      activitycalendar        no      Ditt tips er publisert 
i kommuneportalen. Mvh %1 kulturkontor
@@ -401,7 +401,26 @@
 group_saved_form       activitycalendar        no      Gruppen ble lagret
 published      activitycalendar        no      Publisert
 contactperson_not_set  activitycalendar        no      Kontaktpersoner hentes 
fra valgt organisasjon/gruppe ved lagring.
-description_not_set    activitycalendar        no      Beskrivelse hentes fra 
valgt organisasjon/gruppe ved lagring (Max 255 tegn).
+description_helptext   activitycalendar        no      Hentes fra 
booking/organisasjonsregister ved lagring/oppdatering.
 back_to_list   activitycalendar        no      Tilbake til oversikt
 target_not_selected    activitycalendar        no      Målgruppe må velges!
-district_not_selected  activitycalendar        no      Distrikt må velges!
\ No newline at end of file
+district_not_selected  activitycalendar        no      Distrikt må velges!
+title_helptext activitycalendar        no      Oppgi tittelen for aktiviteten. 
Kort og beskrivende.
+state_helptext activitycalendar        no      Status for aktiviteten. For at 
den skal vises i portalen må status settes til publisert.
+organization_helptext  activitycalendar        no      Velg organisasjon eller 
registrer inn ny.<br/>Stå i feltet og skriv inn første bokstav for å få opp 
oversikt.
+group_helptext activitycalendar        no      Velg gruppe/lag, eller 
ingen.<br/>Feltet vis i portal må være satt til JA om lag/gruppe skal komme opp 
i listen.
+criteria_label activitycalendar        no      Valgkriterier/søkeord i portalen
+criteria_helptext      activitycalendar        no      Feltene må fylles ut 
for at aktiviteten skal komme frem i søk i portalen, koder for kategori og 
målgruppe hentes fra booking. 
+what   activitycalendar        no      HVA
+where_when     activitycalendar        no      HVOR/NÅR
+who    activitycalendar        no      HVEM
+arena_helptext activitycalendar        no      Oppgi arena ved å velge 
kommunalt bygg eller eksterne bygg.
+external_arena activitycalendar        no      Eksterne bygg
+category_helptext      activitycalendar        no      Velg kategori
+target_helptext        activitycalendar        no      Velg målgruppe(r)
+district_helptext      activitycalendar        no      Velg bydel(er) hvor 
aktiviteten foregår
+adaptation_helptext    activitycalendar        no      Kryss av om aktiviteten 
er spesielt tilpasset
+time_helptext  activitycalendar        no      Oppgi tidspunkt for 
aktiviteten, f.eks. onsdag kl. 20-21
+office_helptext        activitycalendar        no      Oppgi kontor som 
saksbehandler aktiviteten
+contact_info   activitycalendar        no      Kontaktinformasjon for 
kulturkontoret
+contact_info_helptext  activitycalendar        no      Hentes fra 
booking/organisasjonsregister ved lagring.

Modified: 
branches/Version-1_0-branch/activitycalendar/templates/base/activity.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/templates/base/activity.php    
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/activitycalendar/templates/base/activity.php    
2011-11-17 18:21:09 UTC (rev 8125)
@@ -38,6 +38,34 @@
        get_available_groups();
 });
 
+function check_internal()
+{
+       if(document.getElementById('internal_arena_id').value != null && 
document.getElementById('internal_arena_id').value > 0)
+       {
+               //disable external arena drop-down
+               document.getElementById('arena_id').disabled="disabled";
+       }
+       else
+       {
+               //enable external arena drop-down
+               document.getElementById('arena_id').disabled="";
+       }
+}
+
+function check_external()
+{
+       if(document.getElementById('arena_id').value != null && 
document.getElementById('arena_id').value > 0)
+       {
+               //disable internal arena drop-down
+               
document.getElementById('internal_arena_id').disabled="disabled";
+       }
+       else
+       {
+               //enable internal arena drop-down
+               document.getElementById('internal_arena_id').disabled="";
+       }
+}
+
 function allOK()
 {
        if(document.getElementById('title').value == null || 
document.getElementById('title').value == '')
@@ -86,9 +114,11 @@
                <form action="#" method="post">
                        <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
                        <dl class="proplist-col">
+                               <h2><?php echo lang('what')?></h2>
                                <dt>
                                        <?php if($activity->get_title() || 
$editable) { ?>
                                        <label for="title"><?php echo 
lang('title') ?></label>
+                                       <br/><?php echo lang('title_helptext')?>
                                        <?php  } ?>
                                </dt>
                                <dd>
@@ -96,7 +126,7 @@
                                        if ($editable)
                                        {
                                        ?>
-                                               <input type="text" name="title" 
id="title" value="<?php echo $activity->get_title() ?>" size="100"/>
+                                               <input type="text" name="title" 
id="title" value='<?php echo $activity->get_title() ?>' size="100"/>
                                        <?php
                                        }
                                        else
@@ -105,9 +135,34 @@
                                        }
                                        ?>
                                </dd>
-                                                               <dt>
+                               <dt>
+                                       <label for="description"><?php echo 
lang('description') ?></label>
+                                       <br/><?php echo 
lang('description_helptext')?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                               if($activity->get_group_id())
+                                               {
+                                                       $group =  
$act_so->get_group_info($activity->get_group_id());
+                                                       if($group)
+                                                       {
+                                                               echo 
$group['description'];
+                                                       }
+                                               }
+                                               else 
if($activity->get_organization_id())
+                                               {
+                                                       $org = 
$act_so->get_org_info($activity->get_organization_id());
+                                                       if($org)
+                                                       {
+                                                               echo 
$org['description'];
+                                                       }
+                                               }
+                                        ?>
+                               </dd>
+                               <dt>
                                        <?php if($activity->get_state() || 
$editable) { ?>
                                        <label for="state"><?php echo 
lang('state') ?></label>
+                                       <br/><?php echo lang('state_helptext')?>
                                        <?php  } ?>
                                </dt>
                                <dd>
@@ -133,126 +188,133 @@
                                        ?>
                                </dd>
                                <dt>
-                                       <?php 
if($activity->get_organization_id() || $editable) { ?>
-                                       <label for="organization_id"><?php echo 
lang('organization') ?></label>
-                                       <?php } ?>
+                                       <?php if($editable) {?>
+                                               <label for="criteria"><?php 
echo lang('criteria_label') ?></label>
+                                               <br/><?php echo 
lang('criteria_helptext')?>
+                                       <?php }?>
                                </dt>
+                               <dt>
+                                       <?php if($activity->get_category() || 
$editable) { ?>
+                                       <label for="category"><?php echo 
lang('category') ?></label>
+                                       <br/><?php echo 
lang('category_helptext') ?>
+                                       <?php  } ?>
+                               </dt>
                                <dd>
                                        <?php
-                                       $current_organization_id = 
$activity->get_organization_id();
+                                       $current_category_id = 
$activity->get_category();
                                        if ($editable)
                                        {
-                                               if($activity->get_new_org())
-                                               {
-                                                       echo $org_name;
-                                               }
-                                               else
-                                               {
                                                ?>
-                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
-                                                       <option value="">Ingen 
organisasjon valgt</option>
+                                               <select name="category" 
id="category">
+                                                       <option value="0">Ingen 
kategori valgt</option>
                                                        <?php
-                                                               
foreach($organizations as $organization)
-                                                               {
-                                                                       echo 
"<option ".($current_organization_id == $organization->get_id() ? 
'selected="selected"' : "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
-                                                               }
-                                                               ?>
+                                                       foreach($categories as 
$category)
+                                                       {
+                                                               echo "<option 
".($current_category_id == $category->get_id() ? 'selected="selected"' : "")." 
value=\"{$category->get_id()}\">".$category->get_name()."</option>";
+                                                       }
+                                                       ?>
                                                </select>
                                                <?php
-                                               }
-                                       ?>
-                                       <?php
                                        }
                                        else
                                        {
-                                               
if($activity->get_organization_id()){
-                                                       echo 
activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
+                                               if($activity->get_category()){
+                                                       echo 
$act_so->get_category_name($activity->get_category());
                                                }
                                        }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_group_id() || 
$editable) { ?>
-                                       <label for="group_id"><?php echo 
lang('group') ?></label>
-                                       <?php } ?>
+                                       <?php if($activity->get_target() || 
$editable) { ?>
+                                       <label for="target"><?php echo 
lang('target') ?></label>
+                                       <br/><?php echo lang('target_helptext') 
?>
+                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_group_id = 
$activity->get_group_id();
+                                       $current_target_ids = 
$activity->get_target();
+                                       $current_target_id_array=explode(",", 
$current_target_ids);
+                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
                                        if ($editable)
                                        {
+                                               foreach($targets as $t)
+                                               {
                                                ?>
-                                               <div id="group_select">
-                                                       <select name="group_id" 
id="group_id">
-                                                               <option 
value="0">Ingen gruppe valgt</option>
-                                                       </select>
-                                               </div>
+                                                       <input name="target[]" 
id="target[]" type="checkbox" value="<?php echo $t->get_id()?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "")?>/><?php 
echo $t->get_name()?><br/>
                                                <?php
-                                       ?>
-                                       <?php
+                                               }
                                        }
                                        else
                                        {
-                                               if($activity->get_group_id()){
-                                                       echo 
activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id());
+                                               if($activity->get_target()){
+                                                       $current_target_ids = 
$activity->get_target();
+                                                       
$current_target_id_array=explode(",", $current_target_ids);
+                                                       
foreach($current_target_id_array as $curr_target)
+                                                       {
+                                                               echo 
$act_so->get_target_name($curr_target).'<br/>';
+                                                       }
                                                }
                                        }
                                        ?>
                                </dd>
-                               <?php if($activity->get_contact_person_1() || 
$editable) { ?>
                                <dt>
-                                       <label for="contact_person_1"><?php 
echo lang('contact_person_1') ?></label>
+                                       <?php if($activity->get_district() || 
$editable) { ?>
+                                       <label for="district"><?php echo 
lang('district') ?></label>
+                                       <br/><?php echo 
lang('district_helptext') ?>
+                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                               if($activity->get_group_id())
+                                       $current_district_ids = 
$activity->get_district();
+                                       $current_district_id_array=explode(",", 
$current_district_ids);
+                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       if ($editable)
+                                       {
+                                               foreach($districts as $d)
                                                {
-                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_1());
+                                               ?>
+                                                       <input 
name="district[]" type="checkbox" value="<?php echo $d['part_of_town_id']?>" 
<?php echo (in_array($d['part_of_town_id'], $current_district_id_array) ? 
'checked' : "")?>/><?php echo $d['name']?><br/>
+                                               <?php
                                                }
-                                               else 
if($activity->get_organization_id())
-                                               {
-                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_1());
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_district()){
+                                                       $current_district_ids = 
$activity->get_district();
+//                                                     echo 
$current_district_ids;
+                                                       
$current_district_id_array=explode(",", $current_district_ids);
+                                                       
foreach($current_district_id_array as $curr_district)
+                                                       {
+                                                               echo 
$act_so->get_district_name($curr_district).'<br/>';
+                                                       }
                                                }
-                                               else
-                                               {
-                                                       echo 
lang('contactperson_not_set');
-                                               }
+                                       }
                                        ?>
                                </dd>
-                               <?php  } ?>
-                               <?php if($activity->get_contact_person_2() || 
$editable) { ?>
                                <dt>
-                                       <label for="contact_person_2"><?php 
echo lang('contact_person_2') ?></label>
+                                       <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
+                                       <br/><?php echo 
lang('adaptation_helptext') ?>
                                </dt>
                                <dd>
-                                       <?php
-                                               if($activity->get_group_id())
-                                               {
-                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_2());
-                                               }
-                                               else 
if($activity->get_organization_id())
-                                               {
-                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_2());
-                                               }
-                                               else
-                                               {
-                                                       echo 
lang('contactperson_not_set');
-                                               }
-                                       ?>
+                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> <?php echo 
!$editable ? ' disabled="disabled"' : '' ?>/>
                                </dd>
-                               <?php  } ?>
+                               <h2><?php echo lang('where_when')?></h2>
                                <dt>
-                                       <?php 
if($activity->get_internal_arena() || $editable) { ?>
-                                       <label for="arena"><?php echo 
lang('building') ?></label>
+                                       <?php if($activity->get_arena() || 
$editable) { ?>
+                                       <label for="arena"><?php echo 
lang('arena') ?></label>
+                                       <br/><?php echo lang('arena_helptext')?>
                                        <?php  } ?>
                                </dt>
+                               <dt>
+                                       <label for="internal_arena_id"><?php 
echo lang('building') ?></label>
+                               </dt>
                                <dd>
                                        <?php
                                        $current_internal_arena_id = 
$activity->get_internal_arena();
                                        if ($editable)
                                        {
                                                ?>
-                                               <select 
name="internal_arena_id" id="internal_arena_id">
+                                               <select 
name="internal_arena_id" id="internal_arena_id" onchange="javascript: 
check_internal();">
                                                        <option value="0">Ingen 
kommunale bygg valgt</option>
                                                        <?php
                                                        foreach($buildings as 
$building_id => $building_name)
@@ -272,9 +334,7 @@
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_arena() || 
$editable) { ?>
-                                       <label for="arena"><?php echo 
lang('arena') ?></label>
-                                       <?php  } ?>
+                                       <label for="arena_id"><?php echo 
lang('external_arena') ?></label>
                                </dt>
                                <dd>
                                        <?php
@@ -282,7 +342,7 @@
                                        if ($editable)
                                        {
                                                ?>
-                                               <select name="arena_id" 
id="arena_id">
+                                               <select name="arena_id" 
id="arena_id" onchange="javascript: check_external();">
                                                        <option value="0">Ingen 
arena valgt</option>
                                                        <?php
                                                        foreach($arenas as 
$arena)
@@ -304,6 +364,7 @@
                                <dt>
                                        <?php if($activity->get_time() || 
$editable) { ?>
                                        <label for="time"><?php echo 
lang('time') ?></label>
+                                       <br/><?php echo lang('time_helptext') ?>
                                        <?php  } ?>
                                </dt>
                                <dd>
@@ -321,157 +382,144 @@
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_category() || 
$editable) { ?>
-                                       <label for="category"><?php echo 
lang('category') ?></label>
+                                       <?php if($activity->get_office() || 
$editable) { ?>
+                                       <label for="office"><?php echo 
lang('office') ?></label>
+                                       <br/><?php echo lang('office_helptext') 
?>
                                        <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_category_id = 
$activity->get_category();
                                        if ($editable)
                                        {
-                                               ?>
-                                               <select name="category" 
id="category">
-                                                       <option value="0">Ingen 
kategori valgt</option>
+                                               $selected_office = 
$activity->get_office();
+                                       ?>
+                                               <select name="office" 
id="office">
+                                                       <option value="0">Ingen 
kontor valgt</option>
                                                        <?php
-                                                       foreach($categories as 
$category)
+                                                       foreach($offices as 
$office)
                                                        {
-                                                               echo "<option 
".($current_category_id == $category->get_id() ? 'selected="selected"' : "")." 
value=\"{$category->get_id()}\">".$category->get_name()."</option>";
+                                                               echo "<option 
".($selected_office == $office['id'] ? 'selected="selected"' : "")." 
value=\"{$office['id']}\">".$office['name']."</option>";
                                                        }
                                                        ?>
                                                </select>
-                                               <?php
+                                       <?php
                                        }
                                        else
                                        {
-                                               if($activity->get_category()){
-                                                       echo 
$act_so->get_category_name($activity->get_category());
+                                               if($activity->get_office()){
+                                                       echo 
$act_so->get_office_name($activity->get_office());
                                                }
                                        }
                                        ?>
                                </dd>
+                               <h2><?php echo lang('who')?></h2>
                                <dt>
-                                       <?php if($activity->get_target() || 
$editable) { ?>
-                                       <label for="target"><?php echo 
lang('target') ?></label>
-                                       <?php  } ?>
+                                       <?php 
if($activity->get_organization_id() || $editable) { ?>
+                                       <label for="organization_id"><?php echo 
lang('organization') ?></label>
+                                       <br/><?php echo 
lang('organization_helptext') ?>
+                                       <?php } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_target_ids = 
$activity->get_target();
-                                       $current_target_id_array=explode(",", 
$current_target_ids);
-                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       $current_organization_id = 
$activity->get_organization_id();
                                        if ($editable)
                                        {
-                                               foreach($targets as $t)
+                                               if($activity->get_new_org())
                                                {
+                                                       echo $org_name;
+                                               }
+                                               else
+                                               {
                                                ?>
-                                                       <input name="target[]" 
id="target[]" type="checkbox" value="<?php echo $t->get_id()?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "")?>/><?php 
echo $t->get_name()?><br/>
+                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
+                                                       <option value="">Ingen 
organisasjon valgt</option>
+                                                       <?php
+                                                               
foreach($organizations as $organization)
+                                                               {
+                                                                       echo 
"<option ".($current_organization_id == $organization->get_id() ? 
'selected="selected"' : "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
+                                                               }
+                                                               ?>
+                                               </select>
                                                <?php
                                                }
+                                       ?>
+                                       <?php
                                        }
                                        else
                                        {
-                                               if($activity->get_target()){
-                                                       $current_target_ids = 
$activity->get_target();
-                                                       
$current_target_id_array=explode(",", $current_target_ids);
-                                                       
foreach($current_target_id_array as $curr_target)
-                                                       {
-                                                               echo 
$act_so->get_target_name($curr_target).'<br/>';
-                                                       }
+                                               
if($activity->get_organization_id()){
+                                                       echo 
activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
                                                }
                                        }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_district() || 
$editable) { ?>
-                                       <label for="district"><?php echo 
lang('district') ?></label>
-                                       <?php  } ?>
+                                       <?php if($activity->get_group_id() || 
$editable) { ?>
+                                       <label for="group_id"><?php echo 
lang('group') ?></label>
+                                       <br/><?php echo lang('group_helptext') 
?>
+                                       <?php } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_district_ids = 
$activity->get_district();
-                                       $current_district_id_array=explode(",", 
$current_district_ids);
-                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       $current_group_id = 
$activity->get_group_id();
                                        if ($editable)
                                        {
-                                               foreach($districts as $d)
-                                               {
                                                ?>
-                                                       <input 
name="district[]" type="checkbox" value="<?php echo $d['part_of_town_id']?>" 
<?php echo (in_array($d['part_of_town_id'], $current_district_id_array) ? 
'checked' : "")?>/><?php echo $d['name']?><br/>
+                                               <div id="group_select">
+                                                       <select name="group_id" 
id="group_id">
+                                                               <option 
value="0">Ingen gruppe valgt</option>
+                                                       </select>
+                                               </div>
                                                <?php
-                                               }
+                                       ?>
+                                       <?php
                                        }
                                        else
                                        {
-                                               if($activity->get_district()){
-                                                       $current_district_ids = 
$activity->get_district();
-//                                                     echo 
$current_district_ids;
-                                                       
$current_district_id_array=explode(",", $current_district_ids);
-                                                       
foreach($current_district_id_array as $curr_district)
-                                                       {
-                                                               echo 
$act_so->get_district_name($curr_district).'<br/>';
-                                                       }
+                                               if($activity->get_group_id()){
+                                                       echo 
activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id());
                                                }
                                        }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_office() || 
$editable) { ?>
-                                       <label for="office"><?php echo 
lang('office') ?></label>
-                                       <?php  } ?>
+                                       <label><?php echo lang('contact_info') 
?></label>
+                                       <br/><?php echo 
lang('contact_info_helptext') ?>
                                </dt>
+                               <?php if($activity->get_contact_person_1() || 
$editable) { ?>
+                               <dt>
+                                       <label for="contact_person_1"><?php 
echo lang('contact_person_1') ?></label>
+                               </dt>
                                <dd>
                                        <?php
-                                       if ($editable)
-                                       {
-                                               $selected_office = 
$activity->get_office();
-                                       ?>
-                                               <select name="office" 
id="office">
-                                                       <option value="0">Ingen 
kontor valgt</option>
-                                                       <?php
-                                                       foreach($offices as 
$office)
-                                                       {
-                                                               echo "<option 
".($selected_office == $office['id'] ? 'selected="selected"' : "")." 
value=\"{$office['id']}\">".$office['name']."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                       <?php
-                                       }
-                                       else
-                                       {
-                                               if($activity->get_office()){
-                                                       echo 
$act_so->get_office_name($activity->get_office());
+                                               if($activity->get_group_id())
+                                               {
+                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_1());
                                                }
-                                       }
+                                               else 
if($activity->get_organization_id())
+                                               {
+                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_1());
+                                               }
                                        ?>
                                </dd>
+                               <?php  } ?>
+                               <?php if($activity->get_contact_person_2() || 
$editable) { ?>
                                <dt>
-                                       <label for="description"><?php echo 
lang('description') ?></label>
+                                       <label for="contact_person_2"><?php 
echo lang('contact_person_2') ?></label>
                                </dt>
                                <dd>
                                        <?php
                                                if($activity->get_group_id())
                                                {
-                                                       $group =  
$act_so->get_group_info($activity->get_group_id());
-                                                       if($group)
-                                                       {
-                                                               echo 
$group['description'];
-                                                       }
+                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_2());
                                                }
                                                else 
if($activity->get_organization_id())
                                                {
-                                                       $org = 
$act_so->get_org_info($activity->get_organization_id());
-                                                       if($org)
-                                                       {
-                                                               echo 
$org['description'];
-                                                       }
+                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_2());
                                                }
-                                               else
-                                               {
-                                                       echo 
lang('description_not_set');
-                                               }
-                                        ?>
+                                       ?>
                                </dd>
+                               <?php  } ?>
                                <dt>
                                        <?php 
if($activity->get_contact_person_2_address() || $editable) { ?>
                                        <label 
for="contact_person_2_address"><?php echo lang('contact_person_2_address') 
?></label>
@@ -510,12 +558,6 @@
                                        }
                                        ?>
                                </dd>
-                           <dt>
-                                       <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
-                               </dt>
-                               <dd>
-                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> <?php echo 
!$editable ? ' disabled="disabled"' : '' ?>/>
-                               </dd>
                        </dl>
                        <div class="form-buttons">
                                <?php

Modified: 
branches/Version-1_0-branch/activitycalendar/templates/base/arena_list_partial.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendar/templates/base/arena_list_partial.php
  2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/activitycalendar/templates/base/arena_list_partial.php
  2011-11-17 18:21:09 UTC (rev 8125)
@@ -59,7 +59,7 @@
                
'index.php?menuaction=activitycalendar.uiarena.query&amp;phpgw_return_as=json<?php
 echo $url_add_on; ?>&amp;editable=<?php echo $editable ? "true" : "false"; ?>',
                columnDefs,
                '<?php echo $list_id ?>_form',
-               ['<?php echo $list_id ?>_ctrl_search_query','<?php echo 
$list_id ?>_ctrl_toggle_arena_type','<?php echo $list_id 
?>_ctrl_toggle_active'],
+               ['<?php echo $list_id ?>_ctrl_search_query','<?php echo 
$list_id ?>_ctrl_toggle_active'],
                '<?php echo $list_id ?>_container',
                '<?php echo $list_id ?>_paginator',
                '<?php echo $list_id ?>',
@@ -75,7 +75,6 @@
     function arena_export(ptype) {
 
         var query = document.getElementById('<?php echo $list_id 
?>_ctrl_search_query').value;
-        var aType = document.getElementById('<?php echo $list_id 
?>_ctrl_toggle_arena_type').value;
         var active = document.getElementById('<?php echo $list_id 
?>_ctrl_toggle_active').value;
         <?php
         /* FIXME Search queries will affect ALL data tables listed on one page 
(of that type) when exporting

Modified: branches/Version-1_0-branch/activitycalendar/templates/base/group.php
===================================================================
--- branches/Version-1_0-branch/activitycalendar/templates/base/group.php       
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/activitycalendar/templates/base/group.php       
2011-11-17 18:21:09 UTC (rev 8125)
@@ -21,6 +21,7 @@
                                <?php }?>
                                </dd>
                                <dt><label>Kontaktperson 1</label></dt>
+                               <?php if($contactperson1){?>
                                <dd><input type="hidden" name="contact1_id" 
value="<?php echo $contactperson1->get_id();?>"/></dd>
                                <dt><label for="contact1_name">Navn</label></dt>
                                <dd>
@@ -34,7 +35,9 @@
                                <dd>
                                        <input type="text" 
name="contact1_email" value="<?php echo $contactperson1->get_email();?>"/>
                                </dd>
+                               <?php }?>
                                <dt><label>Kontaktperson 2</label></dt>
+                               <?php if($contactperson2){?>
                                <dd><input type="hidden" name="contact2_id" 
value="<?php echo $contactperson2->get_id();?>"/></dd>
                                <dt><label for="contact1_name">Navn</label></dt>
                                <dd>
@@ -48,6 +51,7 @@
                                <dd>
                                        <input type="text" 
name="contact2_email" value="<?php echo $contactperson2->get_email();?>"/>
                                </dd>
+                               <?php }?>
                        </dl>
                        <div class="form-buttons">
                                <?php

Modified: 
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
   2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/inc/class.uiactivity.inc.php
   2011-11-17 18:21:09 UTC (rev 8125)
@@ -25,7 +25,275 @@
                 */
                public function add()
                {
-                       
$GLOBALS['phpgw']->redirect_link('/activitycalendarfrontend/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.edit', 'action' => 
'new_activity'));
+                       
//$GLOBALS['phpgw']->redirect_link('/activitycalendarfrontend/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.edit', 'action' => 
'new_activity'));
+                       $GLOBALS['phpgw']->js->validate_file( 'json', 'json', 
'phpgwapi' );
+
+                       $so_activity = 
activitycalendar_soactivity::get_instance();
+                       $so_arena = activitycalendar_soarena::get_instance();
+
+                       $categories = $so_activity->get_categories();
+                       $targets = $so_activity->get_targets();
+                       $offices = $so_activity->select_district_list();
+                       $districts = $so_activity->get_districts();
+                       $buildings = $so_arena->get_buildings();
+                       $arenas = $so_arena->get(null, null, 
'arena.arena_name', true, null, null, null);
+                       $organizations = 
activitycalendar_soorganization::get_instance()->get(null, null, 'org.name', 
true, null, null, null);
+                       $groups = 
activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, 
null, null);
+                       
+                       $g_id = phpgw::get_var('group_id');
+                       $o_id = phpgw::get_var('organization_id');
+                       
+                       $activity = new activitycalendar_activity();
+                       //... set all parameters
+                       $activity->set_title(phpgw::get_var('title'));
+                       $activity->set_organization_id($o_id);
+                       $activity->set_group_id($g_id);
+                       $activity->set_arena(phpgw::get_var('arena_id'));
+                       
$activity->set_internal_arena(phpgw::get_var('internal_arena_id'));
+                       $district_array = phpgw::get_var('district');
+                       $activity->set_district(implode(",", $district_array));
+                       $activity->set_office(phpgw::get_var('office'));
+                       $activity->set_state(1);
+                       $activity->set_category(phpgw::get_var('category'));
+                       $target_array = phpgw::get_var('target');
+                       $activity->set_target(implode(",", $target_array));
+                       $activity->set_description($desc);
+                       $activity->set_time(phpgw::get_var('time'));
+                       $activity->set_contact_persons($persons);
+                       
$activity->set_special_adaptation(phpgw::get_var('special_adaptation'));
+                       $activity->set_frontend(true);
+                       
+                       if(isset($g_id) && is_numeric($g_id) && $g_id > 0)
+                       {
+                               $persons = 
activitycalendar_sogroup::get_instance()->get_contacts($g_id);
+                               $desc = 
activitycalendar_sogroup::get_instance()->get_description($g_id);
+                       }
+                       else if(isset($o_id))
+                       {
+                               if($o_id == "new_org")
+                               {
+                                       $activity->set_new_org(true);
+                                       //add new organization to internal 
activitycalendar organization register
+                                       $org_info['name'] = 
phpgw::get_var('orgname');
+                                       $org_info['orgnr'] = 
phpgw::get_var('orgno');
+                                       $org_info['homepage'] = 
phpgw::get_var('homepage');
+                                       $org_info['phone'] = 
phpgw::get_var('phone');
+                                       $org_info['email'] = 
phpgw::get_var('email');
+                                       $org_info['description'] = 
phpgw::get_var('org_description');
+                                       $org_info['street'] = 
phpgw::get_var('address') . ' ' . phpgw::get_var('number') . ', ' . 
phpgw::get_var('postaddress');
+                                       //$org_info['zip'] = 
phpgw::get_var('postaddress');
+                                       $org_info['district'] = 
phpgw::get_var('org_district'); 
+                                       $org_info['status'] = "new";
+                                       $o_id = 
$so_activity->add_organization_local($org_info);
+                                       
+                                       //add contact persons
+                                       $contact1 = array();
+                                       $contact1['name'] = 
phpgw::get_var('contact1_name');
+                                       $contact1['phone'] = 
phpgw::get_var('contact1_phone');
+                                       $contact1['mail'] = 
phpgw::get_var('contact1_email');
+                                       $contact1['org_id'] = $o_id;
+                                       $contact1['group_id'] = 0;
+                                       
$so_activity->add_contact_person_local($contact1);
+                                       
+                                       $contact2 = array();
+                                       $contact2['name'] = 
phpgw::get_var('contact2_name');
+                                       $contact2['phone'] = 
phpgw::get_var('contact2_phone');
+                                       $contact2['mail'] = 
phpgw::get_var('contact2_email');
+                                       $contact2['org_id'] = $o_id;
+                                       $contact2['group_id'] = 0;
+                                       
$so_activity->add_contact_person_local($contact2);
+                                       
+                                       $persons = 
activitycalendar_soorganization::get_instance()->get_contacts_local($o_id);
+                                       $desc = 
phpgw::get_var('org_description');
+
+                               }
+                               else if($o_id == "change_org")
+                               {
+                                       $change_org_id = 
phpgw::get_var('change_organization_id');
+                                       $organization = 
activitycalendar_soorganization::get_instance()->get_single($change_org_id);
+                               
+                                       $org_info['name'] = 
$organization->get_name();
+                                       $org_info['orgnr'] = 
$organization->get_organization_number();
+                                       $org_info['homepage'] = 
$organization->get_homepage();
+                                       $org_info['phone'] = 
$organization->get_phone();
+                                       $org_info['email'] = 
$organization->get_email();
+                                       $org_info['description'] = 
$organization->get_description();
+                                       $org_info['street'] = 
$organization->get_address();
+                                       $org_info['district'] = 
$organization->get_district(); 
+                                       $org_info['status'] = "change";
+                                       $o_id = 
$so_activity->add_organization_local($org_info);
+                                       
+                                       //add contact persons
+                                       $contact1 = array();
+                                       $contact1['name'] = 
phpgw::get_var('contact1_name');
+                                       $contact1['phone'] = 
phpgw::get_var('contact1_phone');
+                                       $contact1['mail'] = 
phpgw::get_var('contact1_email');
+                                       $contact1['org_id'] = $o_id;
+                                       $contact1['group_id'] = 0;
+                                       
$so_activity->add_contact_person_local($contact1);
+                                       
+                                       $contact2 = array();
+                                       $contact2['name'] = 
phpgw::get_var('contact2_name');
+                                       $contact2['phone'] = 
phpgw::get_var('contact2_phone');
+                                       $contact2['mail'] = 
phpgw::get_var('contact2_email');
+                                       $contact2['org_id'] = $o_id;
+                                       $contact2['group_id'] = 0;
+                                       
$so_activity->add_contact_person_local($contact2);
+                                       
+                                       $message = lang('change_request_ok', 
$organization->get_name());
+                                       
+                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                       $this->render('activity_new.php', array
+                                               (
+                                                       'activity'      => 
$activity,
+                                                       'organizations' => 
$organizations,
+                                                       'groups' => $groups,
+                                                       'arenas' => $arenas,
+                                                       'buildings' => 
$buildings,
+                                                       'categories' => 
$categories,
+                                                       'targets' => $targets,
+                                                       'districts' => 
$districts,
+                                                       'offices' => $offices,
+                                                       'editable' => true,
+                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
+                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error')
+                                               )
+                       );
+                               }
+                               else if(is_numeric($o_id) && $o_id > 0)
+                               {
+                                       if(isset($g_id) && $g_id == "new_group")
+                                       {
+                                               $group_info['name'] = 
phpgw::get_var('groupname');
+                                               $group_info['organization_id'] 
= $o_id;
+                                               $group_info['description'] = 
phpgw::get_var('group_description');
+                                               $group_info['status'] = "new";
+                                               $g_id = 
$so_activity->add_group_local($group_info);
+                                               
+                                               //add contact persons
+                                               $contact1 = array();
+                                               $contact1['name'] = 
phpgw::get_var('contact1_name');
+                                               $contact1['phone'] = 
phpgw::get_var('contact1_phone');
+                                               $contact1['mail'] = 
phpgw::get_var('contact1_email');
+                                               $contact1['org_id'] = 0;
+                                               $contact1['group_id'] = $g_id;
+                                               
$so_activity->add_contact_person_local($contact1);
+                                               
+                                               $contact2 = array();
+                                               $contact2['name'] = 
phpgw::get_var('contact2_name');
+                                               $contact2['phone'] = 
phpgw::get_var('contact2_phone');
+                                               $contact2['mail'] = 
phpgw::get_var('contact2_email');
+                                               $contact2['org_id'] = 0;
+                                               $contact2['group_id'] = $g_id;
+                                               
$so_activity->add_contact_person_local($contact2);
+                                               
+                                               $activity_persons = 
activitycalendar_sogroup::get_instance()->get_contacts_local($g_id);
+                                               $desc = 
phpgw::get_var('group_description');
+                                       }
+                                       else
+                                       {
+                                               $persons = 
activitycalendar_soorganization::get_instance()->get_contacts($o_id);
+                                               $desc = 
activitycalendar_soorganization::get_instance()->get_description($o_id);
+                                       }
+                               }
+                       }
+                       
+                       if(isset($_POST['save_activity'])) // The user has 
pressed the save button
+                       {
+                               if(isset($activity)) // If an activity object 
is created
+                               {
+                                       $target_ok = false;
+                                       $district_ok = false;
+                                       if($activity->get_target() && 
$activity->get_target() != '')
+                                       {
+                                               $target_ok = true;
+                                       }
+                                       if($activity->get_district() && 
$activity->get_district() != '')
+                                       {
+                                               $district_ok = true;
+                                       }
+                                       
+                                       if($target_ok && $district_ok)
+                                       {
+                                               
+                                               
if($so_activity->store($activity)) // ... and then try to store the object
+                                               {
+                                                       $message = 
lang('messages_saved_form'); 
+                                               }
+                                               else
+                                               {
+                                                       $error = 
lang('messages_form_error');
+                                               }
+
+                                               
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+       
+                                               $this->render('activity.php', 
array
+                                                                       (
+                                                                               
'activity'      => $activity,
+                                                                               
'organizations' => $organizations,
+                                                                               
'groups' => $groups,
+                                                                               
'arenas' => $arenas,
+                                                                               
'buildings' => $buildings,
+                                                                               
'categories' => $categories,
+                                                                               
'targets' => $targets,
+                                                                               
'districts' => $districts,
+                                                                               
'offices' => $offices,
+                                                                               
'message' => isset($message) ? $message : phpgw::get_var('message'),
+                                                                               
'error' => isset($error) ? $error : phpgw::get_var('error')
+                                                                       )
+                                               );
+                                       }
+                                       else
+                                       {
+                                               if(!$target_ok)
+                                               {
+                                                       $error .= "<br/>" . 
lang('target_not_selected');
+                                               }
+                                               if(!$district_ok)
+                                               {
+                                                       $error .= "<br/>" . 
lang('district_not_selected');
+                                               }
+                                               return 
$this->render('activity_new.php', array
+                                                       (
+                                                               'activity'      
=> $activity,
+                                                               'organizations' 
=> $organizations,
+                                                               'org_name' => 
$org_name,
+                                                               'groups' => 
$groups,
+                                                               'arenas' => 
$arenas,
+                                                               'buildings' => 
$buildings,
+                                                               'categories' => 
$categories,
+                                                               'targets' => 
$targets,
+                                                               'districts' => 
$districts,
+                                                               'offices' => 
$offices,
+                                                               'editable' => 
true,
+                                                               'cancel_link' 
=> $cancel_link,
+                                                               'message' => 
isset($message) ? $message : phpgw::get_var('message'),
+                                                               'error' => 
isset($error) ? $error : phpgw::get_var('error')
+                                                       )       
+                                               );
+                                       }
+                               }
+                       }
+                       
+                       $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                       $this->render('activity_new.php', array
+                                               (
+                                                       'activity'      => 
$activity,
+                                                       'organizations' => 
$organizations,
+                                                       'groups' => $groups,
+                                                       'arenas' => $arenas,
+                                                       'buildings' => 
$buildings,
+                                                       'categories' => 
$categories,
+                                                       'targets' => $targets,
+                                                       'districts' => 
$districts,
+                                                       'offices' => $offices,
+                                                       'editable' => true,
+                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
+                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error')
+                                               )
+                       );
                }
                
                function view()
@@ -334,7 +602,7 @@
                                                {
                                                        $error .= "<br/>" . 
lang('district_not_selected');
                                                }
-                                               return 
$this->render('activity.php', array
+                                               return 
$this->render('activity_edit.php', array
                                                        (
                                                                'activity'      
=> $activity,
                                                                'organizations' 
=> $organizations,
@@ -358,7 +626,7 @@
                        
                        $GLOBALS['phpgw_info']['flags']['noframework'] = true;
 
-                       $this->render('activity.php', array
+                       $this->render('activity_edit.php', array
                                                (
                                                        'activity'      => 
$activity,
                                                        'organizations' => 
$organizations,

Modified: 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
    2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity.php
    2011-11-17 18:21:09 UTC (rev 8125)
@@ -5,160 +5,6 @@
        $contpers_so = activitycalendar_socontactperson::get_instance();
 ?>
 
-<script type="text/javascript">
-
-function get_available_groups()
-{
-       var org_id = document.getElementById('organization_id').value;
-       var div_select = document.getElementById('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 }?>
-
-       if(org_id != null && org_id == 'new_org')
-       {
-               //alert('new_org');
-               document.getElementById('new_org').style.display = "block";
-               document.getElementById('new_org_fields').style.display = 
"block";
-               document.getElementById('group_label').style.display = "none";
-               document.getElementById('group_select').style.display = "none";
-       }
-       else if(org_id != null && org_id == 'change_org')
-       {
-               document.getElementById('new_org').style.display = "block";
-               document.getElementById('new_org_fields').style.display = 
"none";
-               document.getElementById('change_org_fields').style.display = 
"block";
-               document.getElementById('group_label').style.display = "none";
-               document.getElementById('group_select').style.display = "none";
-       }
-       else
-       {
-               document.getElementById('new_org').style.display = "none";
-               document.getElementById('new_org_fields').style.display = 
"none";
-               document.getElementById('change_org_fields').style.display = 
"none";
-               var divcontent_start = "<select name=\"group_id\" 
id=\"group_id\" onchange=\"javascript:checkNewGroup()\">";
-               var divcontent_end = "</select>";
-               
-               var callback = {
-                       success: function(response){
-                                               div_select.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
-                                       },
-                       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();
-});
-
-function checkNewGroup()
-{
-       var group_selected = document.getElementById('group_id').value;
-       if(group_selected == 'new_group')
-       {
-               document.getElementById('new_group').style.display = "block";
-               document.getElementById('new_group_fields').style.display = 
"block";
-       }
-       else
-       {
-               document.getElementById('new_group').style.display = "none";
-               document.getElementById('new_group_fields').style.display = 
"none";
-       }
-}
-
-function get_address_search()
-{
-       var address = document.getElementById('address_txt').value;
-       var div_address = document.getElementById('address_container');
-
-       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
-
-var divcontent_start = "<select name=\"address\" id=\"address\" size\"5\">";
-var divcontent_end = "</select>";
-       
-       var callback = {
-               success: function(response){
-                                       div_address.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
-                               },
-               failure: function(o) {
-                                        alert("AJAX doesn't work"); //FAILURE
-                                }
-       }
-       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
-       
-}
-
-function get_address_search_cp2()
-{
-       var address = document.getElementById('contact2_address_txt').value;
-       var div_address = document.getElementById('contact2_address_container');
-
-       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
-
-var divcontent_start = "<select name=\"contact2_address\" id=\"address_cp2\" 
size\"5\">";
-var divcontent_end = "</select>";
-       
-       var callback = {
-               success: function(response){
-                                       div_address.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
-                               },
-               failure: function(o) {
-                                        alert("AJAX doesn't work"); //FAILURE
-                                }
-       }
-       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
-       
-}
-
-function allOK()
-{
-       if(document.getElementById('title').value == null || 
document.getElementById('title').value == '')
-       {
-               alert("Tittel må fylles ut!");
-               return false;
-       } 
-       if(document.getElementById('organization_id').value == null || 
document.getElementById('organization_id').value == '')
-       {
-               alert("Organisasjon må fylles ut!");
-               return false;
-       }
-       if(document.getElementById('internal_arena_id').value == null || 
document.getElementById('internal_arena_id').value == 0)
-       {
-               if(document.getElementById('arena_id').value == null || 
document.getElementById('arena_id').value == 0)
-               {
-                       alert("Arena må fylles ut!");
-                       return false;
-               }
-       }
-       if(document.getElementById('time').value == null || 
document.getElementById('time').value == '')
-       {
-               alert("Tid må fylles ut!");
-               return false;
-       }
-       if(document.getElementById('category').value == null || 
document.getElementById('category').value == 0)
-       {
-               alert("Kategori må fylles ut!");
-               return false;
-       }
-       if(document.getElementById('office').value == null || 
document.getElementById('office').value == 0)
-       {
-               alert("Hovedansvarlig kulturkontor må fylles ut!");
-               return false;
-       }
-       else
-               return true;
-}
-
-</script>
-
 <div class="yui-content" style="width: 100%;">
        <div id="details">
        
@@ -177,330 +23,72 @@
                        <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
                        <dl class="proplist-col" style="width: 60%">
                                <dt>
-                                       <?php if($activity->get_title() || 
$editable) { ?>
                                        <label for="title"><?php echo 
lang('title') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
-                                       <?php
-                                       if ($editable)
-                                       {
-                                       ?>
-                                               <?php echo 
lang('title_helptext')?><br/>
-                                               <input type="text" name="title" 
id="title" value="<?php echo $activity->get_title() ?>" size="60"/>
-                                       <?php
-                                       }
-                                       else
-                                       {
-                                               echo $activity->get_title();
-                                       }
-                                       ?>
+                                       <?php echo $activity->get_title();?>
                                </dd>
                                <dt>
-                                       <?php 
if($activity->get_organization_id() || $editable) { ?>
                                        <label for="organization_id"><?php echo 
lang('organization') ?></label>
-                                       <?php } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_organization_id = 
$activity->get_organization_id();
-                                       if ($editable)
-                                       {
-                                               ?>
-                                               <?php echo 
lang('org_helptext')?><br/>
-                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
-                                                       <option value="">Ingen 
organisasjon valgt</option>
-                                                       <option 
value="new_org">Ny organisasjon</option>
-                                                       <option 
value="change_org">Endre organisasjon</option>
-                                                       <?php
-                                                       foreach($organizations 
as $organization)
-                                                       {
-                                                               echo "<option 
".($current_organization_id == $organization->get_id() ? 'selected="selected"' 
: "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                               <?php
-                                       ?>
-                                       <?php
+                                       if($activity->get_organization_id()){
+                                               echo 
activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
                                        }
-                                       else
-                                       {
-                                               
if($activity->get_organization_id()){
-                                                       echo 
activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
-                                               }
-                                       }
                                        ?>
                                </dd>
-                               <div id="new_org" style="display: none;">
-                                       <hr/>
-                                       <div id="change_org_fields" 
style="display: none;">
-                                               <select 
name="change_organization_id" id="change_organization_id" >
-                                                       <option value="">Ingen 
organisasjon valgt</option>
-                                                       <?php
-                                                       foreach($organizations 
as $organization)
-                                                       {
-                                                               echo "<option 
".($current_organization_id == $organization->get_id() ? 'selected="selected"' 
: "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                       </div>
-                                       <div id="new_org_fields" 
style="display: none;">
-                                               <label 
for="orgname">Organisasjonsnavn</label>
-                                               <input type="text" 
name="orgname"/><br/>
-                                               <label 
for="orgno">Organisasjonsnummer</label>
-                                               <input type="text" 
name="orgno"/><br/>
-                                               <label 
for="district">Bydel</label>
-                                                       <select 
name="org_district">
-                                                               <option 
value="0">Ingen bydel valgt</option>
-                                               <?php 
-                                               foreach($districts as $d)
-                                               {
-                                               ?>
-                                                       <option value="<?php 
echo $d['part_of_town_id']?>"><?php echo $d['name']?></option>
-                                               <?php
-                                               }?>
-                                                       </select><br/>
-                                               <label 
for="homepage">Hjemmeside</label>
-                                               <input type="text" 
name="homepage"/><br/>
-                                               <label 
for="email">E-post</label>
-                                               <input type="text" 
name="email"/><br/>
-                                               <label 
for="phone">Telefon</label>
-                                               <input type="text" 
name="phone"/><br/>
-                                               <label for="street">Gate</label>
-                                               <input type="text" 
name="address_txt" id="address_txt" onkeyup="javascript:get_address_search()"/>
-                                               <div 
id="address_container"></div><br/>
-                                               <label 
for="number">Nummer</label>
-                                               <input type="text" 
name="number"/><br/>
-                                               <label 
for="postaddress">Postnummer og Sted</label>
-                                               <input type="text" 
name="postaddress"/>
-                                               <label 
for="org_description">Beskrivelse</label>
-                                               <textarea rows="10" cols="100" 
name="org_description"></textarea>
-                                       </div>
-                                       <hr/>
-                                       <b>Kontaktperson 1</b><br/>
-                                       <label for="contact1_name">Navn</label>
-                                       <input type="text" 
name="contact1_name"/><br/>
-                                       <label 
for="contact1_phone">Telefon</label>
-                                       <input type="text" 
name="contact1_phone"/><br/>
-                                       <label 
for="contact1_mail">E-post</label>
-                                       <input type="text" 
name="contact1_mail"/><br/>
-                                       <b>Kontaktperson 2</b><br/>
-                                       <label for="contact2_name">Navn</label>
-                                       <input type="text" 
name="contact2_name"/><br/>
-                                       <label 
for="contact2_phone">Telefon</label>
-                                       <input type="text" 
name="contact2_phone"/><br/>
-                                       <label 
for="contact2_mail">E-post</label>
-                                       <input type="text" 
name="contact2_mail"/><br/>
-                                       <label 
for="contact2_address">Adresse</label>
-                                       <input type="text" 
name="contact2_address_txt" id="contact2_address_txt" 
onkeyup="javascript:get_address_search_cp2()"/>
-                                       <div 
id="contact2_address_container"></div><br/>
-                                       <label 
for="contact2_number">Nummer</label>
-                                       <input type="text" 
name="contact2_number"/><br/>
-                                       <label 
for="contact2_postaddress">Postnummer og Sted</label>
-                                       <input type="text" 
name="contact2_postaddress"/>
-                                       <hr/>
-                               </div>
                                <dt>
-                                       <?php if($activity->get_group_id() || 
$editable) { ?>
                                        <label for="group_id" 
id="group_label"><?php echo lang('group') ?></label>
-                                       <?php } ?>
                                </dt>
                                <dd>
-                                       <?php
-                                       $current_group_id = 
$activity->get_group_id();
-                                       if ($editable)
-                                       {
-                                               ?>
-                                               <?php echo 
lang('group_helptext')?><br/>
-                                               <div id="group_select">
-                                                       <select name="group_id" 
id="group_id">
-                                                               <option 
value="0">Ingen gruppe valgt</option>
-                                                       </select>
-                                               </div>
-                                               <?php
-                                       ?>
-                                       <?php
+                                       <?php 
+                                       if($activity->get_group_id()){
+                                               echo 
activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id());
                                        }
-                                       else
-                                       {
-                                               if($activity->get_group_id()){
-                                                       echo 
activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id());
-                                               }
-                                       }
                                        ?>
                                </dd>
-                               <div id="new_group" style="display: none;">
-                                       <hr/>
-                                       <div id="new_group_fields" 
style="display: none;">
-                                               <label 
for="groupname">Gruppenavn</label>
-                                               <input type="text" 
name="groupname"/><br/>
-                                               <label 
for="group_description">Beskrivelse</label>
-                                               <textarea rows="10" cols="100" 
name="group_description"></textarea>
-                                       </div>
-                                       <hr/>
-                                       <b>Kontaktperson 1</b><br/>
-                                       <label for="contact1_name">Navn</label>
-                                       <input type="text" 
name="contact1_name"/><br/>
-                                       <label 
for="contact1_phone">Telefon</label>
-                                       <input type="text" 
name="contact1_phone"/><br/>
-                                       <label 
for="contact1_mail">E-post</label>
-                                       <input type="text" 
name="contact1_mail"/><br/>
-                                       <b>Kontaktperson 2</b><br/>
-                                       <label for="contact2_name">Navn</label>
-                                       <input type="text" 
name="contact2_name"/><br/>
-                                       <label 
for="contact2_phone">Telefon</label>
-                                       <input type="text" 
name="contact2_phone"/><br/>
-                                       <label 
for="contact2_mail">E-post</label>
-                                       <input type="text" 
name="contact2_mail"/><br/>
-                                       <label 
for="contact2_address">Adresse</label>
-                                       <input type="text" 
name="contact2_address_txt" id="contact2_address_txt" 
onkeyup="javascript:get_address_search_cp2()"/>
-                                       <div 
id="contact2_address_container"></div><br/>
-                                       <label 
for="contact2_number">Nummer</label>
-                                       <input type="text" 
name="contact2_number"/><br/>
-                                       <label 
for="contact2_postaddress">Postnummer / Sted</label>
-                                       <input type="text" 
name="contact2_postaddress"/>
-                                       <hr/>
-                               </div>
                                <dt>
-                                       <?php 
if($activity->get_internal_arena() || $editable) { ?>
+                                       <?php 
if($activity->get_internal_arena()) { ?>
                                        <label for="arena"><?php echo 
lang('building') ?></label>
-                                       <?php  } ?>
+                                       <?php }?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_internal_arena_id = 
$activity->get_internal_arena();
-                                       if ($editable)
-                                       {
-                                               ?>
-                                               <?php echo 
lang('int_arena_helptext')?><br/>
-                                               <select 
name="internal_arena_id" id="internal_arena_id">
-                                                       <option value="0">Ingen 
kommunale bygg valgt</option>
-                                                       <?php
-                                                       foreach($buildings as 
$building_id => $building_name)
-                                                       {
-                                                               echo "<option 
".($current_internal_arena_id == $building_id? 'selected="selected"' : "")." 
value=\"{$building_id}\">".$building_name."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                               <?php
-                                       }
-                                       else
-                                       {
-                                               if($activity->get_arena()){
+                                               
if($activity->get_internal_arena()){
                                                        echo 
activitycalendar_soarena::get_instance()->get_building_name($activity->get_internal_arena());
                                                }
-                                       }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_arena() || 
$editable) { ?>
+                                       <?php if($activity->get_arena()) { ?>
                                        <label for="arena"><?php echo 
lang('arena') ?></label>
                                        <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_arena_id = 
$activity->get_arena();
-                                       if ($editable)
-                                       {
-                                               ?>
-                                               <?php echo 
lang('arena_helptext')?><br/>
-                                               <select name="arena_id" 
id="arena_id" style="width: 60%">
-                                                       <option value="0">Ingen 
arena valgt</option>
-                                                       <?php
-                                                       foreach($arenas as 
$arena)
-                                                       {
-                                                               echo "<option 
".($current_arena_id == $arena->get_id() ? 'selected="selected"' : "")." 
value=\"{$arena->get_id()}\">".$arena->get_arena_name()."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                               <?php
-                                       }
-                                       else
-                                       {
                                                if($activity->get_arena()){
                                                        echo 
activitycalendar_soarena::get_instance()->get_arena_name($activity->get_arena());
                                                }
-                                       }
                                        ?>
                                </dd>
-                               <dt>
-                                       <?php if($activity->get_state() || 
$editable) { ?>
-                                       <label for="state"><?php echo 
lang('state') ?></label>
-                                       <?php  } ?>
-                               </dt>
-                               <dd>
-                                       <?php
-                                       if ($editable)
-                                       {
-                                               $selected_state = 
$activity->get_state();
-                                       ?>
-                                               <select name="state">
-                                                       <option value="1" <?php 
echo ($selected_state == 1 ? 'selected="selected"' : "")?>><?php echo 
lang('new') ?></option>
-                                                       <option value="2" <?php 
echo ($selected_state == 2 ? 'selected="selected"' : "")?>><?php echo 
lang('change') ?></option>
-                                               </select>
-                                       <?php
-                                       }
-                                       else
-                                       {
-                                               if($activity->get_state() && 
$activity->get_state() > 0){
-                                                       echo 
lang('state_'.$activity->get_state());
-                                               }
-                                       }
-                                       ?>
-                               </dd>
                        </dl>
                        <dl class="proplist-col">
                                <dt>
-                                       <?php if($activity->get_category() || 
$editable) { ?>
                                        <label for="category"><?php echo 
lang('category') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_category_id = 
$activity->get_category();
-                                       if ($editable)
-                                       {
-                                               ?>
-                                               <select name="category" 
id="category">
-                                                       <option value="0">Ingen 
kategori valgt</option>
-                                                       <?php
-                                                       foreach($categories as 
$category)
-                                                       {
-                                                               echo "<option 
".($current_category_id == $category->get_id() ? 'selected="selected"' : "")." 
value=\"{$category->get_id()}\">".$category->get_name()."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                               <?php
-                                       }
-                                       else
-                                       {
                                                if($activity->get_category()){
                                                        echo 
$act_so->get_category_name($activity->get_category());
                                                }
-                                       }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_target() || 
$editable) { ?>
                                        <label for="target"><?php echo 
lang('target') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_target_ids = 
$activity->get_target();
-                                       $current_target_id_array=explode(",", 
$current_target_ids);
-                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
-                                       if ($editable)
-                                       {
-                                               foreach($targets as $t)
-                                               {
-                                               ?>
-                                                       <input name="target[]" 
type="checkbox" value="<?php echo $t->get_id()?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "")?>/><?php 
echo $t->get_name()?><br/>
-                                               <?php
-                                               }
-                                       }
-                                       else
-                                       {
                                                if($activity->get_target()){
                                                        $current_target_ids = 
$activity->get_target();
                                                        
$current_target_id_array=explode(",", $current_target_ids);
@@ -509,100 +97,47 @@
                                                                echo 
$act_so->get_target_name($curr_target).'<br/>';
                                                        }
                                                }
-                                       }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_office() || 
$editable) { ?>
                                        <label for="office"><?php echo 
lang('office') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       if ($editable)
-                                       {
-                                               $selected_office = 
$activity->get_office();
-                                       ?>
-                                               <select name="office" 
id="office">
-                                                       <option value="0">Ingen 
kontor valgt</option>
-                                                       <?php
-                                                       foreach($offices as 
$office)
-                                                       {
-                                                               echo "<option 
".($selected_office == $office['id'] ? 'selected="selected"' : "")." 
value=\"{$office['id']}\">".$office['name']."</option>";
-                                                       }
-                                                       ?>
-                                               </select>
-                                       <?php
-                                       }
-                                       else
-                                       {
                                                if($activity->get_office()){
                                                        echo 
$act_so->get_office_name($activity->get_office());
                                                }
-                                       }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_district() || 
$editable) { ?>
                                        <label for="district"><?php echo 
lang('district') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php
-                                       $current_district_ids = 
$activity->get_district();
-                                       $current_district_id_array=explode(",", 
$current_district_ids);
-                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
-                                       if ($editable)
-                                       {
-                                               foreach($districts as $d)
+                                       if($activity->get_district()){
+                                               $current_district_ids = 
$activity->get_district();
+                                               
$current_district_id_array=explode(",", $current_district_ids);
+                                               
foreach($current_district_id_array as $curr_district)
                                                {
-                                               ?>
-                                                       <input 
name="district[]" type="checkbox" value="<?php echo $d['part_of_town_id']?>" 
<?php echo (in_array($d['part_of_town_id'], $current_district_id_array) ? 
'checked' : "")?>/><?php echo $d['name']?><br/>
-                                               <?php
+                                                       echo 
$act_so->get_district_name($curr_district).'<br/>';
                                                }
                                        }
-                                       else
-                                       {
-                                               if($activity->get_district()){
-                                                       $current_district_ids = 
$activity->get_district();
-                                                       
$current_district_id_array=explode(",", $current_district_ids);
-                                                       
foreach($current_district_id_array as $curr_district)
-                                                       {
-                                                               echo 
$act_so->get_district_name($curr_district).'<br/>';
-                                                       }
-                                               }
-                                       }
                                        ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_description()) 
{ ?>
                                        <label for="description"><?php echo 
lang('description') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
                                        <?php echo 
$activity->get_description(); ?>
                                </dd>
                                <dt>
-                                       <?php if($activity->get_time() || 
$editable) { ?>
                                        <label for="time"><?php echo 
lang('time') ?></label>
-                                       <?php  } ?>
                                </dt>
                                <dd>
-                                       <?php
-                                       if ($editable)
-                                       {
-                                       ?>
-                                               <input type="text" name="time" 
id="time" value="<?php echo $activity->get_time() ?>" />
-                                       <?php
-                                       }
-                                       else
-                                       {
-                                               echo $activity->get_time();
-                                       }
-                                       ?>
+                                       <?php echo $activity->get_time();?>
                                </dd>
                                <dt>
-                                       <?php 
if($activity->get_contact_person_1() || $editable) { ?>
+                                       <?php 
if($activity->get_contact_person_1()) { ?>
                                        <label for="contact_person_1"><?php 
echo lang('contact_person_1') ?></label>
                                        <?php  } ?>
                                </dt>
@@ -619,7 +154,7 @@
                                        ?>
                                </dd>
                                <dt>
-                                       <?php 
if($activity->get_contact_person_2() || $editable) { ?>
+                                       <?php 
if($activity->get_contact_person_2()) { ?>
                                        <label for="contact_person_2"><?php 
echo lang('contact_person_2') ?></label>
                                        <?php  } ?>
                                </dt>
@@ -639,7 +174,7 @@
                                        <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
                                </dt>
                                <dd>
-                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> <?php echo 
!$editable ? ' disabled="disabled"' : '' ?>/>
+                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> 
disabled="disabled" />
                                </dd>
                        </dl>
                        <div class="form-buttons">

Copied: 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_edit.php
 (from rev 8124, 
trunk/activitycalendarfrontend/templates/base/activity_edit.php)
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_edit.php
                               (rev 0)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_edit.php
       2011-11-17 18:21:09 UTC (rev 8125)
@@ -0,0 +1,656 @@
+<?php
+       //include common logic for all templates
+//     include("common.php");
+       $act_so = activitycalendar_soactivity::get_instance();
+       $contpers_so = activitycalendar_socontactperson::get_instance();
+?>
+
+<script type="text/javascript">
+
+function get_available_groups()
+{
+       var org_id = document.getElementById('organization_id').value;
+       var div_select = document.getElementById('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 }?>
+
+       if(org_id != null && org_id == 'new_org')
+       {
+               //alert('new_org');
+               document.getElementById('new_org').style.display = "block";
+               document.getElementById('new_org_fields').style.display = 
"block";
+               document.getElementById('group_label').style.display = "none";
+               document.getElementById('group_select').style.display = "none";
+       }
+       else if(org_id != null && org_id == 'change_org')
+       {
+               document.getElementById('new_org').style.display = "block";
+               document.getElementById('new_org_fields').style.display = 
"none";
+               document.getElementById('change_org_fields').style.display = 
"block";
+               document.getElementById('group_label').style.display = "none";
+               document.getElementById('group_select').style.display = "none";
+       }
+       else
+       {
+               document.getElementById('new_org').style.display = "none";
+               document.getElementById('new_org_fields').style.display = 
"none";
+               document.getElementById('change_org_fields').style.display = 
"none";
+               var divcontent_start = "<select name=\"group_id\" 
id=\"group_id\" onchange=\"javascript:checkNewGroup()\">";
+               var divcontent_end = "</select>";
+               
+               var callback = {
+                       success: function(response){
+                                               div_select.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
+                                       },
+                       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();
+});
+
+function checkNewGroup()
+{
+       var group_selected = document.getElementById('group_id').value;
+       if(group_selected == 'new_group')
+       {
+               document.getElementById('new_group').style.display = "block";
+               document.getElementById('new_group_fields').style.display = 
"block";
+       }
+       else
+       {
+               document.getElementById('new_group').style.display = "none";
+               document.getElementById('new_group_fields').style.display = 
"none";
+       }
+}
+
+function get_address_search()
+{
+       var address = document.getElementById('address_txt').value;
+       var div_address = document.getElementById('address_container');
+
+       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
+
+var divcontent_start = "<select name=\"address\" id=\"address\" size\"5\">";
+var divcontent_end = "</select>";
+       
+       var callback = {
+               success: function(response){
+                                       div_address.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+function get_address_search_cp2()
+{
+       var address = document.getElementById('contact2_address_txt').value;
+       var div_address = document.getElementById('contact2_address_container');
+
+       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
+
+var divcontent_start = "<select name=\"contact2_address\" id=\"address_cp2\" 
size\"5\">";
+var divcontent_end = "</select>";
+       
+       var callback = {
+               success: function(response){
+                                       div_address.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+function allOK()
+{
+       if(document.getElementById('title').value == null || 
document.getElementById('title').value == '')
+       {
+               alert("Tittel må fylles ut!");
+               return false;
+       } 
+       if(document.getElementById('organization_id').value == null || 
document.getElementById('organization_id').value == '')
+       {
+               alert("Organisasjon må fylles ut!");
+               return false;
+       }
+       if(document.getElementById('internal_arena_id').value == null || 
document.getElementById('internal_arena_id').value == 0)
+       {
+               if(document.getElementById('arena_id').value == null || 
document.getElementById('arena_id').value == 0)
+               {
+                       alert("Arena må fylles ut!");
+                       return false;
+               }
+       }
+       if(document.getElementById('time').value == null || 
document.getElementById('time').value == '')
+       {
+               alert("Tid må fylles ut!");
+               return false;
+       }
+       if(document.getElementById('category').value == null || 
document.getElementById('category').value == 0)
+       {
+               alert("Kategori må fylles ut!");
+               return false;
+       }
+       if(document.getElementById('office').value == null || 
document.getElementById('office').value == 0)
+       {
+               alert("Hovedansvarlig kulturkontor må fylles ut!");
+               return false;
+       }
+       else
+               return true;
+}
+
+</script>
+
+<div class="yui-content" style="width: 100%;">
+       <div id="details">
+       
+       <?php if($message){?>
+       <div class="success">
+               <?php echo $message;?>
+       </div>
+       <?php }else if($error){?>
+       <div class="error">
+               <?php echo $error;?>
+       </div>
+       <?php }?>
+       </div>
+               <h1><?php echo lang('activity') ?></h1>
+               <form action="#" method="post">
+                       <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
+                       <dl class="proplist-col" style="width: 60%">
+                               <dt>
+                                       <?php if($activity->get_title() || 
$editable) { ?>
+                                       <label for="title"><?php echo 
lang('title') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                       ?>
+                                               <?php echo 
lang('title_helptext')?><br/>
+                                               <input type="text" name="title" 
id="title" value="<?php echo $activity->get_title() ?>" size="60"/>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               echo $activity->get_title();
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php 
if($activity->get_organization_id() || $editable) { ?>
+                                       <label for="organization_id"><?php echo 
lang('organization') ?></label>
+                                       <?php } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_organization_id = 
$activity->get_organization_id();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('org_helptext')?><br/>
+                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
+                                                       <option value="">Ingen 
organisasjon valgt</option>
+                                                       <option 
value="new_org">Ny organisasjon</option>
+                                                       <option 
value="change_org">Endre organisasjon</option>
+                                                       <?php
+                                                       foreach($organizations 
as $organization)
+                                                       {
+                                                               echo "<option 
".($current_organization_id == $organization->get_id() ? 'selected="selected"' 
: "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       ?>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               
if($activity->get_organization_id()){
+                                                       echo 
activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <div id="new_org" style="display: none;">
+                                       <hr/>
+                                       <div id="change_org_fields" 
style="display: none;">
+                                               <select 
name="change_organization_id" id="change_organization_id" >
+                                                       <option value="">Ingen 
organisasjon valgt</option>
+                                                       <?php
+                                                       foreach($organizations 
as $organization)
+                                                       {
+                                                               echo "<option 
".($current_organization_id == $organization->get_id() ? 'selected="selected"' 
: "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                       </div>
+                                       <div id="new_org_fields" 
style="display: none;">
+                                               <label 
for="orgname">Organisasjonsnavn</label>
+                                               <input type="text" 
name="orgname"/><br/>
+                                               <label 
for="orgno">Organisasjonsnummer</label>
+                                               <input type="text" 
name="orgno"/><br/>
+                                               <label 
for="district">Bydel</label>
+                                                       <select 
name="org_district">
+                                                               <option 
value="0">Ingen bydel valgt</option>
+                                               <?php 
+                                               foreach($districts as $d)
+                                               {
+                                               ?>
+                                                       <option value="<?php 
echo $d['part_of_town_id']?>"><?php echo $d['name']?></option>
+                                               <?php
+                                               }?>
+                                                       </select><br/>
+                                               <label 
for="homepage">Hjemmeside</label>
+                                               <input type="text" 
name="homepage"/><br/>
+                                               <label 
for="email">E-post</label>
+                                               <input type="text" 
name="email"/><br/>
+                                               <label 
for="phone">Telefon</label>
+                                               <input type="text" 
name="phone"/><br/>
+                                               <label for="street">Gate</label>
+                                               <input type="text" 
name="address_txt" id="address_txt" onkeyup="javascript:get_address_search()"/>
+                                               <div 
id="address_container"></div><br/>
+                                               <label 
for="number">Nummer</label>
+                                               <input type="text" 
name="number"/><br/>
+                                               <label 
for="postaddress">Postnummer og Sted</label>
+                                               <input type="text" 
name="postaddress"/>
+                                               <label 
for="org_description">Beskrivelse</label>
+                                               <textarea rows="10" cols="100" 
name="org_description"></textarea>
+                                       </div>
+                                       <hr/>
+                                       <b>Kontaktperson 1</b><br/>
+                                       <label for="contact1_name">Navn</label>
+                                       <input type="text" 
name="contact1_name"/><br/>
+                                       <label 
for="contact1_phone">Telefon</label>
+                                       <input type="text" 
name="contact1_phone"/><br/>
+                                       <label 
for="contact1_mail">E-post</label>
+                                       <input type="text" 
name="contact1_mail"/><br/>
+                                       <b>Kontaktperson 2</b><br/>
+                                       <label for="contact2_name">Navn</label>
+                                       <input type="text" 
name="contact2_name"/><br/>
+                                       <label 
for="contact2_phone">Telefon</label>
+                                       <input type="text" 
name="contact2_phone"/><br/>
+                                       <label 
for="contact2_mail">E-post</label>
+                                       <input type="text" 
name="contact2_mail"/><br/>
+                                       <label 
for="contact2_address">Adresse</label>
+                                       <input type="text" 
name="contact2_address_txt" id="contact2_address_txt" 
onkeyup="javascript:get_address_search_cp2()"/>
+                                       <div 
id="contact2_address_container"></div><br/>
+                                       <label 
for="contact2_number">Nummer</label>
+                                       <input type="text" 
name="contact2_number"/><br/>
+                                       <label 
for="contact2_postaddress">Postnummer og Sted</label>
+                                       <input type="text" 
name="contact2_postaddress"/>
+                                       <hr/>
+                               </div>
+                               <dt>
+                                       <?php if($activity->get_group_id() || 
$editable) { ?>
+                                       <label for="group_id" 
id="group_label"><?php echo lang('group') ?></label>
+                                       <?php } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_group_id = 
$activity->get_group_id();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('group_helptext')?><br/>
+                                               <div id="group_select">
+                                                       <select name="group_id" 
id="group_id">
+                                                               <option 
value="0">Ingen gruppe valgt</option>
+                                                       </select>
+                                               </div>
+                                               <?php
+                                       ?>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_group_id()){
+                                                       echo 
activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <div id="new_group" style="display: none;">
+                                       <hr/>
+                                       <div id="new_group_fields" 
style="display: none;">
+                                               <label 
for="groupname">Gruppenavn</label>
+                                               <input type="text" 
name="groupname"/><br/>
+                                               <label 
for="group_description">Beskrivelse</label>
+                                               <textarea rows="10" cols="100" 
name="group_description"></textarea>
+                                       </div>
+                                       <hr/>
+                                       <b>Kontaktperson 1</b><br/>
+                                       <label for="contact1_name">Navn</label>
+                                       <input type="text" 
name="contact1_name"/><br/>
+                                       <label 
for="contact1_phone">Telefon</label>
+                                       <input type="text" 
name="contact1_phone"/><br/>
+                                       <label 
for="contact1_mail">E-post</label>
+                                       <input type="text" 
name="contact1_mail"/><br/>
+                                       <b>Kontaktperson 2</b><br/>
+                                       <label for="contact2_name">Navn</label>
+                                       <input type="text" 
name="contact2_name"/><br/>
+                                       <label 
for="contact2_phone">Telefon</label>
+                                       <input type="text" 
name="contact2_phone"/><br/>
+                                       <label 
for="contact2_mail">E-post</label>
+                                       <input type="text" 
name="contact2_mail"/><br/>
+                                       <label 
for="contact2_address">Adresse</label>
+                                       <input type="text" 
name="contact2_address_txt" id="contact2_address_txt" 
onkeyup="javascript:get_address_search_cp2()"/>
+                                       <div 
id="contact2_address_container"></div><br/>
+                                       <label 
for="contact2_number">Nummer</label>
+                                       <input type="text" 
name="contact2_number"/><br/>
+                                       <label 
for="contact2_postaddress">Postnummer / Sted</label>
+                                       <input type="text" 
name="contact2_postaddress"/>
+                                       <hr/>
+                               </div>
+                               <dt>
+                                       <?php 
if($activity->get_internal_arena() || $editable) { ?>
+                                       <label for="arena"><?php echo 
lang('building') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_internal_arena_id = 
$activity->get_internal_arena();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('int_arena_helptext')?><br/>
+                                               <select 
name="internal_arena_id" id="internal_arena_id">
+                                                       <option value="0">Ingen 
kommunale bygg valgt</option>
+                                                       <?php
+                                                       foreach($buildings as 
$building_id => $building_name)
+                                                       {
+                                                               echo "<option 
".($current_internal_arena_id == $building_id? 'selected="selected"' : "")." 
value=\"{$building_id}\">".$building_name."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_arena()){
+                                                       echo 
activitycalendar_soarena::get_instance()->get_building_name($activity->get_internal_arena());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_arena() || 
$editable) { ?>
+                                       <label for="arena"><?php echo 
lang('arena') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_arena_id = 
$activity->get_arena();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('arena_helptext')?><br/>
+                                               <select name="arena_id" 
id="arena_id" style="width: 60%">
+                                                       <option value="0">Ingen 
arena valgt</option>
+                                                       <?php
+                                                       foreach($arenas as 
$arena)
+                                                       {
+                                                               echo "<option 
".($current_arena_id == $arena->get_id() ? 'selected="selected"' : "")." 
value=\"{$arena->get_id()}\">".$arena->get_arena_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_arena()){
+                                                       echo 
activitycalendar_soarena::get_instance()->get_arena_name($activity->get_arena());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_state() || 
$editable) { ?>
+                                       <label for="state"><?php echo 
lang('state') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                               $selected_state = 
$activity->get_state();
+                                       ?>
+                                               <select name="state">
+                                                       <option value="1" <?php 
echo ($selected_state == 1 ? 'selected="selected"' : "")?>><?php echo 
lang('new') ?></option>
+                                                       <option value="2" <?php 
echo ($selected_state == 2 ? 'selected="selected"' : "")?>><?php echo 
lang('change') ?></option>
+                                               </select>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_state() && 
$activity->get_state() > 0){
+                                                       echo 
lang('state_'.$activity->get_state());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                       </dl>
+                       <dl class="proplist-col">
+                               <dt>
+                                       <?php if($activity->get_category() || 
$editable) { ?>
+                                       <label for="category"><?php echo 
lang('category') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_category_id = 
$activity->get_category();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <select name="category" 
id="category">
+                                                       <option value="0">Ingen 
kategori valgt</option>
+                                                       <?php
+                                                       foreach($categories as 
$category)
+                                                       {
+                                                               echo "<option 
".($current_category_id == $category->get_id() ? 'selected="selected"' : "")." 
value=\"{$category->get_id()}\">".$category->get_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_category()){
+                                                       echo 
$act_so->get_category_name($activity->get_category());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_target() || 
$editable) { ?>
+                                       <label for="target"><?php echo 
lang('target') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_target_ids = 
$activity->get_target();
+                                       $current_target_id_array=explode(",", 
$current_target_ids);
+                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       if ($editable)
+                                       {
+                                               foreach($targets as $t)
+                                               {
+                                               ?>
+                                                       <input name="target[]" 
type="checkbox" value="<?php echo $t->get_id()?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "")?>/><?php 
echo $t->get_name()?><br/>
+                                               <?php
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_target()){
+                                                       $current_target_ids = 
$activity->get_target();
+                                                       
$current_target_id_array=explode(",", $current_target_ids);
+                                                       
foreach($current_target_id_array as $curr_target)
+                                                       {
+                                                               echo 
$act_so->get_target_name($curr_target).'<br/>';
+                                                       }
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_office() || 
$editable) { ?>
+                                       <label for="office"><?php echo 
lang('office') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                               $selected_office = 
$activity->get_office();
+                                       ?>
+                                               <select name="office" 
id="office">
+                                                       <option value="0">Ingen 
kontor valgt</option>
+                                                       <?php
+                                                       foreach($offices as 
$office)
+                                                       {
+                                                               echo "<option 
".($selected_office == $office['id'] ? 'selected="selected"' : "")." 
value=\"{$office['id']}\">".$office['name']."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_office()){
+                                                       echo 
$act_so->get_office_name($activity->get_office());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_district() || 
$editable) { ?>
+                                       <label for="district"><?php echo 
lang('district') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_district_ids = 
$activity->get_district();
+                                       $current_district_id_array=explode(",", 
$current_district_ids);
+                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       if ($editable)
+                                       {
+                                               foreach($districts as $d)
+                                               {
+                                               ?>
+                                                       <input 
name="district[]" type="checkbox" value="<?php echo $d['part_of_town_id']?>" 
<?php echo (in_array($d['part_of_town_id'], $current_district_id_array) ? 
'checked' : "")?>/><?php echo $d['name']?><br/>
+                                               <?php
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_district()){
+                                                       $current_district_ids = 
$activity->get_district();
+                                                       
$current_district_id_array=explode(",", $current_district_ids);
+                                                       
foreach($current_district_id_array as $curr_district)
+                                                       {
+                                                               echo 
$act_so->get_district_name($curr_district).'<br/>';
+                                                       }
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_description()) 
{ ?>
+                                       <label for="description"><?php echo 
lang('description') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php echo 
$activity->get_description(); ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_time() || 
$editable) { ?>
+                                       <label for="time"><?php echo 
lang('time') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                       ?>
+                                               <input type="text" name="time" 
id="time" value="<?php echo $activity->get_time() ?>" />
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               echo $activity->get_time();
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php 
if($activity->get_contact_person_1() || $editable) { ?>
+                                       <label for="contact_person_1"><?php 
echo lang('contact_person_1') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                               if($activity->get_group_id())
+                                               {
+                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_1());
+                                               }
+                                               else 
if($activity->get_organization_id())
+                                               {
+                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_1());
+                                               }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php 
if($activity->get_contact_person_2() || $editable) { ?>
+                                       <label for="contact_person_2"><?php 
echo lang('contact_person_2') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                               if($activity->get_group_id())
+                                               {
+                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_2());
+                                               }
+                                               else 
if($activity->get_organization_id())
+                                               {
+                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_2());
+                                               }
+                                       ?>
+                               </dd>
+                           <dt>
+                                       <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
+                               </dt>
+                               <dd>
+                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> <?php echo 
!$editable ? ' disabled="disabled"' : '' ?>/>
+                               </dd>
+                       </dl>
+                       <div class="form-buttons">
+                               <?php
+                                       if ($editable) {
+                                               echo '<input type="submit" 
name="save_activity" value="' . lang('save') . '" onclick="return allOK();"/>';
+                                       }
+                               ?>
+                       </div>
+                       
+               </form>
+               
+       </div>
+</div>
\ No newline at end of file

Copied: 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
 (from rev 8124, trunk/activitycalendarfrontend/templates/base/activity_new.php)
===================================================================
--- 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
                                (rev 0)
+++ 
branches/Version-1_0-branch/activitycalendarfrontend/templates/base/activity_new.php
        2011-11-17 18:21:09 UTC (rev 8125)
@@ -0,0 +1,656 @@
+<?php
+       //include common logic for all templates
+//     include("common.php");
+       $act_so = activitycalendar_soactivity::get_instance();
+       $contpers_so = activitycalendar_socontactperson::get_instance();
+?>
+
+<script type="text/javascript">
+
+function get_available_groups()
+{
+       var org_id = document.getElementById('organization_id').value;
+       var div_select = document.getElementById('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 }?>
+
+       if(org_id != null && org_id == 'new_org')
+       {
+               //alert('new_org');
+               document.getElementById('new_org').style.display = "block";
+               document.getElementById('new_org_fields').style.display = 
"block";
+               document.getElementById('group_label').style.display = "none";
+               document.getElementById('group_select').style.display = "none";
+       }
+       else if(org_id != null && org_id == 'change_org')
+       {
+               document.getElementById('new_org').style.display = "block";
+               document.getElementById('new_org_fields').style.display = 
"none";
+               document.getElementById('change_org_fields').style.display = 
"block";
+               document.getElementById('group_label').style.display = "none";
+               document.getElementById('group_select').style.display = "none";
+       }
+       else
+       {
+               document.getElementById('new_org').style.display = "none";
+               document.getElementById('new_org_fields').style.display = 
"none";
+               document.getElementById('change_org_fields').style.display = 
"none";
+               var divcontent_start = "<select name=\"group_id\" 
id=\"group_id\" onchange=\"javascript:checkNewGroup()\">";
+               var divcontent_end = "</select>";
+               
+               var callback = {
+                       success: function(response){
+                                               div_select.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
+                                       },
+                       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();
+});
+
+function checkNewGroup()
+{
+       var group_selected = document.getElementById('group_id').value;
+       if(group_selected == 'new_group')
+       {
+               document.getElementById('new_group').style.display = "block";
+               document.getElementById('new_group_fields').style.display = 
"block";
+       }
+       else
+       {
+               document.getElementById('new_group').style.display = "none";
+               document.getElementById('new_group_fields').style.display = 
"none";
+       }
+}
+
+function get_address_search()
+{
+       var address = document.getElementById('address_txt').value;
+       var div_address = document.getElementById('address_container');
+
+       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
+
+var divcontent_start = "<select name=\"address\" id=\"address\" size\"5\">";
+var divcontent_end = "</select>";
+       
+       var callback = {
+               success: function(response){
+                                       div_address.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+function get_address_search_cp2()
+{
+       var address = document.getElementById('contact2_address_txt').value;
+       var div_address = document.getElementById('contact2_address_container');
+
+       url = 
"index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
+
+var divcontent_start = "<select name=\"contact2_address\" id=\"address_cp2\" 
size\"5\">";
+var divcontent_end = "</select>";
+       
+       var callback = {
+               success: function(response){
+                                       div_address.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
+                               },
+               failure: function(o) {
+                                        alert("AJAX doesn't work"); //FAILURE
+                                }
+       }
+       var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
+       
+}
+
+function allOK()
+{
+       if(document.getElementById('title').value == null || 
document.getElementById('title').value == '')
+       {
+               alert("Tittel må fylles ut!");
+               return false;
+       } 
+       if(document.getElementById('organization_id').value == null || 
document.getElementById('organization_id').value == '')
+       {
+               alert("Organisasjon må fylles ut!");
+               return false;
+       }
+       if(document.getElementById('internal_arena_id').value == null || 
document.getElementById('internal_arena_id').value == 0)
+       {
+               if(document.getElementById('arena_id').value == null || 
document.getElementById('arena_id').value == 0)
+               {
+                       alert("Arena må fylles ut!");
+                       return false;
+               }
+       }
+       if(document.getElementById('time').value == null || 
document.getElementById('time').value == '')
+       {
+               alert("Tid må fylles ut!");
+               return false;
+       }
+       if(document.getElementById('category').value == null || 
document.getElementById('category').value == 0)
+       {
+               alert("Kategori må fylles ut!");
+               return false;
+       }
+       if(document.getElementById('office').value == null || 
document.getElementById('office').value == 0)
+       {
+               alert("Hovedansvarlig kulturkontor må fylles ut!");
+               return false;
+       }
+       else
+               return true;
+}
+
+</script>
+
+<div class="yui-content" style="width: 100%;">
+       <div id="details">
+       
+       <?php if($message){?>
+       <div class="success">
+               <?php echo $message;?>
+       </div>
+       <?php }else if($error){?>
+       <div class="error">
+               <?php echo $error;?>
+       </div>
+       <?php }?>
+       </div>
+               <h1><?php echo lang('activity') ?></h1>
+               <form action="#" method="post">
+                       <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
+                       <dl class="proplist-col" style="width: 60%">
+                               <dt>
+                                       <?php if($activity->get_title() || 
$editable) { ?>
+                                       <label for="title"><?php echo 
lang('title') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                       ?>
+                                               <?php echo 
lang('title_helptext')?><br/>
+                                               <input type="text" name="title" 
id="title" value="<?php echo $activity->get_title() ?>" size="60"/>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               echo $activity->get_title();
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php 
if($activity->get_organization_id() || $editable) { ?>
+                                       <label for="organization_id"><?php echo 
lang('organization') ?></label>
+                                       <?php } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_organization_id = 
$activity->get_organization_id();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('org_helptext')?><br/>
+                                               <select name="organization_id" 
id="organization_id" onchange="javascript:get_available_groups();">
+                                                       <option value="">Ingen 
organisasjon valgt</option>
+                                                       <option 
value="new_org">Ny organisasjon</option>
+                                                       <option 
value="change_org">Endre organisasjon</option>
+                                                       <?php
+                                                       foreach($organizations 
as $organization)
+                                                       {
+                                                               echo "<option 
".($current_organization_id == $organization->get_id() ? 'selected="selected"' 
: "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       ?>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               
if($activity->get_organization_id()){
+                                                       echo 
activitycalendar_soorganization::get_instance()->get_organization_name($activity->get_organization_id());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <div id="new_org" style="display: none;">
+                                       <hr/>
+                                       <div id="change_org_fields" 
style="display: none;">
+                                               <select 
name="change_organization_id" id="change_organization_id" >
+                                                       <option value="">Ingen 
organisasjon valgt</option>
+                                                       <?php
+                                                       foreach($organizations 
as $organization)
+                                                       {
+                                                               echo "<option 
".($current_organization_id == $organization->get_id() ? 'selected="selected"' 
: "")." 
value=\"{$organization->get_id()}\">".$organization->get_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                       </div>
+                                       <div id="new_org_fields" 
style="display: none;">
+                                               <label 
for="orgname">Organisasjonsnavn</label>
+                                               <input type="text" 
name="orgname"/><br/>
+                                               <label 
for="orgno">Organisasjonsnummer</label>
+                                               <input type="text" 
name="orgno"/><br/>
+                                               <label 
for="district">Bydel</label>
+                                                       <select 
name="org_district">
+                                                               <option 
value="0">Ingen bydel valgt</option>
+                                               <?php 
+                                               foreach($districts as $d)
+                                               {
+                                               ?>
+                                                       <option value="<?php 
echo $d['part_of_town_id']?>"><?php echo $d['name']?></option>
+                                               <?php
+                                               }?>
+                                                       </select><br/>
+                                               <label 
for="homepage">Hjemmeside</label>
+                                               <input type="text" 
name="homepage"/><br/>
+                                               <label 
for="email">E-post</label>
+                                               <input type="text" 
name="email"/><br/>
+                                               <label 
for="phone">Telefon</label>
+                                               <input type="text" 
name="phone"/><br/>
+                                               <label for="street">Gate</label>
+                                               <input type="text" 
name="address_txt" id="address_txt" onkeyup="javascript:get_address_search()"/>
+                                               <div 
id="address_container"></div><br/>
+                                               <label 
for="number">Nummer</label>
+                                               <input type="text" 
name="number"/><br/>
+                                               <label 
for="postaddress">Postnummer og Sted</label>
+                                               <input type="text" 
name="postaddress"/>
+                                               <label 
for="org_description">Beskrivelse</label>
+                                               <textarea rows="10" cols="100" 
name="org_description"></textarea>
+                                       </div>
+                                       <hr/>
+                                       <b>Kontaktperson 1</b><br/>
+                                       <label for="contact1_name">Navn</label>
+                                       <input type="text" 
name="contact1_name"/><br/>
+                                       <label 
for="contact1_phone">Telefon</label>
+                                       <input type="text" 
name="contact1_phone"/><br/>
+                                       <label 
for="contact1_mail">E-post</label>
+                                       <input type="text" 
name="contact1_mail"/><br/>
+                                       <b>Kontaktperson 2</b><br/>
+                                       <label for="contact2_name">Navn</label>
+                                       <input type="text" 
name="contact2_name"/><br/>
+                                       <label 
for="contact2_phone">Telefon</label>
+                                       <input type="text" 
name="contact2_phone"/><br/>
+                                       <label 
for="contact2_mail">E-post</label>
+                                       <input type="text" 
name="contact2_mail"/><br/>
+                                       <label 
for="contact2_address">Adresse</label>
+                                       <input type="text" 
name="contact2_address_txt" id="contact2_address_txt" 
onkeyup="javascript:get_address_search_cp2()"/>
+                                       <div 
id="contact2_address_container"></div><br/>
+                                       <label 
for="contact2_number">Nummer</label>
+                                       <input type="text" 
name="contact2_number"/><br/>
+                                       <label 
for="contact2_postaddress">Postnummer og Sted</label>
+                                       <input type="text" 
name="contact2_postaddress"/>
+                                       <hr/>
+                               </div>
+                               <dt>
+                                       <?php if($activity->get_group_id() || 
$editable) { ?>
+                                       <label for="group_id" 
id="group_label"><?php echo lang('group') ?></label>
+                                       <?php } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_group_id = 
$activity->get_group_id();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('group_helptext')?><br/>
+                                               <div id="group_select">
+                                                       <select name="group_id" 
id="group_id">
+                                                               <option 
value="0">Ingen gruppe valgt</option>
+                                                       </select>
+                                               </div>
+                                               <?php
+                                       ?>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_group_id()){
+                                                       echo 
activitycalendar_sogroup::get_instance()->get_group_name($activity->get_group_id());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <div id="new_group" style="display: none;">
+                                       <hr/>
+                                       <div id="new_group_fields" 
style="display: none;">
+                                               <label 
for="groupname">Gruppenavn</label>
+                                               <input type="text" 
name="groupname"/><br/>
+                                               <label 
for="group_description">Beskrivelse</label>
+                                               <textarea rows="10" cols="100" 
name="group_description"></textarea>
+                                       </div>
+                                       <hr/>
+                                       <b>Kontaktperson 1</b><br/>
+                                       <label for="contact1_name">Navn</label>
+                                       <input type="text" 
name="contact1_name"/><br/>
+                                       <label 
for="contact1_phone">Telefon</label>
+                                       <input type="text" 
name="contact1_phone"/><br/>
+                                       <label 
for="contact1_mail">E-post</label>
+                                       <input type="text" 
name="contact1_mail"/><br/>
+                                       <b>Kontaktperson 2</b><br/>
+                                       <label for="contact2_name">Navn</label>
+                                       <input type="text" 
name="contact2_name"/><br/>
+                                       <label 
for="contact2_phone">Telefon</label>
+                                       <input type="text" 
name="contact2_phone"/><br/>
+                                       <label 
for="contact2_mail">E-post</label>
+                                       <input type="text" 
name="contact2_mail"/><br/>
+                                       <label 
for="contact2_address">Adresse</label>
+                                       <input type="text" 
name="contact2_address_txt" id="contact2_address_txt" 
onkeyup="javascript:get_address_search_cp2()"/>
+                                       <div 
id="contact2_address_container"></div><br/>
+                                       <label 
for="contact2_number">Nummer</label>
+                                       <input type="text" 
name="contact2_number"/><br/>
+                                       <label 
for="contact2_postaddress">Postnummer / Sted</label>
+                                       <input type="text" 
name="contact2_postaddress"/>
+                                       <hr/>
+                               </div>
+                               <dt>
+                                       <?php 
if($activity->get_internal_arena() || $editable) { ?>
+                                       <label for="arena"><?php echo 
lang('building') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_internal_arena_id = 
$activity->get_internal_arena();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('int_arena_helptext')?><br/>
+                                               <select 
name="internal_arena_id" id="internal_arena_id">
+                                                       <option value="0">Ingen 
kommunale bygg valgt</option>
+                                                       <?php
+                                                       foreach($buildings as 
$building_id => $building_name)
+                                                       {
+                                                               echo "<option 
".($current_internal_arena_id == $building_id? 'selected="selected"' : "")." 
value=\"{$building_id}\">".$building_name."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_arena()){
+                                                       echo 
activitycalendar_soarena::get_instance()->get_building_name($activity->get_internal_arena());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_arena() || 
$editable) { ?>
+                                       <label for="arena"><?php echo 
lang('arena') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_arena_id = 
$activity->get_arena();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <?php echo 
lang('arena_helptext')?><br/>
+                                               <select name="arena_id" 
id="arena_id" style="width: 60%">
+                                                       <option value="0">Ingen 
arena valgt</option>
+                                                       <?php
+                                                       foreach($arenas as 
$arena)
+                                                       {
+                                                               echo "<option 
".($current_arena_id == $arena->get_id() ? 'selected="selected"' : "")." 
value=\"{$arena->get_id()}\">".$arena->get_arena_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_arena()){
+                                                       echo 
activitycalendar_soarena::get_instance()->get_arena_name($activity->get_arena());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_state() || 
$editable) { ?>
+                                       <label for="state"><?php echo 
lang('state') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                               $selected_state = 
$activity->get_state();
+                                       ?>
+                                               <select name="state">
+                                                       <option value="1" <?php 
echo ($selected_state == 1 ? 'selected="selected"' : "")?>><?php echo 
lang('new') ?></option>
+                                                       <option value="2" <?php 
echo ($selected_state == 2 ? 'selected="selected"' : "")?>><?php echo 
lang('change') ?></option>
+                                               </select>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_state() && 
$activity->get_state() > 0){
+                                                       echo 
lang('state_'.$activity->get_state());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                       </dl>
+                       <dl class="proplist-col">
+                               <dt>
+                                       <?php if($activity->get_category() || 
$editable) { ?>
+                                       <label for="category"><?php echo 
lang('category') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_category_id = 
$activity->get_category();
+                                       if ($editable)
+                                       {
+                                               ?>
+                                               <select name="category" 
id="category">
+                                                       <option value="0">Ingen 
kategori valgt</option>
+                                                       <?php
+                                                       foreach($categories as 
$category)
+                                                       {
+                                                               echo "<option 
".($current_category_id == $category->get_id() ? 'selected="selected"' : "")." 
value=\"{$category->get_id()}\">".$category->get_name()."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                               <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_category()){
+                                                       echo 
$act_so->get_category_name($activity->get_category());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_target() || 
$editable) { ?>
+                                       <label for="target"><?php echo 
lang('target') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_target_ids = 
$activity->get_target();
+                                       $current_target_id_array=explode(",", 
$current_target_ids);
+                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       if ($editable)
+                                       {
+                                               foreach($targets as $t)
+                                               {
+                                               ?>
+                                                       <input name="target[]" 
type="checkbox" value="<?php echo $t->get_id()?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "")?>/><?php 
echo $t->get_name()?><br/>
+                                               <?php
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_target()){
+                                                       $current_target_ids = 
$activity->get_target();
+                                                       
$current_target_id_array=explode(",", $current_target_ids);
+                                                       
foreach($current_target_id_array as $curr_target)
+                                                       {
+                                                               echo 
$act_so->get_target_name($curr_target).'<br/>';
+                                                       }
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_office() || 
$editable) { ?>
+                                       <label for="office"><?php echo 
lang('office') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                               $selected_office = 
$activity->get_office();
+                                       ?>
+                                               <select name="office" 
id="office">
+                                                       <option value="0">Ingen 
kontor valgt</option>
+                                                       <?php
+                                                       foreach($offices as 
$office)
+                                                       {
+                                                               echo "<option 
".($selected_office == $office['id'] ? 'selected="selected"' : "")." 
value=\"{$office['id']}\">".$office['name']."</option>";
+                                                       }
+                                                       ?>
+                                               </select>
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_office()){
+                                                       echo 
$act_so->get_office_name($activity->get_office());
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_district() || 
$editable) { ?>
+                                       <label for="district"><?php echo 
lang('district') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_district_ids = 
$activity->get_district();
+                                       $current_district_id_array=explode(",", 
$current_district_ids);
+                                       //echo 
$current_target_id_array[0]."*".$current_target_id_array[1];
+                                       if ($editable)
+                                       {
+                                               foreach($districts as $d)
+                                               {
+                                               ?>
+                                                       <input 
name="district[]" type="checkbox" value="<?php echo $d['part_of_town_id']?>" 
<?php echo (in_array($d['part_of_town_id'], $current_district_id_array) ? 
'checked' : "")?>/><?php echo $d['name']?><br/>
+                                               <?php
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if($activity->get_district()){
+                                                       $current_district_ids = 
$activity->get_district();
+                                                       
$current_district_id_array=explode(",", $current_district_ids);
+                                                       
foreach($current_district_id_array as $curr_district)
+                                                       {
+                                                               echo 
$act_so->get_district_name($curr_district).'<br/>';
+                                                       }
+                                               }
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_description()) 
{ ?>
+                                       <label for="description"><?php echo 
lang('description') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php echo 
$activity->get_description(); ?>
+                               </dd>
+                               <dt>
+                                       <?php if($activity->get_time() || 
$editable) { ?>
+                                       <label for="time"><?php echo 
lang('time') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       if ($editable)
+                                       {
+                                       ?>
+                                               <input type="text" name="time" 
id="time" value="<?php echo $activity->get_time() ?>" />
+                                       <?php
+                                       }
+                                       else
+                                       {
+                                               echo $activity->get_time();
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php 
if($activity->get_contact_person_1() || $editable) { ?>
+                                       <label for="contact_person_1"><?php 
echo lang('contact_person_1') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                               if($activity->get_group_id())
+                                               {
+                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_1());
+                                               }
+                                               else 
if($activity->get_organization_id())
+                                               {
+                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_1());
+                                               }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <?php 
if($activity->get_contact_person_2() || $editable) { ?>
+                                       <label for="contact_person_2"><?php 
echo lang('contact_person_2') ?></label>
+                                       <?php  } ?>
+                               </dt>
+                               <dd>
+                                       <?php
+                                               if($activity->get_group_id())
+                                               {
+                                                       echo 
$contpers_so->get_group_contact_name($activity->get_contact_person_2());
+                                               }
+                                               else 
if($activity->get_organization_id())
+                                               {
+                                                       echo 
$contpers_so->get_org_contact_name($activity->get_contact_person_2());
+                                               }
+                                       ?>
+                               </dd>
+                           <dt>
+                                       <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
+                               </dt>
+                               <dd>
+                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> <?php echo 
!$editable ? ' disabled="disabled"' : '' ?>/>
+                               </dd>
+                       </dl>
+                       <div class="form-buttons">
+                               <?php
+                                       if ($editable) {
+                                               echo '<input type="submit" 
name="save_activity" value="' . lang('save') . '" onclick="return allOK();"/>';
+                                       }
+                               ?>
+                       </div>
+                       
+               </form>
+               
+       </div>
+</div>
\ No newline at end of file

Modified: branches/Version-1_0-branch/bim/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/bim/setup/setup.inc.php 2011-11-17 18:17:28 UTC 
(rev 8124)
+++ branches/Version-1_0-branch/bim/setup/setup.inc.php 2011-11-17 18:21:09 UTC 
(rev 8125)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['bim']['name']                      = 'bim';
-       $setup_info['bim']['version']           = '0.9.17.501';
+       $setup_info['bim']['version']           = '0.9.17.502';
        $setup_info['bim']['app_order']         = 8;
        $setup_info['bim']['enable']            = 1;
        $setup_info['bim']['app_group']         = 'office';

Modified: branches/Version-1_0-branch/bim/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/bim/setup/tables_update.inc.php 2011-11-17 
18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/bim/setup/tables_update.inc.php 2011-11-17 
18:21:09 UTC (rev 8125)
@@ -35,3 +35,17 @@
                }
        }
 
+       /**
+       * Update bim version from 0.9.17.501 to 0.9.17.502
+       */
+       $test[] = '0.9.17.501';
+       function bim_upgrade0_9_17_501()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+               
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_bim_item','guid',array('type' 
=> 'varchar','precision' => '50','nullable' => False));
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['bim']['currentver'] = 
'0.9.17.502';
+                       return $GLOBALS['setup_info']['bim']['currentver'];
+               }
+       }

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php    
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol_group.inc.php    
2011-11-17 18:21:09 UTC (rev 8125)
@@ -195,12 +195,12 @@
                return $results;
        }
        
-       function get_control_groups_as_array($control_area_id = null, $limit)
+       function get_control_groups_as_array($control_area_id)
        {
                $results = array();
                
                $sql = "SELECT * FROM controller_control_group WHERE 
control_area_id=$control_area_id";
-               $this->db->limit_query($sql, $start, __LINE__, __FILE__, 
$limit);
+               $this->db->query($sql);
                
                while ($this->db->next_record()) {
                        $control_group = new 
controller_control_group($this->unmarshal($this->db->f('id', true), 'int'));
@@ -253,97 +253,9 @@
                }
 
                $filter_clauses = array();
-               /*switch($filters['is_active']){
-                       case "active":
-                               $filter_clauses[] = "rental_composite.is_active 
= TRUE";
-                               break;
-                       case "non_active":
-                               $filter_clauses[] = "rental_composite.is_active 
= FALSE";
-                               break;
-                       case "both":
-                               break;
-               }*/
-               /*
-               $special_query = false; //specify if the query should use 
distinct on rental_composite.id (used for selecting composites that has an 
active or inactive contract)
-               $ts_query = strtotime(date('Y-m-d')); // timestamp for query 
(today)
-               $availability_date_from = $ts_query;
-               $availability_date_to = $ts_query;
-               
-               if(isset($filters['availability_date_from']) && 
$filters['availability_date_from'] != ''){
-                       $availability_date_from = 
strtotime($filters['availability_date_from']); 
-               }
-               
-               if(isset($filters['availability_date_to']) && 
$filters['availability_date_to'] != ''){
-                       $availability_date_to = 
strtotime($filters['availability_date_to']); 
-               }
-               */
-               /*switch($filters['has_contract']){
-                       case "has_contract":
-                               $filter_clauses[] = "NOT 
rental_contract_composite.contract_id IS NULL"; // Composite must have a 
contract
-                               $filter_clauses[] = "NOT 
rental_contract.date_start IS NULL"; // The contract must have start date
-                       */      
-                               /* The contract's start date not after the end 
of the period if there is no end date */
-/*                             $filter_clauses[] = "
-                                       ((NOT rental_contract.date_start > 
$availability_date_to AND rental_contract.date_end IS NULL)
-                                        OR
-                                       (NOT rental_contract.date_start > 
$availability_date_to AND NOT rental_contract.date_end IS NULL AND NOT 
rental_contract.date_end < $availability_date_from))";
-                               $special_query=true;
-                               break;
-                       case "has_no_contract":
-                               $filter_clauses[] = "
-                               (
-                                       rental_contract_composite.contract_id 
IS NULL OR 
-                                       NOT rental_composite.id IN 
-                                       (
-                                               SELECT rental_composite.id FROM 
rental_composite 
-                                               LEFT JOIN  
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) 
-                                               LEFT JOIN  rental_contract ON 
(rental_contract.id = rental_contract_composite.contract_id) 
-                                               WHERE  
-                                               (
-                                                       NOT 
rental_contract_composite.contract_id IS NULL AND
-                                                       NOT 
rental_contract.date_start IS NULL AND
-                                                       ((NOT 
rental_contract.date_start > $availability_date_to AND rental_contract.date_end 
IS NULL)
-                                                       OR
-                                                       (NOT 
rental_contract.date_start > $availability_date_to AND NOT 
rental_contract.date_end IS NULL AND NOT rental_contract.date_end < 
$availability_date_from))
-                                               )
-                                       )
-                               )
-                               ";
-                               $special_query=true;
-                               break;
-                       case "both":
-                               break;
-               }
-               
-               // Furnished, partly furnished, not furnished, not specified
-               if(isset($filters['furnished_status']) & 
$filters['furnished_status'] < 4){
-                       // Not specified
-                       if($filters['furnished_status'] == 0)
-                               $filter_clauses[] = 
"rental_composite.furnish_type_id IS NULL";
-                       else 
-                               $filter_clauses[] = 
"rental_composite.furnish_type_id=".$filters['furnished_status'];
-               }
-
-               if(isset($filters['not_in_contract'])){
-                       $filter_clauses[] = 
"(rental_contract_composite.contract_id != ".$filters['not_in_contract']." OR 
rental_contract_composite.contract_id IS NULL)";
-               }
-               
-               if(isset($filters['location_code'])){
-                       $filter_clauses[] = "rental_unit.location_code = '". 
$filters['location_code'] . "'";
-               }
-               
-               if(isset($filters['contract_id']))
-               {
-                       $filter_clauses[] = "contract_id = 
{$this->marshal($filters['contract_id'],'int')}";
-               }
-               
+                       
                if(isset($filters[$this->get_id_field_name()]))
                {
-                       $filter_clauses[] = "rental_composite.id = 
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
-               }*/
-               
-               if(isset($filters[$this->get_id_field_name()]))
-               {
                        $filter_clauses[] = "controller_control_group.id = 
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
                }
                if(isset($filters['control_areas']))
@@ -371,7 +283,9 @@
                }
                else
                {
-                       $cols .= "controller_control_group.id, group_name, 
controller_control_group.procedure_id, 
controller_control_group.control_area_id, building_part_id, 
fm_building_part.descr AS building_part_descr, controller_procedure.title as 
procedure_title, controller_control_area.title as control_area_name ";
+                       $cols .= "controller_control_group.id, group_name, 
controller_control_group.procedure_id, controller_control_group.control_area_id 
as control_area_id, ";
+                       $cols .= "building_part_id, fm_building_part.descr AS 
building_part_descr, controller_procedure.title as procedure_title, "; 
+                       $cols .= "controller_control_area.title as 
control_area_name ";
                }
                $dir = $ascending ? 'ASC' : 'DESC';
                $order = $sort_field ? "ORDER BY {$this->marshal($sort_field, 
'field')} $dir ": '';

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_group_list.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/class.socontrol_group_list.inc.php   
    2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/controller/inc/class.socontrol_group_list.inc.php   
    2011-11-17 18:21:09 UTC (rev 8125)
@@ -123,6 +123,20 @@
                }
        }
        
+       function delete($control_id, $control_group_id)
+       {               
+               $result = $this->db->query("DELETE FROM 
controller_control_group_list WHERE control_id = $control_id AND 
control_group_id = $control_group_id");
+                               
+               return isset($result);
+       }
+       
+       function delete_control_groups($control_id)
+       {               
+               $result = $this->db->query("DELETE FROM 
controller_control_group_list WHERE control_id = $control_id");
+                               
+               return isset($result);
+       }
+       
        function get_control_groups_by_control_id($control_id)
        {
                $this->db->query("SELECT cg.*, cgl.order_nr FROM 
controller_control_group_list cgl, controller_control_group cg WHERE 
cgl.control_id=$control_id AND cgl.control_group_id=cg.id ORDER BY 
cgl.order_nr", __LINE__, __FILE__);

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php     
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php     
2011-11-17 18:21:09 UTC (rev 8125)
@@ -221,7 +221,7 @@
                }
                else
                {
-                       $cols = 'controller_control_item.id, 
controller_control_item.title, required, what_to_do, how_to_do, 
controller_control_item.control_group_id, 
controller_control_item.control_area_id, controller_control_group.group_name AS 
control_group_name';
+                       $cols = 'controller_control_item.id, 
controller_control_item.title, required, what_to_do, how_to_do, 
controller_control_item.control_group_id, controller_control_group.group_name 
AS control_group_name';
                }
                
                $dir = $ascending ? 'ASC' : 'DESC';

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php    
    2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php    
    2011-11-17 18:21:09 UTC (rev 8125)
@@ -120,13 +120,18 @@
        
        function delete($control_id, $control_item_id)
        {               
-               var_dump("DELETE FROM controller_control_item_list WHERE 
control_id = $control_id AND control_item_id = $control_item_id");
-               
                $result = $this->db->query("DELETE FROM 
controller_control_item_list WHERE control_id = $control_id AND control_item_id 
= $control_item_id", __LINE__,__FILE__);
                                
                return isset($result);
        }
        
+       function delete_control_items($control_id)
+       {               
+               $result = $this->db->query("DELETE FROM 
controller_control_item_list WHERE control_id = $control_id");
+                               
+               return isset($result);
+       }
+       
        /**
         * Get a list of procedure objects matching the specific filters
         * 

Modified: branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2011-11-17 18:21:09 UTC (rev 8125)
@@ -170,10 +170,12 @@
                
                        if(isset($control_id) && $control_id > 0)
                        {
-                               $control = $this->so->get_single($control_id);  
+                               $control = $this->so->get_single($control_id);
                        }
 
                        $control_areas_array = 
$this->so_control_area->get_control_areas_as_array();
+
+                       // Fetches prosedures that are related to first control 
area in list
                        $control_area_id = $control_areas_array[0]['id'];
                        $procedures_array = 
$this->so_procedure->get_procedures_by_control_area_id($control_area_id);
                        
@@ -185,8 +187,6 @@
                                                        'label' => "3: " . 
lang('Choose_control_items')
                                                ), array(
                                                        'label' => "4: " . 
lang('Sort_check_list')
-                                               ), array(
-                                                       'label' => "5: " . 
lang('Show_check_lists')
                                                ));
                        
                        $data = array
@@ -210,7 +210,6 @@
                }
                
                public function save_control_details(){
-               
                        $control_id = phpgw::get_var('control_id');             
                        
                        // Update control details
@@ -224,29 +223,52 @@
                        }
                        
                        $control->populate();
-                       $control_id = $this->so->store($control);
-                       $control_title = $control->get_title();
-               
-                       $this->redirect(array('menuaction' => 
'controller.uicontrol.view_control_groups', 'control_id'=>$control_id, 
'control_area_id'=>$control->get_control_area_id(), 
'control_title'=>$control_title));     
+                                                                       
+                       if( $control->get_title() == "" ){
+                               $this->redirect(array('menuaction' => 
'controller.uicontrol.view_control_details', 'control_id'=>$control_id, 
'control_area_id'=>$control->get_control_area_id()));     
+                       }
+                       else
+                       {
+                               $control_id = $this->so->store($control);
+                               $this->redirect(array('menuaction' => 
'controller.uicontrol.view_control_groups', 'control_id'=>$control_id, 
'control_area_id'=>$control->get_control_area_id()));
+                       }
                }
                                                
                // Displays control groups based on previously chosen control 
area
                public function view_control_groups(){
-                       
                        $control_id = phpgw::get_var('control_id');
-                       $control_area_id = phpgw::get_var('control_area_id');
-                       $control_title = phpgw::get_var('control_title');
-                       $control_group_ids = 
phpgw::get_var('control_group_ids');
-                                       
-                       $control_area = $this->so_control_area->get_single( 
$control_area_id );
+                       $control = $this->so->get_single($control_id);  
+                                                                       
+                       // Fetches saved control groups from db
+                       $saved_control_groups = 
$this->so_control_group_list->get_control_groups_by_control_id($control_id);
+                       $saved_control_group_ids = array();
                        
-                       $control_groups_as_array = 
$this->so_control_group->get_control_groups_as_array($control_area->get_id(), 
25);
+                       foreach($saved_control_groups as $control_group){
+                               $saved_control_group_ids[] = 
$control_group->get_id();
+                       }
                        
+                       // Fetches  control groups based on selected control 
area                                               
+                       $control_area = $this->so_control_area->get_single( 
$control->get_control_area_id );            
+                       $control_groups_as_array = 
$this->so_control_group->get_control_groups_as_array($control->get_control_area_id());
+                       
+                       $control_groups = array();
+                       foreach($control_groups_as_array as $control_group){
+                               $control_group_id = $control_group['id'];
+                               
+                               if( in_array($control_group_id, 
$saved_control_group_ids )){
+                                       $control_groups[] = array("checked" => 
1, "control_group" => $control_group);
+                               }
+                               else
+                               {
+                                       $control_groups[] = array("checked" => 
0, "control_group" => $control_group);
+                               }
+                       }
+                       
                        $tabs = array(
                                                array(
                                                        'label' => "1: " . 
lang('Details'),
-                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.view_control_details', 'view' => "view_control_details", 
-                                                                               
                                                                                
   'id' => $control_id))
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.view_control_details', 
+                                                                               
                                                                                
   'view' => "view_control_details", 'id' => $control_id))
                                                ), 
                                                array(
                                                        'label' => "2: " . 
lang('Choose_control_groups')
@@ -256,49 +278,92 @@
                                                ), 
                                                array(
                                                        'label' => "4: " . 
lang('Sort_check_list')
-                                               ), 
-                                               array(
-                                                       'label' => "5: " . 
lang('Show_check_lists')
-                                               )
-                                       );
+                                               ));
                        
                        $data = array
                        (
-                               'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
-                               'view'                                          
=> "control_groups",
-                               'editable'                                      
=> true,
-                               'control_id'                            => 
$control_id,
-                               'control_title'                         => 
$control_title,
-                               'control_area'                          => 
$control_area->toArray(),
-                               'control_groups'                        => 
$control_groups_as_array,
-                               'chosen_control_groups'         => 
$control_group_ids
+                               'tabs'                                          
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                               'view'                                          
        => "control_groups",
+                               'editable'                                      
        => true,
+                               'control'                                       
        => $control->toArray(),
+                               'control_area'                                  
=> $control_area->toArray(),
+                               'control_groups'                                
=> $control_groups,
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
                        self::render_template_xsl(array('control_tabs', 
'control_groups'), $data);
                }
                
+               public function save_control_groups(){
+                       $control_id = phpgw::get_var('control_id');
+                       $control_group_ids = 
phpgw::get_var('control_group_ids');               
+
+                       // Deleting earlier saved control groups
+                       
$this->so_control_group_list->delete_control_groups($control_id);
+                       
+                       $group_order_nr = 1;
+
+                       // Saving control groups 
+                       foreach ($control_group_ids as $control_group_id)
+                       {
+                               $control_group_list = new 
controller_control_group_list();
+                               
$control_group_list->set_control_id($control_id);
+                               
$control_group_list->set_control_group_id($control_group_id);
+                               
$control_group_list->set_order_nr($group_order_nr);
+                                                       
+                               
$this->so_control_group_list->add($control_group_list);
+                               $group_order_nr++;
+                       }
+
+                       // Redirect: view_control_items
+                       $this->redirect(array('menuaction' => 
'controller.uicontrol.view_control_items', 
+                                                                 
'control_id'=>$control_id, 'control_group_ids'=>$control_group_ids)); 
+               }
+               
                // Gets a comma separated list of control groups, and displays 
control items for these groups
                public function view_control_items(){
                        $control_id = phpgw::get_var('control_id', 'int');
                        $control = $this->so->get_single($control_id);
-                       $control_title = $control->get_title();
                        
-                       $control_group_ids = array();
                        $control_group_ids = 
phpgw::get_var('control_group_ids');
-
+               
+                       // Fetches saved control items from db
+                       $saved_control_items = 
$this->so_control_item->get_control_items_by_control_id($control_id);
+                       $saved_control_item_ids = array();
+                       
+                       foreach($saved_control_items as $control_item){
+                               $saved_control_item_ids[] = 
$control_item->get_id();
+                       }
+                       
+                       // Array with selected control groups and items
                        $groups_with_control_items = array();
-                                       
-                       // Fetching control items for each control group and 
populates array that contains groups with chosen items 
+                       
+                       // Fetches control items for control group and 
populates groups_with_control_items with groups and chosen control items
                        foreach ($control_group_ids as $control_group_id)
                        {       
                                $group_control_items_array = 
$this->so_control_item->get_control_items_as_array($control_group_id);
                                
+                               $control_items_for_group_array = array();
+                               
+                               foreach($group_control_items_array as 
$control_item){
+                                       $control_item_id = $control_item['id'];
+                                       
+                                       if( in_array($control_item_id, 
$saved_control_item_ids )){
+                                               
$control_items_for_group_array[] = array("checked" => 1, "control_item" => 
$control_item);
+                                       }
+                                       else
+                                       {
+                                               
$control_items_for_group_array[] = array("checked" => 0, "control_item" => 
$control_item);
+                                       }
+                               }
+                               
                                $control_group = 
$this->so_control_group->get_single($control_group_id);
                                
-                               $groups_with_control_items[] = 
array("control_group" => $control_group->toArray(), "group_control_items" => 
$group_control_items_array);
+                               $groups_with_control_items[] = 
array("control_group" => $control_group->toArray(), "group_control_items" => 
$control_items_for_group_array);
                        }                       
                        
+                       //print_r( $groups_with_control_items[0] );
+                       
                        $tabs = array(
                                                array(
                                                        'label' => "1: " . 
lang('Details'),
@@ -311,42 +376,45 @@
                                                                                
                                                                               
'control_id' => $control_id, 'control_group_ids' => $control_group_ids, 
                                                                                
                                                                               
'control_area_id' => $control->get_control_area_id()))
                                                ),
-                                               array('label' => "3: " . 
lang('Choose_control_items')), 
-                                               array('label' => "4: " . 
lang('Sort_check_list')), 
-                                               array('label' => "5: " . 
lang('Show_check_lists'))
-                                       );
+                                               array('label' => "3: " . 
lang('Choose_control_items')),
+                                               array(
+                                                       'label' => "4: " . 
lang('Sort_check_list')
+                                               ));
                                        
                        $data = array
                        (
                                'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 2),
                                'view'                                          
=> 'control_items',
                                'control_group_ids'                     => 
implode($control_group_ids, ","),
-                               'control_id'                            => 
$control_id,
-                               'control_title'                         => 
$control_title,
+                               'control'                                   => 
$control->toArray(),
                                'groups_with_control_items'     => 
$groups_with_control_items                   
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'custom_ui.js');
-                       self::render_template_xsl(array('control_tabs', 
'choose_control_items'), $data);
+                       self::render_template_xsl(array('control_tabs', 
'choose_control_items'), $data); 
                }
                
                // Saves chosen control items through receiving a comma 
separated list of control tags (1:2, control_group_id:control_item_id) 
                public function save_control_items(){
                        $control_id = phpgw::get_var('control_id');
-                       $control_title = phpgw::get_var('control_title');
                        $control_group_ids = explode(",", 
phpgw::get_var('control_group_ids'));
                        
                        // Fetching selected control items. Tags are on the 
format 1:2 (group:item). 
                        $control_tag_ids = phpgw::get_var('control_tag_ids');
                        
+                       // Deleting earlier saved control groups
+                       
$this->so_control_group_list->delete_control_groups($control_id);
+                       
+                       // Deleting earlier saved control items
+                       
$this->so_control_item_list->delete_control_items($control_id);
+                                               
                        $group_order_nr = 1;
                        
                        // Saving control groups 
                        foreach ($control_group_ids as $control_group_id)
                        {
-                               //var_dump("control_group_id: " . 
$control_group_id);
                                $control_group_list = new 
controller_control_group_list();
                                
$control_group_list->set_control_id($control_id);
                                
$control_group_list->set_control_group_id($control_group_id);
@@ -375,7 +443,6 @@
                public function view_check_list(){
                        $control_id = phpgw::get_var('control_id');
                        $control = $this->so->get_single($control_id);
-                       $control_title = $control->get_title();
                        
                        $control_group_ids = 
phpgw::get_var('control_group_ids');
                        
@@ -425,7 +492,6 @@
                                                                                
                                                                                
   'view' => "view_control_items", 'control_id' => $control_id, 
                                                                                
                                                                                
   'control_group_ids' => $control_group_ids))
                                                ),array('label' => "4: " . 
lang('Sort_check_list')
-                                               ),array('label' => "5: " . 
lang('Show_check_lists')
                                                )
                                                
                                        );
@@ -434,8 +500,7 @@
                        (
                                'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($tabs, 3),
                                'view'                                  => 
"sort_check_list",
-                               'control_id'                    => $control_id,
-                               'control_title'                 => 
$control_title,
+                               'control'                               => 
$control->toArray(),
                                'saved_groups_with_items_array' => 
$saved_groups_with_items_array
                        );
                        
@@ -517,9 +582,7 @@
                                                                                
                                                                                
   'view' => "view_control_items", 'control_id' => $control_id, 
                                                                                
                                                                                
   'control_group_ids' => $control_group_ids))
                                                ),array('label' => "4: " . 
lang('Sort_check_list')
-                                               ),array('label' => "5: " . 
lang('Show_check_lists')
                                                )
-                                               
                                        );
                        
                        $data = array

Modified: 
branches/Version-1_0-branch/controller/inc/class.uilocation_check_list.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/class.uilocation_check_list.inc.php  
    2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/controller/inc/class.uilocation_check_list.inc.php  
    2011-11-17 18:21:09 UTC (rev 8125)
@@ -39,7 +39,7 @@
                        $this->so_check_list = 
CreateObject('controller.socheck_list');
                        $this->so_check_item = 
CreateObject('controller.socheck_item');
                        
-                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::check_list";
+                       
self::set_active_menu('controller::location_check_list');
                }
                        
                public function view_check_lists_for_location()

Modified: branches/Version-1_0-branch/controller/js/controller/custom_ui.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/custom_ui.js   
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/js/controller/custom_ui.js   
2011-11-17 18:21:09 UTC (rev 8125)
@@ -42,6 +42,25 @@
                $("ul.expand_list").find("li h4 img").attr("src", 
"controller/images/arrow_left.png");
        });
        
+       /* 
=============================================================================== 
*/
+       
+       if( $("#frm_control_items").length > 0 ){
+               var check_box_arr = 
$("#frm_control_items").find("input[type='checkbox']");
+               
+               $(check_box_arr).each(function(index) {
+                       var check_box = check_box_arr[index];
+                       
+                       if( $(check_box).is(':checked') ){
+                               var chbox_id = $(check_box).attr("id");
+                               
+                               var control_group_id = chbox_id.substring( 
chbox_id.indexOf("_")+1, chbox_id.indexOf(":") );
+                               var control_item_id = chbox_id.substring( 
chbox_id.indexOf(":")+1,  chbox_id.length );
+                               
+                               $("#frm_control_items").prepend("<input 
type='hidden' id=hid_" + control_item_id +  " name='control_tag_ids[]' value=" 
+ control_group_id + ":" +  control_item_id + " />");
+                       }
+               });
+       }
+       
        $("#frm_control_items input[type='checkbox']").click(function(){
                var thisCbox = $(this);
                
@@ -56,7 +75,6 @@
                        $("#frm_control_items").prepend("<input type='hidden' 
id=hid_" + control_item_id +  " name='control_tag_ids[]' value=" + 
control_group_id + ":" +  control_item_id + " />");
                }
        });
-       
-       
+               
 });
                

Modified: 
branches/Version-1_0-branch/controller/templates/base/choose_control_items.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/choose_control_items.xsl  
    2011-11-17 18:17:28 UTC (rev 8124)
+++ 
branches/Version-1_0-branch/controller/templates/base/choose_control_items.xsl  
    2011-11-17 18:21:09 UTC (rev 8125)
@@ -2,14 +2,15 @@
 
 <div class="yui-content tab_content">
        <div>
-                 
-          <!-- ===========================  CHOOSE CONTROL ITEMS  
=============================== -->
+          <!-- ===========================  CHOOSE CONTROL ITEMS  
=============================== -->  
           <h2>Velg dine kontrollpunkt</h2>
           
+          <!-- ==== CHOOSE NONE/ALL ===== -->
                <h4 class="expand_header"><div class="expand_all">Vis 
alle</div><div class="collapse_all">Skjul alle</div></h4>
+               
                <form id="frm_control_items" 
action="index.php?menuaction=controller.uicontrol.save_control_items" 
method="post">       
-                       <xsl:variable name="control_id"><xsl:value-of 
select="control_id"/></xsl:variable>
-                       <input type="hidden" name="control_id" 
value="{control_id}" />
+                       <xsl:variable name="control_id"><xsl:value-of 
select="control/id"/></xsl:variable>
+                       <input type="hidden" name="control_id" 
value="{$control_id}" />
                        
                        <xsl:variable name="control_group_ids"><xsl:value-of 
select="control_group_ids"/></xsl:variable>
                        <input type="hidden" name="control_group_ids" 
value="{control_group_ids}" />            
@@ -18,15 +19,29 @@
                                <xsl:for-each 
select="groups_with_control_items">
                                        <ul class="itemlist expand_list">
                                <li>
-                                       <h4><img 
src="controller/images/arrow_left.png" width="14"/><span><xsl:value-of 
select="control_group/group_name"/></span></h4>
-                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
-                                       <ul>            
-                                                       <xsl:for-each 
select="group_control_items">
-                                                               <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
-                                                               
-                                                       <li><xsl:number/>.  
<input type="checkbox"  id="ch_{$control_group_id}:{$control_item_id}" 
value="{$control_group_id}:{$control_item_id}" /><xsl:value-of 
select="title"/></li> 
-                                                       </xsl:for-each>
-                                               </ul>
+                                       <xsl:choose>
+                                               <xsl:when 
test="group_control_items/child::node()">
+                                                       <h4><img 
src="controller/images/arrow_left.png" width="14"/><span><xsl:value-of 
select="control_group/group_name"/></span></h4>
+                                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
+                                                       <ul>            
+                                                                       
<xsl:for-each select="group_control_items">
+                                                                               
<xsl:variable name="control_item_id"><xsl:value-of 
select="control_item/id"/></xsl:variable>
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="checked = 1">
+                                                                               
                <li><xsl:number/>.  <input type="checkbox"  checked="checked" 
id="ch_{$control_group_id}:{$control_item_id}" 
value="{$control_group_id}:{$control_item_id}" /><xsl:value-of 
select="control_item/title"/></li>
+                                                                               
        </xsl:when>
+                                                                               
        <xsl:otherwise>
+                                                                               
                <li><xsl:number/>.  <input type="checkbox"  
id="ch_{$control_group_id}:{$control_item_id}" 
value="{$control_group_id}:{$control_item_id}" /><xsl:value-of 
select="control_item/title"/></li>
+                                                                               
        </xsl:otherwise>
+                                                                               
</xsl:choose>
+                                                                       
</xsl:for-each>
+                                                               </ul>
+                                                       </xsl:when>
+                                               <xsl:otherwise>
+                                                       <div 
class="empty_list"><span><xsl:value-of 
select="control_group/group_name"/></span></div>
+                                                       <div>Ingen 
kontrollpunkt</div>
+                                               </xsl:otherwise>
+                                               </xsl:choose>
                                        </li>
                                </ul>
                                </xsl:for-each>
@@ -36,8 +51,7 @@
                                <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
                                <input type="submit" name="save_control_items" 
value="{$lang_save}" title = "{$lang_save}" />
                        </div>
-               </form>
-                                                               
+               </form>                                 
        </div>
 </div>
 </xsl:template>
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_groups.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control_groups.xsl    
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/templates/base/control_groups.xsl    
2011-11-17 18:21:09 UTC (rev 8125)
@@ -9,18 +9,22 @@
                        <xsl:variable name="control_area_id"><xsl:value-of 
select="control_area/id"/></xsl:variable>
                        <input type="hidden" name="control_area_id" 
value="{$control_area_id}" />
                        
-                       <xsl:variable name="control_id"><xsl:value-of 
select="control_id"/></xsl:variable>
-                       <input type="hidden" name="control_id" 
value="{control_id}" />
+                       <xsl:variable name="control_id"><xsl:value-of 
select="control/id"/></xsl:variable>
+                       <input type="hidden" name="control_id" 
value="{$control_id}" />
                        
                        <ul class="itemlist">
                                <xsl:for-each select="//control_groups">
-                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="id"/></xsl:variable>
-                               
-                                       <xsl:for-each 
select="chosen_control_groups">
-                                               <xsl:value-of select="."/>
-                                       </xsl:for-each>
-                               
-                               <li><input type="checkbox"  
name="control_group_ids[]" value="{$control_group_id}" /><xsl:value-of 
select="group_name"/></li>
+                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
+                                       
+                                       <xsl:choose>
+                                               <xsl:when test="checked = 1">
+                                                       <li><input 
type="checkbox" checked="checked" name="control_group_ids[]" 
value="{$control_group_id}" /><xsl:value-of 
select="control_group/group_name"/></li>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <li><input 
type="checkbox" name="control_group_ids[]" value="{$control_group_id}" 
/><xsl:value-of select="control_group/group_name"/></li>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               
                                </xsl:for-each>
                        </ul>
                        <div>

Modified: branches/Version-1_0-branch/controller/templates/base/control_tabs.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control_tabs.xsl      
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/templates/base/control_tabs.xsl      
2011-11-17 18:21:09 UTC (rev 8125)
@@ -13,46 +13,39 @@
                </xsl:when>
                <xsl:when test="view = 'control_groups'">
                        <div class="identifier-header">
-                               <h1><xsl:value-of select="php:function('lang', 
'Control_groups')"/> for <xsl:value-of select="control_title" /></h1>
+                               <h1><xsl:value-of select="php:function('lang', 
'Control_groups')"/> for <xsl:value-of select="control/title" /></h1>
                        </div>
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
                        <xsl:call-template name="control_groups" />
                </xsl:when>
                <xsl:when test="view = 'control_locations'">
                        <div class="identifier-header">
-                               <h1><xsl:value-of select="php:function('lang', 
'Control_locations')"/> for <xsl:value-of select="control_title" /></h1>
+                               <h1><xsl:value-of select="php:function('lang', 
'Control_locations')"/> for <xsl:value-of select="control/title" /></h1>
                        </div>
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
                        <xsl:call-template name="control_locations" />
                </xsl:when>
                <xsl:when test="view = 'control_equipment'">
                        <div class="identifier-header">
-                               <h1><xsl:value-of select="php:function('lang', 
'Control_equipment')"/> for <xsl:value-of select="control_title" /></h1>
+                               <h1><xsl:value-of select="php:function('lang', 
'Control_equipment')"/> for <xsl:value-of select="control/title" /></h1>
                        </div>
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
                        <xsl:call-template name="control_equipment" />
                </xsl:when>
                <xsl:when test="view = 'control_items'">
                        <div class="identifier-header">
-                               <h1><xsl:value-of select="php:function('lang', 
'Control_items')"/> for <xsl:value-of select="control_title" /></h1>
+                               <h1><xsl:value-of select="php:function('lang', 
'Control_items')"/> for <xsl:value-of select="control/title" /></h1>
                        </div>
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
                        <xsl:call-template name="control_items" />
                </xsl:when>
                <xsl:when test="view = 'sort_check_list'">
                        <div class="identifier-header">
-                               <h1><xsl:value-of select="php:function('lang', 
'Check_list')"/> for <xsl:value-of select="control_title" /></h1>
+                               <h1><xsl:value-of select="php:function('lang', 
'Check_list')"/> for <xsl:value-of select="control/title" /></h1>
                        </div>
                        <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
                        <xsl:call-template name="sort_check_list" />
                </xsl:when>
-               <xsl:when test="view = 'view_check_lists'">
-                       <div class="identifier-header">
-                               <h1><xsl:value-of select="php:function('lang', 
'Check_list')"/> for <xsl:value-of select="control_title" /></h1>
-                       </div>
-                       <xsl:value-of disable-output-escaping="yes" 
select="tabs" />
-                       <xsl:call-template name="tab_view_check_lists" />
-               </xsl:when>
        </xsl:choose>
 </div>
        

Modified: branches/Version-1_0-branch/controller/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/css/base.css  
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/controller/templates/base/css/base.css  
2011-11-17 18:21:09 UTC (rev 8125)
@@ -832,7 +832,7 @@
 ul.calendar li div {
     float: left;
     text-align: center;
-    width: 50px;
+    width: 40px;
     padding: 3px;
 }
 
@@ -878,4 +878,9 @@
     font-weight: bold;
     padding: 0 0 8px;
     text-align: center;
+}
+.empty_list{
+       font-size: 16px;
+    font-weight: bold;
+    padding: 0 0 5px;
 }
\ No newline at end of file

Modified: branches/Version-1_0-branch/property/inc/class.boentity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boentity.inc.php     
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/property/inc/class.boentity.inc.php     
2011-11-17 18:21:09 UTC (rev 8125)
@@ -305,6 +305,8 @@
                        $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);
 
+                       $category = 
$this->soadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+
                        $attrib_filter = array();
                        if($attrib_data)
                        {
@@ -314,14 +316,28 @@
                                        {
                                                if($_attrib_filter_value = 
phpgw::get_var($attrib['column_name'], 'int'))
                                                {
-                                                       $attrib_filter[] = 
"fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} = 
'{$_attrib_filter_value}'";
+                                                       if($category['is_eav'])
+                                                       {
+                                                               
$attrib_filter[] = "xmlexists('//{$attrib['column_name']}[text() = 
''$_attrib_filter_value'']' PASSING BY REF xml_representation)";
+                                                       }
+                                                       else
+                                                       {
+                                                               
$attrib_filter[] = 
"fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} = 
'{$_attrib_filter_value}'";
+                                                       }
                                                }
                                        }
                                        else if($attrib['datatype'] == 'CH')
                                        {
                                                if($_attrib_filter_value = 
phpgw::get_var($attrib['column_name'], 'int'))
                                                {
-                                                       $attrib_filter[] = 
"fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} 
{$GLOBALS['phpgw']->db->like} '%,{$_attrib_filter_value},%'";
+                                                       if($category['is_eav'])
+                                                       {
+                                                               
$attrib_filter[] = 
"xmlexists('//{$attrib['column_name']}[contains(.,'',$_attrib_filter_value,'')]'
 PASSING BY REF xml_representation)";
+                                                       }
+                                                       else
+                                                       {
+                                                               
$attrib_filter[] = 
"fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} 
{$GLOBALS['phpgw']->db->like} '%,{$_attrib_filter_value},%'";
+                                                       }
                                                }
                                        }
                                }
@@ -409,19 +425,30 @@
                                }
                        }
 
+                       //old
                        if($values['p_num'])
                        {
                                $soadmin_entity                         = 
CreateObject('property.soadmin_entity');
                                $soadmin_entity->type           = 'entity';
                                $soadmin_entity->type_app       = 'property';
                                $category = 
$soadmin_entity->read_single_category($values['p_entity_id'],$values['p_cat_id']);
-//                             $category = 
$this->soadmin_entity->read_single_category($values['p_entity_id'],$values['p_cat_id']);
                                
$values['p'][$values['p_entity_id']]['p_num']=$values['p_num'];
                                
$values['p'][$values['p_entity_id']]['p_entity_id']=$values['p_entity_id'];
                                
$values['p'][$values['p_entity_id']]['p_cat_id']=$values['p_cat_id'];
                                
$values['p'][$values['p_entity_id']]['p_cat_name'] = $category['name'];
                        }
 
+                       //new
+                       if($values['p_id'] && $values['p_location_id'])
+                       {
+                               $p_location = 
$GLOBALS['phpgw']->locations->get_name($values['p_location_id']);
+                               $p__location = explode('.', 
$p_location['location']);
+                               
$values['p'][$p__location[2]]['p_num']=$values['p_id'];
+                               
$values['p'][$p__location[2]]['p_entity_id']=$p__location[2];
+                               
$values['p'][$p__location[2]]['p_cat_id']=$p__location[3];
+                               $values['p'][$p__location[2]]['p_cat_name'] = 
$p_location['descr'];
+                       }
+
                        $vfs = CreateObject('phpgwapi.vfs');
                        $vfs->override_acl = 1;
 

Modified: branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php       
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php       
2011-11-17 18:21:09 UTC (rev 8125)
@@ -956,6 +956,10 @@
                        $category = $this->read_single_category($entity_id, 
$id);
                        if($category['is_eav'])
                        {
+                               $this->db->query("SELECT id as type FROM 
fm_bim_type WHERE location_id= {$location_id}",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $type = (int)$this->db->f('type');
+                               $this->db->query("DELETE FROM fm_bim_item WHERE 
type = {$type}",__LINE__,__FILE__);
                                $this->db->query("DELETE FROM fm_bim_type WHERE 
location_id= {$location_id}",__LINE__,__FILE__);
                        }
                        else

Modified: branches/Version-1_0-branch/property/inc/class.soentity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2011-11-17 18:17:28 UTC (rev 8124)
+++ branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2011-11-17 18:21:09 UTC (rev 8125)
@@ -215,7 +215,7 @@
                        return $values;
                }
 
-               function read($data)
+               protected function read_eav($data)
                {
                        $start                  = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
                        $filter                 = isset($data['filter']) && 
$data['filter'] ? $data['filter'] : 'all';
@@ -241,9 +241,562 @@
 
                        if(!$entity_id || !$cat_id)
                        {
+                               return array();
+                       }
+
+                       $grants         = 
$GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}",$this->type_app[$this->type]);
+
+                       if(!$grants)
+                       {
+                               $this->acl      = & $GLOBALS['phpgw']->acl;
+                               $this->acl->set_account_id($this->account);
+                               $grants         = 
$this->acl->get_grants($this->type_app[$this->type],".{$this->type}.{$entity_id}.{$cat_id}");
+                               
$GLOBALS['phpgw']->session->appsession("grants_entity_{$entity_id}_{$cat_id}", 
$this->type_app[$this->type], $grants);
+                       }
+
+                       $location_id = 
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], 
".{$this->type}.{$entity_id}.{$cat_id}");
+                       $entity_table = 'fm_bim_item';
+                       $choice_table = 'phpgw_cust_choice';
+                       $attribute_table = 'phpgw_cust_attribute';
+                       $attribute_filter = " location_id = {$location_id}";
+
+                       $sql = 
'';//$this->bocommon->fm_cache("sql_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+
+                       if(!$sql)
+                       {
+                               $cols_return_extra      = array();
+                               $cols_return            = array();
+                               $uicols                         = array();
+                               $cols                           = 
"{$entity_table}.*";
+
+                               $cols_return[]                          = 
'location_code';
+                               $uicols['input_type'][]         = 'hidden';
+                               $uicols['name'][]                       = 
'location_code';
+                               $uicols['descr'][]                      = 
'dummy';
+                               $uicols['statustext'][]         = 'dummy';
+                               $uicols['align'][]                      = '';
+                               $uicols['datatype'][]           = '';
+                               $uicols['sortable'][]           = true;
+                               $uicols['exchange'][]           = false;
+                               $uicols['formatter'][]          = '';
+                               $uicols['classname'][]          = '';
+
+                               $cols_return[]                          = 'num';
+                               $uicols['input_type'][]         = 'text';
+                               $uicols['name'][]                       = 'num';
+                               $uicols['descr'][]                      = 
lang('ID');
+                               $uicols['statustext'][]         = lang('ID');
+                               $uicols['align'][]                      = '';
+                               $uicols['datatype'][]           = '';
+                               $uicols['sortable'][]           = true;
+                               $uicols['exchange'][]           = false;
+                               $uicols['formatter'][]          = '';
+                               $uicols['classname'][]          = '';
+
+                               $cols_return[]                          = 'id';
+                               $uicols['input_type'][]         = 'hidden';
+                               $uicols['name'][]                       = 'id';
+                               $uicols['descr'][]                      = false;
+                               $uicols['statustext'][]         = false;
+                               $uicols['align'][]                      = '';
+                               $uicols['datatype'][]           = '';
+                               $uicols['sortable'][]           = false;
+                               $uicols['exchange'][]           = false;
+                               $uicols['formatter'][]          = '';
+                               $uicols['classname'][]          = '';
+
+                               if($lookup)
+                               {
+                                       $cols .= ',num as entity_num_' . 
$entity_id;
+                                       $cols_return[] = 'entity_num_' . 
$entity_id;
+                                       $uicols['input_type'][]         = 
'hidden';
+                                       $uicols['name'][]                       
= 'entity_num_' . $entity_id;
+                                       $uicols['descr'][]                      
= 'dummy';
+                                       $uicols['statustext'][]         = 
'dummy';
+                                       $uicols['align'][]                      
= '';
+                                       $uicols['datatype'][]           = '';
+                                       $uicols['sortable'][]           = false;
+                                       $uicols['exchange'][]           = false;
+                                       $uicols['formatter'][]          = '';
+                                       $uicols['classname'][]          = '';
+                               }
+
+               //              $cols .= ", {$entity_table}.user_id";
+                               $cols_return[]                          = 
'user_id';
+
+                               $cols_return_extra[]= array
+                               (
+                                       'name'          => 'user_id',
+                                       'datatype'      => 'user'
+                               );
+
+                               // Don't work with LDAP - where phpgw_accounts 
is empty
+                               //                      $joinmethod = " 
$this->join phpgw_accounts ON ($entity_table.user_id = 
phpgw_accounts.account_id))";
+                               //                      $paranthesis ='(';
+
+                               
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
+                                       
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'lookup'=>$lookup,'location_level'=>$category['location_level']));
+
+
+               //              
$this->bocommon->fm_cache("sql_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}", 
$sql);
+                               
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->uicols);
+                               
$this->bocommon->fm_cache("cols_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->cols_return);
+                               
$this->bocommon->fm_cache("cols_return_lookup_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->cols_return_lookup);
+                               
$this->bocommon->fm_cache("cols_extra_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->cols_extra);
+                               
$this->bocommon->fm_cache("cols_extra_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $cols_return_extra);
+
+                               $uicols                                         
= $this->bocommon->uicols;
+                               $cols_return                            = 
$this->bocommon->cols_return;
+                               $this->cols_return_lookup       = 
$this->bocommon->cols_return_lookup;
+                               $this->cols_extra                       = 
$this->bocommon->cols_extra;
+                       }
+                       else
+                       {
+                               $uicols                                         
= 
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                               $cols_return                            = 
$this->bocommon->fm_cache("cols_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                               $this->cols_return_lookup       = 
$this->bocommon->fm_cache("cols_return_lookup_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                               $this->cols_extra                       = 
$this->bocommon->fm_cache("cols_extra_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                               $cols_return_extra                      = 
$this->bocommon->fm_cache("cols_extra_return_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}");
+                       }
+
+                       if ($cat_id > 0)
+                       {
+                               //-------------------
+
+                               $user_columns = 
isset($GLOBALS['phpgw_info']['user']['preferences'][$this->type_app[$this->type]]['entity_columns_'.$entity_id.'_'.$cat_id])?$GLOBALS['phpgw_info']['user']['preferences'][$this->type_app[$this->type]]['entity_columns_'.$entity_id.'_'.$cat_id]:array();
+                               
+                               $_user_columns = array();
+                               foreach ($user_columns as $user_column_id)
+                               {
+                                       if(ctype_digit($user_column_id))
+                                       {
+                                               $_user_columns[] = 
$user_column_id;
+                                       }
+                               }
+                               $user_column_filter = '';
+
+                               if ($_user_columns)
+                               {
+                                       $user_column_filter = " OR 
($attribute_filter AND id IN (" . implode(',',$_user_columns) .'))';
+                               }
+
+                               $this->db->query("SELECT * FROM 
$attribute_table WHERE list=1 AND $attribute_filter $user_column_filter ORDER 
BY group_id, attrib_sort ASC");
+
+                               $i      = count($uicols['name']);
+                               while ($this->db->next_record())
+                               {
+                                       $uicols['input_type'][]         = 
'text';
+                                       $uicols['name'][]                       
= $this->db->f('column_name');
+                                       $uicols['descr'][]                      
= $this->db->f('input_text');
+                                       $uicols['statustext'][]         = 
$this->db->f('statustext');
+                                       $uicols['datatype'][$i]         = 
$this->db->f('datatype');
+                                       $uicols['sortable'][$i]         = true;
+                                       $uicols['exchange'][$i]         = false;
+                                       $uicols['formatter'][$i]        = '';
+                                       $uicols['classname'][$i]        = '';
+
+                                       $uicols['cols_return_extra'][$i] = array
+                                               (
+                                                       'name'  => 
$this->db->f('column_name'),
+                                                       'datatype'      => 
$this->db->f('datatype'),
+                                                       'attrib_id'     => 
$this->db->f('id')                                   
+                                               );
+
+
+                                       $cols_return_extra[]= array(
+                                               'name'  => 
$this->db->f('column_name'),
+                                               'datatype'      => 
$this->db->f('datatype'),
+                                               'attrib_id'     => 
$this->db->f('id')
+                                       );
+
+                                       $i++;
+                               }
+
+                               $uicols['input_type'][]         = 'text';
+                               $uicols['name'][]                       = 
'entry_date';
+                               $uicols['descr'][]                      = 
lang('entry date');
+                               $uicols['statustext'][]         = lang('entry 
date' );
+                               $uicols['datatype'][]           = 'timestamp';
+                               $uicols['sortable'][]           = true;
+                               $uicols['exchange'][]           = false;
+                               $uicols['formatter'][]  = '';
+                               $uicols['classname'][]  = '';
+
+                               $uicols['cols_return_extra'][$i] = array
+                                       (
+                                               'name'          => 'entry_date',
+                                               'datatype'      => 'timestamp',
+                                       );
+
+
+                               $cols_return_extra[]= array(
+                                       'name'  => 'entry_date',
+                                       'datatype'      => 'timestamp',

@@ Diff output truncated at 153600 characters. @@



reply via email to

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