fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8580] Merge 8558:8579 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [8580] Merge 8558:8579 from trunk
Date: Mon, 16 Jan 2012 07:51:54 +0000

Revision: 8580
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8580
Author:   sigurdne
Date:     2012-01-16 07:51:53 +0000 (Mon, 16 Jan 2012)
Log Message:
-----------
Merge 8558:8579 from trunk

Modified Paths:
--------------
    
branches/Version-1_0-branch/booking/inc/class.async_task_send_reminder.inc.php
    branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php
    
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php
    
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation_export.inc.php
    branches/Version-1_0-branch/booking/inc/class.uievent.inc.php
    branches/Version-1_0-branch/booking/inc/class.uisystem_message.inc.php
    branches/Version-1_0-branch/booking/templates/base/allocation_edit.xsl
    branches/Version-1_0-branch/booking/templates/base/booking_edit.xsl
    branches/Version-1_0-branch/booking/templates/base/building_form.xsl
    branches/Version-1_0-branch/controller/inc/class.socase.inc.php
    branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php
    branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
    
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
    
branches/Version-1_0-branch/controller/inc/component/class.calendar_builder.inc.php
    
branches/Version-1_0-branch/controller/inc/component/class.date_generator.inc.php
    
branches/Version-1_0-branch/controller/inc/helper/class.check_list_status_info.inc.php
    branches/Version-1_0-branch/controller/inc/model/class.check_list.inc.php
    branches/Version-1_0-branch/controller/inc/model/class.control.inc.php
    branches/Version-1_0-branch/controller/js/controller/ajax.js
    branches/Version-1_0-branch/controller/setup/setup.inc.php
    branches/Version-1_0-branch/controller/setup/tables_current.inc.php
    branches/Version-1_0-branch/controller/setup/tables_update.inc.php
    
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
    
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
    
branches/Version-1_0-branch/controller/templates/base/case/create_case_message.xsl
    
branches/Version-1_0-branch/controller/templates/base/case/view_case_message.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/cases_tab_menu.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/edit_check_list.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/register_case.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_closed_cases.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_measurements.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_item/choose_control_items.xsl
    branches/Version-1_0-branch/controller/templates/base/css/base.css
    branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.botts.inc.php
    branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.notify.inc.php
    branches/Version-1_0-branch/property/inc/class.soXport.inc.php
    branches/Version-1_0-branch/property/inc/class.socommon.inc.php
    branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.solocation.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
    
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_basware_X205.php
    branches/Version-1_0-branch/property/inc/export/default/Agresso
    branches/Version-1_0-branch/property/inc/export/default/Basware_X114
    branches/Version-1_0-branch/property/inc/import/default/Import_fra_BKK
    branches/Version-1_0-branch/property/inc/import/default/Import_fra_BKK_csv
    branches/Version-1_0-branch/property/inc/import/default/Import_fra_Kemner
    branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service
    
branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service_xml
    branches/Version-1_0-branch/property/inc/import/default/efaktura_dnb_xml
    
branches/Version-1_0-branch/property/inc/import/default/import_fra_Service_xls
    branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js
    branches/Version-1_0-branch/property/setup/default_records.inc.php
    branches/Version-1_0-branch/property/setup/phpgw_no.lang
    branches/Version-1_0-branch/property/setup/setup.inc.php
    branches/Version-1_0-branch/property/setup/tables_current.inc.php
    branches/Version-1_0-branch/property/setup/tables_update.inc.php
    branches/Version-1_0-branch/property/templates/base/workorder.xsl

Added Paths:
-----------
    
branches/Version-1_0-branch/controller/templates/base/check_list/check_list_tab_menu.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl

Removed Paths:
-------------
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_errors_for_check_list.xsl

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,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557
   + 
/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,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579

Modified: 
branches/Version-1_0-branch/booking/inc/class.async_task_send_reminder.inc.php
===================================================================
--- 
branches/Version-1_0-branch/booking/inc/class.async_task_send_reminder.inc.php  
    2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/booking/inc/class.async_task_send_reminder.inc.php  
    2012-01-16 07:51:53 UTC (rev 8580)
@@ -118,8 +118,9 @@
                        {
                                $body .= "Hvem: %WHO%\n";
                        }
-                       $body .= "\nVennlist oppgi korrekt deltakertall\n";
-                       $body .= "Du kan gjøre dette ved å klikke på linken 
nedenfor\n\n%URL%";
+                       $body .= "\nBergen kommune fører statistikk på bruk av 
lokaler og ber derfor om at dere \n";
+                       $body .= "\netter arrangementet melder inn korrekt 
deltakertall til oss.\n";
+                       $body .= "Du kan gjøre dette ved å klikke på linken 
nedenfor.\n\n%URL%";
 
                        $body = str_replace('%URL%', 
$external_site_address.'/bookingfrontend/?menuaction=bookingfrontend.ui'.$type.'.report_numbers&id='.$id.'&secret='.$secret,
 $body);
                        $body = str_replace('%WHO%', $who, $body);

Modified: 
branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php
===================================================================
--- branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php   
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/booking/inc/class.customer_identifier.inc.php   
2012-01-16 07:51:53 UTC (rev 8580)
@@ -31,9 +31,13 @@
                     {
                        
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = 
$from_entity['customer_number'];
                     }
+                    elseif 
(strlen($from_entity['customer_organization_number']) == 5) 
+                                       {
+                       
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = 
$from_entity['customer_organization_number'];
+                                       }                       
                     else
                     {
-                               
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = '';
+                               
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = lang('None');
                     }
                 } 
                 else 

Modified: 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php
===================================================================
--- 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php   
    2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation.inc.php   
    2012-01-16 07:51:53 UTC (rev 8580)
@@ -150,9 +150,6 @@
                                'season_id'                             => 
isset($reservation['season_id']) ? $reservation['season_id'] : null,
                        );
                        
-                       //echo "$type\n";
-                       //print_r($reservation);
-                       
                        $method = "initialize_completed_{$type}";
                        $this->$method($reservation, $entity);
                        $this->set_description($type, $reservation, $entity);
@@ -265,12 +262,22 @@
             if (intval($organization['customer_internal']) == 1) {
                 if (strlen($organization['customer_number']) == 5) {
                     $entity['customer_organization_number'] = 
$organization['customer_number'];
+                       $entity['customer_identifier_type'] = 
'organization_number';
+                } elseif ($organization['customer_identifier_type'] == 'ssn') {
+                    $entity['customer_ssn'] = $organization['customer_ssn'];
+                       $entity['customer_identifier_type'] = 'ssn';
+                } elseif ($organization['customer_identifier_type'] == 
'organization_number') {
+                    $entity['customer_organization_number'] = 
$organization['customer_organization_number'];
+                       $entity['customer_identifier_type'] = 
'organization_number';
                 } else {
                     $entity['customer_organization_number'] = '';
+                       $entity['customer_identifier_type'] = '';
                 }
             } else {
                 $entity['customer_organization_number'] = 
$organization['organization_number'];
-            }
+                $entity['customer_identifier_type'] = 'organization_number';
+                       }
+                       
                }
                
                protected function initialize_completed_booking(&$booking, 
&$entity) {
@@ -311,8 +318,25 @@
                }
                
                protected function initialize_completed_event(&$event, 
&$entity) {
-                       $this->set_customer_type($entity, $event);
-                       $this->copy_customer_identifier($event, $entity);
+
+                       if($event['customer_organization_id'] > 0) {
+                               static $soorg;
+                               static $cache = array();
+
+                               !$soorg AND $soorg = 
CreateObject('booking.soorganization');
+                               if 
(isset($cache[$event['customer_organization_id']])) {
+                                       $org = 
$cache[$event['customer_organization_id']];
+                               } else {
+                                       $org = 
$soorg->read_single($event['customer_organization_id']);
+                                       
$cache[$event['customer_organization_id']] = $org;
+                               }
+                               $this->set_organization($entity, $org);         
                
+                               $this->set_customer_type($entity, $org);
+                               $this->copy_customer_identifier($event, 
$entity);
+                       } else {
+                               $this->set_customer_type($entity, $event);
+                               $this->copy_customer_identifier($event, 
$entity);
+                       }
                }
                
                public function update_exported_state_of(&$reservations, 
$with_export_id) {

Modified: 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation_export.inc.php
===================================================================
--- 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation_export.inc.php
        2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/booking/inc/class.socompleted_reservation_export.inc.php
        2012-01-16 07:51:53 UTC (rev 8580)
@@ -638,8 +638,6 @@
                        $trans_type = str_pad(substr(strtoupper('42'), 0, 2), 
2, ' ');
                        $voucher_type = str_pad(substr(strtoupper('FK'), 0, 2), 
2, ' ');
                        
-//                     echo "<pre>";print_r($reservations);exit;       
-                       
                        foreach($reservations as &$reservation) {
                                if ($this->get_cost_value($reservation['cost']) 
<= 0) {
                                        continue; //Don't export costless rows
@@ -648,8 +646,8 @@
                                $order_id = 
$sequential_number_generator->increment()->get_current();
                                $export_info[] = 
$this->create_export_item_info($reservation, $order_id);
                                
-                               $reservation = array_map('utf8_decode', 
$reservation);
-                               
+       //                      $reservation = array_map('utf8_decode', 
$reservation);
+
                                //header level
                                $header = $this->get_agresso_row_template();
                                $header['accept_flag'] = '1';
@@ -688,8 +686,8 @@
                                $header['line_no'] = '0000'; //Nothing here 
according to example file but spec. says so
                                
                                //Topptekst til faktura, knyttet mot fagavdeling
-                               $header['long_info1'] = 
str_pad(substr($account_codes['invoice_instruction'], 0, 120), 120, ' ');
-                               
+                               $header['long_info1'] = 
str_pad(substr(iconv("utf-8","windows-1252",$account_codes['invoice_instruction']),
 0, 120), 120, ' ');
+
                                //Ordrenr. UNIKT, løpenr. genereres i booking 
ut fra gitt serie, eks. 38000000
                                $header['order_id'] = str_pad($order_id, 9, 0, 
STR_PAD_LEFT);
                                
@@ -714,7 +712,7 @@
                                /* Data hentes fra booking, tidspunkt legges i 
eget felt som kommer på 
                                 * linjen under: 78_short_info. <navn på bygg>, 
 <navn på ressurs>
                                 */
-                               $item['art_descr'] = 
str_pad(substr($reservation['article_description'], 0, 35), 35, ' '); //35 
chars long
+                               $item['art_descr'] = 
str_pad(substr(iconv("utf-8","windows-1252",$reservation['article_description']),
 0, 35), 35, ' '); //35 chars long
                                
                                //Artikkel opprettes i Agresso (4 siffer), en 
for kultur og en for idrett, inneholder konteringsinfo.
                                $item['article'] = 
str_pad(substr(strtoupper($account_codes['article']), 0, 15), 15, ' ');
@@ -770,7 +768,7 @@
                                $text['batch_id'] = $header['batch_id'];
                                $text['client'] = $header['client'];
                                $text['line_no'] = $item['line_no']; 
-                               $text['short_info'] = 
str_pad(substr($reservation['description'], 0, 60), 60, ' ');
+                               $text['short_info'] = 
str_pad(substr(iconv("utf-8","windows-1252",$reservation['description']), 0, 
60), 60, ' ');
                                $text['trans_type'] = $header['trans_type'];
                                $text['voucher_type'] = $header['voucher_type'];
                                
@@ -781,6 +779,7 @@
                                $output[] = implode('', str_replace(array("\n", 
"\r"), '', $header));
                                $output[] = implode('', str_replace(array("\n", 
"\r"), '', $item));
                                $output[] = implode('', str_replace(array("\n", 
"\r"), '', $text));
+
                        }
                        
                        if (count($export_info) == 0) {

Modified: branches/Version-1_0-branch/booking/inc/class.uievent.inc.php
===================================================================
--- branches/Version-1_0-branch/booking/inc/class.uievent.inc.php       
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/booking/inc/class.uievent.inc.php       
2012-01-16 07:51:53 UTC (rev 8580)
@@ -534,7 +534,8 @@
 
                                if(!$errors['event'] and 
!$errors['resource_number'] and !$errors['organization_number'] and 
!$errors['invoice_data']  && !$errors['contact_name'] && !$errors['cost'])
                                { 
-                                       if (phpgw::get_var('mail', 'POST') || 
phpgw::get_var('sendtorbuilding', 'POST'))
+
+                                       if ((phpgw::get_var('mail', 'POST') || 
phpgw::get_var('sendtorbuilding', 'POST')) && phpgw::get_var('active', 'POST'))
                                        {
                                                
if(phpgw::get_var('sendtocollision', 'POST') || phpgw::get_var('sendtocontact', 
'POST') || phpgw::get_var('sendtorbuilding', 'POST'))
                                                {
@@ -626,15 +627,17 @@
                                                        
$this->send_mailnotification($event['contact_email'], lang('Event changed'), 
phpgw::get_var('mail', 'POST'));
                                                }
                                        } elseif (!phpgw::get_var('active', 
'POST')) {
+                                               
                                                                if 
($event['customer_organization_name']) {
                                                                        
$comment_text_log = $event['customer_organization_name'];
                                                                } else {
                                                                        
$comment_text_log = $event['contact_name'];
                                                                }
-                                                               
$comment_text_log = $comment_text_log.' sitt arrangement i 
'.$event['building_name'].' '.date('d-m-Y H:i', strtotime($event['from_']))." 
har blitt kansellert.\n For mer opplysinger slå opp i AktivBy.";
-//                                                             
$comment_text_log = phpgw::get_var('mail', 'POST');
+                                                               
$comment_text_log = $comment_text_log.' sitt arrangement i 
'.$event['building_name'].' '.date('d-m-Y H:i', strtotime($event['from_']))." 
har blitt kansellert.\n For mer opplysinger slå opp i AktivBy.\n\n";
+                                                               
$comment_text_log .= phpgw::get_var('mail', 'POST');
                                                                $sendt = 0;
                                                                $mail_sendt_to 
= '';
+
                                                                
if($building_info['email']) {
                                                                        
$sendt++;
                                                                        
$mail_sendt_to = $mail_sendt_to.' '.$building_info['email'];

Modified: branches/Version-1_0-branch/booking/inc/class.uisystem_message.inc.php
===================================================================
--- branches/Version-1_0-branch/booking/inc/class.uisystem_message.inc.php      
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/booking/inc/class.uisystem_message.inc.php      
2012-01-16 07:51:53 UTC (rev 8580)
@@ -115,18 +115,10 @@
                                                        'label' => 
lang('Created')
                                                ),
                                                array(
-                                                       'key' => 'modified',
-                                                       'label' => lang('Last 
modified')
-                                               ),
-                                               array(
                                                        'key' => 'what',
                                                        'label' => lang('What')
                                                ),
                                                array(
-                                                       'key' => 
'activity_name',
-                                                       'label' => 
lang('Activity')
-                                               ),
-                                               array(
                                                        'key' => 'contact_name',
                                                        'label' => 
lang('Contact')
                                                ),
@@ -155,35 +147,34 @@
                        while ($record = array_shift($this->db->resultSet)) {
                                $current_user_building_data[] = 
$record['object_id'];
                        }
+
                        $filters['building_id'] = $current_user_building_data;
 
                        if(isset($_SESSION['showall']))
                        {
                                unset($filters['building_id']);
-                       unset($filters['building_name']);
-                       unset($filters['type']);
-                       unset($filters['status']);
                        } else {
+                               $filters['building_id'] = 
$current_user_building_data;
+                       }
 
-                $testdata =  phpgw::get_var('filter_building_id', 'int', 
'REQUEST', null);
-                if ($testdata != 0) {
-                    $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('filter_building_id', 'int', 
'REQUEST', null));        
-                } else {
-                    unset($filters['building_name']);                
-                }
-                $testdata2 =  phpgw::get_var('type', 'str', 'REQUEST');
-                if ($testdata2 != '') {
-                    $filters['type'] = phpgw::get_var('type', 'str', 
'REQUEST');        
-                } else {
-                    unset($filters['type']);
-                }
-                $testdata2 =  phpgw::get_var('status', 'str', 'REQUEST');
-                if ($testdata2 != '') {
-                    $filters['status'] = phpgw::get_var('status', 'str', 
'REQUEST');        
-                } else {
-                    unset($filters['status']);
-                }
+            $testdata =  phpgw::get_var('filter_building_id', 'int', 
'REQUEST', null);
+            if ($testdata != 0) {
+                   $filters['building_name'] = 
$this->bo->so->get_building(phpgw::get_var('filter_building_id', 'int', 
'REQUEST', null));        
+            } else {
+                   unset($filters['building_name']);                
             }
+            $testdata2 =  phpgw::get_var('type', 'str', 'REQUEST');
+            if ($testdata2 != '') {
+                   $filters['type'] = phpgw::get_var('type', 'str', 
'REQUEST');        
+            } else {
+                   unset($filters['type']);
+            }
+            $testdata2 =  phpgw::get_var('status', 'str', 'REQUEST');
+            if ($testdata2 != '') {
+                   $filters['status'] = phpgw::get_var('status', 'str', 
'REQUEST');        
+            } else {
+                   unset($filters['status']);
+            }
             
                        $params = array(
                                'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),

Modified: branches/Version-1_0-branch/booking/templates/base/allocation_edit.xsl
===================================================================
--- branches/Version-1_0-branch/booking/templates/base/allocation_edit.xsl      
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/booking/templates/base/allocation_edit.xsl      
2012-01-16 07:51:53 UTC (rev 8580)
@@ -3,7 +3,7 @@
 
        <ul class="pathway">
            <li><xsl:value-of select="php:function('lang', 'Allocations')" 
/></li>
-           <li><a href="">#<xsl:value-of select="allocation/id"/></a></li>
+           <li>#<xsl:value-of select="allocation/id"/></li>
        </ul>
     <xsl:call-template name="msgbox"/>
        <xsl:call-template name="yui_booking_i18n"/>

Modified: branches/Version-1_0-branch/booking/templates/base/booking_edit.xsl
===================================================================
--- branches/Version-1_0-branch/booking/templates/base/booking_edit.xsl 
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/booking/templates/base/booking_edit.xsl 
2012-01-16 07:51:53 UTC (rev 8580)
@@ -3,7 +3,7 @@
 
         <ul class="pathway">
             <li><xsl:value-of select="php:function('lang', 'Bookings')" /></li>
-            <li><a href="">#<xsl:value-of select="booking/id"/></a></li>
+            <li>#<xsl:value-of select="booking/id"/></li>
         </ul>
     <xsl:call-template name="msgbox"/>
        <xsl:call-template name="yui_booking_i18n"/>

Modified: branches/Version-1_0-branch/booking/templates/base/building_form.xsl
===================================================================
--- branches/Version-1_0-branch/booking/templates/base/building_form.xsl        
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/booking/templates/base/building_form.xsl        
2012-01-16 07:51:53 UTC (rev 8580)
@@ -8,9 +8,7 @@
                        </li>
                        <xsl:if test="not(new_form)">
                                <li>
-                                       <a href="{building/building_link}">
                                                <xsl:value-of 
select="building/name"/>
-                                       </a>
                                </li>
                        </xsl:if>
                </ul>

Modified: branches/Version-1_0-branch/controller/inc/class.socase.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socase.inc.php     
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.socase.inc.php     
2012-01-16 07:51:53 UTC (rev 8580)
@@ -64,6 +64,7 @@
                        if($this->db->next_record()) {
                                $case = new 
controller_check_item_case($this->unmarshal($this->db->f('id', true), 'int'));
                                
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id', true), 
'int'));
+                               
$case->set_status($this->unmarshal($this->db->f('status', true), 'int'));
                                
$case->set_location_id($this->unmarshal($this->db->f('location_id', true), 
'int'));
                                
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id', 
true), 'int'));
                                
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
@@ -80,7 +81,34 @@
                        }
                }
                
