fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9503] Merge 9464:9502 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [9503] Merge 9464:9502 from trunk
Date: Tue, 05 Jun 2012 07:10:44 +0000

Revision: 9503
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9503
Author:   sigurdne
Date:     2012-06-05 07:10:42 +0000 (Tue, 05 Jun 2012)
Log Message:
-----------
Merge 9464:9502 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicommon.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
    branches/Version-1_0-branch/controller/js/controller/ajax.js
    branches/Version-1_0-branch/controller/js/controller/jquery.js
    branches/Version-1_0-branch/controller/setup/phpgw_no.lang
    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/add_component_to_control.xsl
    
branches/Version-1_0-branch/controller/templates/base/add_component_to_control_group.xsl
    
branches/Version-1_0-branch/controller/templates/base/calendar/check_list_status_checker.xsl
    
branches/Version-1_0-branch/controller/templates/base/calendar/select_my_locations.xsl
    
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_for_locations.xsl
    
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_for_locations.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/print_check_list.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_cases_for_check_list.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_check_lists.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_control_items.xsl
    
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
    branches/Version-1_0-branch/controller/templates/base/component.xsl
    branches/Version-1_0-branch/controller/templates/base/control/control.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_group/control_group.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_group/control_group_items.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_group/control_group_tabs.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_item/control_item.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_item/view_control_item_list.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
    branches/Version-1_0-branch/controller/templates/base/css/base.css
    
branches/Version-1_0-branch/controller/templates/base/procedure/procedure_documents.xsl
    
branches/Version-1_0-branch/controller/templates/base/procedure/procedure_item.xsl
    
branches/Version-1_0-branch/controller/templates/base/procedure/view_procedures_for_control.xsl
    
branches/Version-1_0-branch/controller/templates/base/view_component_for_control.xsl
    
branches/Version-1_0-branch/controller/templates/base/view_component_for_control_group.xsl
    branches/Version-1_0-branch/frontend/inc/class.uifrontend.inc.php
    branches/Version-1_0-branch/frontend/templates/base/frontend.xsl
    branches/Version-1_0-branch/property/inc/class.bocommon.inc.php
    branches/Version-1_0-branch/property/inc/class.boentity.inc.php
    branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.bolocation.inc.php
    branches/Version-1_0-branch/property/inc/class.botts.inc.php
    branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php
    branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.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.uiinvoice2.inc.php
    
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_basware_X205.php
    branches/Version-1_0-branch/property/templates/base/invoice2.xsl

Added Paths:
-----------
    
branches/Version-1_0-branch/controller/js/controller/ajax_control_to_component.js
    
branches/Version-1_0-branch/controller/js/controller/jquery-ui-1.8.20.custom.min.js
    
branches/Version-1_0-branch/controller/js/yahoo/register_control_to_component.js
    
branches/Version-1_0-branch/controller/js/yahoo/register_control_to_location.js
    
branches/Version-1_0-branch/controller/templates/base/calendar/select_buildings_on_property.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_component.xsl
    
branches/Version-1_0-branch/controller/templates/base/css/jquery-ui-1.8.20.custom.css

Removed Paths:
-------------
    
branches/Version-1_0-branch/controller/js/controller/yui_drag_drop_garbish.js

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,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463
   + 
/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,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502

Modified: branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php  
2012-06-05 06:37:27 UTC (rev 9502)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol.inc.php  
2012-06-05 07:10:42 UTC (rev 9503)
@@ -167,6 +167,7 @@
 
                function get_controls_by_control_area($control_area_id)
                {
+                       $control_area_id = (int) $control_area_id;
                        $controls_array = array();
 
                        $sql = "SELECT * FROM controller_control WHERE 
control_area_id=$control_area_id";
@@ -235,15 +236,16 @@
 
                function get_control_location($control_id, $location_code)
                {
+                       $control_id = (int)$control_id;
                        $sql =  "SELECT * FROM controller_control_location_list 
WHERE control_id = $control_id AND location_code = '$location_code'";
                        
                        $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
                        
                        if($this->db->next_record()){
-                               $control_location = new 
controller_control_location($this->unmarshal($this->db->f('id', true), 'int'));
+                               $control_location = new 
controller_control_location($this->unmarshal($this->db->f('id'), 'int'));
        
                                
$control_location->set_location_code($this->unmarshal($this->db->f('location_code',
 true), 'string'));
-                               
$control_location->set_control_id($this->unmarshal($this->db->f('control_id', 
true), 'int'));
+                               
$control_location->set_control_id($this->unmarshal($this->db->f('control_id'), 
'int'));
                                                        
                                return $control_location;
                        }
@@ -253,11 +255,48 @@
                        }
                }
                
-               function register_control_to_location($control_id, 
$location_code)
+               function register_control_to_location($control_id, $data)
                {
-                       $sql =  "INSERT INTO controller_control_location_list 
(control_id, location_code) values($control_id, $location_code)";
+
+                       $control_id = (int) $control_id;
+                       $delete_location = array();
+                       $add_location = array();
+                       foreach($data['control_location_orig'] as 
$location_code)
+                       {
+                               if(!in_array($location_code, 
$data['control_location']))
+                               {
+                                       $delete_location[] = $location_code;
+                               }
+                       }
+
+                       foreach($data['control_location'] as $location_code)
+                       {
+                               if(!in_array($location_code, 
$data['control_location_orig']))
+                               {
+                                       $add_location[] = $location_code;
+                               }
+                       }
+
+                       $this->db->transaction_begin();
+                       foreach ($delete_location as $location_code)
+                       {
+                               $sql =  "DELETE FROM 
controller_control_location_list  WHERE control_id = {$control_id} AND 
location_code = '{$location_code}'";
+                               $this->db->query($sql);
+                       }
+
+                       foreach ($add_location as $location_code)
+                       {
+                               $sql =  "SELECT * FROM 
controller_control_location_list WHERE control_id = {$control_id} AND 
location_code = '$location_code'";
+                               $this->db->query($sql, __LINE__, __FILE__);
                        
-                       return $this->db->query($sql);
+                               if(!$this->db->next_record())
+                               {
+                                       $sql =  "INSERT INTO 
controller_control_location_list (control_id, location_code) VALUES ( 
{$control_id}, '{$location_code}')";
+                                       $this->db->query($sql);
+                               }
+                       }
+
+                       return $this->db->transaction_commit();
                }
 
                function add_component_to_control($control_id, $component_id)

Modified: branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2012-06-05 06:37:27 UTC (rev 9502)
+++ branches/Version-1_0-branch/controller/inc/class.uicalendar.inc.php 
2012-06-05 07:10:42 UTC (rev 9503)
@@ -106,6 +106,29 @@
                                $location_code = 
$my_locations[0]["location_code"];
                        }
                        
+                       $level = count(explode('-', $location_code));
+                       
+                       // Property level
+                       if($level == 1){
+                               $property_location_code = $location_code;
+                       }
+                       // Building level
+                       else if($level > 1){
+                               $split_loc_code_array = explode('-', 
$location_code);
+                               $property_location_code = 
$split_loc_code_array[0];
+                       }
+                       
+                       if($manage){
+                               $criteria = array();
+                               $criteria['location_code'] = 
$property_location_code;
+                               $criteria['field_name'] = 'loc2_name';
+                               $criteria['child_level'] = '2';
+                               
+       $buildings_on_property = execMethod('property.solocation.get_children', 
$criteria);
+      }else{
+        $buildings_on_property = 
execMethod('property.solocation.get_children', $property_location_code);
+      }
+                       
                        // Fetches controls for location within specified time 
period
                        $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts);
 
@@ -129,21 +152,26 @@
                                                
                        $data = array
                        (               
-                               'my_locations'                    => 
$my_locations,
-                               'property_array'                  => 
$property_array,
-                               'current_location'                => 
$location_array,
-                               'heading_array'                   => 
month_calendar::get_heading_array($year, $month),
+                               'buildings_on_property'         => 
$buildings_on_property,
+                               'my_locations'                          => 
$my_locations,
+                               'property_array'                        => 
$property_array,
+                               'current_location'                      => 
$location_array,
+                               'heading_array'                         => 
month_calendar::get_heading_array($year, $month),
                                'controls_calendar_array' => 
$controls_calendar_array,
-                               'date_format'                     => 
$date_format,
-                               'current_year'                    => $year,
-                               'current_month_nr'                => $month,
+                               'date_format'                                   
=> $date_format,
+                               'current_year'                                  
=> $year,
+                               'current_month_nr'                      => 
$month,
+                               'location_level'                                
=> $level,
                        );
                        
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
+                       self::add_javascript('controller', 'controller', 
'jquery-ui-1.8.20.custom.min.js');
+                       
self::add_stylesheet('controller/templates/base/css/jquery-ui-1.8.20.custom.css');
                        
                        
self::render_template_xsl(array('calendar/view_calendar_month', 
'calendar/check_list_status_checker', 
-                                                                               
        'calendar/icon_color_map', 'calendar/select_my_locations'), $data);
+                                                                               
                                                                        
'calendar/icon_color_map', 'calendar/select_my_locations', 
+                                                                               
                                                                        
'calendar/select_buildings_on_property'), $data);
                }
                
                public function view_calendar_for_year()
@@ -163,30 +191,47 @@
                        $from_date_ts = strtotime("01/01/$year");
                        $to_year = $year + 1;
                        $to_date_ts = strtotime("01/01/$to_year");
-                       
-                       $manage = false;
+                               
+      $criteria = array
+                       (
+                               'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], // 
+                               'type_id' => 1, // Nivå i bygningsregisteret 
1:eiendom
+                               'role_id' => 0, // For å begrense til en 
bestemt rolle - ellers listes alle roller for brukeren
+                               'allrows' => false
+                       );
                
-                       if($manage)
-            {
-               $locations = execMethod('property.solocation.get_children', 
$location_code);
-           
-            }else{
-               $criteria = array
-                               (
-                                       'user_id' => 
$GLOBALS['phpgw_info']['user']['account_id'], // 
-                                       'type_id' => 1, // Nivå i 
bygningsregisteret 1:eiendom
-                                       'role_id' => 0, // For å begrense til 
en bestemt rolle - ellers listes alle roller for brukeren
-                                       'allrows' => false
-                               );
-               
-                               $location_finder = new location_finder();
-                               $my_locations = 
$location_finder->get_responsibilities( $criteria );
-            }
-                               
+                       $location_finder = new location_finder();
+                       $my_locations = $location_finder->get_responsibilities( 
$criteria );
+            
                        if(empty($location_code)){
                                $location_code = 
$my_locations[0]["location_code"];
                        }
                        
+                       $manage = true;
+       
+                       $level = count(explode('-', $location_code));
+                       
+                       // Property level
+                       if($level == 1){
+                               $property_location_code = $location_code;
+                       }
+                       // Building level
+                       else if($level > 1){
+                               $split_loc_code_array = explode('-', 
$location_code);
+                               $property_location_code = 
$split_loc_code_array[0];
+                       }
+                       
+                       if($manage){
+                               $criteria = array();
+                               $criteria['location_code'] = 
$property_location_code;
+                               $criteria['field_name'] = 'loc2_name';
+                               $criteria['child_level'] = '2';
+                               
+       $buildings_on_property = execMethod('property.solocation.get_children', 
$criteria);
+      }else{
+        $buildings_on_property = 
execMethod('property.solocation.get_children', $property_location_code);
+      }
+                       
                        // Fetches all controls for the location within time 
period
                        $controls_for_location_array = 
$this->so_control->get_controls_by_location($location_code, $from_date_ts, 
$to_date_ts,  $repeat_type = null);
                        
@@ -232,22 +277,27 @@
                        }
                        
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
-                       
+
                        $data = array
                        (
-                               'my_locations'                    => 
$my_locations,
-                               'current_location'        => $location_array,
-                               'heading_array'                   => 
year_calendar::get_heading_array(),
+                               'buildings_on_property'         => 
$buildings_on_property,
+                               'my_locations'                                  
        => $my_locations,
+                               'current_location'              => 
$location_array,
+                               'heading_array'                         => 
year_calendar::get_heading_array(),
                                'controls_calendar_array' => 
$controls_calendar_array,
-                               'date_format'                     => 
$date_format,
-                               'current_year'                    => $year,
+                               'date_format'                                   
=> $date_format,
+                               'current_year'                                  
=> $year,
+                               'location_level'                                
=> $level,
                        );
                        
                        
self::render_template_xsl(array('calendar/view_calendar_year', 
'calendar/check_list_status_checker', 
-                                                                               
        'calendar/icon_color_map', 'calendar/select_my_locations'), $data);
+                                                                               
                                                                        
'calendar/icon_color_map', 'calendar/select_my_locations', 
+                                                                               
                                                                        
'calendar/select_buildings_on_property'), $data);
                        
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'ajax.js');
+                       self::add_javascript('controller', 'controller', 
'jquery-ui-1.8.20.custom.min.js');
+                       
self::add_stylesheet('controller/templates/base/css/jquery-ui-1.8.20.custom.css');
                }
 
                public function view_calendar_year_for_locations()