+               public function get_cases_by_message($message_ticket_id, 
$return_type = "return_object")
+               {
+                       $sql = "SELECT * FROM controller_check_item_case "; 
+                       $sql .= "WHERE location_item_id = $message_ticket_id";
+
+                       $this->db->query($sql);
+
+                       while ($this->db->next_record()) {
+                               $case = new 
controller_check_item_case($this->unmarshal($this->db->f('id', true), 'int'));
+                               
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id', true), 
'int'));
+                               
$case->set_location_id($this->unmarshal($this->db->f('location_id', true), 
'int'));
+                               
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id', 
true), 'int'));
+                               
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
+                               
$case->set_user_id($this->unmarshal($this->db->f('user_id', true), 'int'));     
+                               
$case->set_entry_date($this->unmarshal($this->db->f('entry_date', true), 
'int'));
+                               
$case->set_modified_date($this->unmarshal($this->db->f('modified_date', true), 
'int'));
+                               
$case->set_modified_by($this->unmarshal($this->db->f('modified_by', true), 
'int'));
+
+                               if($return_type == "return_object")
+                                       $cases_array[] = $case;
+                               else
+                                       $cases_array[] = $case->toArray();
+                       }
+
+                       return $cases_array;
+               }
                
+               
                function add(&$case)
                {
                        $cols = array(
@@ -97,7 +125,7 @@
 
                        $values = array(
                                $this->marshal($case->get_check_item_id(), 
'int'),
-                               $case->get_status(),
+                               $this->marshal($case->get_status(), 'int'),
                                $this->marshal($case->get_location_id(), 'int'),
                                $this->marshal($case->get_location_item_id(), 
'int'),
                                $this->marshal($case->get_descr(), 'string'),
@@ -118,6 +146,7 @@
 
                        $values = array(
                                'check_item_id = ' . 
$this->marshal($case->get_check_item_id(), 'int'),
+                               'status = ' . $case->get_status(),
                                'location_id = ' . 
$this->marshal($case->get_location_id(), 'int'),
                                'location_item_id = ' . 
$this->marshal($case->get_location_item_id(), 'int'),
                                'descr = ' . $this->marshal($case->get_descr(), 
'string'),

Modified: branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php       
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.socheck_item.inc.php       
2012-01-16 07:51:53 UTC (rev 8580)
@@ -70,7 +70,6 @@
                                $this->marshal($check_item->get_status(), 
'int'),
                                $this->marshal($check_item->get_comment(), 
'string'),
                                
$this->marshal($check_item->get_check_list_id(), 'int'),
-                               
$this->marshal($check_item->get_message_ticket_id(), 'int'),
                                $this->marshal($check_item->get_measurement(), 
'int')
                        );
 
@@ -85,11 +84,10 @@
 
                        $values = array(
                                'control_item_id = ' . 
$this->marshal($check_item->get_control_item_id(), 'int'),
-                               'status = ' . $check_item->get_status(),
+                               'status = ' . 
$this->marshal($check_item->get_status(), 'int'),
                                'comment = ' . 
$this->marshal($check_item->get_comment(), 'string'),
                                'check_list_id = ' . 
$this->marshal($check_item->get_check_list_id(), 'int'),
-                               'message_ticket_id = ' . 
$this->marshal($check_item->get_message_ticket_id(), 'int'),
-                               'measurement = ' . 
$this->marshal($check_item->get_measurement(), 'int')
+                               'measurement = ' . 
$this->marshal($check_item->get_measurement(), 'string')
                        );
 
                        $result = $this->db->query('UPDATE 
controller_check_item SET ' . join(',', $values) . " WHERE id=$id", 
__LINE__,__FILE__);
@@ -137,6 +135,80 @@
                        }
                }
                
+               public function get_single_with_cases($check_item_id, 
$returnType = "return_object"){
+                       $sql  = "SELECT ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment, ci.measurement, check_list_id, ";
+                       $sql .= "cic.id as cic_id, cic.status as cic_status, 
cic.*, ";
+                       $sql .= "coi.id as coi_id, coi.* ";
+                       $sql .= "FROM controller_check_item ci "; 
+                       $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
+                       $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
+                       $sql .= "WHERE ci.id = $check_item_id ";
+                                                                               
        
+                       $this->db->query($sql);
+                       
+                       $counter = 0;
+                       $check_item = null;
+                       while ($this->db->next_record()) {
+                               
+                               if( $counter == 0 ){
+                                                                       
+                                       $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
+                                       
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
+                                       
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true), 
'bool'));
+                                       
$check_item->set_comment($this->unmarshal($this->db->f('comment', true), 
'string'));
+                                       
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
+                                       
$check_item->set_measurement($this->unmarshal($this->db->f('measurement', 
true), 'int'));
+                                       
+                                       $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id', true), 'int'));
+                                       
$control_item->set_title($this->db->f('title', true), 'string');
+                                       
$control_item->set_required($this->db->f('required', true), 'string');
+                                       
$control_item->set_what_to_do($this->db->f('what_to_do', true), 'string');
+                                       
$control_item->set_how_to_do($this->db->f('how_to_do', true), 'string');
+                                       
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
+                                       
$control_item->set_type($this->db->f('type', true), 'string');
+                               
+                                       if($returnType == "return_array")
+                                               
$check_item->set_control_item($control_item->toArray());
+                                       else
+                                               
$check_item->set_control_item($control_item);
+                                               
+                                       $cases_array = array();
+                               }
+                               
+                               if($this->db->f('cic_id', true) != ''){
+                                       $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id', true), 
'int'));
+                                       
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id', true), 
'int'));
+                                       
$case->set_status($this->unmarshal($this->db->f('cic_status', true), 'int'));
+                                       
$case->set_location_id($this->unmarshal($this->db->f('location_id', true), 
'int'));
+                                       
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id', 
true), 'int'));
+                                       
$case->set_descr($this->unmarshal($this->db->f('descr', true), 'string'));
+                                       
$case->set_user_id($this->unmarshal($this->db->f('user_id', true), 'int'));     
+                                       
$case->set_entry_date($this->unmarshal($this->db->f('entry_date', true), 
'int'));
+                                       
$case->set_modified_date($this->unmarshal($this->db->f('modified_date', true), 
'int'));
+                                       
$case->set_modified_by($this->unmarshal($this->db->f('modified_by', true), 
'int'));
+                               
+                               
+                                       if($returnType == "return_array")
+                                               $cases_array[] = 
$case->toArray();
+                                       else
+                                               $cases_array[] = $case;
+                               }
+                               
+                               $check_item_id =  $check_item->get_id();
+                               $counter++;
+                       }
+                       
+                       if($check_item != null){
+                               $check_item->set_cases_array($cases_array);
+                               
+                               if($returnType == "return_array")
+                                       return $check_item->toArray();
+                               else
+                                       return $check_item;
+                       }else{
+                               return null;
+                       }
+               }
                
                public function 
get_check_item_by_check_list_and_control_item($check_list_id, $control_item_id)
                {
@@ -213,7 +285,7 @@
                        return $check_items_array;
                }
                
-               public function get_check_items_and_cases($check_list_id, 
$status = "open", $messageStatus = null, $returnType = "return_object"){
+               public function get_check_items_with_cases($check_list_id, 
$status = "open", $messageStatus = null, $returnType = "return_object"){
                        $sql  = "SELECT ci.id as ci_id, ci.status, 
control_item_id, ci.comment, ci.measurement, check_list_id, cic.id as cic_id, 
cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
                        $sql .= "FROM controller_check_item ci "; 
@@ -303,8 +375,9 @@
                        }
                }
                
-               public function 
get_check_items_and_cases_by_message($message_ticket_id, $returnType = 
"object"){
-                       $sql  = "SELECT ci.id as ci_id, ci.status, 
control_item_id, ci.comment, ci.measurement, check_list_id, cic.id as cic_id, 
cic.*, ";
+               public function 
get_check_items_with_cases_by_message($message_ticket_id, $returnType = 
"return_object"){
+                       $sql  = "SELECT ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment, ci.measurement, "; 
+                       $sql .= "check_list_id, cic.id as cic_id, cic.status as 
cic_status, cic.*, ";
                        $sql .= "coi.id as coi_id, coi.* ";
                        $sql .= "FROM controller_check_item ci "; 
                        $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
@@ -322,7 +395,7 @@
                                        if($check_item_id != 0){
                                                
$check_item->set_cases_array($cases_array);
                                                
-                                               if($returnType == "array")
+                                               if($returnType == 
"return_array")
                                                        $check_items_array[] = 
$check_item->toArray();
                                                else
                                                        $check_items_array[] = 
$check_item;
@@ -330,7 +403,7 @@
                                
                                        $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
                                        
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
-                                       
$check_item->set_status($this->unmarshal($this->db->f('status', true), 'bool'));
+                                       
$check_item->set_status($this->unmarshal($this->db->f('ci_status', true), 
'bool'));
                                        
$check_item->set_comment($this->unmarshal($this->db->f('comment', true), 
'string'));
                                        
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
                                        
$check_item->set_measurement($this->unmarshal($this->db->f('measurement', 
true), 'int'));
@@ -343,13 +416,17 @@
                                        
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
                                        
$control_item->set_type($this->db->f('type', true), 'string');
                                
-                                       
$check_item->set_control_item($control_item->toArray());
+                                       if($returnType == "return_array")
+                                               
$check_item->set_control_item($control_item->toArray());
+                                       else
+                                               
$check_item->set_control_item($control_item);
                                                                        
                                        $cases_array = array();
                                }
                                
                                if($this->db->f('cic_id', true) != ''){
                                        $case = new 
controller_check_item_case($this->unmarshal($this->db->f('cic_id', true), 
'int'));
+                                       
$case->set_status($this->unmarshal($this->db->f('cic_status', true), 'int'));
                                        
$case->set_check_item_id($this->unmarshal($this->db->f('check_item_id', true), 
'int'));
                                        
$case->set_location_id($this->unmarshal($this->db->f('location_id', true), 
'int'));
                                        
$case->set_location_item_id($this->unmarshal($this->db->f('location_item_id', 
true), 'int'));
@@ -360,7 +437,7 @@
                                        
$case->set_modified_by($this->unmarshal($this->db->f('modified_by', true), 
'int'));
                                
                                
-                                       if($returnType == "array")
+                                       if($returnType == "return_array")
                                                $cases_array[] = 
$case->toArray();
                                        else
                                                $cases_array[] = $case;
@@ -372,7 +449,7 @@
                        if($check_item != null){
                                $check_item->set_cases_array($cases_array);
                                
-                               if($returnType == "array")
+                               if($returnType == "return_array")
                                        $check_items_array[] = 
$check_item->toArray();
                                else
                                        $check_items_array[] = $check_item;
@@ -383,35 +460,26 @@
                        }
                }
                
-               public function get_check_items_by_message($message_ticket_id){
-                       $sql  = "SELECT ci.id as ci_id, ci.status, 
control_item_id, ci.comment, ci.measurement, check_list_id, "; 
-                       $sql .= "coi.id as coi_id, coi.title, coi.required, 
coi.what_to_do, coi.how_to_do, coi.control_group_id, coi.type "; 
+               public function get_check_items_by_message($message_ticket_id, 
$returnType = "return_array" ){
+                       $sql  = "SELECT ci.* "; 
                        $sql .= "FROM controller_check_item ci "; 
-                       $sql .= "LEFT JOIN controller_control_item as coi ON 
ci.control_item_id = coi.id ";
                        $sql .= "LEFT JOIN controller_check_item_case as cic ON 
ci.id = cic.check_item_id ";
                        $sql .= "WHERE cic.location_item_id = 
$message_ticket_id ";
                                                                
                        $this->db->query($sql);
                        
                        while ($this->db->next_record()) {
-                               $check_item = new 
controller_check_item($this->unmarshal($this->db->f('ci_id', true), 'int'));
+                               $check_item = new 
controller_check_item($this->unmarshal($this->db->f('id', true), 'int'));
                                
$check_item->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
                                
$check_item->set_status($this->unmarshal($this->db->f('status', true), 'bool'));
                                
$check_item->set_comment($this->unmarshal($this->db->f('comment', true), 
'string'));
                                
$check_item->set_check_list_id($this->unmarshal($this->db->f('check_list_id', 
true), 'int'));
                                
$check_item->set_measurement($this->unmarshal($this->db->f('measurement', 
true), 'int'));
                                
-                               $control_item = new 
controller_control_item($this->unmarshal($this->db->f('coi_id', true), 'int'));
-                               $control_item->set_title($this->db->f('title', 
true), 'string');
-                               
$control_item->set_required($this->db->f('required', true), 'string');
-                               
$control_item->set_what_to_do($this->db->f('what_to_do', true), 'string');
-                               
$control_item->set_how_to_do($this->db->f('how_to_do', true), 'string');
-                               
$control_item->set_control_group_id($this->db->f('control_group_id', true), 
'string');
-                               $control_item->set_type($this->db->f('type', 
true), 'string');
-                               
-                               
$check_item->set_control_item($control_item->toArray());
-                               
-                               $check_items_array[] = $check_item->toArray();
+                               if($returnType == "return_array")
+                                       $check_items_array[] = 
$check_item->toArray();
+                               else
+                                       $check_items_array[] = $check_item;
                        }
                        
                        return $check_items_array;

Modified: branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php       
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.socheck_list.inc.php       
2012-01-16 07:51:53 UTC (rev 8580)
@@ -97,7 +97,7 @@
        public function get_single_with_check_items($check_list_id, $status, 
$type){
                $sql  = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.control_id, cl.comment as cl_comment, deadline, planned_date, 
completed_date, location_code, ";
                $sql .= "ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment as ci_comment, check_list_id, "; 
-               $sql .= "coi.title as coi_id, coi.title as coi_title, 
coi.required as coi_required, coi.required as coi_required, ";
+               $sql .= "coi.title as coi_title, coi.required as coi_required, 
";
                $sql .= "coi.what_to_do as coi_what_to_do, coi.how_to_do as 
coi_how_to_do, coi.control_group_id as coi_control_group_id, coi.type "; 
                $sql .= "FROM controller_check_list cl "; 
                $sql .= "LEFT JOIN controller_check_item as ci ON cl.id = 
ci.check_list_id ";
@@ -203,7 +203,8 @@
        }
        
        function get_check_lists_for_control($control_id){
-               $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, ";
+               $sql = "SELECT cl.id as cl_id, cl.status as cl_status, 
cl.comment as cl_comment, deadline, planned_date, "; 
+               $sql .= "completed_date, component_id, location_code, 
num_open_cases ";
                $sql .= "ci.id as ci_id, ci.status as ci_status, 
control_item_id, ci.comment as ci_comment, check_list_id ";
                $sql .= "FROM controller_check_list cl, controller_check_item 
ci ";
                $sql .= "WHERE cl.control_id = $control_id ";
@@ -225,8 +226,13 @@
                                $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
                                
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'bool'));
                                
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
-                               
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));     
-
+                               
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
+                               
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
+                               
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int')); 
+                               
$check_list->set_component_id($this->unmarshal($this->db->f('component_id', 
true), 'int'));
+                               
$check_list->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));
+                               
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int'));
+                               
                                $check_items_array = array();
                        }
                        
@@ -306,19 +312,21 @@
        }
        
        function get_check_lists_for_location( $location_code, $from_date, 
$to_date, $repeat_type ){
-               $sql =  "SELECT c.id as c_id, cl.id as cl_id, cl.status as 
cl_status, cl.comment as cl_comment, ";
-               $sql .= "deadline, planned_date, completed_date, 
cl.location_code as cl_loc, c.* "; 
-               $sql .= "FROM controller_check_list cl, controller_control c ";
+               $sql =  "SELECT c.id as c_id, title, description, start_date, 
end_date, control_area_id, c.location_code as c_location_code, repeat_type, 
repeat_interval, ";
+               $sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as 
cl_comment, deadline, planned_date, completed_date, ";
+               $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases "; 
+               $sql .= "FROM controller_control c ";
+               $sql .= "LEFT JOIN controller_check_list cl on cl.control_id = 
c.id ";
                $sql .= "WHERE cl.location_code = $location_code ";
                $sql .= "AND c.repeat_type = $repeat_type ";
-               $sql .= "AND cl.control_id = c.id ";
-               $sql .= "AND deadline BETWEEN $from_date AND $to_date";
+               $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
                $sql .= "ORDER BY c.id;";
-               
+
                $this->db->query($sql);
                
                $control_id = 0;
                $control = null;
+               $controls_array = array();
                while ($this->db->next_record()) {
                        
                        if( $this->db->f('c_id', true) != $control_id ){
@@ -333,16 +341,8 @@
                                
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
                                
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
                                
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
-                               
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true), 
'int'));
-                               
$control->set_procedure_name($this->unmarshal($this->db->f('procedure_name', 
true), 'string'));
-                               
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id', 
true), 'int'));
-                               
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
 true), 'int'));
-                               
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
                                
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
-                               
$control->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
 true), 'string'));
-                               
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
 true), 'int'));