@@ -311,12 +361,12 @@
                        
                        $data = array
                        (
-                               'my_locations'                                  
=> $my_locations,
-                               'control'                                       
        => $control->toArray(),
-                               'heading_array'                                 
=> year_calendar::get_heading_array(),
+                               'my_locations'                                  
                => $my_locations,
+                               'control'                                       
                                        => $control->toArray(),
+                               'heading_array'                                 
                => year_calendar::get_heading_array(),
                                'locations_with_calendar_array' => 
$locations_with_calendar_array,
-                               'date_format'                                   
=> $date_format,
-                               'current_year'                                  
=> $year,
+                               'date_format'                                   
                        => $date_format,
+                               'current_year'                                  
        => $year,
                        );
                        
                        self::render_template_xsl( 
array('calendar/view_calendar_year_for_locations', 
'calendar/check_list_status_checker', 

Modified: branches/Version-1_0-branch/controller/inc/class.uicommon.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicommon.inc.php   
2012-06-05 06:37:27 UTC (rev 9502)
+++ branches/Version-1_0-branch/controller/inc/class.uicommon.inc.php   
2012-06-05 07:10:42 UTC (rev 9503)
@@ -754,7 +754,7 @@
                {
                        return self::get_messages($messages, 'info');
                }
-
+ 
                /**
                 * Download xls, csv or similar file representation of a data 
table
                 */

Modified: 
branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php 
2012-06-05 06:37:27 UTC (rev 9502)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php 
2012-06-05 07:10:42 UTC (rev 9503)
@@ -29,6 +29,12 @@
        */
        
        phpgw::import_class('phpgwapi.yui');
+
+       /**
+       * Import the jQuery class
+       */
+       phpgw::import_class('phpgwapi.jquery');
+
        phpgw::import_class('controller.uicommon');
        phpgw::import_class('controller.socontrol_area');
        
@@ -57,13 +63,17 @@
                private $so_procedure;
        
                var $public_functions = array(
-                                                                               
'index' => true,
+                                                                               
'index'                                                         => true,
                                                                                
'view_locations_for_control'            => true,
                                                                                
'register_control_to_location'          => true,
                                                                                
'register_control_to_location_2'        => true,
+                                                                               
'register_control_to_component'         => true,
                                                                                
'get_locations_for_control'             => true,
                                                                                
'get_location_category'                         => true,
-                                                                               
'get_district_part_of_town'                     => true
+                                                                               
'get_district_part_of_town'                     => true,
+                                                                               
'entity'                                                        => true,
+                                                                               
'index2'                                                        => true,
+                                                                               
'get_category_by_entity'                        => true
                                                                        );
 
                function __construct()
@@ -109,10 +119,10 @@
                        
                        $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
                                                        
-                       $control_areas_array2 = array();
+                       $control_areas_array = array();
                        foreach($control_areas['cat_list'] as $cat_list)
                        {
-                               $control_areas_array2[] = array
+                               $control_areas_array[] = array
                                (
                                        'id'    => $cat_list['cat_id'],
                                        'name'  => $cat_list['name'],
@@ -130,7 +140,7 @@
                        $data = array(
                                'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($tabs, 0),
                                'view'                                  => 
"view_locations_for_control",
-                               'control_areas_array2'  => 
$control_areas_array2,
+                               'control_areas_array'   => $control_areas_array,
                                'locations_table' => array(
                                        'source' => 
self::link(array('menuaction' => 
'controller.uicontrol_location.get_locations_for_control', 'control_id' => 
$control_id ,'phpgw_return_as' => 'json')),
                                        'field' => array(
@@ -183,40 +193,218 @@
                
                function register_control_to_location()
                {
+                       $control_id = phpgw::get_var('control_id');
                        if(phpgw::get_var('save_location'))
                        {
+                               $values = phpgw::get_var('values');
                                //add component to control using component item 
ID
-                               $items_checked = array();
-                               $items = phpgw::get_var('values_assign');
-                               $item_arr = explode('|',$items);
-                               foreach($item_arr as $item)
+                               $values['control_location'] = 
isset($values['control_location']) && $values['control_location'] ? 
array_unique($values['control_location']) : array();
+                               $values['control_location_orig'] = 
isset($values['control_location_orig']) && $values['control_location_orig'] ? 
array_unique($values['control_location_orig']) : array();
+
+                               $ok = 
$this->so_control->register_control_to_location($control_id, $values);
+
+/*                             if($ok)
                                {
-                                       $items_checked[] = explode(';',$item);
+                                       return json_encode( array( "status" => 
"saved" ) );
                                }
-                               //var_dump($items_checked);
+                               else
+                               {
+                                       return json_encode( array( "status" => 
"not_saved" ) );
+                               }
+*/
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 
'controller.uicontrol_location.register_control_to_location', 'control_id' => 
$control_id));
 
-                               $control_id = phpgw::get_var('control_id');
-                               //$location_code = 
phpgw::get_var('location_code');
+                       }
+                       else
+                       {
+                               if(phpgw::get_var('phpgw_return_as') == 'json') 
{
+                                       return $this->query();
+                               }
+                               $building_types  = 
execMethod('property.soadmin_location.read',array());
+                               //$type_id=phpgw::get_var('type_id');
+                               //if(!isset($type_id))
+                               $type_id = 1;
                                
-                               $control_location  = null;
-                               $control_location_id = 0;
+                               $category_types = 
$this->bocommon->select_category_list(array(
+                                                                               
                                                                        
'format'=>'filter',
+                                                                               
                                                                        
'selected' => $this->cat_id,
+                                                                               
                                                                        'type' 
=>'location',
+                                                                               
                                                                        
'type_id' =>$type_id,
+                                                                               
                                                                        
'order'=>'descr'
+                                                                               
                                                                ));
+                               $default_value = array 
('id'=>'','name'=>lang('no category selected'));
+                               array_unshift($category_types,$default_value);
+                                                                               
                                                                
+                               $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no district'));
+                               array_unshift($district_list,$default_value);
                                
-                               foreach($items_checked as $location_code)
+                               $part_of_town_list =  
$this->bocommon->select_part_of_town('filter',$this->part_of_town_id,$this->district_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no part of town'));
+                               
array_unshift($part_of_town_list,$default_value);
+                               
+                               $_role_criteria = array
+                                               (
+                                                       'type'          => 
'responsibility_role',
+                                                       'filter'        => 
array('location_level' => (int)$type_id),
+                                                       'order'         => 
'name'
+                                               );
+       
+                               $responsibility_roles_list = 
execMethod('property.sogeneric.get_list',$_role_criteria);
+                               $default_value = array 
('id'=>'','name'=>lang('no role'));
+                               array_unshift 
($responsibility_roles,$default_value);
+                               
+                               $cats   = CreateObject('phpgwapi.categories', 
-1, 'controller', '.control');
+                               $cats->supress_info     = true;
+                               
+                               $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
+                                                               
+                               $control_areas_array = array();
+                               foreach($control_areas['cat_list'] as $cat_list)
                                {
-                                       $control_location = 
$this->so_control->get_control_location($control_id, $location_code[0]);
-                                       
-                                       if($control_location == null )
-                                       {                                       
-                                               $control_location_id = 
$this->so_control->register_control_to_location($control_id, $location_code[0]);
-                                       }
+                                       $control_areas_array[] = array
+                                       (
+                                               'id'    => $cat_list['cat_id'],
+                                               'name'  => $cat_list['name'],
+                                       );              
                                }
+
+                               $control_info = 
execMethod('controller.socontrol.get_single', $control_id);
+                               if($control_info)
+                               {
+                                       $control_array = array
+                                       (
+                                               'id' => $control_id,
+                                               'title' => 
$control_info->get_title()
+                                       );
+                               }
+
+                               $tabs = array
+                               ( 
+                                       array
+                                       (
+                                               'label' => 
lang('View_locations_for_control'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
+                                       ),
+                                       array
+                                       (
+                                               'label' => 
lang('Add_locations_for_control')
+                                       ),
+                                       array
+                                       (
+                                               'label' => lang('add components 
for control'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_component'))
+                                       )
+
+                               );
+                                               
+                               $data = array(
+                                       'tabs'                                  
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                                       'view'                                  
        => "register_control_to_location",
+                                       'control_id'                            
=> $control_id,
+                                       'control_filters'                       
=> array(
+                                               'control_areas_array'   => 
$control_areas_array,
+                                               'control_array'                 
        => $control_array
+                                       ),
+                                       'filter_form'                           
=> array(
+                                               'building_types'                
        => $building_types,
+                                               'category_types'                
        => $category_types,
+                                               'district_list'                 
        => $district_list,
+                                               'part_of_town_list'             
=> $part_of_town_list
+                                       ),
+                                       'datatable' => array(
+                                               'source' => 
self::link(array('menuaction' => 'controller.uicontrol_location.index', 
'phpgw_return_as' => 'json', 'view_type' => 
'register_control','control_id_init'    => $control_id)),
+                                               'field' => array(
+                                                       array(
+                                                               'key' => 
'location_registered',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 
'location_code',
+                                                               'label' => 
lang('Property'),
+                                                               'sortable'      
=> true,
+                                                               'formatter' => 
'YAHOO.portico.formatLink'
+                                                       ),
+                                                       array(
+                                                               'key'   =>      
'loc1_name',
+                                                               'label' =>      
lang('Property name'),
+                                                               'sortable'      
=>      false
+                                                       ),
+                                                       array(
+                                                               'key' => 
'adresse1',
+                                                               'label' => 
lang('Address'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
+                                                               'key' => 
'postnummer',
+                                                               'label' => 
lang('Zip code'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
+                                                               'key' => 
'control_name',
+                                                               'label' => 
lang('control'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
+                                                                       'key' 
=> 'checked',
+                                                                       'label' 
=> 'Velg',
+                                                                       
'sortable' => false,
+                                                                       
'formatter' => 'formatterCheckLocation',
+                                                                       
'className' => 'mychecks'
+                                                       ),
+                                                       array(
+                                                               'key' => 
'actions',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 
'labels',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
+                                                               'key' => 'ajax',
+                                                               'hidden' => true
+                                                       ),array(
+                                                               'key' => 
'parameters',
+                                                               'hidden' => true
+                                                       )                       
                        
+                                               )
+                                       )
+                               );
                                
-/*                             if($control_location_id > 0)
+                               phpgwapi_yui::load_widget('paginator');
+                               
+                               self::add_javascript('controller', 
'controller', 'jquery.js');
+                               self::add_javascript('controller', 
'controller', 'ajax.js');
+                               self::add_javascript('controller', 'yahoo', 
'register_control_to_location.js');
+       
+                               
self::render_template_xsl(array('control_location/control_location_tabs', 
'control_location/register_control_to_location', 'common'), $data);
+                       }               
+               }
+               
+
+
+               function register_control_to_component()
+               {
+                       $control_id = phpgw::get_var('control_id');
+                       if(phpgw::get_var('save_location'))
+                       {
+                               $values = phpgw::get_var('values');
+                               //add component to control using component item 
ID
+                               $values['control_location'] = 
isset($values['control_location']) && $values['control_location'] ? 
array_unique($values['control_location']) : array();
+                               $values['control_location_orig'] = 
isset($values['control_location_orig']) && $values['control_location_orig'] ? 
array_unique($values['control_location_orig']) : array();
+
+                               $ok = 
$this->so_control->register_control_to_location($control_id, $values);
+
+/*                             if($ok)
+                               {
                                        return json_encode( array( "status" => 
"saved" ) );
+                               }
                                else
+                               {
                                        return json_encode( array( "status" => 
"not_saved" ) );
+                               }
 */
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_location.index'));
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 
'controller.uicontrol_location.register_control_to_location', 'control_id' => 
$control_id));
 
                        }
                        else
@@ -258,37 +446,56 @@
                                $default_value = array 
('id'=>'','name'=>lang('no role'));
                                array_unshift 
($responsibility_roles,$default_value);
                                
-                               // Sigurd: START as categories
                                $cats   = CreateObject('phpgwapi.categories', 
-1, 'controller', '.control');
                                $cats->supress_info     = true;
                                
                                $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
                                                                
-                               $control_areas_array2 = array();
+                               $control_areas_array = array();
                                foreach($control_areas['cat_list'] as $cat_list)
                                {
-                                       $control_areas_array2[] = array
+                                       $control_areas_array[] = array
                                        (
                                                'id'    => $cat_list['cat_id'],
                                                'name'  => $cat_list['name'],
                                        );              
                                }
-                               // END as categories
-                               
-                               
-                               $tabs = array( array(
-                                                       'label' => 
lang('View_locations_for_control'),
-                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
-                               
-                                               ), array(
-                                                       'label' => 
lang('Add_locations_for_control')
-                                               ));
+
+                               $control_info = 
execMethod('controller.socontrol.get_single', $control_id);
+                               if($control_info)
+                               {
+                                       $control_array = array
+                                       (
+                                               'id' => $control_id,
+                                               'title' => 
$control_info->get_title()
+                                       );
+                               }
+
+                               $tabs = array
+                               ( 
+                                       array
+                                       (
+                                               'label' => 
lang('View_locations_for_control'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.index'))
+                                       ),
+                                       array
+                                       (
+                                               'label' => 
lang('Add_locations_for_control'),
+                                               'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol_location.register_control_to_location'))
+                                       ),
+                                       array
+                                       (
+                                               'label' => lang('add components 
for control'),
+                                       )
+
+                               );
                                                
                                $data = array(
-                                       'tabs'                                  
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                                       'tabs'                                  
        => $GLOBALS['phpgw']->common->create_tabs($tabs, 2),
                                        'view'                                  
        => "register_control_to_location",
+                                       'control_id'                            
=> $control_id,
                                        'control_filters'                       
=> array(
-                                               'control_areas_array2'  => 
$control_areas_array2,
+                                               'control_areas_array'   => 
$control_areas_array,
                                                'control_array'                 
        => $control_array
                                        ),
                                        'filter_form'                           
=> array(
@@ -298,9 +505,13 @@
                                                'part_of_town_list'             
=> $part_of_town_list
                                        ),
                                        'datatable' => array(
-                                               'source' => 
self::link(array('menuaction' => 'controller.uicontrol_location.index', 
'phpgw_return_as' => 'json', 'view_type' => 'register_control')),
+                                               'source' => 
self::link(array('menuaction' => 'controller.uicontrol_location.index', 
'phpgw_return_as' => 'json', 'view_type' => 
'register_control','control_id_init'    => $control_id)),
                                                'field' => array(
                                                        array(
+                                                               'key' => 
'location_registered',
+                                                               'hidden' => true
+                                                       ),
+                                                       array(
                                                                'key' => 
'location_code',
                                                                'label' => 
lang('Property'),
                                                                'sortable'      
=> true,
@@ -322,10 +533,15 @@
                                                                'sortable'      
=> false
                                                        ),
                                                        array(
+                                                               'key' => 
'control_name',
+                                                               'label' => 
lang('control'),
+                                                               'sortable'      
=> false
+                                                       ),
+                                                       array(
                                                                        'key' 
=> 'checked',
                                                                        'label' 
=> 'Velg',
                                                                        
'sortable' => false,
-                                                                       
'formatter' => 'YAHOO.widget.DataTable.formatCheckbox',
+                                                                       
'formatter' => 'formatterCheckLocation',
                                                                        
'className' => 'mychecks'
                                                        ),
                                                        array(
@@ -351,11 +567,394 @@
                                
                                self::add_javascript('controller', 
'controller', 'jquery.js');
                                self::add_javascript('controller', 
'controller', 'ajax.js');
+                               self::add_javascript('controller', 'yahoo', 
'register_control_to_location.js');
        
                                
self::render_template_xsl(array('control_location/control_location_tabs', 
'control_location/register_control_to_location', 'common'), $data);
                        }               
                }
-               
+
+
+
+               function entity()
+               {
+                       $bocommon                                       = 
CreateObject('property.bocommon');
+                       $boentity                                       = 
CreateObject('property.boentity');
+                       $boadmin_entity                         = 
CreateObject('property.boadmin_entity');
+                       $this->start                            = 
$boentity->start;
+                       $this->query                            = 
$boentity->query;
+                       $this->sort                                     = 
$boentity->sort;
+                       $this->order                            = 
$boentity->order;
+                       $this->filter                           = 
$boentity->filter;
+                       $this->cat_id                           = 
$boentity->cat_id;
+                       $this->part_of_town_id          = 
$boentity->part_of_town_id;
+                       $this->district_id                      = 
$boentity->district_id;
+                       $this->entity_id                        = 
$boentity->entity_id;
+                       $this->location_code            = 
$boentity->location_code;
+                       $this->criteria_id                      = 
$boentity->criteria_id;
+
+                       $second_display = phpgw::get_var('second_display', 
'bool');
+                       $default_district       = 
(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['default_district'])?$GLOBALS['phpgw_info']['user']['preferences']['property']['default_district']:'');
+
+                       if ($default_district && !$second_display && 
!$this->district_id)
+                       {
+                               $this->bo->district_id  = $default_district;
+                               $this->district_id              = 
$default_district;
+                       }
+
+                       if( phpgw::get_var('phpgw_return_as') != 'json' )
+                       {
+
+                               $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
+                                       (
+                                               'menuaction'            => 
'property.uilookup.entity',
+                                               'entity_id'                     
=> $this->entity_id,
+                                               'cat_id'                        
=> $this->cat_id,
+                                               'district_id'           => 
$this->district_id,
+                                               'query'                         
=> $this->query,
+                                               'filter'                        
=> $this->filter,
+                                               'location_code'         => 
$this->location_code,
+                                               'criteria_id'           => 
$this->criteria_id
+                                       ));
+
+                               $datatable['config']['allow_allrows'] = true;
+
+                               $datatable['config']['base_java_url'] = 
"menuaction:'property.uilookup.entity',"
+                                       ."second_display:1,"
+                                       ."entity_id:'{$this->entity_id}',"
+                                       ."cat_id:'{$this->cat_id}',"
+                                       ."district_id:'{$this->district_id}',"
+                                       ."query:'{$this->query}',"
+                                       ."filter:'{$this->filter}',"
+                                       ."criteria_id:'{$this->criteria_id}',"
+                                       
."location_code:'{$this->location_code}'";
+
+                               $values_combo_box[0] = 
$boentity->select_category_list('filter',$this->cat_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no category'));
+                               array_unshift 
($values_combo_box[0],$default_value);
+
+                               $values_combo_box[1]  = 
$bocommon->select_district_list('filter',$this->district_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no district'));
+                               array_unshift 
($values_combo_box[1],$default_value);
+
+                               $values_combo_box[2]  = 
$boentity->get_criteria_list($this->criteria_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no criteria'));
+                               array_unshift 
($values_combo_box[2],$default_value);
+
+                               $datatable['actions']['form'] = array
+                                       (
+                                               array
+                                               (
+                                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
+                                                       array
+                                                       (
+                                                               'menuaction'    
        => 'property.uilookup.entity',
+                                                               
'second_display'        => $second_display,
+                                                               'entity_id'     
                => $this->entity_id,
+                                                               'cat_id'        
                => $this->cat_id,
+                                                               'district_id'   
        => $this->district_id,
+                                                               'query'         
                => $this->query,
+                                                               'filter'        
                => $this->filter
+                                                       )
+                                               ),
+                                               'fields'        => array
+                                               (
+                                                       'field' => array
+                                                       (
+                                                               array
+                                                               ( //boton       
CATEGORY
+                                                                       'id' => 
'btn_cat_id',
+                                                                       'name' 
=> 'cat_id',
+                                                                       'value' 
=> lang('Category'),
+                                                                       'type' 
=> 'button',
+                                                                       'style' 
=> 'filter',
+                                                                       
'tab_index' => 1
+                                                               ),
+                                                               array
+                                                               ( //boton       
CATEGORY
+                                                                       'id' => 
'btn_district_id',
+                                                                       'name' 
=> 'district_id',
+                                                                       'value' 
=> lang('District'),
+                                                                       'type' 
=> 'button',
+                                                                       'style' 
=> 'filter',
+                                                                       
'tab_index' => 2
+                                                               ),
+                                                               array
+                                                               ( //boton       
search criteria
+                                                                       'id' => 
'btn_criteria_id',
+                                                                       'name' 
=> 'criteria_id',
+                                                                       'value' 
=> lang('search criteria'),
+                                                                       'type' 
=> 'button',
+                                                                       'style' 
=> 'filter',
+                                                                       
'tab_index' => 3
+                                                               ),
+                                                               array
+                                                               ( //boton  
SEARCH
+                                                                       'id' => 
'btn_search',
+                                                                       'name' 
=> 'search',
+                                                                       'value' 
   => lang('search'),
+                                                                       'type' 
=> 'button',
+                                                                       
'tab_index' => 5
+                                                               ),
+                                                               array
+                                                               ( // TEXT IMPUT
+                                                                       'name'  
   => 'query',
+                                                                       'id'    
 => 'txt_query',
+                                                                       'value' 
   => '',//'',//$query,
+                                                                       'type' 
=> 'text',
+                                                                       'size'  
  => 28,
+                                                                       
'onkeypress' => 'return pulsar(event)',
+                                                                       
'tab_index' => 4
+                                                               )
+                                                       ),
+                                                       'hidden_value' => array
+                                                       (
+                                                               array
+                                                               ( //div values  
combo_box_0
+                                                                       'id' => 
'values_combo_box_0',
+                                                                       'value' 
=> $bocommon->select2String($values_combo_box[0]) //i.e.  id,value/id,vale/
+                                                               ),
+                                                               array
+                                                               ( //div values  
combo_box_1
+                                                                       'id' => 
'values_combo_box_1',
+                                                                       'value' 
=> $bocommon->select2String($values_combo_box[1]) //i.e.  id,value/id,vale/
+                                                               ),
+                                                               array
+                                                               ( //div values  
combo_box_2
+                                                                       'id' => 
'values_combo_box_2',
+                                                                       'value' 
=> $bocommon->select2String($values_combo_box[2]) //i.e.  id,value/id,vale/
+                                                               )
+                                                       )
+                                               )
+                                       )
+                               );
+                       }
+
+                       $entity_list = $boentity->read(array('lookup'=>true));
+                       $input_name = 
$GLOBALS['phpgw']->session->appsession('lookup_fields','property');
+                       $uicols = $boentity->uicols;
+
+                       if (count($uicols['name']) > 0)
+                       {
+                               for ($m = 0; $m<count($input_name); $m++)
+                               {
+                                       if 
(!array_search($input_name[$m],$uicols['name']))
+                                       {
+                                               $uicols['name'][]       = 
$input_name[$m];
+                                               $uicols['descr'][]      = '';
+                                               $uicols['input_type'][]         
= 'hidden';
+                                       }
+                               }
+                       }
+                       else
+                       {
+
+                               $uicols['name'][]       = 'num';
+                               $uicols['descr'][]      = 'ID';
+                               $uicols['input_type'][]         = 'text';
+                       }
+
+                       $content = array();
+                       $j=0;
+                       if (isset($entity_list) && is_array($entity_list))
+                       {
+                               foreach($entity_list as $entity_entry)
+                               {
+                                       for 
($i=0;$i<count($uicols['name']);$i++)
+                                       {
+                                               
$datatable['rows']['row'][$j]['column'][$i]['value']    = 
($entity_entry[$uicols['name'][$i]] == null ? '' : 
$entity_entry[$uicols['name'][$i]]);
+                                               
$datatable['rows']['row'][$j]['column'][$i]['name']     = $uicols['name'][$i];
+
+                                               if(isset($uicols['datatype']) 
&& isset($uicols['datatype'][$i]) && $uicols['datatype'][$i]=='link' && 
$entity_entry[$uicols['name'][$i]])
+                                               {
+                                                       
$datatable['rows']['row'][$j]['column'][$i]['format']   = 'link';
+                                                       
$datatable['rows']['row'][$j]['column'][$i]['value']    = lang('link');
+                                                       
$datatable['rows']['row'][$j]['column'][$i]['link']             = 
$entity_entry[$uicols['name'][$i]];
+                                                       
$datatable['rows']['row'][$j]['column'][$i]['target']   = '_blank';
+                                               }
+                                       }
+
+                                       /*for ($i=0;$i<count($input_name);$i++)
+                                       {
+                                               
$datatable['rows']['row'][$j]['hidden'][$i]['value']    = 
$entity_entry[$input_name[$i]];
+                                               
$datatable['rows']['row'][$j]['hidden'][$i]['name']     = $input_name[$i];
+                                       }*/
+                                       $j++;
+                               }
+                       }
+
+                       $uicols_count   = count($uicols['descr']);
+                       $datatable['rowactions']['action'] = array();
+                       for ($i=0;$i<$uicols_count;$i++)
+                       {
+                               //all colums should be have formatter
+                               
$datatable['headers']['header'][$i]['formatter'] = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
+
+                               if($uicols['input_type'][$i]!='hidden')
+                               {
+                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
+                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
+                                       
$datatable['headers']['header'][$i]['visible']                  = true;
+                                       
$datatable['headers']['header'][$i]['sortable']                 = false;
+
+                                       if($uicols['name'][$i]=='loc1' || 
$uicols['name'][$i]=='num')
+                                       {
+                                               
$datatable['headers']['header'][$i]['sortable']         = true;
+                                               
$datatable['headers']['header'][$i]['sort_field']       = $uicols['name'][$i];
+                                       }
+                               }
+                               else
+                               {
+                                       
$datatable['headers']['header'][$i]['name']                     = 
$uicols['name'][$i];
+                                       
$datatable['headers']['header'][$i]['text']                     = 
$uicols['descr'][$i];
+                                       
$datatable['headers']['header'][$i]['visible']                  = false;
+                                       
$datatable['headers']['header'][$i]['sortable']         = false;
+                                       
$datatable['headers']['header'][$i]['format']                   = 'hidden';
+                               }
+                       }
+
+                       $function_exchange_values = '';
+
+                       for ($i=0;$i<count($input_name);$i++)
+                       {
+                               $function_exchange_values .= 
"opener.document.getElementsByName('{$input_name[$i]}')[0].value = '';\r\n";
+                       }
+
+                       for ($i=0;$i<count($input_name);$i++)
+                       {
+                               $function_exchange_values .= 
"opener.document.getElementsByName('{$input_name[$i]}')[0].value = 
data.getData('{$input_name[$i]}');\r\n";
+                       }
+
+                       $function_exchange_values .= 'window.close()';
+
+                       $datatable['exchange_values'] = 
$function_exchange_values;
+                       $datatable['valida'] = '';
+
+                       // path for property.js
+                       $datatable['property_js'] = 
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property.js";
+
+                       // Pagination and sort values
+                       $datatable['pagination']['records_start']       = 
(int)$this->start;
+                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       $datatable['pagination']['records_returned']= 
count($entity_list);
+                       $datatable['pagination']['records_total']       = 
$boentity->total_records;
+
+                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
+                       {
+                               $datatable['sorting']['order']                  
= 'num'; // name key Column in myColumnDef
+                               $datatable['sorting']['sort']                   
= 'desc'; // ASC / DESC
+                       }
+                       else
+                       {
+                               $datatable['sorting']['order']                  
= phpgw::get_var('order', 'string'); // name of column of Database
+                               $datatable['sorting']['sort']                   
= phpgw::get_var('sort', 'string'); // ASC / DESC
+                       }
+
+
+                       //-- BEGIN----------------------------- JSON CODE 
------------------------------
+
+                       //values for Pagination
+                       $json = array
+                               (
+                                       'recordsReturned'       => 
$datatable['pagination']['records_returned'],
+                                       'totalRecords'          => 
(int)$datatable['pagination']['records_total'],
+                                       'startIndex'            => 
$datatable['pagination']['records_start'],
+                                       'sort'                          => 
$datatable['sorting']['order'],
+                                       'dir'                           => 
$datatable['sorting']['sort'],
+                                       'records'                       => 
array(),
+                                       'headers'                       => 
$uicols
+
+                               );
+
+                       // values for datatable
+                       if(isset($datatable['rows']['row']) && 
is_array($datatable['rows']['row'])){
+                               foreach( $datatable['rows']['row'] as $row )
+                               {
+                                       $json_row = array();
+                                       foreach( $row['column'] as $column)
+                                       {
+                                               if(isset($column['format']) && 
$column['format']== "link" && $column['java_link']==true)
+                                               {
+                                                       
$json_row[$column['name']] = "<a href='#' id='{$column['link']}' 
onclick='javascript:filter_data(this.id);'>{$column['value']}</a>";
+                                               }
+                                               else 
if(isset($column['format']) && $column['format']== "link")
+                                               {
+                                                       
$json_row[$column['name']] = "<a href='{$column['link']}' 
target='_blank'>{$column['value']}</a>";
+                                               }
+                                               else
+                                               {
+                                                       
$json_row[$column['name']] = $column['value'];
+                                               }
+                                       }
+                                       $json['records'][] = $json_row;
+                               }
+                       }
+
+                       // right in datatable
+                       if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
+                       {
+                               $json ['rights'] = 
$datatable['rowactions']['action'];
+                       }
+
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       {
+                               return $json;
+                       }
+
+                       $datatable['json_data'] = json_encode($json);
+                       //-------------------- JSON CODE ----------------------
+
+                       // Prepare template variables and process XSLT
+                       $template_vars = array();
+                       $template_vars['datatable'] = $datatable;
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('datatable'),PHPGW_SERVER_ROOT . 
'/phpgwapi/templates/base');
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
$template_vars);
+
+                       if($this->entity_id)
+                       {
+                               $entity         = 
$boadmin_entity->read_single($this->entity_id,false);
+                               $appname        = $entity['name'];
+                       }
+                       if($this->cat_id)
+                       {
+                               $category = 
$boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
+                               $function_msg                                   
= lang('lookup') . ' ' . $category['name'];
+                       }
+
+                       //Title of Page
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
+                       // Prepare YUI Library
+                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'lookup.entity.index', 'property' );
+
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('dragdrop');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('menu');
+                       phpgwapi_yui::load_widget('connection');
+                       phpgwapi_yui::load_widget('loader');
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('paginator');
+                       phpgwapi_yui::load_widget('animation');
+
+                       if ( !isset($GLOBALS['phpgw']->css) || 
!is_object($GLOBALS['phpgw']->css) )
+                       {
+                               $GLOBALS['phpgw']->css = 
createObject('phpgwapi.css');
+                       }
+                       // Prepare CSS Style
+                       $GLOBALS['phpgw']->css->validate_file('datatable');
+                       $GLOBALS['phpgw']->css->validate_file('property');
+                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
+
+//                     $this->save_sessiondata();
+               }
+
+
                // Returns locations for a control
                public function get_locations_for_control()
                {
@@ -382,9 +981,27 @@
                        return $this->yui_results($results);
                }
                
-               public function query(){
-                       $type_id = phpgw::get_var('type_id');
-                       //var_dump($type_id);
+               public function query()
+               {
+                       $type_id = phpgw::get_var('type_id', 'int');
+                       $control_id = phpgw::get_var('control_id', 'int');
+                       $control_id_init = phpgw::get_var('control_id_init', 
'int');
+                       $control_area_id = phpgw::get_var('control_area_id', 
'int');
+
+                       $control_id = $control_id ? $control_id : 
$control_id_init;
+                       
+                       if($control_area_id && 
!execMethod('controller.socontrol.get_controls_by_control_area',$control_area_id))
+                       {
+                               $control_id = 0;
+                       }
+
+                       $control_info = 
execMethod('controller.socontrol.get_single', $control_id);
+                       $control_name = '';
+                       if($control_info)
+                       {
+                               $control_name = $control_info->get_title();
+                       }
+
                        $view_type = phpgw::get_var('view_type');
                        $return_results = phpgw::get_var('results', 'int', 
'REQUEST', 0);
                        
@@ -397,15 +1014,15 @@
                        
                        $location_list = $this->bo->read(array('user_id' => 
$user_id, 'role_id' =>$role_id, 
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
                                                                                
                   'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run' 
=>$dry_run, 'results' => $return_results));
-//_debug_array($location_list);
-                       $rows_total = $this->bo->read(array('type_id' => 
$type_id, 'allrows' => true));
-                       
-                       foreach($location_list as $location)
+
+                       foreach($location_list as &$location)
                        {
+                               $location['control_name'] = $control_name;
+                               $location['location_registered'] = 
!!$this->so_control->get_control_location($control_id, 
$location['location_code']);
                                $results['results'][]= $location;       
                        }
                        
-                       $results['total_records'] = count($rows_total);
+                       $results['total_records'] = $this->bo->total_records;
                        $results['start'] = $this->start;
                        $results['sort'] = 'location_code';
                        $results['dir'] = "ASC";
@@ -482,4 +1099,302 @@
 
                        return json_encode( $part_of_town_list );
                }
+
+
+               /*
+
+                * Return parts of town based on chosen district
+                */
+               public function get_category_by_entity()
+               {
+                       $entity_id              = phpgw::get_var('entity_id');
+                       $entity                 = 
CreateObject('property.soadmin_entity');
+
+                       $category_list = 
$entity->read_category(array('allrows'=>true,'entity_id'=>$entity_id));
+
+/*                     $default_value = array 
('id'=>'','name'=>lang('select'));
+                       array_unshift($category_list,$default_value);
+*/
+                       return $category_list;
+               }
+
+               function index2()
+               {
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+                       $receipt = array();
+
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query2();
+                       }
+
+                       $msgbox_data = array();
+                       if( phpgw::get_var('phpgw_return_as') != 'json' && 
$receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+                       {
+                               phpgwapi_cache::session_clear('phpgwapi', 
'phpgw_messages');
+                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($receipt);
+                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                       }
+
+                       $myColumnDefs = array();
+                       $datavalues = array();
+                       $myButtons      = array();
+
+                       $datavalues[] = array
+                       (
+                               'name'                          => "0",
+                               'values'                        => 
$this->query2(),//json_encode(array()),
+                               'total_records'         => 0,
+                               'permission'            => "''",
+                               'is_paginator'          => 0,
+                               'edit_action'           => "''",
+                               'footer'                        => 0
+                       );
+
+                       $datatable = array
+                       (
+                               array
+                               (
+                               'key' => 'id',
+                               'hidden' => true
+                               ),
+                               array
+                               (
+                                       'key' => 'user',
+                                       'label' => lang('user'),
+                                       'sortable' => false
+                               ),
+                               array
+                               (
+                                       'key' => 'ecodimb',
+                                       'label' => lang('dim b'),
+                                       'sortable' => false,
+                                       'formatter' => 'FormatterRight',
+                               ),
+                               array
+                               (
+                                       'key'   =>      'role',
+                                       'label' =>      lang('role'),
+                                       'formatter' => 'FormatterRight',
+                                       'sortable'      =>      true
+                               ),
+                               array
+                               (
+                                       'key' => 'default_user',
+                                       'label' => lang('default'),
+                                       'sortable'      => false,
+                                       'formatter' => 'FormatterCenter',
+                               ),
+                               array
+                               (
+                                       'key' => 'active_from',
+                                       'label' => lang('date from'),
+                                       'sortable'      => true,
+                                       'formatter' => 'FormatterRight',
+                               ),
+                               array
+                               (
+                                       'key' => 'active_to',
+                                       'label' => lang('date to'),
+                                       'sortable' => false,
+                                       'formatter' => 'FormatterCenter',
+                               ),
+                               array
+                               (
+                                       'key' => 'add',
+                                       'label' => lang('add'),
+                                       'sortable' => false,
+                                       'formatter' => 'FormatterCenter',
+                               ),
+                               array
+                               (
+                                       'key' => 'delete',
+                                       'label' => lang('delete'),
+                                       'sortable' => false,
+                                       'formatter' => 'FormatterCenter',
+                               ),
+                               array
+                               (
+                                       'key' => 'alter_date',
+                                       'label' => lang('alter_date'),
+                                       'sortable' => false,
+                                       'formatter' => 'FormatterCenter',
+                               ),
+                       );
+
+                       $myColumnDefs[0] = array
+                       (
+                               'name'          => "0",
+                               'values'        =>      json_encode($datatable)
+                       );      
+
+
+
+                       $GLOBALS['phpgw']->translation->add_app('property');
+                       $entity                 = 
CreateObject('property.soadmin_entity');
+                       $entity_list    = $entity->read(array('allrows' => 
true));
+
+                       $district_list  = 
$this->bocommon->select_district_list('filter',$this->district_id);
+
+                       $part_of_town_list = 
execMethod('property.bogeneric.get_list', array('type'=>'part_of_town', 
'selected' => $part_of_town_id ));
+
+                       array_unshift($entity_list ,array 
('id'=>'','name'=>lang('select')));
+                       array_unshift($district_list ,array 
('id'=>'','name'=>lang('select')));
+
+
+
+                       array_unshift ($role_list ,array 
('id'=>'','name'=>lang('select')));
+                       array_unshift ($dimb_list ,array 
('id'=>'','name'=>lang('select')));
+
+
+
+                       $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
+                       $cats->supress_info     = true;
+
+                       $control_area = 
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl' 
=> $this->_category_acl));
+
+                                                               
+                       $control_area_list = array();
+                       foreach($control_area['cat_list'] as $cat_list)
+                       {
+                               $control_area_list[] = array
+                               (
+                                       'id'    => $cat_list['cat_id'],
+                                       'name'  => $cat_list['name'],
+                               );              
+                       }
+
+                       array_unshift ($control_area_list ,array 
('id'=>'','name'=>lang('select')));
+
+                       $data = array
+                       (
+                               'td_count'                                      
        => '""',
+                               'property_js'                                   
=> 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
+                               'datatable'                                     
        => $datavalues,
+                               'myColumnDefs'                                  
=> $myColumnDefs,
+                               'myButtons'                                     
        => $myButtons,
+
+                               'msgbox_data'                                   
=> $msgbox_data,
+                               'filter_form'                                   
=> array
+                                                                               
                        (
+                                                                               
                                'control_area_list'     => array('options' => 
$control_area_list),
+                                                                               
                                'entity_list'           => array('options' => 
$entity_list),
+                                                                               
                                'district_list'         => array('options' => 
$district_list),
+                                                                               
                                'part_of_town_list'     => array('options' => 
$part_of_town_list),
+                                                                               
                        ),
+                               'update_action'                                 
=> self::link(array('menuaction' => 'controller.uicontrol_location.edit'))
+                       );
+
+                       $GLOBALS['phpgw']->jqcal->add_listener('query_start');
+                       $GLOBALS['phpgw']->jqcal->add_listener('query_end');
+                       $GLOBALS['phpgw']->jqcal->add_listener('active_from');
+                       $GLOBALS['phpgw']->jqcal->add_listener('active_to');
+
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+
+                       phpgwapi_yui::load_widget('dragdrop');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('connection');
+                       phpgwapi_yui::load_widget('loader');
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('paginator');
+                       phpgwapi_yui::load_widget('animation');
+
+                       phpgwapi_jquery::load_widget('core');
+
+                       self::add_javascript('controller', 'controller', 
'ajax_control_to_component.js');
+                       self::add_javascript('controller', 'yahoo', 
'register_control_to_component.js');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('control_location/register_control_to_component'));
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('data' => $data));
+               }
+       
+
+               public function query2()
+               {
+                       $user_id =      phpgw::get_var('user_id', 'int');
+                       $dimb_id =      phpgw::get_var('dimb_id', 'int');
+                       $role_id =      phpgw::get_var('role_id', 'int');
+                       $query_start =  phpgw::get_var('query_start');
+                       $query_end =    phpgw::get_var('query_end');
+
+//                     $this->bo->allrows = true;
+                       $values = $this->bo->read(array('user_id' => $user_id, 
'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query_start' => $query_start, 
'query_end' => $query_end));
+
+                       foreach($values as &$entry)
+                       {
+                               if($entry['active_from'])
+                               {
+                                       $default_user_checked = 
$entry['default_user'] == 1 ? 'checked = "checked"' : '';
+                                       $entry['default_user'] = "<input 
id=\"default_user\" type =\"checkbox\" $default_user_checked 
name=\"values[default_user][]\" value=\"{$entry['id']}\">";
+                                       $entry['delete'] = "<input 
id=\"delete\" type =\"checkbox\" name=\"values[delete][]\" 
value=\"{$entry['id']}\">";
+                                       $entry['alter_date'] = "<input 
id=\"alter_date\" type =\"checkbox\" name=\"values[alter_date][]\" 
value=\"{$entry['id']}\">";
+                                       $entry['add'] = '';
+                               }
+                               else
+                               {
+                                       $entry['default_user'] = '';
+                                       $entry['delete'] = '';
+                                       $entry['alter_date'] = '';
+                                       $entry['add'] = "<input id=\"add\" type 
=\"checkbox\" name=\"values[add][]\" 
value=\"{$entry['ecodimb']}_{$entry['role_id']}_{$entry['user_id']}\">";        
                   
+                               }
+                               $results['results'][]= $entry;
+                       }
+
+                       return json_encode($values);
+               }
+
+               public function edit()
+               {
+                       $user_id =      phpgw::get_var('user_id', 'int');
+                       $dimb_id =      phpgw::get_var('dimb_id', 'int');
+                       $role_id =      phpgw::get_var('role_id', 'int');
+                       $query =        phpgw::get_var('query');
+
+                       if($values = phpgw::get_var('values'))
+                       {
+                               if(!$GLOBALS['phpgw']->acl->check('.admin', 
PHPGW_ACL_EDIT, 'property'))
+                               {
+                                       $receipt['error'][]=true;
+                                       phpgwapi_cache::message_set(lang('you 
are not approved for this task'), 'error');
+                               }
+                               if(!$receipt['error'])
+                               {
+                                       if($this->bo->edit($values))
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'updated'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'error'
+                                               );
+                                       }
+                               }
+                       }
+
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               if( $receipt = 
phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+                               {
+                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                       $result['receipt'] = $receipt;
+                               }
+                               else
+                               {
+                                       $result['receipt'] = array();
+                               }
+                               return $result;
+                       }
+                       else
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_location.index2', 'user_id' => 
$user_id, 'dimb_id' => $dimb_id, 'role_id' => $role_id, 'query' => $query));
+                       }
+               }
        }

Modified: branches/Version-1_0-branch/controller/js/controller/ajax.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-06-05 06:37:27 UTC (rev 9502)
+++ branches/Version-1_0-branch/controller/js/controller/ajax.js        
2012-06-05 07:10:42 UTC (rev 9503)
@@ -1,5 +1,22 @@
 $(document).ready(function(){
 
+       // Changes location level between building and property in serch 
location select box
+       $("#choose-loc a").click(function(){
+               
+               $("#choose-loc a").removeClass("active");
+               $(this).addClass("active");
+               
+               var loc_type = $(this).attr("href");
+               
+               $("#loc_type").val( loc_type.substring(9, 10) );
+               $("#search-location-name").focus();
+
+               $( "#search-location-name" ).autocomplete( "search");
+               
+               return false;
+       });
+
+       // Changes control type location level between building and property in 
serch location select box
        $(".control_item_type").click(function(){
                var thisBtn = $(this).find(".btn");
                var thisRadio = $(this).find("input[type=radio]");
@@ -21,68 +38,10 @@
                }
        });
        
-       $(".choose_loc").live( "change", function () {
-               var thisSelectBox = $(this);
-               var loc_code = $(this).val();
-               var loc_id = $(this).attr("id");
-               var loc_arr = loc_id.split('_');
-               var loc_level = parseInt(loc_arr[1]);
-               var new_loc_id = "loc_" + (parseInt(loc_level)+1);
-               
-               var id = "";
-               var new_loc_code = "";
-               var level;
-               for(level = 1;level <= loc_level;level++){
-                       id = "loc_" + level;
-                       if(level > 1)
-                               new_loc_code += "-" + $("#" + id).val();
-                       else
-                               new_loc_code += $("#" + id).val();
-               }
-               
-               if(!loc_code)
-               {
-                       return false;
-               }
-               var oArgs = {menuaction:'registration.boreg.get_locations', 
location_code:new_loc_code};
-               var requestUrl = phpGWLink('registration/main.php', oArgs, 
true);
-      
-               var htmlString = "";
-
-               $.ajax({
-                       type: 'POST',
-                       dataType: 'json',
-                       url: requestUrl,
-                       success: function(data) {
-                               if( data != null)
-                               {
-                                       htmlString  = "<select 
class='choose_loc' name='" + new_loc_id  + "' id='" + new_loc_id  + "' >" +
-                                                                 "<option 
value = ''>" + data.length + " lokasjone(r) funnet</option>";
-                                                                 
-                                                                 
-                                       var obj = data;
-
-                                       $.each(obj, function(i) {
-                                               htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
-                                       });
-
-                                       htmlString += "</select>";
-                                       
-                                       $(thisSelectBox).after( htmlString );
-                               }
-                               else
-                               {
-                                       htmlString  += "<option>Ingen 
lokasjoner</option>"
-                                       $(new_loc_id).html( htmlString );
-                               }
-                       } 
-               });     
-    });
-       
-       $("#choose_my_location").change(function () {
+       $(".selectLocation").change(function () {
                 var location_code = $(this).val();
                 var thisForm = $(this).parents("form");
-                
+
                 var period_type = 
$(thisForm).find("input[name='period_type']").val();
                 var year = $(thisForm).find("input[name='year']").val();
                 var month = $(thisForm).find("input[name='month']").val();
@@ -170,10 +129,11 @@
        
        $("#control_area_list").change(function () {
                var control_area_id = $(this).val();
-                var oArgs = 
{menuaction:'controller.uicontrol.get_controls_by_control_area', 
phpgw_return_as:'json'};
+                var oArgs = 
{menuaction:'controller.uicontrol.get_controls_by_control_area'};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
-         //var requestUrl = 
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
          
+               $("#hidden_control_area_id").val( control_area_id );
+         var control_id_init = $("#hidden_control_id").val();
          var htmlString = "";
          
          $.ajax({
@@ -186,19 +146,33 @@
                                          var obj = jQuery.parseJSON(data);
                                                
                                          $.each(obj, function(i) {
-                                                 htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].title + "</option>";
+
+                                               var selected = '';
+                                               if(obj[i].id == control_id_init)
+                                               {
+                                                       selected = ' selected';
+                                               }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].title + "</option>";
                                        });
                                                                                
                          
                                          $("#control_id").html( htmlString );
-                                       }else {
+                                       }
+                                       else
+                                       {
                                        htmlString  += "<option>Ingen 
kontroller</option>"
                                        $("#control_id").html( htmlString );
+                                               
$("#hidden_control_id").val(-1); //reset
                                }
                          }  
                        });
                        
     });
 
+       $("#control_id").change(function () {
+               var control_id = $(this).val();
+               $("#hidden_control_id").val( control_id );
+    });
+
        // file: uicheck_list.xsl
        // When control area is selected, controls are fetched from db and 
control select list is populated
        $("#control_group_area_list").change(function () {
@@ -269,40 +243,6 @@
                        
     });
        
-       // When control area is selected, controls are fetched from db and 
control select list is populated
-/*     $("#control_group").change(function () {
-                var control_group_id = $(this).val();
-            var oArgs = 
{menuaction:'controller.uicontrol_group.get_control_area_by_control_group', 
phpgw_return_as:'json'};
-                var requestUrl = phpGWLink('index.php', oArgs, true);
-
-         //var requestUrl = 
"index.php?menuaction=controller.uicontrol_group.get_control_groups_by_control_area&phpgw_return_as=json"
-         
-         var htmlString = "";
-         
-         $.ajax({
-                         type: 'POST',
-                         dataType: 'json',
-                         url: requestUrl + "&control_group_id=" + 
control_group_id,
-                         success: function(data) {
-                                 if( data != null){
-                                         htmlString  = "<option>Ingen 
kontrollområde</option>"
-                                         var obj = jQuery.parseJSON(data);
-                                               
-                                         $.each(obj, function(i) {
-                                                 htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].group_name + "</option>";
-                                       });
-                                                                               
                          
-                                         $("#control_group_id").html( 
htmlString );
-                                       }else {
-                                       htmlString  += "<option>Ingen 
kontrollområder</option>"
-                                       $("#control_group_id").html( htmlString 
);
-                               }
-                         }  
-                       });
-                       
-    });
-*/
-       
        // file: add_component_to_control.xsl
        // When component category is selected, corresponding component types 
are fetched from db and component type select list is populated
        $("#ifc").change(function () {
@@ -423,28 +363,6 @@
                $(this).parent().find("input[name=option_value]").val('');
        });
        
-       /*
-       $("#frm_add_control_item_option").live("submit", function(e){
-               e.preventDefault();
-alert("feil")
-               var thisForm = $(this);
-               var requestUrl = $(thisForm).attr("action");
-               
-               $.ajax({
-                         type: 'POST',
-                         url: requestUrl + "&phpgw_return_as=json&" + 
$(thisForm).serialize(),
-                         success: function(data) {
-                                 if(data){
-                                 var obj = jQuery.parseJSON(data);
-                                 
-                                 if(obj.status == "saved"){
-                                       
$("#control_item_options").append("<li><label>Valgverdi</label>" + 
obj.saved_object.label + "</li>")
-                                 }
-                                 }
-                               }
-                       });
-       });
-       */
        /* =========================  CONTROL  
=============================================== */
        
        // SAVE CONTROL DETAILS
@@ -614,11 +532,6 @@
        });
        
        