-                               
$control->set_component_id($this->unmarshal($this->db->f('component_id', true), 
'int'));
-                               
$control->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));
+                               
$control->set_location_code($this->unmarshal($this->db->f('c_location_code', 
true), 'int'));
                                
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
                                
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
                                                                
@@ -350,13 +350,68 @@
                        }
 
                        $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
-                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'string'));
+                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'int'));
                        
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
-                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));     
+                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
                        
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
-                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int'));
-                       
$check_list->set_location_code($this->unmarshal($this->db->f('cl_loc', true), 
'int'));
+                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int')); 
+                       
$check_list->set_component_id($this->unmarshal($this->db->f('cl_component_id', 
true), 'int'));
+                       
$check_list->set_location_code($this->unmarshal($this->db->f('cl_location_code',
 true), 'int'));
+                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int'));
+                       
+                       $check_lists_array[] = $check_list;
+
+                       $control_id =  $control->get_id();
+               }
                
+               if($control != null){
+                       $control->set_check_lists_array($check_lists_array);
+                       $controls_array[] = $control;
+               }       
+               
+               return $controls_array;
+       }
+       
+       function get_check_lists_for_location_2( $location_code, $from_date, 
$to_date, $repeat_type ){
+               $sql =  "SELECT c.id as c_id, ";
+               $sql .= "cl.id as cl_id, cl.status as cl_status, cl.comment as 
cl_comment, deadline, planned_date, completed_date, ";
+               $sql .= "cl.component_id as cl_component_id, cl.location_code 
as cl_location_code, num_open_cases "; 
+               $sql .= "FROM controller_control c ";
+               $sql .= "LEFT JOIN controller_check_list cl on cl.control_id = 
c.id ";
+               $sql .= "WHERE cl.location_code = $location_code ";
+               $sql .= "AND c.repeat_type = $repeat_type ";
+               $sql .= "AND deadline BETWEEN $from_date AND $to_date ";
+               $sql .= "ORDER BY c.id;";
+
+               $this->db->query($sql);
+               
+               $control_id = 0;
+               $control = null;
+               $controls_array = array();
+               while ($this->db->next_record()) {
+                       
+                       if( $this->db->f('c_id', true) != $control_id ){
+                               
+                               if($control_id != 0){
+                                       
$control->set_check_lists_array($check_lists_array);
+                                       $controls_array[] = $control;
+                               }
+                       
+                               $control = new 
controller_control($this->unmarshal($this->db->f('c_id', true), 'int'));
+                                                                               
                
+                               $check_lists_array = array();
+                       }
+
+                       $check_list = new 
controller_check_list($this->unmarshal($this->db->f('cl_id', true), 'int'));
+                       
$check_list->set_status($this->unmarshal($this->db->f('cl_status', true), 
'int'));
+                       
$check_list->set_comment($this->unmarshal($this->db->f('cl_comment', true), 
'string'));
+                       
$check_list->set_deadline($this->unmarshal($this->db->f('deadline', true), 
'int'));
+                       
$check_list->set_planned_date($this->unmarshal($this->db->f('planned_date', 
true), 'int'));
+                       
$check_list->set_completed_date($this->unmarshal($this->db->f('completed_date', 
true), 'int')); 
+                       
$check_list->set_component_id($this->unmarshal($this->db->f('cl_component_id', 
true), 'int'));
+                       
$check_list->set_location_code($this->unmarshal($this->db->f('cl_location_code',
 true), 'int'));
+                       
$check_list->set_num_open_cases($this->unmarshal($this->db->f('num_open_cases', 
true), 'int'));
+                       
                        $check_lists_array[] = $check_list;
 
                        $control_id =  $control->get_id();
@@ -365,11 +420,9 @@
                if($control != null){
                        $control->set_check_lists_array($check_lists_array);
                        $controls_array[] = $control;
-                       
-                       return $controls_array;
-               }else {
-                       return null;
                }       
+               
+               return $controls_array;
        }
        
        function get_query(string $sort_field, boolean $ascending, string 
$search_for, string $search_type, array $filters, boolean $return_count)

Modified: branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php  
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php  
2012-01-16 07:51:53 UTC (rev 8580)
@@ -112,8 +112,51 @@
                        //return isset($result);
                }
 
+               public function get_controls_by_location($location_code, 
$from_date, $to_date, $repeat_type, $return_type = "return_object")
+               {
+                       $controls_array = array();
+                       
+                       $sql  = "SELECT distinct c.* FROM 
controller_control_location_list cll "; 
+                       $sql .= "LEFT JOIN controller_control c on 
cll.control_id=c.id ";
+                       $sql .= "WHERE cll.location_code = $location_code ";
+                       $sql .= "AND c.repeat_type = $repeat_type ";
+                       $sql .= "AND c.start_date >= $from_date ";
+                       $sql .= "AND (c.end_date < $to_date OR c.end_date IS 
NULL)";
+                       
+                       $this->db->query($sql);
 
+                       while($this->db->next_record()) {
+                               $control = new 
controller_control($this->unmarshal($this->db->f('id', true), 'int'));
+                               
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+                               
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
+                               
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
+                               
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
+                               
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true), 
'int'));
+                               
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id', 
true), 'int'));
+                               
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
 true), 'int'));
+                               
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
+                               
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
+                               
$control->set_component_type_id($this->unmarshal($this->db->f('component_type_id',
 true), 'int'));
+                               
$control->set_component_id($this->unmarshal($this->db->f('component_id', true), 
'int'));
+                               
$control->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));
+                               
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+                               
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
+                               
+                               if($return_type == "return_object")
+                                       $controls_array[] = $control;
+                               else
+                                       $controls_array[] = $control->toArray();
+                       }
 
+                       if( count( $controls_array ) > 0 ){
+                               return $controls_array; 
+                       }
+                       else
+                       {
+                               return null;
+                       }
+               }
+
                function get_controls_by_control_area($control_area_id)
                {
                        $controls_array = array();

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     
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php     
2012-01-16 07:51:53 UTC (rev 8580)
@@ -134,7 +134,8 @@
                        
$control_item->set_how_to_do($this->unmarshal($this->db->f('how_to_do', true), 
'string'));
                        
$control_item->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
                        
$control_item->set_control_group_name($this->unmarshal($this->db->f('control_group_name',
 true), 'string'));
-
+                       
$control_item->set_type($this->unmarshal($this->db->f('type', true), 'string'));
+                       
                        return $control_item;
                }
 

Modified: branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2012-01-16 07:51:53 UTC (rev 8580)
@@ -93,12 +93,17 @@
                        }
                        
                        $this->calendar_builder = new 
calendar_builder($from_date, $to_date);
-                               
+                       
                        $repeat_type = 0;
-                       $check_list_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date, $to_date, 
$repeat_type);
                        
-                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $check_list_array, null, 31, 
"view_days" );
+                       $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date, 
$to_date, $repeat_type);
                        
+                       $control_id_with_check_list_array = 
$this->so->get_check_lists_for_location_2($location_code, $from_date, $to_date, 
$repeat_type);
+                       
+                       $controls_with_check_list = 
$this->populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array);
+                       
+                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $controls_with_check_list, null, 
31, "view_days" );
+
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                        
                        $month_array = array("Januar", "Februar", "Mars", 
"April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", 
"Desember");
@@ -123,6 +128,20 @@
                        
self::render_template_xsl('calendar/view_calendar_month', $data);
                }
                
+               public function 
populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array){
+                       $controls_with_check_list = array();
+                       
+                       foreach($controls_for_location_array as $control){
+                               foreach($control_id_with_check_list_array as 
$control_id){
+                                       if($control->get_id() == 
$control_id->get_id())
+                                               
$control->set_check_lists_array($control_id->get_check_lists_array());          
                                
+                               }       
+                               $controls_with_check_list[] = $control;
+                       }
+                       
+                       return $controls_with_check_list;
+               }
+               
                public function view_calendar_for_year()
                {
                        $location_code = phpgw::get_var('location_code');

Modified: branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicase.inc.php     
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.uicase.inc.php     
2012-01-16 07:51:53 UTC (rev 8580)
@@ -47,7 +47,8 @@
                                                                        
'register_case'                 => true,
                                                                        
'create_case_message'   => true,
                                                                        
'view_case_message'     => true,
-                                                                       
'register_case_message' => true
+                                                                       
'register_case_message' => true,
+                                                                       
'updateStatusForCases' => true
                                                                );
 
                function __construct()
@@ -100,7 +101,7 @@
                        $check_list_id = phpgw::get_var('check_list_id');
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                                                
-                       $check_items_and_cases = 
$this->so_check_item->get_check_items_and_cases($check_list_id, "open", 
"no_message_registered", "return_array");
+                       $check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, "open", 
"no_message_registered", "return_array");
 
                        $control_id = $check_list->get_control_id();
                        $control = $this->so_control->get_single( $control_id );
@@ -145,7 +146,7 @@
                        
                        
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
                        
-                       self::render_template_xsl('case/create_case_message', 
$data);
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu', 
'case/create_case_message'), $data);
                }
                
                function register_case_message(){
@@ -166,14 +167,27 @@
        
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
 
-                       $message_details = "Kontroll: " .  
$control->get_title() . "\n\n";
-                       //$message_details = "Kontrollområde: " .  
$control->get_title() . "\n\n";
+                       $message_details = "Kontroll: " .  
$control->get_title() . "\n";
                        
+                       $cats = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
+                       $cats->supress_info     = true;
+
+                       //liste alle
+                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => 
$control_area_id,'globals' => true,'use_acl' => $_category_acl));
+
+                       $control_area_id = $control->get_control_area_id();
+                       $control_area = $cats->return_single($control_area_id);
+                       $control_area_name = $control_area[0]['name'];
+                       
+                       $message_details .= "Kontrollområde: " .  
$control_area_name . "\n\n";
+                       
                        // Generates message details from comment field in 
check item 
+                       $counter = 1;
                        foreach($case_ids as $case_id){
                                $case = $this->so->get_single($case_id);
-                               $message_details .= "Gjøremål: ";
+                               $message_details .= "Gjøremål $counter: ";
                                $message_details .=  $case->get_descr() . 
"<br>";
+                               $counter++;
                        }
                        
                        $location_id    = 
$GLOBALS['phpgw']->locations->get_id("controller", ".checklist");
@@ -196,8 +210,7 @@
                        $todays_date = mktime(0,0,0,date("m"), date("d"), 
date("Y"));
 
                        $user_id = $GLOBALS['phpgw_info']['user']['id'];
-                       $status = 0;
-                       
+                                               
                        // Registers message and updates check items with 
message ticket id
                        foreach($case_ids as $case_id){
                                $case = $this->so->get_single($case_id);
@@ -223,7 +236,7 @@
        
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
 
-                       $check_items_and_cases = 
$this->so_check_item->get_check_items_and_cases_by_message($message_ticket_id, 
"array");
+                       $check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases_by_message($message_ticket_id, 
"return_array");
                                                
                        $botts = CreateObject('property.botts',true);
                        $message_ticket = 
$botts->read_single($message_ticket_id);
@@ -251,8 +264,57 @@
                        
                        
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
                        
-                       self::render_template_xsl('case/view_case_message', 
$data);
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu', 
'case/view_case_message'), $data);
                }
                
+               public function updateStatusForCases($location_id, 
$location_item_id, $updateStatus = 0){
+                       
+                       $cases_array = $this->so->get_cases_by_message( 
$location_item_id );
+                       
+                       foreach($cases_array as $case){
+                               $case->set_status( $updateStatus );
+                               $this->so->update( $case );     
+                       }
+                       
+                       $check_items = 
$this->so_check_item->get_check_items_by_message($message_ticket_id, 
"return_object");
+                       
+                       if($updateStatus == 0){
+
+                               foreach($check_items as $check_item){
+                                       $check_item->set_status(0);
+                                       
$this->so_check_item->update($check_item);
+                               }
+                       }
+                       else if($updateStatus == 1){
+                               
+                               foreach($check_items as $check_item){
+                                       $check_item = 
$this->so_check_item->get_single_with_cases($check_item->get_id());
+                                       
+                                       if($check_item->get_status() == 0){
+                                               
+                                               $cases_array = 
$check_item->get_cases_array();  
+                                               
+                                               if(count($cases_array) == 0){ 
+                                                       
$check_item->set_status(1);
+                                                       
$this->so_check_item->update($check_item);
+                                               }
+                                               else{
+                                                       $all_cases_status = 1;
+                                                       
+                                                       foreach($cases_array as 
$case){
+                                                               
if($case->get_status() == 0)
+                                                                       
$all_cases_status = 0;          
+                                                       }
+                                                       
+                                                       if($all_cases_status == 
1){
+                                                               
$check_item->set_status(1);
+                                                               
$this->so_check_item->update($check_item);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               
                public function query(){}
        }

Modified: branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php       
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/class.uicheck_list.inc.php       
2012-01-16 07:51:53 UTC (rev 8580)
@@ -64,8 +64,8 @@
                        'register_case'                                         
=>      true,
                        'view_open_cases'                                       
=>      true,
                        'view_closed_cases'                                     
=>      true,
-                       'view_measurements'                                     
=>      true
-               
+                       'view_measurements'                                     
=>      true,
+                       'get_cases_for_check_list'                      =>      
true
                );
 
                public function __construct()
@@ -209,7 +209,16 @@
                        
                        return json_encode( $check_list );
                }
+               
+               public function get_cases_for_check_list()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
 
+                       $check_items_with_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, "open", null, 
"return_array");
+                       
+                       return json_encode( $check_items_with_cases );
+               }
+
                public function edit_check_list()
                {
                        $check_list_id = phpgw::get_var('check_list_id');
@@ -378,7 +387,7 @@
                                'check_list'    => $check_list->toArray()
                        );
                        
-                       self::render_template_xsl('check_list/register_case', 
$data);
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu', 
'check_list/register_case'), $data);
                }
                
                function view_open_cases(){
@@ -386,7 +395,7 @@
                        
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                        
-                       $open_check_items_and_cases = 
$this->so_check_item->get_check_items_and_cases($check_list_id, 'open', null, 
'return_array');
+                       $open_check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, 'open', null, 
'return_array');
                        
                        $data = array
                        (
@@ -402,7 +411,7 @@
                        
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
                        
-                       $closed_check_items_and_cases = 
$this->so_check_item->get_check_items_and_cases($check_list_id, 'closed', null, 
'return_array');
+                       $closed_check_items_and_cases = 
$this->so_check_item->get_check_items_with_cases($check_list_id, 'closed', 
null, 'return_array');
                                                        
                        $data = array
                        (
@@ -498,20 +507,25 @@
                        $check_item_id = phpgw::get_var('check_item_id');
                        $comment = phpgw::get_var('comment');
                        $status = phpgw::get_var('status');
-                                               
+                                                                       
                        $check_item = 
$this->so_check_item->get_single($check_item_id);
+                       $control_item_id = $check_item->get_control_item_id();
+                       
+                       $control_item = 
$this->so_control_item->get_single($check_item->get_control_item_id());
+                       
+                       if($control_item->get_type() == 'control_item_type_2')
+                       {
+                               $measurement = phpgw::get_var('measurement');
+                               $check_item->set_measurement( $measurement );   
+                       }
+                       
                        $check_item->set_status( $status );
                        $check_item->set_comment( $comment );
                        
                        $check_item_id = $this->so_check_item->store( 
$check_item );
 
-                       if($status == 0)
-                               $status_text = "not_fixed";
-                       else
-                               $status_text = "fixed";
-                       
                        if($check_item_id > 0)
-                               return json_encode( array( "saveStatus" => 
"saved", "fixedStatus" => $status_text ) );
+                               return json_encode( array( "saveStatus" => 
"saved" ) );
                        else
                                return json_encode( array( "status" => 
"not_saved" ) );
                }

Modified: 
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
  2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/inc/class.uicheck_list_for_location.inc.php
  2012-01-16 07:51:53 UTC (rev 8580)
@@ -60,10 +60,10 @@
                                                                                
'add_location_to_control'               => true,
                                                                                
'add_check_list_for_location'   => true,
                                                                                
'save_check_list_for_location'  => true,
-                                                                               
'edit_check_list_for_location'  => true,
+                                                                               
'edit_check_list'                               => true,
                                                                                
'create_case_message'                   => true,
                                                                                
'view_control_info'                     => true,
-                                                                               
'view_errors_for_check_list'    => true
+                                                                               
'view_cases_for_check_list'     => true
                                                                        );
 
                function __construct()
@@ -365,7 +365,7 @@
                        
self::render_template_xsl(array('add_check_list_for_location'), $data);
                }
                
-               function edit_check_list_for_location(){
+               function edit_check_list(){
                        $check_list_id = phpgw::get_var('check_list_id');
                        
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
@@ -389,10 +389,10 @@
                        
                        
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
                        
-                       self::render_template_xsl('check_list/edit_check_list', 
$data);
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu','check_list/edit_check_list'),
 $data);
                }
                
-               function view_errors_for_check_list(){
+               function view_cases_for_check_list(){
                        $check_list_id = phpgw::get_var('check_list_id');
                        
                        $check_list = 
$this->so_check_list->get_single($check_list_id);
@@ -416,7 +416,7 @@
                        
                        
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/jquery-ui.custom.css');
                        
-                       
self::render_template_xsl('check_list/view_errors_for_check_list', $data);
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu', 
'check_list/view_cases_for_check_list'), $data);
                }
                
                function save_check_list_for_location(){
@@ -441,7 +441,7 @@
                        
                        $check_list_id = $this->so_check_list->add($check_list);
                        
-                       $this->redirect(array('menuaction' => 
'controller.uicheck_list_for_location.edit_check_list_for_location', 
'check_list_id'=>$check_list_id));
+                       $this->redirect(array('menuaction' => 
'controller.uicheck_list_for_location.edit_check_list', 
'check_list_id'=>$check_list_id));
                }
                
                function create_case_message(){
@@ -520,7 +520,7 @@
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'jquery-ui.custom.min.js');
                        
-                       
self::render_template_xsl('check_list/view_control_info', $data);
+                       
self::render_template_xsl(array('check_list/check_list_tab_menu','check_list/view_control_info'),
 $data);
                }
                
                function get_timestamp_from_date( $date_string ){

Modified: 
branches/Version-1_0-branch/controller/inc/component/class.calendar_builder.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/component/class.calendar_builder.inc.php
 2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/inc/component/class.calendar_builder.inc.php
 2012-01-16 07:51:53 UTC (rev 8580)
@@ -20,10 +20,10 @@
                        for($i=1;$i<=$num;$i++){
                                $calendar_array[$i] = null;
                        }
-                                               
+
                        $date_generator = new 
date_generator($control->get_start_date(), $control->get_end_date(), 
$this->period_start_date, $this->period_end_date, $control->get_repeat_type(), 
$control->get_repeat_interval());
                        $dates_array = $date_generator->get_dates();
-                       
+               
                        // Inserts dates on behalf of repeat type and repeat 
interval
                        foreach($dates_array as $date){
                                
@@ -55,11 +55,15 @@
                
                                $todays_date = mktime(0,0,0,date("m"), 
date("d"), date("Y"));
                                
-                               if( $check_list->get_status() == 0 & 
$check_list->get_planned_date() > 0 )
+                               if( $check_list->get_status() == 0 & 
$check_list->get_planned_date() > 0 & $check_list->get_deadline() > 
$todays_date)
                                {
                                        $status = "control_planned";
                                        
$check_list_status_info->set_info_text("Planlagt utført: " . 
$check_list->get_planned_date());
                                }
+                               else if( $check_list->get_status() == 0 & 
$check_list->get_planned_date() > 0 & $check_list->get_deadline() < 
$todays_date)
+                               {
+                                       $status = 
"control_not_accomplished_with_info";
+                               }
                                else if( $check_list->get_status() == 0 & 
$check_list->get_deadline() > $todays_date )
                                {
                                        $status = "control_not_accomplished";
@@ -74,6 +78,7 @@
                                }
                                else if( $check_list->get_status() == 2  ){
                                        $status = 
"control_accomplished_with_errors";
+                                       
$check_list_status_info->set_num_open_cases($check_list->get_num_open_cases());
                                }
                                else if( $check_list->get_status() == 3 )
                                {

Modified: 
branches/Version-1_0-branch/controller/inc/component/class.date_generator.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/component/class.date_generator.inc.php
   2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/inc/component/class.date_generator.inc.php
   2012-01-16 07:51:53 UTC (rev 8580)
@@ -25,8 +25,9 @@
        function generate_calendar(){
        
                $control_start_date = $this->find_control_start_date();
+               
                $period_start_date = $this->find_start_date_for_period( 
$control_start_date );
-                
+       
                $interval_date = $period_start_date;
                
                while($interval_date <= $this->period_end_date){
@@ -59,8 +60,11 @@
        
        public function find_control_start_date(){
        
-               if( $this->repeat_type == 1 || $this->repeat_type == 0 ){
+               if( $this->repeat_type == 0 ){
                        $search_date = $this->start_date;
+               }
+               else if( $this->repeat_type == 1 ){
+                       $search_date = $this->start_date;
        
                        while(date("l", $search_date) != "Sunday")
                        {

Modified: 
branches/Version-1_0-branch/controller/inc/helper/class.check_list_status_info.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/helper/class.check_list_status_info.inc.php
      2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/inc/helper/class.check_list_status_info.inc.php
      2012-01-16 07:51:53 UTC (rev 8580)
@@ -35,7 +35,8 @@
                private $status_text;
                private $deadline_date;
                private $info_text;
-
+               private $num_open_cases;
+       
                public function __construct(){}
                
                public function set_check_list_id($check_list_id)
@@ -73,7 +74,14 @@
                
                public function get_info_text() { return $this->info_text; }
                
+               public function set_num_open_cases($num_open_cases)
+               {
+                       $this->num_open_cases = $num_open_cases;
+               }
                
+               public function get_num_open_cases() { return 
$this->num_open_cases; }
+               
+               
                public function serialize()
                {
                        return array(
@@ -81,7 +89,8 @@
                                'status' => $this->get_status(),
                                'status_text' => $this->get_status_text(),
                                'deadline_date' => $this->get_deadline_date(),
-                               'info_text' => $this->get_info_text()
+                               'info_text' => $this->get_info_text(),
+                               'num_open_cases' => $this->get_num_open_cases()
                        );
                }
        }

Modified: 
branches/Version-1_0-branch/controller/inc/model/class.check_list.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/model/class.check_list.inc.php   
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/model/class.check_list.inc.php   
2012-01-16 07:51:53 UTC (rev 8580)
@@ -44,6 +44,9 @@
                protected $location_code;
                protected $component_id;
                
+               // Aggregate field. Field not in a table
+               protected $num_open_cases;
+               
                // Objects
                protected $check_item_array = array();
                protected $control;
@@ -128,7 +131,14 @@
                }
                
                public function get_component_id() { return 
$this->component_id; }
+
+               public function get_num_open_cases() { return 
$this->num_open_cases; }
                
+               public function set_num_open_cases($num_open_cases)
+               {
+                       $this->num_open_cases = $num_open_cases;
+               }
+               
                public function set_control($control)
                {
                        $this->control = $control;

Modified: branches/Version-1_0-branch/controller/inc/model/class.control.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/model/class.control.inc.php      
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/inc/model/class.control.inc.php      
2012-01-16 07:51:53 UTC (rev 8580)
@@ -54,6 +54,7 @@
                protected $control_area_id;
                protected $control_area_name;
 
+               // Objects
                protected $check_lists_array = array();
                
                

Modified: branches/Version-1_0-branch/controller/js/controller/ajax.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-01-16 07:51:53 UTC (rev 8580)
@@ -136,7 +136,7 @@
                
                var add_param = $(thisA).find("span").text();
                
-               var requestUrl = 
"http://portico/pe/index.php?menuaction=controller.uicheck_list.get_check_list_info";
 + add_param;
+               var requestUrl = 
"http://portico/pe/index.php?menuaction=controller.uicheck_list.get_cases_for_check_list";
 + add_param;
                
                $.ajax({
                          type: 'POST',
@@ -151,32 +151,22 @@
                                  $(infoBox).show();
                                  $(infoBox).html("");
                                  
-                                 if(obj.deadline == 0 ){
-                                         var deadline_string = "Ikke satt";
-                                 }else{
-                                         var date  = new Date(obj.deadline * 
1000);
-                                         var deadline_string = date.getDate() 
+ "/" + (parseInt(date.getMonth()) + 1) + "-" + date.getFullYear();
-                                 }
+                                 $(infoBox).html("<h5>Åpne saker</h5>");
                                  
-                                 var months = ['Januar', 'Februar', 'Mars', 
'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 
'Desember'];
-
-                                 
-                                 $(infoBox).html("<h5>Sjekkliste for " + 
months[date.getMonth()]);
-                                 
-                                 var htmlList = "<ul>" +
-                                                                
"<li><label>Frist</label><span> " + deadline_string + "</span></li>" +
-                                                                
"<li><label>Status</label><span> " + obj.status + "</span></li>" +
-                                                                
"<li><label>Kommentar</label><span>" + obj.comment + "</span></li>" +
-                                                                
"<li><label>Sjekkpunkter</label><li>";
-                                 
-                                 $.each(obj.check_item_array, function(i) {
-                                         htmlList +=   "<ul><li><label>" + 
(parseInt(i) + 1) + ": Tittel</label><span>" + 
obj.check_item_array[i].control_item.title + "</span></li>" + 
-                                                                       
"<li><label>Status</label><span>" + obj.check_item_array[i].status + 
"</span></li>" + 
-                                                                       
"<li><label>Kommentar</label><span>" + obj.check_item_array[i].comment + 
"</span></li></ul>";
+                                 var htmlList = "<ul>";
+                               
+                                 $.each(obj, function(i) {
+                                         htmlList += "<li><label>" + 
(parseInt(i) + 1) + ": Tittel</label><span>" + obj[i].control_item.title + 
"</span>";
+                                         htmlList += "<ul>";
+                                         
+                                         
$(obj[i].cases_array).each(function(j) {
+                                                 htmlList += "<li>" + "Sak " + 
(parseInt(j) + 1) + ":  " + obj[i].cases_array[j].descr + "</li>";
+                                         });
+                                         htmlList += "</li></ul>";
                                        });
                                  
-                                 htmlList += "</li></ul>"; 
-                                 
+                                 htmlList += "</ul>"; 
+                               
                                  $(infoBox).append( htmlList );  
                          }
                  }
@@ -194,8 +184,6 @@
        $("#frm_save_check_item").live("submit", function(e){
                e.preventDefault();
                var thisForm = $(this);
-               var liWrp = $(this).parent();
-               var liWrpClone = $(liWrp).clone();
                var submitBnt = $(thisForm).find("input[type='submit']");
                var requestUrl = $(thisForm).attr("action"); 
 
@@ -206,25 +194,15 @@
                                  if(data){
                                  var obj = jQuery.parseJSON(data);
                                
-                                 if(obj.saveStatus == "saved" & 
obj.fixedStatus == "fixed"){
-                                         $(liWrp).fadeOut('3000', function() {
-                                                                               
  
-                                                 
$("#check_list_fixed_list").append(liWrpClone);
-                                                                               
  
-                                                 $(liWrp).addClass("hidden");
-                                         });
-                                         
-                                         }
-                                 else if(obj.saveStatus == "saved" & 
obj.fixedStatus == "not_fixed"){
-                                         
+                                 if(obj.saveStatus == "saved"){
                                          var submitBnt = 
$(thisForm).find("input[type='submit']");
-                                               $(submitBnt).val("Lagret");     
+                                         $(submitBnt).val("Lagret");   
                                                  
                                                // Changes text on save button 
back to original
                                                window.setTimeout(function() {
-                                                 $(submitBnt).val('Oppdater 
håndtert avvik');
+                                                 $(submitBnt).val('Oppdater 
måling');
                                                  
$(submitBnt).addClass("not_active");
-                                                        }, 1000);
+                                                        }, 1000);              
                          
                                          }
                                  }
                                }
@@ -255,7 +233,7 @@
                        });
        });
        
-       $("#frm_update_check_list").live("click", function(e){
+       $("#frm_update_check_list").live("submit", function(e){
                e.preventDefault();
 
                var thisForm = $(this);

Modified: branches/Version-1_0-branch/controller/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/setup.inc.php  2012-01-16 
07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/setup/setup.inc.php  2012-01-16 
07:51:53 UTC (rev 8580)
@@ -1,6 +1,6 @@
 <?php
        $setup_info['controller']['name'] = 'controller';
-       $setup_info['controller']['version'] = '0.1.19';
+       $setup_info['controller']['version'] = '0.1.20';
        $setup_info['controller']['app_order'] = 100;
        $setup_info['controller']['enable'] = 1;
        $setup_info['controller']['app_group']  = 'office';

Modified: branches/Version-1_0-branch/controller/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2012-01-16 07:51:53 UTC (rev 8580)
@@ -76,7 +76,8 @@
                                'planned_date' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
                                'completed_date' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
                                'component_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
-                               'location_code' => array('type' => 'int', 
'precision' => 4, 'nullable' => True)
+                               'location_code' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
+                               'num_open_cases' => array('type' => 'int', 
'precision' => 4, 'nullable' => True)
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: branches/Version-1_0-branch/controller/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/tables_update.inc.php  
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/setup/tables_update.inc.php  
2012-01-16 07:51:53 UTC (rev 8580)
@@ -415,4 +415,17 @@
                
                $GLOBALS['setup_info']['controller']['currentver'] = '0.1.19';
                return $GLOBALS['setup_info']['controller']['currentver'];
+       }
+       
+       $test[] = '0.1.19';
+       function controller_upgrade0_1_19()
+       {
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('controller_check_list','num_open_cases',array(
+                       'type' => 'int',
+                       'precision' => 4,
+                       'nullable' => True
+               ));
+               
+               $GLOBALS['setup_info']['controller']['currentver'] = '0.1.20';
+               return $GLOBALS['setup_info']['controller']['currentver'];
        }
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
      2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_month.xsl
      2012-01-16 07:51:53 UTC (rev 8580)
@@ -134,7 +134,7 @@
                                                                                
<div>
                                                                                
<a>
                                                                                
        <xsl:attribute name="href">
-                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                <xsl:value-of select="info/check_list_id"/>
                                                                                
        </xsl:attribute>
@@ -146,7 +146,7 @@
                                                                                
<div>
                                                                                
        <a>
                                                                                
        <xsl:attribute name="href">
-                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                <xsl:value-of select="info/check_list_id"/>
                                                                                
        </xsl:attribute>
@@ -160,7 +160,7 @@
                                                                                
<div id="info_box" style="position:absolute;display:none;"></div>
                                                                                
        <a>
                                                                                
        <xsl:attribute name="href">
-                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                <xsl:value-of select="info/check_list_id"/>
                                                                                
        </xsl:attribute>
@@ -170,11 +170,28 @@
                                                                                
</div>
                                                                        
</xsl:when>
                                                                        
<xsl:when test="status = 'control_accomplished_with_errors'">
+                                                                               
<div style="position:relative;background: 
url(controller/images/status_icon_red_empty.png) no-repeat 50% 50%;">
+                                                                               
        <div id="info_box" style="position:absolute;display:none;"></div>
+                                                                               
<a class="view_check_list">
+                                                                               
                <xsl:attribute name="href">
+                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
+                                                                               
                        <xsl:text>&amp;check_list_id=</xsl:text>
+                                                                               
                        <xsl:value-of select="info/check_list_id"/>
+                                                                               
                </xsl:attribute>
+                                                                               
                <span style="display:none">
+                                                                               
                        <xsl:text>&amp;check_list_id=</xsl:text><xsl:value-of 
select="info/check_list_id"/>
+                                                                               
                        <xsl:text>&amp;phpgw_return_as=json</xsl:text>
+                                                                               
                </span>
+                                                                               
                <xsl:value-of select="info/num_open_cases"/>
+                                                                               
        </a>
+                                                                               
</div>
+                                                                       
</xsl:when>
+                                                                       <!-- 
xsl:when test="status = 'control_accomplished_with_errors'">
                                                                                
<div style="position:relative;">
                                                                                
<div id="info_box" style="position:absolute;display:none;"></div>
                                                                                
        <a class="view_check_list">
                                                                                
                <xsl:attribute name="href">
-                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                        
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                        <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                        <xsl:value-of select="info/check_list_id"/>
                                                                                
                </xsl:attribute>
@@ -186,12 +203,27 @@
                                                                                
        </a>
                                                                                
</div>
                                                                        
</xsl:when>
-                                                                       
<xsl:when test="status = 'control_canceled'">
+                                                                        -->
+                                                                       
<xsl:when test="status = 'control_not_accomplished_with_info'">
+                                                                               
<div style="position:relative;">
+                                                                               
<div id="info_box" style="position:absolute;display:none;"></div>
+                                                                               
        <a>
+                                                                               
        <xsl:attribute name="href">
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
+                                                                               
                <xsl:text>&amp;check_list_id=</xsl:text>
+                                                                               
                <xsl:value-of select="info/check_list_id"/>
+                                                                               
        </xsl:attribute>
+                                                                               
                <span style="display:none"><xsl:value-of 
select="info/id"/></span>
+                                                                               
                <img height="15" 
src="controller/images/status_icon_red_cross.png" />
+                                                                               
        </a>
+                                                                               
</div>
+                                                                       
</xsl:when>
+                                                                       
<xsl:when test="status = 'control_not_accomplished'">
                                                                                
<div>
                                                                                
        <img height="15" src="controller/images/status_icon_red_cross.png" />
                                                                                
</div>
                                                                        
</xsl:when>
-                                                                       
<xsl:when test="status = 'control_not_accomplished'">
+                                                                       
<xsl:when test="status = 'control_canceled'">
                                                                                
<div>
                                                                                
        <img height="15" src="controller/images/status_icon_red_cross.png" />
                                                                                
</div>

Modified: 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
       2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/calendar/view_calendar_year.xsl
       2012-01-16 07:51:53 UTC (rev 8580)
@@ -100,7 +100,7 @@
                                                                                
<div>
                                                                                
<a>
                                                                                
        <xsl:attribute name="href">
-                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for</xsl:text>
                                                                                
                <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                <xsl:value-of select="info/check_list_id"/>
                                                                                
        </xsl:attribute>
@@ -112,7 +112,7 @@
                                                                                
<div>
                                                                                
        <a>
                                                                                
        <xsl:attribute name="href">
-                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                <xsl:value-of select="info/check_list_id"/>
                                                                                
        </xsl:attribute>
@@ -126,7 +126,7 @@
                                                                                
<div id="info_box" style="position:absolute;display:none;"></div>
                                                                                
        <a>
                                                                                
        <xsl:attribute name="href">
-                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
+                                                                               
                
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
                                                                                
                <xsl:text>&amp;check_list_id=</xsl:text>
                                                                                
                <xsl:value-of select="info/check_list_id"/>
                                                                                
        </xsl:attribute>

Modified: 
branches/Version-1_0-branch/controller/templates/base/case/create_case_message.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/case/create_case_message.xsl
  2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/case/create_case_message.xsl
  2012-01-16 07:51:53 UTC (rev 8580)
@@ -5,7 +5,9 @@
 <div id="main_content">
        
                <h1>Registrer avviksmelding</h1>
-                       
+       
+               <xsl:call-template name="check_list_tab_menu" />
+       
                <h3 class="box_header">Meldingen gjelder</h3>
                <div id="case_details">
                        <h3 class="first">Tittel på kontroll: <xsl:value-of 
select="control/title"/></h3>
@@ -93,7 +95,7 @@
                                        
                                        <div class="form-buttons">
                                                <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
-                                               <input class="btn focus" 
type="submit" name="save_control" value="Registrer avviksmelding" 
title="{$lang_save}" />
+                                               <input class="btn focus" 
type="submit" name="save_control" value="Registrer melding" 
title="{$lang_save}" />
                                        </div>
                                </form>                 
                                </xsl:when>
@@ -102,15 +104,6 @@
                                </xsl:otherwise>
                        </xsl:choose>
                </fieldset>
-               
-               <a class="btn">
-               <xsl:attribute name="href">
-                               
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
-                               <xsl:text>&amp;check_list_id=</xsl:text>
-                               <xsl:value-of select="check_list/id"/>
-                       </xsl:attribute>
-             Vis sjekkliste
-           </a>
                        
 </div>
 </xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/case/view_case_message.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/case/view_case_message.xsl
    2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/case/view_case_message.xsl
    2012-01-16 07:51:53 UTC (rev 8580)
@@ -6,6 +6,7 @@
        
                <h1>Avviksmelding registrert</h1>
                
+               <xsl:call-template name="check_list_tab_menu" />
                
                <h3 class="box_header" href="#">Meldingen gjaldt</h3>
                <div id="case_details">
@@ -53,22 +54,13 @@
                                </xsl:for-each>
                        </ul>
                </div>
-               
-               <a class="btn">
+               <a class="btn focus">
                        <xsl:attribute name="href">
                                
<xsl:text>index.php?menuaction=controller.uicase.create_case_message</xsl:text>
                                <xsl:text>&amp;check_list_id=</xsl:text>
                                <xsl:value-of select="check_list/id"/>
                        </xsl:attribute>
              Registrer ny melding
-           </a>
-               <a class="btn">
-               <xsl:attribute name="href">
-                               
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
-                               <xsl:text>&amp;check_list_id=</xsl:text>
-                               <xsl:value-of select="check_list/id"/>
-                       </xsl:attribute>
-             Endre sjekkliste
-           </a>
+               </a>
 </div>
 </xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/cases_tab_menu.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/cases_tab_menu.xsl
 2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/cases_tab_menu.xsl
 2012-01-16 07:51:53 UTC (rev 8580)
@@ -13,7 +13,7 @@
                                <xsl:value-of select="check_list/id"/>
                                
<xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
                        </xsl:attribute>
-                       Vis åpne saker
+                       Åpne saker
                </a>
                <a id="view_closed_cases">
                        <xsl:if test="$active_tab = 'view_closed_cases'">
@@ -25,7 +25,7 @@
                                <xsl:value-of select="check_list/id"/>
                                
<xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
                        </xsl:attribute>
-                       Vis lukkede saker
+                       Lukkede saker
                </a>
                <a id="view_measurements">
                        <xsl:if test="$active_tab = 'view_measurements'">
@@ -37,7 +37,7 @@
                                <xsl:value-of select="check_list/id"/>
                                
<xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
                        </xsl:attribute>
-                       Vis målinger
+                       Målinger
                </a>
        </div>
 </xsl:template>

Copied: 
branches/Version-1_0-branch/controller/templates/base/check_list/check_list_tab_menu.xsl
 (from rev 8579, 
trunk/controller/templates/base/check_list/check_list_tab_menu.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/check_list_tab_menu.xsl
                            (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/check_list_tab_menu.xsl
    2012-01-16 07:51:53 UTC (rev 8580)
@@ -0,0 +1,60 @@
+<xsl:template name="check_list_tab_menu" xmlns:php="http://php.net/xsl";>
+
+<xsl:param name="active_tab" />
+
+<div id="edit_check_list_menu" class="hor_menu">
+               
+               <a>
+                       <xsl:if test="$active_tab = 'view_details'">
+                               <xsl:attribute 
name="class">active</xsl:attribute>
+                       </xsl:if>
+                       <xsl:attribute name="href">
+                               
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list</xsl:text>
+                               <xsl:text>&amp;check_list_id=</xsl:text>
+                               <xsl:value-of select="check_list/id"/>
+                       </xsl:attribute>
+                       Vis detaljer for sjekkliste
+               </a>
+               <a>
+                       <xsl:if test="$active_tab = 'view_cases'">
+                               <xsl:attribute 
name="class">active</xsl:attribute>
+                       </xsl:if>
+                       <xsl:attribute name="href">
+                               
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_cases_for_check_list</xsl:text>
+                               <xsl:text>&amp;check_list_id=</xsl:text>
+                               <xsl:value-of select="check_list/id"/>
+                       </xsl:attribute>
+                       Vis saker
+               </a>                    
+               <a>
+                       <xsl:if test="$active_tab = 'view_control_info'">
+                               <xsl:attribute 
name="class">active</xsl:attribute>
+                       </xsl:if>
+                       <xsl:attribute name="href">
+                               
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_control_info</xsl:text>
+                               <xsl:text>&amp;check_list_id=</xsl:text>
+                               <xsl:value-of select="check_list/id"/>
+                       </xsl:attribute>
+                       Vis info om kontroll
+               </a>
+               <div>
+                       <a class="btn focus first">
+                               <xsl:attribute name="href">
+                                       
<xsl:text>index.php?menuaction=controller.uicheck_list.register_case</xsl:text>
+                                       <xsl:text>&amp;check_list_id=</xsl:text>
+                                       <xsl:value-of select="check_list/id"/>
+                               </xsl:attribute>
+                               Registrer sak
+                       </a>
+                       <a class="btn focus">
+                               <xsl:attribute name="href">
+                                       
<xsl:text>index.php?menuaction=controller.uicase.create_case_message</xsl:text>
+                                       <xsl:text>&amp;check_list_id=</xsl:text>
+                                       <xsl:value-of select="check_list/id"/>
+                               </xsl:attribute>
+                               Registrer melding
+                       </a>
+               </div>
+       </div>
+               
+</xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/edit_check_list.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/edit_check_list.xsl
        2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/edit_check_list.xsl
        2012-01-16 07:51:53 UTC (rev 8580)
@@ -27,42 +27,10 @@
                
                <h1>Sjekkliste for <xsl:value-of 
select="location_array/loc1_name"/></h1>
                
-               <div id="edit_check_list_menu" class="hor_menu">
-                       <a class="active">
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis detaljer for sjekkliste
-                       </a>
-                       <a>
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_errors_for_check_list</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis avvik/saker for sjekkliste
-                       </a>                    
-                       <a>
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_control_info</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis info om kontroll
-                       </a>
-                       
-                       <a style="background:#DD624B;border-bottom: 1px solid 
#CB563F;border-top: 1px solid #EE836F;box-shadow: 0 1px 0 #A9422E, 0 -1px 0 
#A9422E;color: #FFFFFF;height: 18px;margin-left: 75px;margin-top: 1px;">
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.register_error</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Registrer avvik/sak
-                       </a>
-               </div>
-               
+               <xsl:call-template name="check_list_tab_menu">
+                       <xsl:with-param 
name="active_tab">view_details</xsl:with-param>
+               </xsl:call-template>
+       
                <h3 class="box_header">Sjekklistedetaljer</h3>
                <fieldset class="check_list_details">
                        <form id="frm_update_check_list" 
action="index.php?menuaction=controller.uicheck_list.update_check_list" 
method="post">

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/register_case.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/register_case.xsl
  2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/register_case.xsl
  2012-01-16 07:51:53 UTC (rev 8580)
@@ -2,103 +2,89 @@
 
 <xsl:template match="data" xmlns:php="http://php.net/xsl";>
 
-<div id="error_message_menu">
-       <a class="btn" id="view_open_cases">                                    
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicheck_list.view_open_cases</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-                       <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-               </xsl:attribute>
-               Vis avvik/måling
-       </a>
-       <a class="btn">
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicase.create_case_message</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-               </xsl:attribute>
-               Registrer avviksmelding
-       </a>
-</div>
+<div id="main_content">
+       <h1>Registrer avviksmelding</h1>
+       
+       <xsl:call-template name="check_list_tab_menu" />
 
-<div id="register_errors_content">
-                       <div class="tab_menu"><a class="active">Registrer 
sak/måling</a></div>
-                                       
-                       <div class="tab_item active">
+       <div id="view_cases">
+
+               <h3 class="box_header">Registrer sak/måling</h3>
+               <div class="tab_item active">
+               
+               <xsl:choose>
+                       <xsl:when 
test="control_items_for_check_list/child::node()">
                        
-                       <xsl:choose>
-                               <xsl:when 
test="control_items_for_check_list/child::node()">
-                               
-                                       <div class="expand_menu"><div 
class="expand_all">Vis alle</div><div class="collapse_all focus">Skjul 
alle</div></div>
-                               
-                                       <ul id="control_items_list" 
class="check_items expand_list">
-                                               <xsl:for-each 
select="control_items_for_check_list">
-                                                       <li>
-                                                       <h4><img 
src="controller/images/arrow_right.png" width="14"/><span><xsl:value-of 
select="title"/></span></h4>                                           
-                                                               <form 
id="frm_register_case" 
action="index.php?menuaction=controller.uicase.register_case&amp;phpgw_return_as=json"
 method="post">
-                                                                       
<xsl:variable name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
-                                                                       <input 
type="hidden" name="control_item_id" value="{$control_item_id}" /> 
-                                                                       <input 
name="check_list_id" type="hidden">
-                                                                     
<xsl:attribute name="value">
-                                                                       
<xsl:value-of select="//check_list/id"/>
-                                                                     
</xsl:attribute>
-                                                                   </input>
-                                                                   <input 
name="status" type="hidden" value="0" />
-                                                                     
-                                                               <xsl:choose>
-                                                                       
<xsl:when test="type = 'control_item_type_1'">
-                                                                               
<input name="type" type="hidden" value="control_item_type_1" />
-                                                                           
-                                                                               
<div class="check_item">
-                                                                              
<div>
-                                                                               
         <label class="comment">Beskrivelse av sak</label>
-                                                                               
         <textarea name="case_descr">
-                                                                               
                        <xsl:value-of select="comment"/>
-                                                                               
                 </textarea>
-                                                                               
   </div>
-                                                                              
<div class="form-buttons">
-                                                                               
                <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'register_error')" /></xsl:variable>
-                                                                               
                <input type="submit" name="save_control" value="{$lang_save}" 
class="not_active" title="{$lang_save}" />
-                                                                               
        </div>
+                               <div class="expand_menu"><div 
class="expand_all">Vis alle</div><div class="collapse_all focus">Skjul 
alle</div></div>
+                       
+                               <ul id="control_items_list" class="check_items 
expand_list">
+                                       <xsl:for-each 
select="control_items_for_check_list">
+                                               <li>
+                                               <h4><img 
src="controller/images/arrow_right.png" width="14"/><span><xsl:value-of 
select="title"/></span></h4>                                           
+                                                       <form 
id="frm_register_case" 
action="index.php?menuaction=controller.uicase.register_case&amp;phpgw_return_as=json"
 method="post">
+                                                               <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                                               <input 
type="hidden" name="control_item_id" value="{$control_item_id}" /> 
+                                                               <input 
name="check_list_id" type="hidden">
+                                                             <xsl:attribute 
name="value">
+                                                               <xsl:value-of 
select="//check_list/id"/>
+                                                             </xsl:attribute>
+                                                           </input>
+                                                           <input 
name="status" type="hidden" value="0" />
+                                                             
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="type = 'control_item_type_1'">
+                                                                       <input 
name="type" type="hidden" value="control_item_type_1" />
+                                                                   
+                                                                       <div 
class="check_item">
+                                                                      <div>
+                                                                               
 <label class="comment">Beskrivelse av sak</label>
+                                                                               
 <textarea name="case_descr">
+                                                                               
                <xsl:value-of select="comment"/>
+                                                                               
         </textarea>
+                                                                          
</div>
+                                                                      <div 
class="form-buttons">
+                                                                               
        <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'register_error')" /></xsl:variable>
+                                                                               
        <input type="submit" name="save_control" value="{$lang_save}" 
class="not_active" title="{$lang_save}" />
                                                                                
</div>
-                                                                       
</xsl:when>
-                                                                       
<xsl:when test="type = 'control_item_type_2'">
-                                                                               
<input name="type" type="hidden" value="control_item_type_2" />
-                                                                               
<div class="check_item">
-                                                                               
 <div>
-                                                                               
 <label class="comment">Registrer målingsverdi</label>
-                                                                               
   <input>
-                                                                               
              <xsl:attribute name="name">measurement</xsl:attribute>
-                                                                               
              <xsl:attribute name="type">text</xsl:attribute>
-                                                                               
              <xsl:attribute name="value">
-                                                                               
                <xsl:value-of select="measurement"/>
-                                                                               
              </xsl:attribute>
-                                                                               
            </input>
-                                                                              
</div>
-                                                                              
<div>
-                                                                               
         <label class="comment">Beskrivelse av sak</label>
-                                                                               
         <textarea name="case_descr">
-                                                                               
                        <xsl:value-of select="comment"/>
-                                                                               
                 </textarea>
-                                                                               
   </div>
-                                                                              
<div class="form-buttons">
-                                                                               
                <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'register_error')" /></xsl:variable>
-                                                                               
                <input type="submit" name="save_control" value="Registrer sak" 
class="not_active" title="{$lang_save}" />
-                                                                               
        </div>
+                                                                       </div>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="type = 'control_item_type_2'">
+                                                                       <input 
name="type" type="hidden" value="control_item_type_2" />
+                                                                       <div 
class="check_item">
+                                                                        <div>
+                                                                        <label 
class="comment">Registrer målingsverdi</label>
+                                                                          
<input>
+                                                                               
      <xsl:attribute name="name">measurement</xsl:attribute>
+                                                                               
      <xsl:attribute name="type">text</xsl:attribute>
+                                                                               
      <xsl:attribute name="value">
+                                                                               
        <xsl:value-of select="measurement"/>
+                                                                               
      </xsl:attribute>
+                                                                               
    </input>
+                                                                      </div>
+                                                                      <div>
+                                                                               
 <label class="comment">Beskrivelse av sak</label>
+                                                                               
 <textarea name="case_descr">
+                                                                               
                <xsl:value-of select="comment"/>
+                                                                               
         </textarea>
+                                                                          
</div>
+                                                                      <div 
class="form-buttons">
+                                                                               
        <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'register_error')" /></xsl:variable>
+                                                                               
        <input type="submit" name="save_control" value="Registrer sak" 
class="not_active" title="{$lang_save}" />
                                                                                
</div>
-                                                                       
</xsl:when>
-                                                               </xsl:choose>   
                                                                                
                        
-                                                                       
-                                                               </form>
-                                                   </li>
-                                               </xsl:for-each>
-                                       </ul>                   
-                                       </xsl:when>
-                                       <xsl:otherwise>
-                                               Alle sjekkpunkter for kontroll 
er registert som åpent/håndtert avvik eller måling 
-                                       </xsl:otherwise>
-                       </xsl:choose>
-               </div>
-               </div>
+                                                                       </div>
+                                                               </xsl:when>
+                                                       </xsl:choose>           
                                                                                
                
+                                                               
+                                                       </form>
+                                           </li>
+                                       </xsl:for-each>
+                               </ul>                   
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       Alle sjekkpunkter for kontroll er 
registert som åpent/håndtert avvik eller måling 
+                               </xsl:otherwise>
+               </xsl:choose>
+       </div>
+</div>
+</div>
 </xsl:template>

Copied: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
 (from rev 8579, 
trunk/controller/templates/base/check_list/view_cases_for_check_list.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
                              (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
      2012-01-16 07:51:53 UTC (rev 8580)
@@ -0,0 +1,75 @@
+<!-- $Id: edit_check_list.xsl 8513 2012-01-07 10:38:09Z vator $ -->
+<xsl:template match="data" name="view_check_list" 
xmlns:php="http://php.net/xsl";>
+<xsl:variable name="date_format">d/m-Y</xsl:variable>
+
+<div id="main_content">
+               
+       <script>
+       
+               // ======================  LASTER FANEN view_open_errors NÅR 
SIDEN LASTES FØRSTE GANG  ===================
+               $(document).ready(function() {
+                       var requestUrl = $("#view_open_cases").attr("href");
+                       load_tab(requestUrl);
+               });
+                       
+               // ======================  FUNKSJONALITET FOR LASTING AV TABS 
===================
+               $(function() {
+       
+                       $("#register_case").live("click", function(){
+                               var requestUrl = $(this).attr("href");
+                               load_tab(requestUrl);
+                       
+                               return false;
+                       });
+                                               
+                       $("#view_open_cases").live("click", function(){
+                               var requestUrl = $(this).attr("href");
+                               load_tab(requestUrl);
+                       
+                               return false;
+                       });
+                       
+                       $("#view_closed_cases").live("click", function(){
+                               var requestUrl = $(this).attr("href");
+                               load_tab(requestUrl);
+                       
+                               return false;
+                       });
+                       
+                       $("#view_measurements").live("click", function(){
+                               var requestUrl = $(this).attr("href");
+                               load_tab(requestUrl);
+                       
+                               return false;
+                       });
+               });
+
+               function load_tab(requestUrl){
+                       $.ajax({
+                                 type: 'POST',
+                                 url: requestUrl,
+                                 success: function(data) {
+                                       $("#load_view_content").html(data);
+                                 }
+                       });
+               }
+       </script>
+               
+               <h1>Sjekkliste for <xsl:value-of 
select="location_array/loc1_name"/></h1>
+               
+               <xsl:call-template name="check_list_tab_menu">
+                       <xsl:with-param 
name="active_tab">view_cases</xsl:with-param>
+               </xsl:call-template>
+               
+               <a style="display:none;" id="view_open_cases">
+                       <xsl:attribute name="href">
+                               
<xsl:text>index.php?menuaction=controller.uicheck_list.view_open_cases</xsl:text>
+                               <xsl:text>&amp;check_list_id=</xsl:text>
+                               <xsl:value-of select="check_list/id"/>
+                               
<xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
+                       </xsl:attribute>
+               </a>
+       
+               <div id="load_view_content"></div>      
+</div>
+</xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_closed_cases.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_closed_cases.xsl
      2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_closed_cases.xsl
      2012-01-16 07:51:53 UTC (rev 8580)
@@ -1,28 +1,8 @@
 <!-- $Id: choose_control_items.xsl 8267 2011-12-11 12:27:18Z sigurdne $ -->
 
 <xsl:template match="data">
-
-<div id="error_message_menu">
-       <a class="btn" id="register_errors">                                    
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicheck_list.register_case</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-                       <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-               </xsl:attribute>
-               Registrer sak/måling
-       </a>
-       <a class="btn">
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicase.create_case_message</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-               </xsl:attribute>
-               Registrer avviksmelding
-       </a>
-</div>
        
-<div id="view_errors">
+<div id="view_cases">
        
        <xsl:call-template name="cases_tab_menu">
                <xsl:with-param 
name="active_tab">view_closed_cases</xsl:with-param>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
      2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_info.xsl
      2012-01-16 07:51:53 UTC (rev 8580)
@@ -68,41 +68,9 @@
                
        <h1>Sjekkliste for <xsl:value-of 
select="location_array/loc1_name"/></h1>
        
-       <div id="edit_check_list_menu" class="hor_menu">
-                       <a>
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis detaljer for sjekkliste
-                       </a>
-                       <a>
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_errors_for_check_list</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis avvik/saker for sjekkliste
-                       </a>                    
-                       <a class="active">
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_control_info</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis info om kontroll
-                       </a>
-                       
-                       <a style="background:#DD624B;border-bottom: 1px solid 
#CB563F;border-top: 1px solid #EE836F;box-shadow: 0 1px 0 #A9422E, 0 -1px 0 
#A9422E;color: #FFFFFF;height: 18px;margin-left: 75px;margin-top: 1px;">
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.register_error</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Registrer avvik/sak
-                       </a>
-               </div>
+       <xsl:call-template name="check_list_tab_menu">
+               <xsl:with-param 
name="active_tab">view_control_info</xsl:with-param>
+       </xsl:call-template>
                                
        <div class="tab_menu">
                <a id="view_control_details" class="active">

Deleted: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_errors_for_check_list.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_errors_for_check_list.xsl
     2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_errors_for_check_list.xsl
     2012-01-16 07:51:53 UTC (rev 8580)
@@ -1,108 +0,0 @@
-<!-- $Id: edit_check_list.xsl 8513 2012-01-07 10:38:09Z vator $ -->
-<xsl:template match="data" name="view_check_list" 
xmlns:php="http://php.net/xsl";>
-<xsl:variable name="date_format">d/m-Y</xsl:variable>
-
-<div id="main_content">
-               
-       <script>
-       
-               // ======================  LASTER FANEN view_open_errors NÅR 
SIDEN LASTES FØRSTE GANG  ===================
-               $(document).ready(function() {
-                       var requestUrl = $("#view_open_cases").attr("href");
-                       load_tab(requestUrl);
-               });
-                       
-               // ======================  FUNKSJONALITET FOR LASTING AV TABS 
===================
-               $(function() {
-       
-                       $("#register_case").live("click", function(){
-                               var requestUrl = $(this).attr("href");
-                               load_tab(requestUrl);
-                       
-                               return false;
-                       });
-                                               
-                       $("#view_open_cases").live("click", function(){
-                               var requestUrl = $(this).attr("href");
-                               load_tab(requestUrl);
-                       
-                               return false;
-                       });
-                       
-                       $("#view_closed_cases").live("click", function(){
-                               var requestUrl = $(this).attr("href");
-                               load_tab(requestUrl);
-                       
-                               return false;
-                       });
-                       
-                       $("#view_measurements").live("click", function(){
-                               var requestUrl = $(this).attr("href");
-                               load_tab(requestUrl);
-                       
-                               return false;
-                       });
-               });
-
-               function load_tab(requestUrl){
-                       $.ajax({
-                                 type: 'POST',
-                                 url: requestUrl,
-                                 success: function(data) {
-                                       $("#load_view_content").html(data);
-                                 }
-                       });
-               }
-       </script>
-               
-               <h1>Sjekkliste for <xsl:value-of 
select="location_array/loc1_name"/></h1>
-               
-               <div id="edit_check_list_menu" class="hor_menu">
-                       <a>
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.edit_check_list_for_location</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis detaljer for sjekkliste
-                       </a>
-                       <a class="active">
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_errors_for_check_list</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis avvik/saker for sjekkliste
-                       </a>                    
-                       <a>
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.view_control_info</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Vis info om kontroll
-                       </a>
-                       
-                       <a style="background:#DD624B;border-bottom: 1px solid 
#CB563F;border-top: 1px solid #EE836F;box-shadow: 0 1px 0 #A9422E, 0 -1px 0 
#A9422E;color: #FFFFFF;height: 18px;margin-left: 75px;margin-top: 1px;">
-                               <xsl:attribute name="href">
-                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.register_error</xsl:text>
-                                       <xsl:text>&amp;check_list_id=</xsl:text>
-                                       <xsl:value-of select="check_list/id"/>
-                               </xsl:attribute>
-                               Registrer avvik/sak
-                       </a>
-               </div>
-               
-               
-               <a style="display:none;" id="view_open_cases">
-                       <xsl:attribute name="href">
-                               
<xsl:text>index.php?menuaction=controller.uicheck_list.view_open_cases</xsl:text>
-                               <xsl:text>&amp;check_list_id=</xsl:text>
-                               <xsl:value-of select="check_list/id"/>
-                               
<xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-                       </xsl:attribute>
-               </a>
-       
-               <div id="load_view_content"></div>      
-</div>
-</xsl:template>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_measurements.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_measurements.xsl
      2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_measurements.xsl
      2012-01-16 07:51:53 UTC (rev 8580)
@@ -1,28 +1,8 @@
 <!-- $Id: choose_control_items.xsl 8267 2011-12-11 12:27:18Z sigurdne $ -->
 
 <xsl:template match="data">
-
-<div id="error_message_menu">
-       <a class="btn" id="register_errors">                                    
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicheck_list.register_case</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-                       <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-               </xsl:attribute>
-               Registrer sak/måling
-       </a>
-       <a class="btn">
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicase.create_case_message</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-               </xsl:attribute>
-               Registrer avviksmelding
-       </a>
-</div>
        
-<div id="view_errors">
+<div id="view_cases">
        
        <xsl:call-template name="cases_tab_menu">
                <xsl:with-param 
name="active_tab">view_measurements</xsl:with-param>
@@ -37,25 +17,40 @@
                                <ul id="check_list_not_fixed_list" 
class="check_items expand_list">
                                        <xsl:for-each 
select="measurement_check_items">
                                                        <li>
-                                                       <xsl:if test="status = 
0">
                                                                <h4><img 
src="controller/images/arrow_right.png" width="14"/><span><xsl:value-of 
select="control_item/title"/></span></h4>                                       
       
-                                                               <form 
class="frm_save_check_item" 
action="index.php?menuaction=controller.uicheck_list.save_check_item" 
method="post">
+                                                               <form 
id="frm_save_check_item" 
action="index.php?menuaction=controller.uicheck_list.save_check_item" 
method="post">
                                                                        
<xsl:variable name="check_item_id"><xsl:value-of select="id"/></xsl:variable>
                                                                        <input 
type="hidden" name="check_item_id" value="{$check_item_id}" />
                                                                        <input 
type="hidden" name="type" value="measurement" />
                                                                         
                                                                        <div 
class="check_item">
+                                                                          <div>
+                                                                               
<label>Status</label>
+                                                                               
<select name="status">
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="status = 0">
+                                                                               
                        <option value="0" SELECTED="SELECTED">Ikke 
utført</option>
+                                                                               
                        <option value="1" >Utført</option>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:when test="status = 1">
+                                                                               
                        <option value="0">Ikke utført</option>
+                                                                               
                        <option value="1" SELECTED="SELECTED">Utført</option>
+                                                                               
                </xsl:when>
+                                                                               
        </xsl:choose>
+                                                                               
</select>
+                                                                         </div>
                                                                          <div>
                                                                               
<label>Målingsverdi</label>
                                                                               
<input>
                                                                                
      <xsl:attribute name="name">measurement</xsl:attribute>
                                                                                
      <xsl:attribute name="type">text</xsl:attribute>
                                                                                
      <xsl:attribute name="value">
-                                                                               
        <xsl:value-of select="measurement"/>
+                                                                               
        <xsl:if test="measurement > 0">
+                                                                               
                <xsl:value-of select="measurement"/>
+                                                                               
        </xsl:if>
                                                                                
      </xsl:attribute>
                                                                                
    </input>
                                                                       </div>
-                                                                      
                                                                       <div>
                                                                         <label 
class="comment">Kommentar</label>
                                                                         
<textarea name="comment">
@@ -64,12 +59,11 @@
                                                                       </div>
                                                                       <div 
class="form-buttons">
                                                                                
        <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save_check_item')" /></xsl:variable>
-                                                                               
        <input type="submit" name="save_control" value="Oppdater registert 
måling" class="not_active" title="{$lang_save}" />
+                                                                               
        <input type="submit" name="save_control" value="Oppdater måling" 
class="not_active" title="{$lang_save}" />
                                                                                
</div>
                                                                        </div>
                                                                </form>
-                                                       </xsl:if>
-                                           </li>
+                                               </li>
                                        </xsl:for-each>
                                </ul>                   
                                </xsl:when>

Modified: 
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
        2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
        2012-01-16 07:51:53 UTC (rev 8580)
@@ -2,28 +2,8 @@
 
 <xsl:template match="data" xmlns:php="http://php.net/xsl";>
 
-<div id="error_message_menu">
-       <a class="btn" id="register_case">                                      
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicheck_list.register_case</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-                       <xsl:text>&amp;phpgw_return_as=stripped_html</xsl:text>
-               </xsl:attribute>
-               Registrer sak/måling
-       </a>
-       <a class="btn">
-               <xsl:attribute name="href">
-                       
<xsl:text>index.php?menuaction=controller.uicase.create_case_message</xsl:text>
-                       <xsl:text>&amp;check_list_id=</xsl:text>
-                       <xsl:value-of select="check_list/id"/>
-               </xsl:attribute>
-               Registrer avviksmelding
-       </a>
-</div>
+<div id="view_cases">
        
-<div id="view_errors">
-       
        <xsl:call-template name="cases_tab_menu">
                <xsl:with-param 
name="active_tab">view_open_cases</xsl:with-param>
        </xsl:call-template>
@@ -67,7 +47,16 @@
                                        </xsl:choose>
                                </xsl:for-each>
                        </ul>
-                                       
+                       
+                       <a style="font-size: 11px;margin-top: 20px;padding: 3px 
20px;" class="btn focus">
+                               <xsl:attribute name="href">
+                                       
<xsl:text>index.php?menuaction=controller.uicheck_list_for_location.register_error</xsl:text>
+                                       <xsl:text>&amp;check_list_id=</xsl:text>
+                                       <xsl:value-of select="check_list/id"/>
+                               </xsl:attribute>
+                               Registrer melding
+                       </a>
+                       
                        </xsl:when>
                        <xsl:otherwise>
                                Ingen registrerte åpne avvik

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_item/choose_control_items.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_item/choose_control_items.xsl
 2012-01-16 07:43:33 UTC (rev 8579)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_item/choose_control_items.xsl
 2012-01-16 07:51:53 UTC (rev 8580)
@@ -22,7 +22,7 @@
                                        <li>
                                                <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>
+                                                               <h4><img 
src="controller/images/arrow_right.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">

Modified: branches/Version-1_0-branch/controller/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/css/base.css  
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/controller/templates/base/css/base.css  
2012-01-16 07:51:53 UTC (rev 8580)
@@ -1014,7 +1014,7 @@
 }
 
 .frm_save_check_item input[type='submit']{
-       width: 185px;
+       width: 165px;
 }
 ul.check_items {
     width: 625px;
@@ -1063,7 +1063,7 @@
     border: 1px solid #A3A3A3;
     margin: 0 318px 0 0;
     padding: 15px;
-    width: 628px;
+    width: 800px;
 }
 .tab_item h2{
        margin:0 0 10px;
@@ -1158,7 +1158,22 @@
     margin-top: 1px;   
 }
 
+#edit_check_list_menu div{
+       float:left;
+       margin-left: 75px;
+}
 
+#edit_check_list_menu a.focus {
+    float: none;
+    font-size: 11px;
+    margin-top: 3px;
+    padding: 3px 0;
+}
+
+#edit_check_list_menu a.focus.first{
+    margin-top: 0;
+}
+
 #frm_update_check_list input[type="submit"]{
        width: 140px;   
 }
@@ -1173,9 +1188,9 @@
     display:block;
 }
 
-#view_errors {
-       float:left;
-    margin: 20px 0 0 10px;   
+#view_cases {
+    float: left;
+    margin: 20px 0 0 0;
 }
 #register_errors_content {
     float: right;
@@ -1183,14 +1198,13 @@
 }
 #edit_check_list_menu a {
     float: left;
-    height: 20px;
-    padding-top: 10px;
+    padding: 14px 0;
     text-align: center;
     width: 185px;
 }
-#edit_check_list_menu{
-               height:30px;
-               margin:0 0 20px 0;
+#edit_check_list_menu {
+    margin: 0 0 20px;
+    overflow: hidden;
 }
 .content_wrp {
        background: none repeat scroll 0 0 #EDF5FF;
@@ -1221,4 +1235,13 @@
 li.check_item_cases ul li {
     list-style: disc outside none;
     margin: 5px 0 0 20px;
-}
\ No newline at end of file
+}
+a.view_check_list{
+       color: #FFFFFF;
+    display: block;
+    font-size: 10px;
+    font-weight: bold;
+    height: 13px;
+    text-decoration: none;
+    width: 24px;       
+}

Modified: branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php    
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php    
2012-01-16 07:51:53 UTC (rev 8580)
@@ -27,6 +27,7 @@
        * @version $Id$
        */
 
+       phpgw::import_class('phpgwapi.datetime');
        /**
         * Description
         * @package property
@@ -224,32 +225,21 @@
 
                function tax_code_list($selected='')
                {
-                       $tax_codes=$this->so->tax_code_list();
-
-                       while (is_array($tax_codes) && list(,$code) = 
each($tax_codes))
+                       if(!$selected && $selected !== '0' )
                        {
-                               $sel_code = '';
-                               if ($code['id']==$selected)
-                               {
-                                       $sel_code = 'selected';
-                               }
-
-                               $tax_code_list[] = array
-                                       (
-                                               'id'                    => 
$code['id'],
-                                               'selected'              => 
$sel_code
-                                       );
+                               $selected = '#';
                        }
-
-                       for ($i=0;$i<count($tax_code_list);$i++)
+                       else
                        {
-                               if ($tax_code_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($tax_code_list[$i]['selected']);
-                               }
+                               $selected = (int)$selected;
                        }
-
-                       return $tax_code_list;
+                       $tax_codes = $this->so->tax_code_list();
+                       
+                       foreach ($tax_codes as &$tax_code)
+                       {
+                               $tax_code['selected'] = (int)$tax_code['id'] 
=== $selected ? 1 : 0;
+                       }
+                       return $tax_codes;
                }
 
                function update_period($voucher_id='',$period='')
@@ -363,6 +353,109 @@
                        }
                }
 
+               public function add_manual_invoice($values)
+               {
+                       $receipt = array();
+                       $config = 
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property', 
'.invoice'));
+
+                       $buffer = array();
+                       $soXport    = CreateObject('property.soXport');
+                       if($values['loc1']=$values['location']['loc1'])
+                       {
+                               $values['dima']=implode('',$values['location']);
+                               $values['location_code']        = explode('-', 
$values['location']);
+                       }
+                       $values['spbudact_code']        = 
$values['b_account_id'];
+                       $values['fakturanr']            = $values['invoice_id'];
+                       $values['spvend_code']          = $values['vendor_id'];
+                       $values['belop']                        = 
$values['amount'];
+                       $values['godkjentbelop']        = $values['amount'];
+
+                       $_dateformat = $this->bocommon->dateformat;
+                       
+                       $values['fakturadato']          = 
date($_dateformat,phpgwapi_datetime::date_to_timestamp($values['invoice_date']));
+                       $values['forfallsdato']         = 
date($_dateformat,phpgwapi_datetime::date_to_timestamp($values['payment_date']));
+                       $values['periode']                      = 
date('Ym',phpgwapi_datetime::date_to_timestamp($values['paid_date']));
+
+                       $values['kildeid']                      = 1;
+                       $values['pmwrkord_code']        = $values['order_id'];
+
+                       
if(isset($config->config_data['common']['manual_voucher_id']) && 
$config->config_data['common']['manual_voucher_id'])
+                       {
+                               if( 
$soXport->check_voucher_id($values['voucher_out_id']))
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('voucher id already taken'));
+                               }
+                               $values['bilagsnr']             = 
$values['voucher_out_id'];
+                               $values['bilagsnr_ut']  = '';
+                       }
+                       else
+                       {
+                               $values['bilagsnr']                     = 
execMethod('property.socommon.increment_id','Bilagsnummer');
+                               $values['bilagsnr_ut']          = 
$values['voucher_out_id'];                    
+                       }
+
+                       if( $soXport->check_invoice_id($values['vendor_id'], 
$values['invoice_id']))
+                       {
+                               $receipt['error'][] = 
array('msg'=>lang('invoice id already taken for this vendor'));
+                       }
+
+                       if(isset($receipt['error']))
+                       {
+                               return $receipt;
+                       }
+
+                       $values['kostra_id']            = 
$soXport->get_kostra_id($values['loc1']);
+                       $values['mvakode']                      = 
(int)$values['tax_code'];
+                       $values['project_id']           = 
$values['project_group'];                     
+
+                       $values['oppsynsmannid']                = 
$values['janitor'];
+                       $values['saksbehandlerid']              = 
$values['supervisor'];
+                       $values['budsjettansvarligid']  = 
$values['budget_responsible'];
+
+                       if($values['order_id'] && $order_type = 
$soXport->check_order($values['order_id']))
+                       {
+                               if($order_type=='workorder')
+                               {
+                                       $buffer[0]=$values;
+                               }
+
+                               if($order_type=='s_agreement')
+                               {
+                                       $sos_agreement = 
CreateObject('property.sos_agreement');
+                                       $s_agreement = 
$sos_agreement->read_single(array('s_agreement_id'=>$values['order_id']));
+                                       $values = 
$this->set_responsible($values,$s_agreement['user_id'],$s_agreement['b_account_id']);
+                                       $s_agreement_detail = 
$sos_agreement->read(array('allrows'=>true,'s_agreement_id'=>$values['order_id'],'detail'=>true));
+
+                                       $sum_agreement=0;
+                                       for 
($i=0;$i<count($s_agreement_detail);$i++)
+                                       {
+                                               $sum_agreement = $sum_agreement 
+ $s_agreement_detail[$i]['cost'];
+                                       }
+
+                                       for 
($i=0;$i<count($s_agreement_detail);$i++)
+                                       {
+                                               $buffer[$i]                     
                        = $values;
+                                               $buffer[$i]['location_code']    
= $s_agreement_detail[$i]['location_code'];
+                                               $buffer[$i]['dima']             
                = str_replace('-','',$s_agreement_detail[$i]['location_code']);
+                                               $buffer[$i]['belop']            
        = round($values['belop'] / $sum_agreement * 
$s_agreement_detail[$i]['cost'],2);
+                                               $buffer[$i]['godkjentbelop']    
= $buffer[$i]['belop'];
+                                       }
+                               }
+
+                               if($soXport->add_manual_invoice($buffer))
+                               {
+                                       $receipt['message'][] = 
array('msg'=>lang('Invoice %1 is added',$soXport->voucher_id));
+                                       $receipt['voucher_id'] = 
$soXport->voucher_id;
+                               }
+                               else
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Invoice is NOT added!'));
+                               }
+                       }
+                       return $receipt;
+               }
+
                function add($values,$debug='')
                {
                        $this->soXport    = CreateObject('property.soXport');
@@ -460,7 +553,6 @@
                                                $buffer[$i]['location_code']    
=$s_agreement_detail[$i]['location_code'];
                                                $buffer[$i]['dima']             
                =str_replace('-','',$s_agreement_detail[$i]['location_code']);
 
-
                                                $buffer[$i]['belop']    =       
round($values['belop'] / $sum_agreement * $s_agreement_detail[$i]['cost'],2);
                                                $buffer[$i]['godkjentbelop'] 
=$buffer[$i]['belop'];
 
@@ -534,7 +626,7 @@
                        }
                }
 
-               function set_responsible($values,$user_id='',$b_account_id='')
+               function set_responsible($values, $user_id=0, $b_account_id='')
                {
                        $config                         = 
CreateObject('phpgwapi.config','property');
                        $config->read();
@@ -545,15 +637,17 @@
                        if (!$values['budget_responsible'])
                        {
                                $criteria_budget_responsible            = 
array('ecodimb' => $values['dimb'], 'cat_id' => $responsible_responsible);
-                               $budget_responsible_contact_id          = 
$responsible->get_responsible($criteria_budget_responsible);
-                               $budget_responsible_user_id                     
= $responsible->get_contact_user_id($budget_responsible_contact_id);
-                               $values['budget_responsible']           = 
$GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
-                               $values['budsjettansvarligid']          = 
$values['budget_responsible'];
+                               if($budget_responsible_contact_id = 
$responsible->get_responsible($criteria_budget_responsible))
+                               {
+                                       $budget_responsible_user_id             
        = $responsible->get_contact_user_id($budget_responsible_contact_id);
+                                       $values['budget_responsible']           
= $GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
+                                       $values['budsjettansvarligid']          
= $values['budget_responsible'];
+                               }
                        }
 
                        if (!$values['budget_responsible'])
                        {
-                               $values['budget_responsible'] = 
$this->soXport->get_responsible($b_account_id);
+                               $values['budget_responsible'] = 
execMethod('property.soXport.get_responsible',$b_account_id);
                                $values['budsjettansvarligid'] = 
$values['budget_responsible'];
                        }
 
@@ -561,10 +655,12 @@
                        if(!$values['supervisor'])
                        {
                                $criteria_supervisor                            
= array('ecodimb' => $values['dimb'], 'cat_id' => $responsible_supervisor);
-                               $supervisor_contact_id                          
= $responsible->get_responsible($criteria_supervisor);
-                               $supervisor_user_id                             
        = $responsible->get_contact_user_id($supervisor_contact_id);
-                               $values['supervisor']                           
= $GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
-                               $values['saksbehandlerid']                      
= $values['supervisor'];
+                               if($supervisor_contact_id = 
$responsible->get_responsible($criteria_supervisor))
+                               {
+                                       $supervisor_user_id                     
                = $responsible->get_contact_user_id($supervisor_contact_id);
+                                       $values['supervisor']                   
        = $GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
+                                       $values['saksbehandlerid']              
        = $values['supervisor'];
+                               }
                        }
 
                        $values['janitor']                              = 
$GLOBALS['phpgw']->accounts->get($user_id)->lid;

Modified: branches/Version-1_0-branch/property/inc/class.botts.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.botts.inc.php        
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.botts.inc.php        
2012-01-16 07:51:53 UTC (rev 8580)
@@ -943,9 +943,6 @@
                        {
                                $body .= lang('Group').': '. $group_name ."\n";
                        }
-                       $body .= lang('Opened By').': '. $ticket['user_name'] 
."\n\n";
-                       $body .= lang('First Note Added').":\n";
-                       $body .= 
stripslashes(strip_tags($ticket['details']))."\n\n";
 
                        
/**************************************************************\
                         * Display additional notes                             
        *
@@ -954,7 +951,7 @@
                        {
                                $i=1;
 
-                               $history_array = 
$this->historylog->return_array(array(),array('C'),'','',$id);
+                               $history_array = 
$this->historylog->return_array(array(),array('C'),'history_id','DESC',$id);
 
                                foreach($history_array as $value)
                                {
@@ -963,7 +960,7 @@
                                        $body .=lang('Note').': '. 
nl2br(stripslashes($value['new_value']))."\n\n";
                                        $i++;
                                }
-                               $subject.= "-" .$i;
+                               $subject .= "::{$i}";
                        }
                        
/**************************************************************\
                         * Display record history                               
        *
@@ -975,6 +972,10 @@
                        }
 
 
+                       $body .= lang('Opened By').': '. $ticket['user_name'] 
."\n\n";
+                       $body .= lang('First Note Added').":\n";
+                       $body .= 
stripslashes(strip_tags($ticket['details']))."\n\n";
+
                        if($get_message)
                        {
                                return array('subject' => $subject, 'body' => 
$body);

Modified: branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2012-01-16 07:51:53 UTC (rev 8580)
@@ -481,6 +481,11 @@
 
                function read_single($workorder_id)
                {
+                       if(!$workorder_id)
+                       {
+                               return array();
+                       }
+
                        $contacts       = CreateObject('property.sogeneric');
                        $contacts->get_location_info('vendor',false);
                        $workorder                                              
= $this->so->read_single($workorder_id);

Modified: branches/Version-1_0-branch/property/inc/class.notify.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.notify.inc.php       
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.notify.inc.php       
2012-01-16 07:51:53 UTC (rev 8580)
@@ -130,7 +130,7 @@
                {
                        if(!isset($data['count']))
                        {
-                               throw new 
Exception("property_notify::get_yui_table_def() - Missing count in input");     
              
+                               throw new 
Exception("property_notify::get_yui_table_def() - Missing count in input");
                        }       
 
                        $content = array();

Modified: branches/Version-1_0-branch/property/inc/class.soXport.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soXport.inc.php      
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.soXport.inc.php      
2012-01-16 07:51:53 UTC (rev 8580)
@@ -27,6 +27,8 @@
        * @version $Id$
        */
 
+       phpgw::import_class('phpgwapi.datetime');
+
        /**
         * Description
         * @package property
@@ -39,6 +41,7 @@
                var $total_records = 0;
                var $bilagsnr;
                var $voucher_id;
+               protected $global_lock = false;
 
                function __construct()
                {
@@ -53,13 +56,13 @@
                }
 
 
-               function auto_tax($dima='')
+               function auto_tax($loc1='')
                {
-                       if(!$dima)
+                       if(!$loc1)
                        {
                                return;
                        }
-                       $sql = "select mva as tax_code from fm_location1 where 
loc1='" . substr($dima,0,4) . "'";
+                       $sql = "SELECT mva as tax_code FROM fm_location1 WHERE 
loc1='{$loc1}'";
                        $this->db->query($sql);
                        $this->db->next_record();
 
@@ -72,7 +75,7 @@
                        {
                                return $mvakode;
                        }
-                       $sql = "select mva as tax_code from fm_b_account where 
id='$b_account_id'";
+                       $sql = "SELECT mva as tax_code FROM fm_b_account WHERE 
id='$b_account_id'";
                        $this->db->query($sql);
                        $this->db->next_record();
 
@@ -93,7 +96,7 @@
                        {
                                return $mvakode;
                        }
-                       $sql = "select mva as tax_code from fm_vendor where 
id='$vendor_id'";
+                       $sql = "SELECT mva as tax_code FROM fm_vendor WHERE 
id='$vendor_id'";
                        $this->db->query($sql);
                        $this->db->next_record();
 
@@ -108,13 +111,13 @@
 
                }
 
-               function get_kostra_id($dima='')
+               function get_kostra_id($loc1='')
                {
-                       if(!$dima)
+                       if(!$loc1)
                        {
                                return;
                        }
-                       $sql = "select kostra_id from fm_location1 where 
loc1='" . substr($dima,0,4) . "'";
+                       $sql = "SELECT kostra_id FROM fm_location1 WHERE 
loc1='{$loc1}'";
                        $this->db->query($sql);
                        $this->db->next_record();
 
@@ -123,9 +126,9 @@
 
                function anleggsnr_to_objekt($anleggsnr,$meter_table)
                {
-                       $this->db->query("select 
$meter_table.ext_meter_id,$meter_table.loc1,$meter_table.loc2,$meter_table.loc3,fm_part_of_town.district_id
 "
-                               . " from $meter_table $this->join fm_location1 
ON $meter_table.loc1 = fm_location1.loc1 $this->join "
-                               . " fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id where 
$meter_table.ext_system_id='$anleggsnr'");
+                       $this->db->query("SELECT 
$meter_table.ext_meter_id,$meter_table.loc1,$meter_table.loc2,$meter_table.loc3,fm_part_of_town.district_id
 "
+                               . " FROM $meter_table $this->join fm_location1 
ON $meter_table.loc1 = fm_location1.loc1 $this->join "
+                               . " fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id WHERE 
$meter_table.ext_system_id='$anleggsnr'");
 
                        $this->db->next_record();
 
@@ -173,7 +176,7 @@
                        $loc1=substr($dima,0,4);
                        $loc2=substr($dima,4,2);
                        $loc3=substr($dima,6,2);
-                       $sql = "select loc3_name from fm_location3 where loc1 = 
'$loc1' and loc2= '$loc2' and loc3 = '$loc3' ";
+                       $sql = "SELECT loc3_name FROM fm_location3 WHERE loc1 = 
'$loc1' and loc2= '$loc2' and loc3 = '$loc3' ";
                        $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
                        $GLOBALS['phpgw']->db->next_record();
                        $address=$GLOBALS['phpgw']->db->f('loc3_name');
@@ -183,7 +186,7 @@
 
                function check_order($id)
                {
-                       $this->db->query("SELECT id,type FROM fm_orders where 
id='{$id}'");
+                       $this->db->query("SELECT id,type FROM fm_orders WHERE 
id='{$id}'");
                        $this->db->next_record();
                        return $this->db->f('type');
                }
@@ -201,14 +204,21 @@
                function check_spbudact_code($id)
                {
 
-                       $this->db->query("select count(*) as cnt from 
fm_b_account where id='$id'");
+                       $this->db->query("SELECT count(*) as cnt FROM 
fm_b_account WHERE id='$id'");
                        $this->db->next_record();
                        return $this->db->f('cnt');
                }
 
                function add($buffer)
                {
-                       $this->db->transaction_begin();
+                       if ( $this->db->get_transaction() )
+                       {
+                               $this->global_lock = true;
+                       }
+                       else
+                       {
+                               $this->db->transaction_begin();
+                       }
 
                        $num=0;
                        foreach ($buffer as $fields)
@@ -281,7 +291,10 @@
                        $start_date = (int)$this->db->f('start_date');
                        $this->db->query("UPDATE fm_idgenerator set value = 
{$bilagsnr} WHERE name = 'Bilagsnummer' AND start_date = {$start_date}");
 
-                       $this->db->transaction_commit();
+                       if ( !$this->global_lock )
+                       {
+                               $this->db->transaction_commit();
+                       }
 
                        return $num;
                }
@@ -324,13 +337,14 @@
                                $data['utbetalingid'],
                                $data['utbetalingsigndato'],
                                $data['filnavn'],
-                               date($this->db->datetime_format()),
+                               isset($data['overftid']) && $data['overftid'] ? 
$data['overftid'] : date($this->db->datetime_format()),
                                $data['item_type'],
                                $data['item_id'],
                                $data['external_ref'],
                                $data['currency'],
                                $this->db->db_addslashes($data['process_log']),
-                               $data['process_code']
+                               $data['process_code'],
+                               $data['manual_record']
                        );
 
                        $values = $this->db->validate_insert($values);
@@ -339,19 +353,77 @@
                                . " 
periode,periodization,periodization_start,forfallsdato,fakturanr,spbudact_code,regtid,artid,spvend_code,dima,loc1,"
                                . " 
dimb,mvakode,dimd,oppsynsmannid,saksbehandlerid,budsjettansvarligid,oppsynsigndato,saksigndato,"
                                . " 
budsjettsigndato,merknad,splitt,utbetalingid,utbetalingsigndato,filnavn,overftid,item_type,item_id,external_ref,"
-                               . " 
currency,process_log,process_code,belop,godkjentbelop,ordrebelop)"
-                               . "values ($values, "
+                               . " 
currency,process_log,process_code,manual_record,belop,godkjentbelop,ordrebelop)"
+                               . "VALUES ($values, "
                                . $this->db->money_format($data['belop']) . ","
                                . 
$this->db->money_format($data['godkjentbelop']) . ","
                                . $this->db->money_format($data['ordrebelop']) 
. ")";
 
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       //echo 'sql ' . $sql.'<br>';
+                       return $this->db->query($sql,__LINE__,__FILE__);
                }
 
+
+       function get_voucher($bilagsnr)
+       {
+                       $sql= "SELECT fm_ecobilag.* FROM fm_ecobilag WHERE 
bilagsnr = {$bilagsnr}";
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $voucher = array();
+                       while ($this->db->next_record())
+                       {
+                               $voucher[] = array
+                               (
+                                       'id'                                    
=> $this->db->f('id'),
+                                       'bilagsnr'                              
=> $bilagsnr,
+                                       'bilagsnr_ut'                   => 
$this->db->f('bilagsnr_ut'),
+                                       'kidnr'                                 
=> $this->db->f('kidnr'),
+                                       'typeid'                                
=> $this->db->f('typeid'),
+                                       'kildeid'                               
=> $this->db->f('kildeid'),
+                                       'project_id'                    => 
$this->db->f('project_id'),
+                                       'pmwrkord_code'                 => 
$this->db->f('pmwrkord_code'),
+                                       'order_id'                              
=> $this->db->f('pmwrkord_code'),
+                                       'belop'                                 
=> $this->db->f('belop'),
+                                       'fakturadato'                   => 
$this->db->f('fakturadato'),
+                                       'periode'                               
=> $this->db->f('periode'),
+                                       'periodization'                 => 
$this->db->f('periodization'),
+                                       'periodization_start'   => 
$this->db->f('periodization_start'),
+                                       'forfallsdato'                  => 
$this->db->f('forfallsdato'),
+                                       'fakturanr'                             
=> $this->db->f('fakturanr'),
+                                       'spbudact_code'                 => 
$this->db->f('spbudact_code'),
+                                       'regtid'                                
=> $this->db->f('regtid'),
+                                       'artid'                                 
=> $this->db->f('artid'),
+                                       'godkjentbelop'                 => 
$this->db->f('godkjentbelop'),
+                                       'spvend_code'                   => 
$this->db->f('spvend_code'),
+                                       'loc1'                                  
=> $this->db->f('loc1'),
+                                       'dima'                                  
=> $this->db->f('dima'),
+                                       'dimb'                                  
=> $this->db->f('dimb'),
+                                       'mvakode'                               
=> $this->db->f('mvakode'),
+                                       'dimd'                                  
=> $this->db->f('dimd'),
+                                       'oppsynsmannid'                 => 
$this->db->f('oppsynsmannid'),
+                                       'saksbehandlerid'               => 
$this->db->f('saksbehandlerid'),
+                                       'budsjettansvarligid'   => 
$this->db->f('budsjettansvarligid'),
+                                       'oppsynsigndato'                => 
$this->db->f('oppsynsigndato'),
+                                       'saksigndato'                   => 
$this->db->f('saksigndato'),
+                                       'budsjettsigndato'              => 
$this->db->f('budsjettsigndato'),
+                                       'merknad'                               
=> $this->db->f('merknad',true),
+                                       'splitt'                                
=> $this->db->f('splitt'),
+                                       'utbetalingid'                  => 
$this->db->f('utbetalingid'),
+                                       'utbetalingsigndato'    => 
$this->db->f('utbetalingsigndato'),
+                                       'external_ref'                  => 
$this->db->f('external_ref'),
+                                       'kostra_id'                             
=> $this->db->f('kostra_id'),
+                                       'currency'                              
=> $this->db->f('currency'),
+                                       'process_log'                   => 
$this->db->f('process_log',true),
+                                       'process_code'                  => 
$this->db->f('process_code'),
+                               );
+                       }
+
+                       return $voucher;
+       }
+
+
                function delete_from_fm_ecobilag($id)
                {
-                       $sql="delete from fm_ecobilag where id=$id";
+                       $sql="DELETE FROM fm_ecobilag WHERE id=$id";
                        $this->db->query($sql,__LINE__,__FILE__);
                }
 
@@ -360,11 +432,11 @@
                {
                        if($pre_transfer)
                        {
-                               $sql= "SELECT sum(belop) as belop, bilagsnr 
from fm_ecobilag WHERE periode='$periode' AND utbetalingsigndato IS NULL GROUP 
BY bilagsnr ";
+                               $sql= "SELECT sum(belop) as belop, bilagsnr 
FROM fm_ecobilag WHERE periode='$periode' AND utbetalingsigndato IS NULL GROUP 
BY bilagsnr ";
                        }
                        else
                        {
-                               $sql="select sum(belop) as belop, bilagsnr from 
fm_ecobilag where periode='$periode'  AND budsjettsigndato is not NULL  AND ( 
saksigndato is not NULL  OR oppsynsigndato is not NULL  ) AND 
utbetalingsigndato is not NULL group by bilagsnr";
+                               $sql="SELECT sum(belop) as belop, bilagsnr FROM 
fm_ecobilag WHERE periode='$periode'  AND budsjettsigndato is not NULL  AND ( 
saksigndato is not NULL  OR oppsynsigndato is not NULL  ) AND 
utbetalingsigndato is not NULL group by bilagsnr";
                        }
 
                        $this->db->query($sql,__LINE__,__FILE__);
@@ -385,7 +457,7 @@
                                {
                                        $bilagsnr = 
$hoved_bilag_temp[$i]['bilagsnr'];
 
-                                       $sql= "select 
fm_ecobilag.*,fm_ecouser.initials as saksbehandler from fm_ecobilag $this->join 
fm_ecouser on fm_ecobilag.budsjettansvarligid=fm_ecouser.lid where 
bilagsnr=$bilagsnr ";
+                                       $sql= "SELECT 
fm_ecobilag.*,fm_ecouser.initials as saksbehandler FROM fm_ecobilag $this->join 
fm_ecouser on fm_ecobilag.budsjettansvarligid=fm_ecouser.lid WHERE 
bilagsnr='{$bilagsnr}'";
                                        
$this->db->query($sql,__LINE__,__FILE__);
 
                                        $this->db->next_record();
@@ -532,28 +604,35 @@
                        $belop=$oRsBilag['belop'];
                        $godkjentbelop=$oRsBilag['godkjentbelop'];
 
-                       $sql="INSERT INTO fm_ecoavvik 
(bilagsnr,fakturadato,forfallsdato,oppsynsmannid,oppsynsigndato,saksbehandlerid,saksigndato,budsjettansvarligid,budsjettsigndato,artid,spvend_code,belop,godkjentbelop)
  values "
+                       $sql="INSERT INTO fm_ecoavvik 
(bilagsnr,fakturadato,forfallsdato,oppsynsmannid,oppsynsigndato,saksbehandlerid,saksigndato,budsjettansvarligid,budsjettsigndato,artid,spvend_code,belop,godkjentbelop)
  VALUES "
                                . 
"($bilagsnr','$fakturadato','$forfallsdato','$oppsynsmannid','$oppsynsigndato','$saksbehandlerid','$saksigndato','$budsjettansvarligid','$budsjettsigndato','$artid','$spvend_code','$belop','$godkjentbelop')";
                        $this->db->query($sql,__LINE__,__FILE__);
                }
 
                function delete_avvik($bilagsnr)
                {
-                       $sql="delete from fm_ecoavvik where 
bilagsnr='$bilagsnr'";
+                       $sql="DELETE FROM fm_ecoavvik WHERE 
bilagsnr='$bilagsnr'";
                        $this->db->query($sql,__LINE__,__FILE__);
                }
 
                function delete_invoice($bilagsnr)
                {
-                       $sql="delete from fm_ecobilagoverf where 
bilagsnr='$bilagsnr'";
+                       $sql="DELETE FROM fm_ecobilagoverf WHERE 
bilagsnr='$bilagsnr'";
                        $this->db->query($sql,__LINE__,__FILE__);
                }
 
+               function delete_voucher_from_fm_ecobilag($bilagsnr)
+               {
+                       $bilagsnr = (int) $bilagsnr;
+                       $sql="DELETE FROM fm_ecobilag WHERE bilagsnr = 
$bilagsnr";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
                //Logg transaksjon
                function log_transaction($batchid,$bilagid,$message='')
                {
                        $tid=date($this->datetimeformat);
-                       $sql= "insert into fm_ecologg 
(batchid,ecobilagid,melding,tid) values ('$batchid','$bilagid' 
,'$message','$tid')";
+                       $sql= "INSERT INTO fm_ecologg 
(batchid,ecobilagid,melding,tid) VALUES ('$batchid','$bilagid' 
,'$message','$tid')";
                        $this->db->query($sql,__LINE__,__FILE__);
                }
 
@@ -581,9 +660,140 @@
 
                function get_responsible($b_abbount_id)
                {
-                       $this->db->query("select account_lid from fm_b_account 
$this->join phpgw_accounts on fm_b_account.responsible = 
phpgw_accounts.account_id where fm_b_account.id = '$b_abbount_id'");
+                       $this->db->query("SELECT account_lid FROM fm_b_account 
$this->join phpgw_accounts on fm_b_account.responsible = 
phpgw_accounts.account_id WHERE fm_b_account.id = '$b_abbount_id'");
                        $this->db->next_record();
                        $responsible = $this->db->f('account_lid');
                        return $responsible;
                }
+
+               function add_manual_invoice($values)
+               {
+                       $this->add($values);
+                       $_dateformat = $this->db->date_format();
+                       $this->db->transaction_begin();
+                       $voucher = $this->get_voucher($values[0]['bilagsnr']);
+                       foreach ($voucher as &$line)
+                       {
+                               $line['overftid']                               
= 
date($_dateformat,phpgwapi_datetime::date_to_timestamp($values[0]['paid_date']));
     
+                               $line['ordrebelop']                             
= $line['godkjentbelop'];       
+                               $line['filnavn']                                
= 'dummy';              
+                               $line['oppsynsigndato']                 = date( 
$_dateformat );
+                               $line['saksigndato']                    = date( 
$_dateformat );
+                               $line['budsjettsigndato']               = date( 
$_dateformat );
+                               $line['utbetalingsigndato']             = date( 
$_dateformat );
+                               $line['utbetalingid']                   = 
$GLOBALS['phpgw']->accounts->get($this->account_id)->lid;
+                               $line['manual_record']                  = 1;
+
+                               $this->add_OverfBilag($line);
+
+                               $amount =  $line['godkjentbelop'] * 100; 
+
+                               if($line['order_id'])
+                               {
+                                       //Oppdater beløp på bestilling
+                                       if ($line['dimd'] % 2 == 0)
+                                       {
+                                               
$actual_cost_field='act_mtrl_cost';
+                                       }
+                                       else
+                                       {
+                                               
$actual_cost_field='act_vendor_cost';
+                                       }
+                                       $operator = '+';
+                                       if(!$this->debug)
+                                       {
+                                               
$this->correct_actual_cost($line['order_id'],$amount, $actual_cost_field, 
$operator);
+                                       }
+                               }
+                       }
+
+                       
$this->delete_voucher_from_fm_ecobilag($values[0]['bilagsnr']);
+                       return $this->db->transaction_commit();
+               }
+
+
+               // Oppdater beløp på arbeidsordre
+               // operator="-" ved tilbakerulling
+               public function correct_actual_cost($order_id, $amount, 
$actual_cost_field, $operator)
+               {
+                       $sql = "SELECT type FROM fm_orders WHERE 
id='{$order_id}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       $table = '';
+                       $update_paid = '';
+                       switch($this->db->f('type'))
+                       {
+                               case 'workorder':
+                                       $table = 'fm_workorder';
+                                       if($operator == "-")
+                                       {
+                                               $update_paid = ", paid = 1";
+                                       }
+                                       else
+                                       {
+                                               $update_paid = ", paid = 2";
+                                       }
+                                       break;
+                               case 's_agreement':
+                                       $table = 'fm_s_agreement';
+                                       $actual_cost_field = 'actual_cost';
+                                       break;
+                       }
+
+                       $amount = $amount/100;
+                       if(!$table)
+                       {
+                               throw new Exception('ERROR: the order id seems 
to not correspond with any order type');
+                       }
+
+                       $sql="UPDATE {$table} SET 
{$actual_cost_field}={$actual_cost_field} {$operator} {$amount} {$update_paid} 
WHERE id='{$order_id}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               public function check_voucher_id($voucher_id)
+               {
+                       $found = 0;
+                       $sql = "SELECT bilagsnr FROM fm_ecobilag WHERE 
bilagsnr='{$voucher_id}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       
+                       if($this->db->next_record())
+                       {
+                               $found++;
+                       }
+
+                       $sql = "SELECT bilagsnr FROM fm_ecobilagoverf WHERE 
bilagsnr='{$voucher_id}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       
+                       if($this->db->next_record())
+                       {
+                               $found++;
+                       }
+                       return $found;
+               }
+
+               public function check_invoice_id($vendor_id, $invoice_id)
+               {
+                       $found = 0;
+
+                       $values['fakturanr']            = $values['invoice_id'];
+                       $values['spvend_code']          = $values['vendor_id'];
+
+                       $sql = "SELECT bilagsnr FROM fm_ecobilag WHERE 
spvend_code= '{$vendor_id}' AND fakturanr='{$invoice_id}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       
+                       if($this->db->next_record())
+                       {
+                               $found++;
+                       }
+
+                       $sql = "SELECT bilagsnr FROM fm_ecobilagoverf WHERE 
spvend_code= '{$vendor_id}' AND fakturanr='{$invoice_id}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       
+                       if($this->db->next_record())
+                       {
+                               $found++;
+                       }
+                       return $found;
+               }
        }

Modified: branches/Version-1_0-branch/property/inc/class.socommon.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.socommon.inc.php     
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.socommon.inc.php     
2012-01-16 07:51:53 UTC (rev 8580)
@@ -306,9 +306,14 @@
                        return $entity;
                }
 
+
                function increment_id($name)
                {
-                       $now = time();
+                       if(!$name)
+                       {
+                               throw new 
Exception("property_socommon::increment_id() - Missing name");
+                       }
+
                        if($name == 'order') // FIXME: temporary hack
                        {
                                $name = 'workorder';
@@ -317,15 +322,24 @@
                        {
                                $name = 'workorder';
                        }
-                       $this->db->query("SELECT value, start_date FROM 
fm_idgenerator WHERE name='{$name}' AND start_date < {$now} ORDER BY start_date 
DESC" );
+
+                       $this->db->query("SELECT name FROM fm_idgenerator WHERE 
name='{$name}'");
                        $this->db->next_record();
+                       if(!$this->db->f('name'))
+                       {
+                               throw new 
Exception("property_socommon::increment_id() - not a valid name: '{$name}'");   
              
+                       }
+
+                       $now = time();
+                       $this->db->query("SELECT value, start_date FROM 
fm_idgenerator WHERE name='{$name}' AND start_date < {$now} ORDER BY start_date 
DESC");
+                       $this->db->next_record();
                        $next_id = $this->db->f('value') +1;
                        $start_date = (int)$this->db->f('start_date');
-
                        $this->db->query("UPDATE fm_idgenerator SET value = 
$next_id WHERE name = '{$name}' AND start_date = {$start_date}");
                        return $next_id;
                }
 
+
                function new_db($db ='' )
                {
                        if(is_object($db))
@@ -399,4 +413,5 @@
                        }
                        return $access_location;
                }
+
        }

Modified: branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2012-01-16 07:51:53 UTC (rev 8580)
@@ -967,18 +967,20 @@
                }
 
 
-               function tax_code_list($selected='')
+               function tax_code_list()
                {
-                       $this->db->query("SELECT * FROM fm_ecomva order by id 
asc ");
-                       $tax_code_list = array();
+                       $this->db->query("SELECT * FROM fm_ecomva ORDER BY id 
ASC ");
+                       $values = array();
                        while ($this->db->next_record())
                        {
-                               $tax_code_list[] = Array(
-                                       'id'        => $this->db->f('id'),
+                               $id = $this->db->f('id');
+                               $values[] = array
+                               (
+                                       'id'    => $id,
+                                       'name'  => $id,
                                );
                        }
-
-                       return $tax_code_list;
+                       return $values;
                }
 
 
@@ -1461,7 +1463,8 @@
                        }
                        
                        $filter = 'WHERE periode IN(' . implode(',', $data) . 
')';
-                       
+//                     $filter .= ' AND manual_record IS NULL';
+
                        $sql = "SELECT * FROM fm_ecobilagoverf {$filter} ORDER 
BY periode DESC, id ASC";
                        $this->db->query($sql,__LINE__,__FILE__);
                        

Modified: branches/Version-1_0-branch/property/inc/class.solocation.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.solocation.inc.php   
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.solocation.inc.php   
2012-01-16 07:51:53 UTC (rev 8580)
@@ -538,6 +538,18 @@
                                        $paranthesis .='(';
                                        $joinmethod .= " {$this->join} 
fm_responsibility_role ON ( fm_responsibility.id = 
fm_responsibility_role.responsibility_id))";
                                        $paranthesis .='(';
+
+                                       $cols.= ',fm_responsibility_role.id as 
role_id';
+                                       $cols_return[]  = 'role_id';
+                                       $uicols['input_type'][]         = 
'hidden';
+                                       $uicols['name'][]                       
= 'role_id';
+                                       $uicols['descr'][]                      
= 'dummy';
+                                       $uicols['statustext'][]         = 
'dummy';
+                                       $uicols['exchange'][]           = false;
+                                       $uicols['align'][]                      
= '';
+                                       $uicols['datatype'][]           = '';
+                                       $uicols['formatter'][]          = '';
+
                                }
 
                                $from = " FROM {$paranthesis} 
fm_location{$type_id} ";
@@ -730,8 +742,15 @@
                                $time = time() +1;
                                $filtermethod .= " {$where} active_from < 
{$time} AND (active_to > {$time} OR active_to = 0)"
                                        ." AND expired_on IS NULL AND 
fm_responsibility_role.id ={$role_id} AND contact_id = 
{$filter_role_on_contact}";
-                               $where= 'AND';                  
+                               $where= 'AND';
                        }
+                       else if ($filter_role_on_contact)
+                       {
+                               $time = time() +1;
+                               $filtermethod .= " {$where} active_from < 
{$time} AND (active_to > {$time} OR active_to = 0)"
+                                       ." AND expired_on IS NULL AND 
contact_id = {$filter_role_on_contact}";
+                               $where= 'AND';  
+                       }
 
                        $_querymethod = array();
                        $__querymethod = array();

Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2012-01-16 07:51:53 UTC (rev 8580)
@@ -629,6 +629,10 @@
                        //      $this->update_actual_cost_global();
                        //      $this->update_planned_cost_global();
 
+                       if(!$workorder_id)
+                       {
+                               return array();
+                       }
                        $sql = "SELECT fm_workorder.*, fm_chapter.descr as 
chapter ,fm_workorder.user_id as user_id FROM fm_workorder"
        //                      . " $this->join fm_project on 
fm_workorder.project_id=fm_project.id"
                                . " $this->left_join fm_chapter on "

Modified: branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php    
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php    
2012-01-16 07:51:53 UTC (rev 8580)
@@ -3612,7 +3612,7 @@
                        switch($order_type)
                        {
                                case 'workorder':
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uiworkorder.edit', 'id'=> $order_id));
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uiworkorder.edit', 'id'=> $order_id, 'tab' => 'budget'));
                                        break;
                                case 's_agreement':
                                        
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uis_agreement.view', 'id'=> $order_id));

Modified: branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2012-01-16 07:43:33 UTC (rev 8579)
+++ branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2012-01-16 07:51:53 UTC (rev 8580)
@@ -57,7 +57,8 @@
                                'edit'                  => true,
                                'delete'                => true,
                                'view_file'             => true,
-                               'columns'               => true
+                               'columns'               => true,
+                               'add_invoice'   => true
                        );
 
                function property_uiworkorder()
@@ -826,6 +827,7 @@
                function edit($mode = 'edit')
                {
                        $id = phpgw::get_var('id'); // in case of bigint
+                       $selected_tab = phpgw::get_var('tab', 'string', 
'REQUEST', 'general');
 
                        if($mode == 'edit' && (!$this->acl_add && 
!$this->acl_edit))
                        {
@@ -1615,7 +1617,7 @@
                                        'datatable'                             
                                => $datavalues,
                                        'myColumnDefs'                          
                        => $myColumnDefs,
                                        'myButtons'                             
                                => $myButtons,
-                                       'tabs'                                  
                                => 
self::_generate_tabs(array(),array('documents' => $id?false:true, 'history' => 
$id?false:true)),
+                                       'tabs'                                  
                                => 
self::_generate_tabs(array(),array('documents' => $id?false:true, 'history' => 
$id?false:true),$selected_tab),
                                        'msgbox_data'                           
                        => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                        'value_origin'                          
                        => isset($values['origin']) ? $values['origin'] : '',
                                        'value_origin_type'                     
                        => isset($origin)?$origin:'',
@@ -1797,6 +1799,11 @@
                        phpgwapi_yui::load_widget('paginator');
                        phpgwapi_yui::load_widget('animation');
 
+//                     phpgwapi_yui::load_widget('container');
+//                     phpgwapi_yui::load_widget('button');
+
+
+
                        $GLOBALS['phpgw']->css->validate_file('datatable');
                        $GLOBALS['phpgw']->css->validate_file('property');
                        
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
@@ -1906,8 +1913,278 @@
                        $this->edit('view');
                }
 
-               protected function _generate_tabs($tabs_ = array(), $suppress = 
array())
+               function add_invoice()
                {
+                       if(!$this->acl_add)
+                       {
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
true;
+                               echo lang('No Access');
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
+
+                       $order_id = phpgw::get_var('order_id');
+
+                       $receipt = array();
+
+                       $bolocation     = CreateObject('property.bolocation');
+                       $boinvoice      = CreateObject('property.boinvoice');
+
+                       $referer = parse_url(phpgw::get_var('HTTP_REFERER', 
'string' , 'SERVER'));
+                       parse_str($referer['query']); // produce $menuaction
+                       if(phpgw::get_var('cancel', 'bool'))
+                       {
+                               $redirect = true;
+                       }
+//_debug_array( $menuaction);die();
+                       if($add_invoice = phpgw::get_var('add', 'bool'))
+                       {
+                               $values = phpgw::get_var('values');
+
+                               if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']))
+                               {
+                                       $values['amount']               = 
str_ireplace($GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],'',$values['amount']);
+                               }
+                               $values['amount']               = 
str_replace(array(' ',','),array('','.'),$values['amount']);
+
+                               $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
+                               $values = 
$this->bocommon->collect_locationdata($values,$insert_record);
+                               $values['b_account_id'] = 
phpgw::get_var('b_account_id');
+                               $values['project_group'] = 
phpgw::get_var('project_group');
+                               $values['dimb'] = phpgw::get_var('ecodimb');
+                               $values['vendor_id'] = 
phpgw::get_var('vendor_id');
+                       }
+
+
+                       if($add_invoice && is_array($values))
+                       {
+                               if($values['order_id'] && 
!ctype_digit($values['order_id']))
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('Please enter an integer for order!'));
+                                       unset($values['order_id']);
+                               }
+
+                               
if(!execMethod('property.soXport.check_order',$values['order_id']))
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('Not a valid order!'));                   
                
+                               }
+
+                               if (!$values['amount'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - enter an amount!'));
+                               }
+                               if (!$values['artid'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select type invoice!'));
+                               }
+
+                               if (!$values['vendor_id'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select Vendor!'));
+                               }
+                               else if 
(!$boinvoice->check_vendor($values['vendor_id']))
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('That Vendor ID is not valid !'). ' : ' . 
$values['vendor_id']);
+                               }
+
+                               if (!$values['typeid'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select type order!'));
+                               }
+
+                               if (!$values['budget_responsible'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select budget responsible!'));
+                               }
+
+                               if (!$values['invoice_id'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - enter a invoice num!'));
+                               }
+
+                               if (!$values['payment_date'] && 
!$values['num_days'])
+                               {
+                                       $receipt['error'][] = 
array('msg'=>lang('Please - select either payment date or number of days from 
invoice date !'));
+                               }
+
+                               //_debug_array($values);
+                               if (!is_array($receipt['error']))
+                               {
+                                       $values['regtid']               = 
date($this->bocommon->datetimeformat);
+
+                                       $_receipt = array();//local errors

@@ Diff output truncated at 153600 characters. @@



reply via email to

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