-
-       
-       
-       
-       
        //=======================================  CASE  
======================================
        
        // REGISTER CASE

Copied: 
branches/Version-1_0-branch/controller/js/controller/ajax_control_to_component.js
 (from rev 9502, trunk/controller/js/controller/ajax_control_to_component.js)
===================================================================
--- 
branches/Version-1_0-branch/controller/js/controller/ajax_control_to_component.js
                           (rev 0)
+++ 
branches/Version-1_0-branch/controller/js/controller/ajax_control_to_component.js
   2012-06-05 07:10:42 UTC (rev 9503)
@@ -0,0 +1,216 @@
+$(document).ready(function()
+{
+
+       $("#control_area_id").change(function () {
+               var control_area_id = $(this).val();
+                var oArgs = 
{menuaction:'controller.uicontrol.get_controls_by_control_area'};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+        
+       //      $("#hidden_control_area_id").val( control_area_id );
+    //     var control_id_init = $("#hidden_control_id").val();
+         var htmlString = "";
+         
+         $.ajax({
+                         type: 'POST',
+                         dataType: 'json',
+                         url: requestUrl + "&control_area_id=" + 
control_area_id,
+                         success: function(data) {
+                                 if( data != null){
+                                         htmlString  = "<option>Velg 
kontroll</option>"
+                                         var obj = jQuery.parseJSON(data);
+                                               
+                                         $.each(obj, function(i) {
+
+                                               var selected = '';
+/*
+                                               if(obj[i].id == control_id_init)
+                                               {
+                                                       selected = ' selected';
+                                               }
+*/
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].title + "</option>";
+                                       });
+                                                                               
                          
+                                         $("#control_id").html( htmlString );
+                                       }
+                                       else
+                                       {
+                                       htmlString  += "<option>Ingen 
kontroller</option>"
+                                       $("#control_id").html( htmlString );
+//                                             
$("#hidden_control_id").val(-1); //reset
+                               }
+                         }  
+                       });
+                       
+    });
+
+
+
+       $("#entity_id").change(function () {
+                var oArgs = 
{menuaction:'controller.uicontrol_location.get_category_by_entity', entity_id: 
$(this).val()};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+        
+         var htmlString = "";
+         
+         $.ajax({
+                         type: 'POST',
+                         dataType: 'json',
+                         url: requestUrl,
+                         success: function(data) {
+                                 if( data != null){
+                                         htmlString  = "<option>Velg</option>"
+                                         var obj = data;
+
+                                         $.each(obj, function(i) {
+
+                                               var selected = '';
+/*
+                                               if(obj[i].id == control_id_init)
+                                               {
+                                                       selected = ' selected';
+                                               }
+*/
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                       });
+                                                                               
                          
+                                         $("#category_id").html( htmlString );
+                                       }
+                                       else
+                                       {
+                                       htmlString  += "<option>Ingen 
kontroller</option>"
+                                       $("#category_id").html( htmlString );
+                               }
+                         }  
+                       });
+                       
+    });
+
+
+       //update part of town category based on district
+       $("#district_id").change(function () {
+               var district_id = $(this).val();
+                var oArgs = 
{menuaction:'controller.uicontrol_location.get_district_part_of_town'};
+                var requestUrl = phpGWLink('index.php', oArgs, true);
+         
+         var htmlString = "";
+         
+         $.ajax({
+                         type: 'POST',
+                         dataType: 'json',
+                         url: requestUrl + "&district_id=" + district_id,
+                         success: function(data) {
+                                 if( data != null){
+                                         var obj = jQuery.parseJSON(data);
+                                               
+                                         $.each(obj, function(i) {
+                                                 htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+                                       });
+                                                                               
                          
+                                         $("#part_of_town_id").html( 
htmlString );
+                                       }else {
+                                       htmlString  += "<option>Ingen 
kontroller</option>"
+                                       $("#part_of_town_id").html( htmlString 
);
+                               }
+                         }  
+         });
+    });
+
+
+
+
+       $("#dimb_id").change(function ()
+       {
+               update_dimb_role_user_table();
+    });
+
+       $("#user_id").change(function ()
+       {
+               update_dimb_role_user_table();
+    });
+
+       $("#role_id").change(function ()
+       {
+               update_dimb_role_user_table();
+    });
+
+       $("#search").click(function(e)
+       {
+               update_dimb_role_user_table();
+    });
+
+       $("#acl_form").live("submit", function(e){
+               e.preventDefault();
+               var thisForm = $(this);
+               var submitBnt = $(thisForm).find("input[type='submit']");
+               var requestUrl = $(thisForm).attr("action");
+               $.ajax({
+                       type: 'POST',
+                       url: requestUrl + "&phpgw_return_as=json&" + 
$(thisForm).serialize(),
+                       success: function(data) {
+                               if(data)
+                               {
+                                       if(data.sessionExpired)
+                                       {
+                                               alert('Sesjonen er utløpt - du 
må logge inn på nytt');
+                                               return;
+                                       }
+
+                               var obj = data;
+                       
+                               var submitBnt = 
$(thisForm).find("input[type='submit']");
+                               if(obj.status == "updated")
+                               {
+                                       $(submitBnt).val("Lagret");
+                                               var oArgs = 
{menuaction:'property.uidimb_role_user.query', dimb_id:$("#dimb_id").val(), 
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query_start:$("#query_start").val(),query_end:$("#query_end").val()};
+                                               
execute_async(myDataTable_0,oArgs);
+                                       }
+                                       else
+                                       {
+                                       $(submitBnt).val("Feil ved lagring");   
                                
+                                       }
+                                                
+                               // Changes text on save button back to original
+                               window.setTimeout(function() {
+                                               $(submitBnt).val('Lagre');
+                                               
$(submitBnt).addClass("not_active");
+                               }, 1000);
+
+                                       var htmlString = "";
+                                       if(typeof(data['receipt']['error']) != 
'undefined')
+                                       {
+                                               for ( var i = 0; i < 
data['receipt']['error'].length; ++i )
+                                               {
+                                                       htmlString += "<div 
class=\"error\">";
+                                                       htmlString += 
data['receipt']['error'][i]['msg'];
+                                                       htmlString += '</div>';
+                                               }
+                                       
+                                       }
+                                       if(typeof(data['receipt']['message']) 
!= 'undefined')
+                                       {
+                                               for ( var i = 0; i < 
data['receipt']['message'].length; ++i )
+                                               {
+                                                       htmlString += "<div 
class=\"msg_good\">";
+                                                       htmlString += 
data['receipt']['message'][i]['msg'];
+                                                       htmlString += '</div>';
+                                               }
+                                       
+                                       }
+                                       $("#receipt").html(htmlString);
+                               }
+                       }
+               });
+       });
+});
+
+
+function update_dimb_role_user_table()
+{
+       var oArgs = {menuaction:'property.uidimb_role_user.query', 
dimb_id:$("#dimb_id").val(), 
user_id:$("#user_id").val(),role_id:$("#role_id").val(),query_start:$("#query_start").val(),query_end:$("#query_end").val()};
+       execute_async(myDataTable_0,  oArgs);
+       $("#receipt").html('');
+}
+
+
+
+

Copied: 
branches/Version-1_0-branch/controller/js/controller/jquery-ui-1.8.20.custom.min.js
 (from rev 9502, trunk/controller/js/controller/jquery-ui-1.8.20.custom.min.js)
===================================================================
--- 
branches/Version-1_0-branch/controller/js/controller/jquery-ui-1.8.20.custom.min.js
                         (rev 0)
+++ 
branches/Version-1_0-branch/controller/js/controller/jquery-ui-1.8.20.custom.min.js
 2012-06-05 07:10:42 UTC (rev 9503)
@@ -0,0 +1,125 @@
+/*! jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.core.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){function c(b,c){var 
e=b.nodeName.toLowerCase();if("area"===e){var 
f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function
 d(b){return!a(b).parents().andSelf().filter(function(){return 
a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.20",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return
 typeof b=="number"?this.each(function(){var 
d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var
 b;return 
a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return
 this.css("zIndex",c);if(this.length){var 
d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return
 f}d=d.parent()}}return 0},disableSelection:function(){return 
this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return
 
this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function
 h(b,c,d,f){return 
a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var
 
e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return
 
c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return
 typeof 
b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return
 c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var 
d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var 
b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in
 
c,b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){var
 e=a.ui[b].prototype;for(var f in 
d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var
 d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var 
e=0;e<d.length;e++)a.options[d[e][0]]&&d[e][1].apply(a.element,c)}},contains:function(a,b){return
 
document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var
 d=c&&c==="left"?"scrollLeft":"scrollTop",e=!1;return 
b[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return 
a>b&&a<b+c},isOver:function(b,c,d,e,f,g){return 
a.ui.isOverAxis(b,d,f)&&a.ui.isOverAxis(c,e,g)}})})(jQuery);;/*! jQuery UI - 
v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.widget.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){if(a.cleanData){var 
c=a.cleanData;a.cleanData=function(b){for(var 
d=0,e;(e=b[d])!=null;d++)try{a(e).triggerHandler("remove")}catch(f){}c(b)}}else{var
 d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){return 
c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}}),d.call(a(this),b,c)})}}a.widget=function(b,c,d){var
 
e=b.split(".")[0],f;b=b.split(".")[1],f=e+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][f]=function(c){return!!a.data(c,b)},a[e]=a[e]||{},a[e][b]=function(a,b){arguments.length&&this._createWidget(a,b)};var
 g=new 
c;g.options=a.extend(!0,{},g.options),a[e][b].prototype=a.extend(!0,g,{namespace:e,widgetName:b,widgetEventPrefix:a[e][b].prototype.widgetEventPrefix||b,widgetBaseClass:f},d),a.widget.bridge(b,a[e][b])},a.widget.bridge=function(c,d){a.fn[c]=function(e){var
 f=typeof e=="string",g=Array.prototype.slice.call(arguments,1),h=this;return 
e=!f&&g.length?a.extend.apply(null,[!0,e].concat(g)):e,f&&e.charAt(0)==="_"?h:(f?this.each(function(){var
 
d=a.data(this,c),f=d&&a.isFunction(d[e])?d[e].apply(d,g):d;if(f!==d&&f!==b)return
 h=f,!1}):this.each(function(){var 
b=a.data(this,c);b?b.option(e||{})._init():a.data(this,c,new 
d(e,this))}),h)}},a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)},a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this),this.element=a(c),this.options=a.extend(!0,{},this.options,this._getCreateOptions(),b);var
 
d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return
 
a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled
 "+"ui-state-disabled")},widget:function(){return 
this.element},option:function(c,d){var e=c;if(arguments.length===0)return 
a.extend({},this.options);if(typeof c=="string"){if(d===b)return 
this.options[c];e={},e[c]=d}return 
this._setOptions(e),this},_setOptions:function(b){var c=this;return 
a.each(b,function(a,b){c._setOption(a,b)}),this},_setOption:function(a,b){return
 
this.options[a]=b,a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+"
 "+"ui-state-disabled").attr("aria-disabled",b),this},enable:function(){return 
this._setOption("disabled",!1)},disable:function(){return 
this._setOption("disabled",!0)},_trigger:function(b,c,d){var 
e,f,g=this.options[b];d=d||{},c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),c.target=this.element[0],f=c.originalEvent;if(f)for(e
 in f)e in c||(c[e]=f[e]);return 
this.element.trigger(c,d),!(a.isFunction(g)&&g.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}})(jQuery);;/*!
 jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.mouse.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){var 
c=!1;a(document).mouseup(function(a){c=!1}),a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var
 b=this;this.element.bind("mousedown."+this.widgetName,function(a){return 
b._mouseDown(a)}).bind("click."+this.widgetName,function(c){if(!0===a.data(c.target,b.widgetName+".preventClickEvent"))return
 
a.removeData(c.target,b.widgetName+".preventClickEvent"),c.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(b){if(c)return;this._mouseStarted&&this._mouseUp(b),this._mouseDownEvent=b;var
 d=this,e=b.which==1,f=typeof 
this.options.cancel=="string"&&b.target.nodeName?a(b.target).closest(this.options.cancel).length:!1;if(!e||f||!this._mouseCapture(b))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){d.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=this._mouseStart(b)!==!1;if(!this._mouseStarted)return
 
b.preventDefault(),!0}return!0===a.data(b.target,this.widgetName+".preventClickEvent")&&a.removeData(b.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(a){return
 d._mouseMove(a)},this._mouseUpDelegate=function(a){return 
d._mouseUp(a)},a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),b.preventDefault(),c=!0,!0},_mouseMove:function(b){return!a.browser.msie||document.documentMode>=9||!!b.button?this._mouseStarted?(this._mouseDrag(b),b.preventDefault()):(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b)),!this._mouseStarted):this._mouseUp(b)},_mouseUp:function(b){return
 
a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b)),!1},_mouseDistanceMet:function(a){return
 
Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return
 
this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);;/*!
 jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.position.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){a.ui=a.ui||{};var 
c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return
 g.apply(this,arguments);b=a.extend({},b);var 
h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" 
"):[0,0],l,m,n;return 
i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left
 
top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var
 a=(b[this]||"").split(" 
");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1],this.each(function(){var
 
c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var
 
d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var
 
d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]===e)return;var
 
d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0},top:function(b,c){if(c.at[1]===e)return;var
 
d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var
 
d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in
 c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var 
c=this[0];return!c||!c.ownerDocument?null:b?this.each(function(){a.offset.setOffset(this,b)}):h.call(this)}),function(){var
 
b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&a.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var
 j in 
g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position:
 absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 
201px;",h=a(c).offset(function(a,b){return 
b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery);;/*!
 jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.draggable.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},destroy:function(){if(!this.element.data("draggable"))return;return
 
this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable
 ui-draggable-dragging 
ui-draggable-disabled"),this._mouseDestroy(),this},_mouseCapture:function(b){var
 c=this.options;return 
this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(b),this.handle?(c.iframeFix&&a(c.iframeFix===!0?"iframe":c.iframeFix).each(function(){a('<div
 class="ui-draggable-iframeFix" style="background: 
#fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(a(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(b){var
 c=this.options;return 
this.helper=this._createHelper(b),this._cacheHelperProportions(),a.ui.ddmanager&&(a.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt),c.containment&&this._setContainment(),this._trigger("start",b)===!1?(this._clear(),!1):(this._cacheHelperProportions(),a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.helper.addClass("ui-draggable-dragging"),this._mouseDrag(b,!0),a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,b),!0)},_mouseDrag:function(b,c){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute");if(!c){var
 d=this._uiHash();if(this._trigger("drag",b,d)===!1)return 
this._mouseUp({}),!1;this.position=d.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return
 a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),!1},_mouseStop:function(b){var 
c=!1;a.ui.ddmanager&&!this.options.dropBehaviour&&(c=a.ui.ddmanager.drop(this,b)),this.dropped&&(c=this.dropped,this.dropped=!1);var
 
d=this.element[0],e=!1;while(d&&(d=d.parentNode))d==document&&(e=!0);if(!e&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!c||this.options.revert=="valid"&&c||this.options.revert===!0||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,c)){var
 
f=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){f._trigger("stop",b)!==!1&&f._clear()})}else
 
this._trigger("stop",b)!==!1&&this._clear();return!1},_mouseUp:function(b){return
 
this.options.iframeFix===!0&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,b),a.ui.mouse.prototype._mouseUp.call(this,b)},cancel:function(){return
 
this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(b){var
 
c=!this.options.handle||!a(this.options.handle,this.element).length?!0:!1;return
 
a(this.options.handle,this.element).find("*").andSelf().each(function(){this==b.target&&(c=!0)}),c},_createHelper:function(b){var
 
c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b])):c.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return
 
d.parents("body").length||d.appendTo(c.appendTo=="parent"?this.element[0].parentNode:c.appendTo),d[0]!=this.element[0]&&!/(fixed|absolute)/.test(d.css("position"))&&d.css("position","absolute"),d},_adjustOffsetFromHelper:function(b){typeof
 b=="string"&&(b=b.split(" 
")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in 
b&&(this.offset.click.left=b.left+this.margins.left),"right"in 
b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in
 b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in 
b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var
 
b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var
 
a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var
 
b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[b.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,b.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(b.containment=="document"?0:a(window).scrollLeft())+a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b.containment=="document"?0:a(window).scrollTop())+(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)&&b.containment.constructor!=Array){var
 c=a(b.containment),d=c[0];if(!d)return;var 
e=c.offset(),f=a(d).css("overflow")!="hidden";this.containment=[(parseInt(a(d).css("borderLeftWidth"),10)||0)+(parseInt(a(d).css("paddingLeft"),10)||0),(parseInt(a(d).css("borderTopWidth"),10)||0)+(parseInt(a(d).css("paddingTop"),10)||0),(f?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(a(d).css("borderLeftWidth"),10)||0)-(parseInt(a(d).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(f?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(a(d).css("borderTopWidth"),10)||0)-(parseInt(a(d).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=c}else
 
b.containment.constructor==Array&&(this.containment=b.containment)},_convertPositionTo:function(b,c){c||(c=this.position);var
 
d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var
 
c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName),f=b.pageX,g=b.pageY;if(this.originalPosition){var
 h;if(this.containment){if(this.relative_container){var 
i=this.relative_container.offset();h=[this.containment[0]+i.left,this.containment[1]+i.top,this.containment[2]+i.left,this.containment[3]+i.top]}else
 
h=this.containment;b.pageX-this.offset.click.left<h[0]&&(f=h[0]+this.offset.click.left),b.pageY-this.offset.click.top<h[1]&&(g=h[1]+this.offset.click.top),b.pageX-this.offset.click.left>h[2]&&(f=h[2]+this.offset.click.left),b.pageY-this.offset.click.top>h[3]&&(g=h[3]+this.offset.click.top)}if(c.grid){var
 
j=c.grid[1]?this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1]:this.originalPageY;g=h?j-this.offset.click.top<h[1]||j-this.offset.click.top>h[3]?j-this.offset.click.top<h[1]?j+c.grid[1]:j-c.grid[1]:j:j;var
 
k=c.grid[0]?this.originalPageX+Math.round((f-this.originalPageX)/c.grid[0])*c.grid[0]:this.originalPageX;f=h?k-this.offset.click.left<h[0]||k-this.offset.click.left>h[2]?k-this.offset.click.left<h[0]?k+c.grid[0]:k-c.grid[0]:k:k}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:d.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(b,c,d){return
 
d=d||this._uiHash(),a.ui.plugin.call(this,b,[c,d]),b=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),a.Widget.prototype._trigger.call(this,b,c,d)},plugins:{},_uiHash:function(a){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),a.extend(a.ui.draggable,{version:"1.8.20"}),a.ui.plugin.add("draggable","connectToSortable",{start:function(b,c){var
 
d=a(this).data("draggable"),e=d.options,f=a.extend({},c,{item:d.element});d.sortables=[],a(e.connectToSortable).each(function(){var
 
c=a.data(this,"sortable");c&&!c.options.disabled&&(d.sortables.push({instance:c,shouldRevert:c.options.revert}),c.refreshPositions(),c._trigger("activate",b,f))})},stop:function(b,c){var
 
d=a(this).data("draggable"),e=a.extend({},c,{item:d.element});a.each(d.sortables,function(){this.instance.isOver?(this.instance.isOver=0,d.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(b),this.instance.options.helper=this.instance.options._helper,d.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",b,e))})},drag:function(b,c){var
 d=a(this).data("draggable"),e=this,f=function(b){var 
c=this.offset.click.top,d=this.offset.click.left,e=this.positionAbs.top,f=this.positionAbs.left,g=b.height,h=b.width,i=b.top,j=b.left;return
 
a.ui.isOver(e+c,f+d,i,j,g,h)};a.each(d.sortables,function(f){this.instance.positionAbs=d.positionAbs,this.instance.helperProportions=d.helperProportions,this.instance.offset.click=d.offset.click,this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(e).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return
 
c.helper[0]},b.target=this.instance.currentItem[0],this.instance._mouseCapture(b,!0),this.instance._mouseStart(b,!0,!0),this.instance.offset.click.top=d.offset.click.top,this.instance.offset.click.left=d.offset.click.left,this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top,d._trigger("toSortable",b),d.dropped=this.instance.element,d.currentItem=d.element,this.instance.fromOutside=d),this.instance.currentItem&&this.instance._mouseDrag(b)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",b,this.instance._uiHash(this.instance)),this.instance._mouseStop(b,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),d._trigger("fromSortable",b),d.dropped=!1)})}}),a.ui.plugin.add("draggable","cursor",{start:function(b,c){var
 
d=a("body"),e=a(this).data("draggable").options;d.css("cursor")&&(e._cursor=d.css("cursor")),d.css("cursor",e.cursor)},stop:function(b,c){var
 
d=a(this).data("draggable").options;d._cursor&&a("body").css("cursor",d._cursor)}}),a.ui.plugin.add("draggable","opacity",{start:function(b,c){var
 
d=a(c.helper),e=a(this).data("draggable").options;d.css("opacity")&&(e._opacity=d.css("opacity")),d.css("opacity",e.opacity)},stop:function(b,c){var
 
d=a(this).data("draggable").options;d._opacity&&a(c.helper).css("opacity",d._opacity)}}),a.ui.plugin.add("draggable","scroll",{start:function(b,c){var
 
d=a(this).data("draggable");d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"&&(d.overflowOffset=d.scrollParent.offset())},drag:function(b,c){var
 
d=a(this).data("draggable"),e=d.options,f=!1;if(d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"){if(!e.axis||e.axis!="x")d.overflowOffset.top+d.scrollParent[0].offsetHeight-b.pageY<e.scrollSensitivity?d.scrollParent[0].scrollTop=f=d.scrollParent[0].scrollTop+e.scrollSpeed:b.pageY-d.overflowOffset.top<e.scrollSensitivity&&(d.scrollParent[0].scrollTop=f=d.scrollParent[0].scrollTop-e.scrollSpeed);if(!e.axis||e.axis!="y")d.overflowOffset.left+d.scrollParent[0].offsetWidth-b.pageX<e.scrollSensitivity?d.scrollParent[0].scrollLeft=f=d.scrollParent[0].scrollLeft+e.scrollSpeed:b.pageX-d.overflowOffset.left<e.scrollSensitivity&&(d.scrollParent[0].scrollLeft=f=d.scrollParent[0].scrollLeft-e.scrollSpeed)}else{if(!e.axis||e.axis!="x")b.pageY-a(document).scrollTop()<e.scrollSensitivity?f=a(document).scrollTop(a(document).scrollTop()-e.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<e.scrollSensitivity&&(f=a(document).scrollTop(a(document).scrollTop()+e.scrollSpeed));if(!e.axis||e.axis!="y")b.pageX-a(document).scrollLeft()<e.scrollSensitivity?f=a(document).scrollLeft(a(document).scrollLeft()-e.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<e.scrollSensitivity&&(f=a(document).scrollLeft(a(document).scrollLeft()+e.scrollSpeed))}f!==!1&&a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(d,b)}}),a.ui.plugin.add("draggable","snap",{start:function(b,c){var
 
d=a(this).data("draggable"),e=d.options;d.snapElements=[],a(e.snap.constructor!=String?e.snap.items||":data(draggable)":e.snap).each(function(){var
 
b=a(this),c=b.offset();this!=d.element[0]&&d.snapElements.push({item:this,width:b.outerWidth(),height:b.outerHeight(),top:c.top,left:c.left})})},drag:function(b,c){var
 
d=a(this).data("draggable"),e=d.options,f=e.snapTolerance,g=c.offset.left,h=g+d.helperProportions.width,i=c.offset.top,j=i+d.helperProportions.height;for(var
 k=d.snapElements.length-1;k>=0;k--){var 
l=d.snapElements[k].left,m=l+d.snapElements[k].width,n=d.snapElements[k].top,o=n+d.snapElements[k].height;if(!(l-f<g&&g<m+f&&n-f<i&&i<o+f||l-f<g&&g<m+f&&n-f<j&&j<o+f||l-f<h&&h<m+f&&n-f<i&&i<o+f||l-f<h&&h<m+f&&n-f<j&&j<o+f)){d.snapElements[k].snapping&&d.options.snap.release&&d.options.snap.release.call(d.element,b,a.extend(d._uiHash(),{snapItem:d.snapElements[k].item})),d.snapElements[k].snapping=!1;continue}if(e.snapMode!="inner"){var
 
p=Math.abs(n-j)<=f,q=Math.abs(o-i)<=f,r=Math.abs(l-h)<=f,s=Math.abs(m-g)<=f;p&&(c.position.top=d._convertPositionTo("relative",{top:n-d.helperProportions.height,left:0}).top-d.margins.top),q&&(c.position.top=d._convertPositionTo("relative",{top:o,left:0}).top-d.margins.top),r&&(c.position.left=d._convertPositionTo("relative",{top:0,left:l-d.helperProportions.width}).left-d.margins.left),s&&(c.position.left=d._convertPositionTo("relative",{top:0,left:m}).left-d.margins.left)}var
 t=p||q||r||s;if(e.snapMode!="outer"){var 
p=Math.abs(n-i)<=f,q=Math.abs(o-j)<=f,r=Math.abs(l-g)<=f,s=Math.abs(m-h)<=f;p&&(c.position.top=d._convertPositionTo("relative",{top:n,left:0}).top-d.margins.top),q&&(c.position.top=d._convertPositionTo("relative",{top:o-d.helperProportions.height,left:0}).top-d.margins.top),r&&(c.position.left=d._convertPositionTo("relative",{top:0,left:l}).left-d.margins.left),s&&(c.position.left=d._convertPositionTo("relative",{top:0,left:m-d.helperProportions.width}).left-d.margins.left)}!d.snapElements[k].snapping&&(p||q||r||s||t)&&d.options.snap.snap&&d.options.snap.snap.call(d.element,b,a.extend(d._uiHash(),{snapItem:d.snapElements[k].item})),d.snapElements[k].snapping=p||q||r||s||t}}}),a.ui.plugin.add("draggable","stack",{start:function(b,c){var
 
d=a(this).data("draggable").options,e=a.makeArray(a(d.stack)).sort(function(b,c){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(c).css("zIndex"),10)||0)});if(!e.length)return;var
 
f=parseInt(e[0].style.zIndex)||0;a(e).each(function(a){this.style.zIndex=f+a}),this[0].style.zIndex=f+e.length}}),a.ui.plugin.add("draggable","zIndex",{start:function(b,c){var
 
d=a(c.helper),e=a(this).data("draggable").options;d.css("zIndex")&&(e._zIndex=d.css("zIndex")),d.css("zIndex",e.zIndex)},stop:function(b,c){var
 
d=a(this).data("draggable").options;d._zIndex&&a(c.helper).css("zIndex",d._zIndex)}})})(jQuery);;/*!
 jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.droppable.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){a.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var
 
b=this.options,c=b.accept;this.isover=0,this.isout=1,this.accept=a.isFunction(c)?c:function(a){return
 
a.is(c)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},a.ui.ddmanager.droppables[b.scope]=a.ui.ddmanager.droppables[b.scope]||[],a.ui.ddmanager.droppables[b.scope].push(this),b.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){var
 b=a.ui.ddmanager.droppables[this.options.scope];for(var 
c=0;c<b.length;c++)b[c]==this&&b.splice(c,1);return 
this.element.removeClass("ui-droppable 
ui-droppable-disabled").removeData("droppable").unbind(".droppable"),this},_setOption:function(b,c){b=="accept"&&(this.accept=a.isFunction(c)?c:function(a){return
 
a.is(c)}),a.Widget.prototype._setOption.apply(this,arguments)},_activate:function(b){var
 
c=a.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),c&&this._trigger("activate",b,this.ui(c))},_deactivate:function(b){var
 
c=a.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),c&&this._trigger("deactivate",b,this.ui(c))},_over:function(b){var
 
c=a.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return;this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",b,this.ui(c)))},_out:function(b){var
 
c=a.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return;this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",b,this.ui(c)))},_drop:function(b,c){var
 
d=c||a.ui.ddmanager.current;if(!d||(d.currentItem||d.element)[0]==this.element[0])return!1;var
 e=!1;return 
this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var
 
b=a.data(this,"droppable");if(b.options.greedy&&!b.options.disabled&&b.options.scope==d.options.scope&&b.accept.call(b.element[0],d.currentItem||d.element)&&a.ui.intersect(d,a.extend(b,{offset:b.element.offset()}),b.options.tolerance))return
 
e=!0,!1}),e?!1:this.accept.call(this.element[0],d.currentItem||d.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",b,this.ui(d)),this.element):!1},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}}),a.extend(a.ui.droppable,{version:"1.8.20"}),a.ui.intersect=function(b,c,d){if(!c.offset)return!1;var
 
e=(b.positionAbs||b.position.absolute).left,f=e+b.helperProportions.width,g=(b.positionAbs||b.position.absolute).top,h=g+b.helperProportions.height,i=c.offset.left,j=i+c.proportions.width,k=c.offset.top,l=k+c.proportions.height;switch(d){case"fit":return
 i<=e&&f<=j&&k<=g&&h<=l;case"intersect":return 
i<e+b.helperProportions.width/2&&f-b.helperProportions.width/2<j&&k<g+b.helperProportions.height/2&&h-b.helperProportions.height/2<l;case"pointer":var
 
m=(b.positionAbs||b.position.absolute).left+(b.clickOffset||b.offset.click).left,n=(b.positionAbs||b.position.absolute).top+(b.clickOffset||b.offset.click).top,o=a.ui.isOver(n,m,k,i,c.proportions.height,c.proportions.width);return
 
o;case"touch":return(g>=k&&g<=l||h>=k&&h<=l||g<k&&h>l)&&(e>=i&&e<=j||f>=i&&f<=j||e<i&&f>j);default:return!1}},a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(b,c){var
 
d=a.ui.ddmanager.droppables[b.options.scope]||[],e=c?c.type:null,f=(b.currentItem||b.element).find(":data(droppable)").andSelf();g:for(var
 
h=0;h<d.length;h++){if(d[h].options.disabled||b&&!d[h].accept.call(d[h].element[0],b.currentItem||b.element))continue;for(var
 
i=0;i<f.length;i++)if(f[i]==d[h].element[0]){d[h].proportions.height=0;continue 
g}d[h].visible=d[h].element.css("display")!="none";if(!d[h].visible)continue;e=="mousedown"&&d[h]._activate.call(d[h],c),d[h].offset=d[h].element.offset(),d[h].proportions={width:d[h].element[0].offsetWidth,height:d[h].element[0].offsetHeight}}},drop:function(b,c){var
 d=!1;return 
a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&a.ui.intersect(b,this,this.options.tolerance)&&(d=this._drop.call(this,c)||d),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],b.currentItem||b.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,c))}),d},dragStart:function(b,c){b.element.parents(":not(body,html)").bind("scroll.droppable",function(){b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)})},drag:function(b,c){b.options.refreshPositions&&a.ui.ddmanager.prepareOffsets(b,c),a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var
 
d=a.ui.intersect(b,this,this.options.tolerance),e=!d&&this.isover==1?"isout":d&&this.isover==0?"isover":null;if(!e)return;var
 f;if(this.options.greedy){var 
g=this.element.parents(":data(droppable):eq(0)");g.length&&(f=a.data(g[0],"droppable"),f.greedyChild=e=="isover"?1:0)}f&&e=="isover"&&(f.isover=0,f.isout=1,f._out.call(f,c)),this[e]=1,this[e=="isout"?"isover":"isout"]=0,this[e=="isover"?"_over":"_out"].call(this,c),f&&e=="isout"&&(f.isout=0,f.isover=1,f._over.call(f,c))})},dragStop:function(b,c){b.element.parents(":not(body,html)").unbind("scroll.droppable"),b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)}}})(jQuery);;/*!
 jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.resizable.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){a.widget("ui.resizable",a.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var
 
b=this,c=this.options;this.element.addClass("ui-resizable"),a.extend(this,{_aspectRatio:!!c.aspectRatio,aspectRatio:c.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:c.helper||c.ghost||c.animate?c.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(a('<div
 class="ui-wrapper" style="overflow: 
hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=c.handles||(a(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var
 d=this.handles.split(",");this.handles={};for(var e=0;e<d.length;e++){var 
f=a.trim(d[e]),g="ui-resizable-"+f,h=a('<div class="ui-resizable-handle 
'+g+'"></div>');h.css({zIndex:c.zIndex}),"se"==f&&h.addClass("ui-icon 
ui-icon-gripsmall-diagonal-se"),this.handles[f]=".ui-resizable-"+f,this.element.append(h)}}this._renderAxis=function(b){b=b||this.element;for(var
 c in 
this.handles){this.handles[c].constructor==String&&(this.handles[c]=a(this.handles[c],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var
 
d=a(this.handles[c],this.element),e=0;e=/sw|ne|nw|se|n|s/.test(c)?d.outerHeight():d.outerWidth();var
 
f=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join("");b.css(f,e),this._proportionallyResize()}if(!a(this.handles[c]).length)continue}},this._renderAxis(this.element),this._handles=a(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!b.resizing){if(this.className)var
 
a=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=a&&a[1]?a[1]:"se"}}),c.autoHide&&(this._handles.hide(),a(this.element).addClass("ui-resizable-autohide").hover(function(){if(c.disabled)return;a(this).removeClass("ui-resizable-autohide"),b._handles.show()},function(){if(c.disabled)return;b.resizing||(a(this).addClass("ui-resizable-autohide"),b._handles.hide())})),this._mouseInit()},destroy:function(){this._mouseDestroy();var
 b=function(b){a(b).removeClass("ui-resizable ui-resizable-disabled 
ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var
 
c=this.element;c.after(this.originalElement.css({position:c.css("position"),width:c.outerWidth(),height:c.outerHeight(),top:c.css("top"),left:c.css("left")})).remove()}return
 
this.originalElement.css("resize",this.originalResizeStyle),b(this.originalElement),this},_mouseCapture:function(b){var
 c=!1;for(var d in 
this.handles)a(this.handles[d])[0]==b.target&&(c=!0);return!this.options.disabled&&c},_mouseStart:function(b){var
 
d=this.options,e=this.element.position(),f=this.element;this.resizing=!0,this.documentScroll={top:a(document).scrollTop(),left:a(document).scrollLeft()},(f.is(".ui-draggable")||/absolute/.test(f.css("position")))&&f.css({position:"absolute",top:e.top,left:e.left}),this._renderProxy();var
 
g=c(this.helper.css("left")),h=c(this.helper.css("top"));d.containment&&(g+=a(d.containment).scrollLeft()||0,h+=a(d.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:g,top:h},this.size=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalSize=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalPosition={left:g,top:h},this.sizeDiff={width:f.outerWidth()-f.width(),height:f.outerHeight()-f.height()},this.originalMousePosition={left:b.pageX,top:b.pageY},this.aspectRatio=typeof
 
d.aspectRatio=="number"?d.aspectRatio:this.originalSize.width/this.originalSize.height||1;var
 i=a(".ui-resizable-"+this.axis).css("cursor");return 
a("body").css("cursor",i=="auto"?this.axis+"-resize":i),f.addClass("ui-resizable-resizing"),this._propagate("start",b),!0},_mouseDrag:function(b){var
 
c=this.helper,d=this.options,e={},f=this,g=this.originalMousePosition,h=this.axis,i=b.pageX-g.left||0,j=b.pageY-g.top||0,k=this._change[h];if(!k)return!1;var
 
l=k.apply(this,[b,i,j]),m=a.browser.msie&&a.browser.version<7,n=this.sizeDiff;this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)l=this._updateRatio(l,b);return
 
l=this._respectSize(l,b),this._propagate("resize",b),c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",b,this.ui()),!1},_mouseStop:function(b){this.resizing=!1;var
 c=this.options,d=this;if(this._helper){var 
e=this._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName),g=f&&a.ui.hasScroll(e[0],"left")?0:d.sizeDiff.height,h=f?0:d.sizeDiff.width,i={width:d.helper.width()-h,height:d.helper.height()-g},j=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,k=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;c.animate||this.element.css(a.extend(i,{top:k,left:j})),d.helper.height(d.size.height),d.helper.width(d.size.width),this._helper&&!c.animate&&this._proportionallyResize()}return
 
a("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",b),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(a){var
 
b=this.options,c,e,f,g,h;h={minWidth:d(b.minWidth)?b.minWidth:0,maxWidth:d(b.maxWidth)?b.maxWidth:Infinity,minHeight:d(b.minHeight)?b.minHeight:0,maxHeight:d(b.maxHeight)?b.maxHeight:Infinity};if(this._aspectRatio||a)c=h.minHeight*this.aspectRatio,f=h.minWidth/this.aspectRatio,e=h.maxHeight*this.aspectRatio,g=h.maxWidth/this.aspectRatio,c>h.minWidth&&(h.minWidth=c),f>h.minHeight&&(h.minHeight=f),e<h.maxWidth&&(h.maxWidth=e),g<h.maxHeight&&(h.maxHeight=g);this._vBoundaries=h},_updateCache:function(a){var
 
b=this.options;this.offset=this.helper.offset(),d(a.left)&&(this.position.left=a.left),d(a.top)&&(this.position.top=a.top),d(a.height)&&(this.size.height=a.height),d(a.width)&&(this.size.width=a.width)},_updateRatio:function(a,b){var
 c=this.options,e=this.position,f=this.size,g=this.axis;return 
d(a.height)?a.width=a.height*this.aspectRatio:d(a.width)&&(a.height=a.width/this.aspectRatio),g=="sw"&&(a.left=e.left+(f.width-a.width),a.top=null),g=="nw"&&(a.top=e.top+(f.height-a.height),a.left=e.left+(f.width-a.width)),a},_respectSize:function(a,b){var
 
c=this.helper,e=this._vBoundaries,f=this._aspectRatio||b.shiftKey,g=this.axis,h=d(a.width)&&e.maxWidth&&e.maxWidth<a.width,i=d(a.height)&&e.maxHeight&&e.maxHeight<a.height,j=d(a.width)&&e.minWidth&&e.minWidth>a.width,k=d(a.height)&&e.minHeight&&e.minHeight>a.height;j&&(a.width=e.minWidth),k&&(a.height=e.minHeight),h&&(a.width=e.maxWidth),i&&(a.height=e.maxHeight);var
 
l=this.originalPosition.left+this.originalSize.width,m=this.position.top+this.size.height,n=/sw|nw|w/.test(g),o=/nw|ne|n/.test(g);j&&n&&(a.left=l-e.minWidth),h&&n&&(a.left=l-e.maxWidth),k&&o&&(a.top=m-e.minHeight),i&&o&&(a.top=m-e.maxHeight);var
 p=!a.width&&!a.height;return 
p&&!a.left&&a.top?a.top=null:p&&!a.top&&a.left&&(a.left=null),a},_proportionallyResize:function(){var
 b=this.options;if(!this._proportionallyResizeElements.length)return;var 
c=this.helper||this.element;for(var 
d=0;d<this._proportionallyResizeElements.length;d++){var 
e=this._proportionallyResizeElements[d];if(!this.borderDif){var 
f=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],g=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];this.borderDif=a.map(f,function(a,b){var
 c=parseInt(a,10)||0,d=parseInt(g[b],10)||0;return 
c+d})}if(!a.browser.msie||!a(c).is(":hidden")&&!a(c).parents(":hidden").length)e.css({height:c.height()-this.borderDif[0]-this.borderDif[2]||0,width:c.width()-this.borderDif[1]-this.borderDif[3]||0});else
 continue}},_renderProxy:function(){var 
b=this.element,c=this.options;this.elementOffset=b.offset();if(this._helper){this.helper=this.helper||a('<div
 style="overflow:hidden;"></div>');var 
d=a.browser.msie&&a.browser.version<7,e=d?1:0,f=d?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+f,height:this.element.outerHeight()+f,position:"absolute",left:this.elementOffset.left-e+"px",top:this.elementOffset.top-e+"px",zIndex:++c.zIndex}),this.helper.appendTo("body").disableSelection()}else
 
this.helper=this.element},_change:{e:function(a,b,c){return{width:this.originalSize.width+b}},w:function(a,b,c){var
 
d=this.options,e=this.originalSize,f=this.originalPosition;return{left:f.left+b,width:e.width-b}},n:function(a,b,c){var
 
d=this.options,e=this.originalSize,f=this.originalPosition;return{top:f.top+c,height:e.height-c}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(b,c,d){return
 
a.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},sw:function(b,c,d){return
 
a.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,c,d]))},ne:function(b,c,d){return
 
a.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},nw:function(b,c,d){return
 
a.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,c,d]))}},_propagate:function(b,c){a.ui.plugin.call(this,b,[c,this.ui()]),b!="resize"&&this._trigger(b,c,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),a.extend(a.ui.resizable,{version:"1.8.20"}),a.ui.plugin.add("resizable","alsoResize",{start:function(b,c){var
 d=a(this).data("resizable"),e=d.options,f=function(b){a(b).each(function(){var 
b=a(this);b.data("resizable-alsoresize",{width:parseInt(b.width(),10),height:parseInt(b.height(),10),left:parseInt(b.css("left"),10),top:parseInt(b.css("top"),10)})})};typeof
 
e.alsoResize=="object"&&!e.alsoResize.parentNode?e.alsoResize.length?(e.alsoResize=e.alsoResize[0],f(e.alsoResize)):a.each(e.alsoResize,function(a){f(a)}):f(e.alsoResize)},resize:function(b,c){var
 
d=a(this).data("resizable"),e=d.options,f=d.originalSize,g=d.originalPosition,h={height:d.size.height-f.height||0,width:d.size.width-f.width||0,top:d.position.top-g.top||0,left:d.position.left-g.left||0},i=function(b,d){a(b).each(function(){var
 
b=a(this),e=a(this).data("resizable-alsoresize"),f={},g=d&&d.length?d:b.parents(c.originalElement[0]).length?["width","height"]:["width","height","top","left"];a.each(g,function(a,b){var
 c=(e[b]||0)+(h[b]||0);c&&c>=0&&(f[b]=c||null)}),b.css(f)})};typeof 
e.alsoResize=="object"&&!e.alsoResize.nodeType?a.each(e.alsoResize,function(a,b){i(a,b)}):i(e.alsoResize)},stop:function(b,c){a(this).removeData("resizable-alsoresize")}}),a.ui.plugin.add("resizable","animate",{stop:function(b,c){var
 
d=a(this).data("resizable"),e=d.options,f=d._proportionallyResizeElements,g=f.length&&/textarea/i.test(f[0].nodeName),h=g&&a.ui.hasScroll(f[0],"left")?0:d.sizeDiff.height,i=g?0:d.sizeDiff.width,j={width:d.size.width-i,height:d.size.height-h},k=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,l=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;d.element.animate(a.extend(j,l&&k?{top:l,left:k}:{}),{duration:e.animateDuration,easing:e.animateEasing,step:function(){var
 
c={width:parseInt(d.element.css("width"),10),height:parseInt(d.element.css("height"),10),top:parseInt(d.element.css("top"),10),left:parseInt(d.element.css("left"),10)};f&&f.length&&a(f[0]).css({width:c.width,height:c.height}),d._updateCache(c),d._propagate("resize",b)}})}}),a.ui.plugin.add("resizable","containment",{start:function(b,d){var
 e=a(this).data("resizable"),f=e.options,g=e.element,h=f.containment,i=h 
instanceof 
a?h.get(0):/parent/.test(h)?g.parent().get(0):h;if(!i)return;e.containerElement=a(i);if(/document/.test(h)||h==document)e.containerOffset={left:0,top:0},e.containerPosition={left:0,top:0},e.parentData={element:a(document),left:0,top:0,width:a(document).width(),height:a(document).height()||document.body.parentNode.scrollHeight};else{var
 
j=a(i),k=[];a(["Top","Right","Left","Bottom"]).each(function(a,b){k[a]=c(j.css("padding"+b))}),e.containerOffset=j.offset(),e.containerPosition=j.position(),e.containerSize={height:j.innerHeight()-k[3],width:j.innerWidth()-k[1]};var
 
l=e.containerOffset,m=e.containerSize.height,n=e.containerSize.width,o=a.ui.hasScroll(i,"left")?i.scrollWidth:n,p=a.ui.hasScroll(i)?i.scrollHeight:m;e.parentData={element:i,left:l.left,top:l.top,width:o,height:p}}},resize:function(b,c){var
 
d=a(this).data("resizable"),e=d.options,f=d.containerSize,g=d.containerOffset,h=d.size,i=d.position,j=d._aspectRatio||b.shiftKey,k={top:0,left:0},l=d.containerElement;l[0]!=document&&/static/.test(l.css("position"))&&(k=g),i.left<(d._helper?g.left:0)&&(d.size.width=d.size.width+(d._helper?d.position.left-g.left:d.position.left-k.left),j&&(d.size.height=d.size.width/d.aspectRatio),d.position.left=e.helper?g.left:0),i.top<(d._helper?g.top:0)&&(d.size.height=d.size.height+(d._helper?d.position.top-g.top:d.position.top),j&&(d.size.width=d.size.height*d.aspectRatio),d.position.top=d._helper?g.top:0),d.offset.left=d.parentData.left+d.position.left,d.offset.top=d.parentData.top+d.position.top;var
 
m=Math.abs((d._helper?d.offset.left-k.left:d.offset.left-k.left)+d.sizeDiff.width),n=Math.abs((d._helper?d.offset.top-k.top:d.offset.top-g.top)+d.sizeDiff.height),o=d.containerElement.get(0)==d.element.parent().get(0),p=/relative|absolute/.test(d.containerElement.css("position"));o&&p&&(m-=d.parentData.left),m+d.size.width>=d.parentData.width&&(d.size.width=d.parentData.width-m,j&&(d.size.height=d.size.width/d.aspectRatio)),n+d.size.height>=d.parentData.height&&(d.size.height=d.parentData.height-n,j&&(d.size.width=d.size.height*d.aspectRatio))},stop:function(b,c){var
 
d=a(this).data("resizable"),e=d.options,f=d.position,g=d.containerOffset,h=d.containerPosition,i=d.containerElement,j=a(d.helper),k=j.offset(),l=j.outerWidth()-d.sizeDiff.width,m=j.outerHeight()-d.sizeDiff.height;d._helper&&!e.animate&&/relative/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m}),d._helper&&!e.animate&&/static/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m})}}),a.ui.plugin.add("resizable","ghost",{start:function(b,c){var
 
d=a(this).data("resizable"),e=d.options,f=d.size;d.ghost=d.originalElement.clone(),d.ghost.css({opacity:.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof
 
e.ghost=="string"?e.ghost:""),d.ghost.appendTo(d.helper)},resize:function(b,c){var
 
d=a(this).data("resizable"),e=d.options;d.ghost&&d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})},stop:function(b,c){var
 
d=a(this).data("resizable"),e=d.options;d.ghost&&d.helper&&d.helper.get(0).removeChild(d.ghost.get(0))}}),a.ui.plugin.add("resizable","grid",{resize:function(b,c){var
 
d=a(this).data("resizable"),e=d.options,f=d.size,g=d.originalSize,h=d.originalPosition,i=d.axis,j=e._aspectRatio||b.shiftKey;e.grid=typeof
 e.grid=="number"?[e.grid,e.grid]:e.grid;var 
k=Math.round((f.width-g.width)/(e.grid[0]||1))*(e.grid[0]||1),l=Math.round((f.height-g.height)/(e.grid[1]||1))*(e.grid[1]||1);/^(se|s|e)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l):/^(ne)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l):/^(sw)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.left=h.left-k):(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l,d.position.left=h.left-k)}});var
 c=function(a){return 
parseInt(a,10)||0},d=function(a){return!isNaN(parseInt(a,10))}})(jQuery);;/*! 
jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.selectable.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
+(function(a,b){a.widget("ui.selectable",a.ui.mouse,{options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var
 b=this;this.element.addClass("ui-selectable"),this.dragged=!1;var 
c;this.refresh=function(){c=a(b.options.filter,b.element[0]),c.addClass("ui-selectee"),c.each(function(){var
 
b=a(this),c=b.offset();a.data(this,"selectable-item",{element:this,$element:b,left:c.left,top:c.top,right:c.left+b.outerWidth(),bottom:c.top+b.outerHeight(),startselected:!1,selected:b.hasClass("ui-selected"),selecting:b.hasClass("ui-selecting"),unselecting:b.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=c.addClass("ui-selectee"),this._mouseInit(),this.helper=a("<div
 class='ui-selectable-helper'></div>")},destroy:function(){return 
this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable
 
ui-selectable-disabled").removeData("selectable").unbind(".selectable"),this._mouseDestroy(),this},_mouseStart:function(b){var
 c=this;this.opos=[b.pageX,b.pageY];if(this.options.disabled)return;var 
d=this.options;this.selectees=a(d.filter,this.element[0]),this._trigger("start",b),a(d.appendTo).append(this.helper),this.helper.css({left:b.clientX,top:b.clientY,width:0,height:0}),d.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var
 
d=a.data(this,"selectable-item");d.startselected=!0,!b.metaKey&&!b.ctrlKey&&(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",b,{unselecting:d.element}))}),a(b.target).parents().andSelf().each(function(){var
 d=a.data(this,"selectable-item");if(d){var 
e=!b.metaKey&&!b.ctrlKey||!d.$element.hasClass("ui-selected");return 
d.$element.removeClass(e?"ui-unselecting":"ui-selected").addClass(e?"ui-selecting":"ui-unselecting"),d.unselecting=!e,d.selecting=e,d.selected=e,e?c._trigger("selecting",b,{selecting:d.element}):c._trigger("unselecting",b,{unselecting:d.element}),!1}})},_mouseDrag:function(b){var
 c=this;this.dragged=!0;if(this.options.disabled)return;var 
d=this.options,e=this.opos[0],f=this.opos[1],g=b.pageX,h=b.pageY;if(e>g){var 
i=g;g=e,e=i}if(f>h){var i=h;h=f,f=i}return 
this.helper.css({left:e,top:f,width:g-e,height:h-f}),this.selectees.each(function(){var
 i=a.data(this,"selectable-item");if(!i||i.element==c.element[0])return;var 
j=!1;d.tolerance=="touch"?j=!(i.left>g||i.right<e||i.top>h||i.bottom<f):d.tolerance=="fit"&&(j=i.left>e&&i.right<g&&i.top>f&&i.bottom<h),j?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,c._trigger("selecting",b,{selecting:i.element}))):(i.selecting&&((b.metaKey||b.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),c._trigger("unselecting",b,{unselecting:i.element}))),i.selected&&!b.metaKey&&!b.ctrlKey&&!i.startselected&&(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,c._trigger("unselecting",b,{unselecting:i.element})))}),!1},_mouseStop:function(b){var
 c=this;this.dragged=!1;var d=this.options;return 
a(".ui-unselecting",this.element[0]).each(function(){var 
d=a.data(this,"selectable-item");d.$element.removeClass("ui-unselecting"),d.unselecting=!1,d.startselected=!1,c._trigger("unselected",b,{unselected:d.element})}),a(".ui-selecting",this.element[0]).each(function(){var
 
d=a.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass("ui-selected"),d.selecting=!1,d.selected=!0,d.startselected=!0,c._trigger("selected",b,{selected:d.element})}),this._trigger("stop",b),this.helper.remove(),!1}}),a.extend(a.ui.selectable,{version:"1.8.20"})})(jQuery);;/*!
 jQuery UI - v1.8.20 - 2012-04-30
+* https://github.com/jquery/jquery-ui
+* Includes: jquery.ui.sortable.js
+* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */

@@ Diff output truncated at 153600 characters. @@



reply via email to

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