fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [14778] controller integration


From: Sigurd Nes
Subject: [Fmsystem-commits] [14778] controller integration
Date: Sat, 27 Feb 2016 23:37:23 +0000

Revision: 14778
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14778
Author:   sigurdne
Date:     2016-02-27 23:36:06 +0000 (Sat, 27 Feb 2016)
Log Message:
-----------
controller integration

Modified Paths:
--------------
    trunk/controller/inc/class.socheck_list.inc.php
    trunk/phpgwapi/js/jquery/common.js
    trunk/property/inc/class.uientity.inc.php
    trunk/property/js/portico/entity.edit.js
    trunk/property/templates/base/entity.xsl

Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php     2016-02-27 15:43:46 UTC 
(rev 14777)
+++ trunk/controller/inc/class.socheck_list.inc.php     2016-02-27 23:36:06 UTC 
(rev 14778)
@@ -485,6 +485,26 @@
                        return $controls_array;
                }
 
+               function get_start_and_end_for_component( $location_id, 
$component_id )
+               {
+                       $location_id = (int)$location_id;
+                       $component_id = (int)$component_id;
+
+                       $sql = "SELECT  MIN(deadline) AS start_timestamp, 
MAX(deadline) AS end_timestamp"
+                               . " FROM controller_check_list"
+                               . " WHERE location_id = {$location_id}"
+                               . " AND component_id = {$component_id}";
+
+                       $this->db->query($sql);
+                       $this->db->next_record();
+                       
+                       return array(
+                               'start_timestamp' => 
$this->db->f('start_timestamp'),
+                               'end_timestamp' => 
$this->db->f('end_timestamp'),
+                       );
+
+               }
+
                /**
                 * Get array with check lists for a component within time 
period and for a specified repeat type
                 *

Modified: trunk/phpgwapi/js/jquery/common.js
===================================================================
--- trunk/phpgwapi/js/jquery/common.js  2016-02-27 15:43:46 UTC (rev 14777)
+++ trunk/phpgwapi/js/jquery/common.js  2016-02-27 23:36:06 UTC (rev 14778)
@@ -12,122 +12,137 @@
 JqueryPortico.inlineTablesDefined = 0;
 JqueryPortico.inlineTablesRendered = 0;
 
-JqueryPortico.formatLink = function (key, oData) {
-        
+JqueryPortico.formatLink = function (key, oData)
+{
+
        var name = oData[key];
        var link = oData['link'];
        return '<a href="' + link + '">' + name + '</a>';
 };
 
-JqueryPortico.formatLinkEvent = function (key, oData) {
+JqueryPortico.formatLinkEvent = function (key, oData)
+{
 
-    var name = 'Link';
-    var link = oData['url'];
-    return '<a href="' + link + '">' + name + '</a>';
+       var name = 'Link';
+       var link = oData['url'];
+       return '<a href="' + link + '">' + name + '</a>';
 }
 
-JqueryPortico.formatLinkTenant = function (key, oData) {
-        
+JqueryPortico.formatLinkTenant = function (key, oData)
+{
+
        var id = oData[key];
-       var strURL = phpGWLink('index.php', 
{menuaction:"property.uiworkorder.edit", id: id});
+       var strURL = phpGWLink('index.php', {menuaction: 
"property.uiworkorder.edit", id: id});
        return '<a href="' + strURL + '">' + id + '</a>';
 };
 
-JqueryPortico.formatProject = function (key, oData) {
+JqueryPortico.formatProject = function (key, oData)
+{
        var name = oData[key];
        var link = oData['link'];
        return '<a href="' + link + '&id=' + name + '">' + name + '</a>';
 }
 
-JqueryPortico.formatLinkGallery = function (key, oData) {
-     
-        var name = 'Link';
+JqueryPortico.formatLinkGallery = function (key, oData)
+{
+
+       var name = 'Link';
        var link = oData[key];
-       return '<a href="' + link + '" target="_blank">' + name + '</a>'; 
+       return '<a href="' + link + '" target="_blank">' + name + '</a>';
 }
 
-JqueryPortico.formatLinkGeneric = function (key, oData) {
-        
+JqueryPortico.formatLinkGeneric = function (key, oData)
+{
+
        if (!oData[key])
        {
                return '';
        }
-            
+
        var data = oData[key];
-       if (key == 'opcion_edit') {
-                var link = data;
-                var name = 'Edit';
-        }
-       else if (key == 'opcion_delete') {
-                var link = data;
-                var name = 'Delete';
-        }
+       if (key == 'opcion_edit')
+       {
+               var link = data;
+               var name = 'Edit';
+       }
+       else if (key == 'opcion_delete')
+       {
+               var link = data;
+               var name = 'Delete';
+       }
        else if (key == 'actions')
-        {
-                var link = data;
-                var name = 'Delete';
-        }
+       {
+               var link = data;
+               var name = 'Delete';
+       }
        else if (typeof (data) == 'object')
        {
                var link = data['href'];
                var name = data['label'];
        }
-        else
+       else
        {
                var name = 'Link';
                var link = data;
        }
-       if (link) {
-       return '<a href="' + link + '">' + name + '</a>';
-       } else {
+       if (link)
+       {
+               return '<a href="' + link + '">' + name + '</a>';
+       }
+       else
+       {
                return name;
        }
 
 };
 
-JqueryPortico.formatLinkGenericLlistAttribute = function (key, oData) {
-        
+JqueryPortico.formatLinkGenericLlistAttribute = function (key, oData)
+{
+
        var link = oData['link'];
-        var type = oData['link'].split(".");
-        
-        var resort = '';
+       var type = oData['link'].split(".");
+
+       var resort = '';
        if (key == 'up')
-        {
-            resort = 'up';
-        }
-        else
-        {
-            resort = 'down';
-        }
-        
+       {
+               resort = 'up';
+       }
+       else
+       {
+               resort = 'down';
+       }
+
        if (type[2] == 'uiadmin_entity' || type[2] == 'ui_custom')
-        {
+       {
                var url = "'" + link + '&resort=' + resort + "'";
        }
        else
-        {
+       {
                var url = "'" + link + '&resort=' + resort + "',''";
-        }
-        
+       }
+
        return '<a href="#" onclick="JqueryPortico.move_record(' + url + ')">' 
+ key + '</a>';
 };
 
 JqueryPortico.move_record = function (sUrl)
-{   
-    var baseUrl = sUrl + "&confirm=yes&phpgw_return_as=json";
-       $.post(baseUrl, function (data) {
-        oTable.fnDraw();
-     });
+{
+       var baseUrl = sUrl + "&confirm=yes&phpgw_return_as=json";
+       $.post(baseUrl, function (data)
+       {
+               oTable.fnDraw();
+       });
 };
 
-JqueryPortico.searchLink = function (key, oData) {
+JqueryPortico.searchLink = function (key, oData)
+{
        var name = oData[key];
        var link = oData['query_location'][key];
 
        return '<a id="' + link + '" onclick="searchData(this.id);">' + name + 
'</a>';
 };
 
-JqueryPortico.formatCheck = function (key, oData) {
+JqueryPortico.formatCheck = function (key, oData)
+{
        var checked = '';
        var hidden = '';
        if (oData['responsible_item'])
@@ -146,31 +161,35 @@
 //        return hidden + "<center><input type=\"checkbox\" class=\"mychecks\" 
 name=\"values[events]["+oData['id']+"_"+oData['schedule_time']+"]\" 
value=\""+oData['id']+"\"/></center>";
 //}
 
-JqueryPortico.formatCheckUis_agremment = function (key, oData) {
-    
-        var checked = '';
+JqueryPortico.formatCheckUis_agremment = function (key, oData)
+{
+
+       var checked = '';
        var hidden = '';
-        
+
        return hidden + "<center><input type=\"checkbox\" " + checked + " 
class=\"mychecks\"  name=\"values[alarm][" + oData['id'] + "]\" value=\"\" 
/></center>";
 };
 
-JqueryPortico.formatCheckCustom = function (key, oData) {
-    
-        var checked = '';
+JqueryPortico.formatCheckCustom = function (key, oData)
+{
+
+       var checked = '';
        var hidden = '';
 
        return hidden + "<center><input type=\"checkbox\" " + checked + " 
class=\"mychecks\"  name=\"values[delete][]\" value=\"" + oData['id'] + "\" 
onMouseout=\"window.status='';return true;\" /></center>";
 };
 
-JqueryPortico.formatUpDown = function (key, oData) {
-    
-  var linkUp = oData['link_up'];
-  var linkDown = oData['link_down'];
-  
-  return '<a href="' + linkUp + '">up</a> | <a href="' + linkDown + 
'">down</a>';
-}; 
+JqueryPortico.formatUpDown = function (key, oData)
+{
 
-JqueryPortico.formatRadio = function (key, oData) {
+       var linkUp = oData['link_up'];
+       var linkDown = oData['link_down'];
+
+       return '<a href="' + linkUp + '">up</a> | <a href="' + linkDown + 
'">down</a>';
+};
+
+JqueryPortico.formatRadio = function (key, oData)
+{
        var checked = '';
        var hidden = '';
        return hidden + "<center><input type=\"radio\" name=\"rad_template\" 
class=\"myValuesForPHP\" value=\"" + oData['template_id'] + "\" /></center>";
@@ -182,53 +201,58 @@
        if (oData['img_id'])
        {
                var img_name = oData['file_name'];
-               var img_id       = oData['img_id'];
-               var img_url  = oData['img_url'];
+               var img_id = oData['img_id'];
+               var img_url = oData['img_url'];
                var thumbnail_flag = oData['thumbnail_flag'];
                link = "<a href='" + img_url + "' title='" + img_name + "' 
id='" + img_id + "' target='_blank'><img src='" + img_url + "&" + 
thumbnail_flag + "' alt='" + img_name + "' /></a>";
-       } 
+       }
        return link;
 };
-       
-JqueryPortico.FormatterAmount0 = function (key, oData) {
 
+JqueryPortico.FormatterAmount0 = function (key, oData)
+{
+
        var amount = $.number(oData[key], 0, ',', ' ');
        return amount;
 };
 
-JqueryPortico.FormatterAmount2 = function (key, oData) {
+JqueryPortico.FormatterAmount2 = function (key, oData)
+{
 
        var amount = $.number(oData[key], 2, ',', ' ');
        return amount;
 };
-       
-JqueryPortico.FormatterRight = function (key, oData) {
+
+JqueryPortico.FormatterRight = function (key, oData)
+{
        return "<div align=\"right\">" + oData[key] + "</div>";
 };
 
-JqueryPortico.FormatterCenter = function (key, oData) {
+JqueryPortico.FormatterCenter = function (key, oData)
+{
        return "<center>" + oData[key] + "</center>";
 };
 
-JqueryPortico.inlineTableHelper = function (container, ajax_url, columns, 
options, data) {
+JqueryPortico.inlineTableHelper = function (container, ajax_url, columns, 
options, data)
+{
 
        options = options || {};
-       var disablePagination   = options['disablePagination'] || false;
-       var disableFilter               = options['disableFilter'] || false;
+       var disablePagination = options['disablePagination'] || false;
+       var disableFilter = options['disableFilter'] || false;
        var buttons_def = options['TableTools'] || false;
        var select = false;
        var singleSelect = options['singleSelect'] || false;
-       var order                               = options['order'] || [0, 
'desc'];
+       var order = options['order'] || [0, 'desc'];
        var responsive = options['responsive'] || false;
        var initial_search = options['initial_search'] || false;
        var editor_action = options['editor_action'] || false;
        var editor_cols = [];
 
-       for(i=0;i < columns.length;i++)
+       for (i = 0; i < columns.length; i++)
        {
                if (columns[i]['editor'] === true)
                {
-                       editor_cols.push({sUpdateURL:editor_action + 
'&field_name=' + columns[i]['data']});
+                       editor_cols.push({sUpdateURL: editor_action + 
'&field_name=' + columns[i]['data']});
                }
                else
                {
@@ -241,7 +265,7 @@
        {
                lengthMenu = JqueryPortico.i18n.lengthmenu();
        }
-       catch(err)
+       catch (err)
        {
                lengthMenu = [10, 25, 50, 100];
        }
@@ -269,13 +293,13 @@
                var sDom_def = 'B<"clear">lfrtip';
 //             var sDom_def = 'Bfrtlip';
                var sDom_def = '<lfB<t>ip>'
-               if(singleSelect == true)
+               if (singleSelect == true)
                {
                        select = true;
                }
                else
                {
-                       select = {style:'multi'};
+                       select = {style: 'multi'};
                }
        }
        else
@@ -284,114 +308,124 @@
        }
 //     $(document).ready(function ()
 //     {
-               JqueryPortico.inlineTablesRendered += 1;
+       JqueryPortico.inlineTablesRendered += 1;
 
-               var oTable = $("#" + container).dataTable({
-                       paginate:               disablePagination ? false : 
true,
-                       filter:                 disableFilter ? false : true,
-                       info:                   disableFilter ? false : true,
-                       order:                  order,
-                       processing:             true,
-                       serverSide:             serverSide_def,
+       var oTable = $("#" + container).dataTable({
+               paginate: disablePagination ? false : true,
+               filter: disableFilter ? false : true,
+               info: disableFilter ? false : true,
+               order: order,
+               processing: true,
+               serverSide: serverSide_def,
                responsive: responsive,
-                       deferRender:    true,
+               deferRender: true,
                select: select,
-                       data:                   data,
-                       ajax:                   ajax_def,
-               fnServerParams: function (aoData) {
+               data: data,
+               ajax: ajax_def,
+               fnServerParams: function (aoData)
+               {
                        if (typeof (aoData.order) != 'undefined')
-                               {
-                                       var column = aoData.order[0].column;
-                                       var dir = aoData.order[0].dir;
-                                       var column_to_keep = 
aoData.columns[column];
-                                       delete aoData.columns;
-                                       aoData.columns = {};
-                                       aoData.columns[column] = column_to_keep;
-                               }
-                        },
-                       fnInitComplete: function (oSettings, json)
                        {
+                               var column = aoData.order[0].column;
+                               var dir = aoData.order[0].dir;
+                               var column_to_keep = aoData.columns[column];
+                               delete aoData.columns;
+                               aoData.columns = {};
+                               aoData.columns[column] = column_to_keep;
+                       }
+               },
+               fnInitComplete: function (oSettings, json)
+               {
                        /*if(JqueryPortico.inlineTablesRendered == 
JqueryPortico.inlineTablesDefined)
-                               {
-                                       if(typeof(JqueryPortico.render_tabs) == 
'function')
-                                       {
+                        {
+                        if(typeof(JqueryPortico.render_tabs) == 'function')
+                        {
                         var delay=15;//allow extra 350 milliseconds to really 
finish
-                                               setTimeout(function()
-                                               {
-                                                       
JqueryPortico.render_tabs();
+                        setTimeout(function()
+                        {
+                        JqueryPortico.render_tabs();
                         alert(JqueryPortico.inlineTablesRendered);
 
-                                               },delay);
-                                       }
+                        },delay);
+                        }
                         }*/
-                       },
-                       lengthMenu:             lengthMenu,
+               },
+               lengthMenu: lengthMenu,
                //      language:               JqueryPortico.i18n.datatable(),
-                       columns: columns,
+               columns: columns,
                //      stateSave:              true,
                //      stateDuration: -1, //sessionstorage
                //      tabIndex:               1,
-                       fnDrawCallback: function () {
-                       if(typeof(oTable) != 'undefined')
+               fnDrawCallback: function ()
+               {
+                       if (typeof (oTable) != 'undefined')
                        {
                                oTable.makeEditable({
                                        sUpdateURL: editor_action,
-                                       fnOnEditing: function(input){
+                                       fnOnEditing: function (input)
+                                       {
                                                var iPos = 
input.closest("tr").prevAll().length;
-                                               var aData = oTable.fnGetData( 
iPos );
+                                               var aData = 
oTable.fnGetData(iPos);
                                                id = aData['id'];
                                                cell = input.parents("td");
                                                return true;
                                        },
-                                       fnOnEdited: function(status, sOldValue, 
sNewCellDisplayValue, aPos0, aPos1, aPos2)
+                                       fnOnEdited: function (status, 
sOldValue, sNewCellDisplayValue, aPos0, aPos1, aPos2)
                                        {
                                                
//document.getElementById("message").innerHTML += '<br/>' + status;
                                        },
                                        oUpdateParameters: {
-                                               "id": function(){ return id; }
+                                               "id": function ()
+                                               {
+                                                       return id;
+                                               }
                                        },
                                        aoColumns: editor_cols,
                                        sSuccessResponse: "IGNORE",
-                                       fnShowError: function(){ return; }
+                                       fnShowError: function ()
+                                       {
+                                               return;
+                                       }
                                });
                        }
-                       if(typeof(addFooterDatatable) == 'function')
+                       if (typeof (addFooterDatatable) == 'function')
                        {
                                addFooterDatatable(oTable);
                        }
-                                       try
-                                       {
-                                               window['local_DrawCallback' + 
JqueryPortico.inlineTablesRendered](oTable);
-                                       }
+                       try
+                       {
+                               window['local_DrawCallback' + 
JqueryPortico.inlineTablesRendered](oTable);
+                       }
                        catch (err)
-                                       {
-                                               //nothing
-                                       }
-                       },
-                       sDom: sDom_def,
+                       {
+                               //nothing
+                       }
+               },
+               sDom: sDom_def,
                buttons: buttons_def,
                search: initial_search
-               });
-       $("#" + container + ' tbody').on( 'click', 'tr', function () {
-                       var api = oTable.api();
-                       var selectedRows = api.rows( { selected: true } 
).count();
-                       api.buttons( '.record' ).enable( selectedRows > 0 );
+       });
+       $("#" + container + ' tbody').on('click', 'tr', function ()
+       {
+               var api = oTable.api();
+               var selectedRows = api.rows({selected: true}).count();
+               api.buttons('.record').enable(selectedRows > 0);
 
-                       var row = $(this);
-                       var checkbox = row.find('input[type="checkbox"]');
+               var row = $(this);
+               var checkbox = row.find('input[type="checkbox"]');
 
-                       if(checkbox && checkbox.hasClass('mychecks'))
+               if (checkbox && checkbox.hasClass('mychecks'))
+               {
+                       if ($(this).hasClass('selected'))
                        {
-                               if($(this).hasClass('selected'))
-                               {
-                                       checkbox.prop("checked", true);
-                               }
-                               else
-                               {
-                                       checkbox.prop("checked", false);
-                               }
+                               checkbox.prop("checked", true);
                        }
-        } );
+                       else
+                       {
+                               checkbox.prop("checked", false);
+                       }
+               }
+       });
 
 
 //     });
@@ -417,6 +451,7 @@
                var api = _oTable.api();
                api.ajax.url(requestUrl).load();
        }
+       return _oTable;
 };
 
 JqueryPortico.fnGetSelected = function (oTable)
@@ -439,21 +474,23 @@
 
        if (typeof (result.message) !== 'undefined')
        {
-               $.each(result.message, function (k, v) {
+               $.each(result.message, function (k, v)
+               {
                        document.getElementById('message' + n).innerHTML += 
v.msg + '<br/>';
                });
        }
 
        if (typeof (result.error) !== 'undefined')
        {
-               $.each(result.error, function (k, v) {
+               $.each(result.error, function (k, v)
+               {
                        document.getElementById('message' + n).innerHTML += 
v.msg + '<br/>';
                });
        }
 };
 
 JqueryPortico.execute_ajax = function (requestUrl, callback, data, type, 
dataType)
-{                                       
+{
        type = typeof type !== 'undefined' ? type : 'POST';
        dataType = typeof dataType !== 'undefined' ? dataType : 'html';
        data = typeof data !== 'undefined' ? data : {};
@@ -495,14 +532,16 @@
        }
        return cnt;
 };
-               
-               
-JqueryPortico.autocompleteHelper = function (baseUrl, field, hidden, 
container, label_attr) {
+
+
+JqueryPortico.autocompleteHelper = function (baseUrl, field, hidden, 
container, label_attr)
+{
        label_attr = (label_attr) ? label_attr : 'name';
-       $(document).ready(function () 
+       $(document).ready(function ()
        {
                $("#" + field).autocomplete({
-                       source: function (request, response) {
+                       source: function (request, response)
+                       {
                                //console.log(request.term);
                                $.ajax({
                                        url: baseUrl,
@@ -512,14 +551,19 @@
                                                query: request.term,
                                                phpgw_return_as: "json"
                                        },
-                                       success: function (data) {
+                                       success: function (data)
+                                       {
                                                var data_t = "";
-                                               if (data.ResultSet) {
+                                               if (data.ResultSet)
+                                               {
                                                        data_t = 
data.ResultSet.Result;
-                                               } else if (data.data) {
+                                               }
+                                               else if (data.data)
+                                               {
                                                        data_t = data.data;
                                                }
-                                               response($.map(data_t, function 
(item) {
+                                               response($.map(data_t, function 
(item)
+                                               {
                                                        return {
                                                                label: 
item[label_attr],
                                                                value: item.id
@@ -528,34 +572,38 @@
                                        }
                                });
                        },
-                       focus: function (event, ui) {
+                       focus: function (event, ui)
+                       {
                                $(event.target).val(ui.item.label);
                                return false;
                        },
                        minLength: 1,
-                       select: function (event, ui) {
+                       select: function (event, ui)
+                       {
                                $("#" + hidden).val(ui.item.value);
                                // have to wait to set the value
-                               setTimeout(function () {
+                               setTimeout(function ()
+                               {
                                        $("#" + field).val(ui.item.label);
                                }, 1);
                        }
-        });
+               });
        });
 
 
-};     
+};
 
 JqueryPortico.openPopup = function (oArgs, options)
 {
-               options = options || {};
-               var width = options['width'] || 750;
-               var height = options['height'] || 450;
-               var closeAction = options['closeAction'] || false;
-               
+       options = options || {};
+       var width = options['width'] || 750;
+       var height = options['height'] || 450;
+       var closeAction = options['closeAction'] || false;
 
-               var requestUrl = phpGWLink('index.php', oArgs);
-       TINY.box.show({iframe: requestUrl, boxid: 'frameless', width: width, 
height: height, fixed: false, maskid: 'darkmask', maskopacity: 40, mask: true, 
animate: true, close: true, closejs: function () {
+
+       var requestUrl = phpGWLink('index.php', oArgs);
+       TINY.box.show({iframe: requestUrl, boxid: 'frameless', width: width, 
height: height, fixed: false, maskid: 'darkmask', maskopacity: 40, mask: true, 
animate: true, close: true, closejs: function ()
+               {
                        JqueryPortico.onPopupClose(closeAction);
                }});
 };
@@ -563,24 +611,24 @@
 JqueryPortico.onPopupClose = function (closeAction)
 {
        if (closeAction == 'reload')
-               {
-                       location.reload();
-               }
+       {
+               location.reload();
+       }
        if (closeAction == 'close')
+       {
+               TINY.box.hide();
+
+               if (typeof (afterPopupClose) == 'function')
                {
-                       TINY.box.hide();
-                       
-               if (typeof (afterPopupClose) == 'function')
-                       {
-                               afterPopupClose();
-                       }
+                       afterPopupClose();
                }
+       }
 };
 
 JqueryPortico.lightboxlogin = function ()
 {
        var oArgs = {lightbox: 1};
-               var strURL = phpGWLink('login.php', oArgs);
+       var strURL = phpGWLink('login.php', oArgs);
        TINY.box.show({iframe: strURL, boxid: 'frameless', width: 
$(window).width(), height: 400, fixed: false, maskid: 'darkmask', maskopacity: 
40, mask: true, animate: true, close: false, closejs: false});
 };
 
@@ -592,87 +640,100 @@
 JqueryPortico.checkAll = function (myclass)
 {
        $("." + myclass).each(function ()
+       {
+               if ($(this).prop("checked"))
                {
-               if ($(this).prop("checked"))
-                       {
-                               $(this).prop("checked", false);
-                       }
-                       else
-                       {
-                               $(this).prop("checked", true);
-                       }
-               });
+                       $(this).prop("checked", false);
+               }
+               else
+               {
+                       $(this).prop("checked", true);
+               }
+       });
 }
 
 JqueryPortico.CreateRowChecked = function (Class)
 {
-               //create the anchor node
+       //create the anchor node
        myA = document.createElement("A");
        url = "javascript:JqueryPortico.checkAll(\"" + Class + "\")";
        myA.setAttribute("href", url);
-               //create the image node
-               url = "property/templates/portico/images/check.png";
+       //create the image node
+       url = "property/templates/portico/images/check.png";
        myImg = document.createElement("IMG");
        myImg.setAttribute("src", url);
        myImg.setAttribute("width", "16");
        myImg.setAttribute("height", "16");
        myImg.setAttribute("border", "0");
        myImg.setAttribute("alt", "Select All");
-               // Appends the image node to the anchor
-               myA.appendChild(myImg);
-               // Appends myA to mydiv
+       // Appends the image node to the anchor
+       myA.appendChild(myImg);
+       // Appends myA to mydiv
        mydiv = document.createElement("div");
        mydiv.setAttribute("align", "center");
-               mydiv.appendChild(myA);
-               return mydiv;
+       mydiv.appendChild(myA);
+       return mydiv;
 }
 
 
 
-function updateTablePaginator(p, m) {
+function updateTablePaginator(p, m)
+{
        var paginator = p;
 
-       if (paginator.limit == 0) {
+       if (paginator.limit == 0)
+       {
                return;
        }
 
        paginator.start += m;
        var e = 0;
 
-       if (paginator.start < 0) {
+       if (paginator.start < 0)
+       {
                paginator.start = 0;
                e++;
        }
-       if ((paginator.start) > paginator.max) {
+       if ((paginator.start) > paginator.max)
+       {
                paginator.start -= m;
                e++;
        }
 
-       if ((paginator.start - Math.abs(m)) < 0) {
+       if ((paginator.start - Math.abs(m)) < 0)
+       {
                paginator.tablePaginatorPrevButton.classList.add('disabled');
                paginator.tablePaginatorPrevButton.classList.remove('enabled');
-       } else {
+       }
+       else
+       {
                paginator.tablePaginatorPrevButton.classList.remove('disabled');
                paginator.tablePaginatorPrevButton.classList.add('enabled');
        }
 
-       if ((paginator.start + Math.abs(m)) > paginator.max) {
+       if ((paginator.start + Math.abs(m)) > paginator.max)
+       {
                paginator.tablePaginatorNextButton.classList.add('disabled');
                paginator.tablePaginatorNextButton.classList.remove('enabled');
-       } else {
+       }
+       else
+       {
                paginator.tablePaginatorNextButton.classList.remove('disabled');
                paginator.tablePaginatorNextButton.classList.add('enabled');
        }
 
-       if (e > 0) {
+       if (e > 0)
+       {
                return;
        }
        createTable(paginator.container, paginator.url, paginator.col, 
paginator.r, paginator.class, paginator);
 }
 
-function createPaginatorTable(c, p) {
+function createPaginatorTable(c, p)
+{
        var paginator = p;
-       if (!paginator.limit) {
+       if (!paginator.limit)
+       {
                paginator.limit = 0;
        }
 
@@ -710,15 +771,18 @@
        paginator.tablePaginatorPrevButton = tablePaginatorPrevButton;
        paginator.tablePaginatorNextButton = tablePaginatorNextButton;
 
-       if (!paginator.start) {
+       if (!paginator.start)
+       {
                paginator.start = 0;
        }
 
-       tablePaginatorPrevButton.addEventListener('click', function () {
+       tablePaginatorPrevButton.addEventListener('click', function ()
+       {
                updateTablePaginator(paginator, (parseInt(paginator.limit) * 
-1));
        }, false);
 
-       tablePaginatorNextButton.addEventListener('click', function () {
+       tablePaginatorNextButton.addEventListener('click', function ()
+       {
                updateTablePaginator(paginator, parseInt(paginator.limit));
        }, false);
 
@@ -732,13 +796,15 @@
 //r  => respuesta
 //cl => clase
 //l  => limit
-function createTable(d, u, c, r, cl, l) {
+function createTable(d, u, c, r, cl, l)
+{
        var container = document.getElementById(d);
        var xTable = document.createElement('table');
        var tableHead = document.createElement('thead');
        var tableHeadTr = document.createElement('tr');
 
-       if (!container) {
+       if (!container)
+       {
                return;
        }
 
@@ -747,12 +813,15 @@
 
        xTable.setAttribute('class', tableClass);
 
-       $.each(c, function (i, v) {
+       $.each(c, function (i, v)
+       {
                var label = (v.label) ? v.label : "";
                var tableHeadTrTh = document.createElement('th');
                tableHeadTrTh.innerHTML = label;
-               if (v.attrs) {
-                       $.each(v.attrs, function (i, v) {
+               if (v.attrs)
+               {
+                       $.each(v.attrs, function (i, v)
+                       {
                                tableHeadTrTh.setAttribute(v.name, v.value);
                        });
                }
@@ -774,7 +843,8 @@
        $("#" + d + " span.select_first_text").remove();
        $("#" + d + " table").remove();
 
-       if (l) {
+       if (l)
+       {
                l.container = d;
                l.url = u;
                l.col = c;
@@ -785,75 +855,103 @@
 
        container.appendChild(xTable);
 
-       $.get(u, function (data) {
+       $.get(u, function (data)
+       {
                var selected = new Array();
                var totalResults = "";
-               if (typeof (r) == 'object') {
+               if (typeof (r) == 'object')
+               {
                        selected = data;
-                       $.each(r, function (i, e) {
+                       $.each(r, function (i, e)
+                       {
                                selected = selected[e['n']];
                        });
                        totalResults = data.ResultSet.totalRecords;
-               } else {
+               }
+               else
+               {
                        selected = data[r];
                        totalResults = data['recordsTotal'];
                }
 
-               if (!selected) {
+               if (!selected)
+               {
                        return;
                }
                tableBody.innerHTML = "";
-               if (selected.length == 0) {
+               if (selected.length == 0)
+               {
                        tableBodyTr.innerHTML = "";
                        tableBodyTrTd.setAttribute('colspan', c.length);
                        tableBodyTrTd.innerHTML = "No records found";
                        tableBodyTr.appendChild(tableBodyTrTd);
                        tableBody.appendChild(tableBodyTr);
-               } else {
-                       if (l) {
+               }
+               else
+               {
+                       if (l)
+                       {
                                l.tablePaginator.style.display = 'block';
                                l.max = totalResults;
                                l.tablePaginatorText.innerHTML = (l.start + 1) 
+ " - " + (((l.start + l.limit) > l.max || l.limit == 0) ? l.max : l.start + 
l.limit) + " / " + l.max;
-                               if (l.limit > l.max || l.limit == 0) {
+                               if (l.limit > l.max || l.limit == 0)
+                               {
                                        
l.tablePaginatorNextButton.classList.add('disabled');
                                        
l.tablePaginatorNextButton.classList.remove('enabled');
                                }
                        }
 
-                       $.each(selected, function (id, vd) {
+                       $.each(selected, function (id, vd)
+                       {
                                var tableBodyTr = document.createElement('tr');
-                               $.each(c, function (ic, vc) {
+                               $.each(c, function (ic, vc)
+                               {
                                        var tableBodyTrTd = 
document.createElement('td');
                                        tableBodyTrTdText = "";
-                                       if (vc['object']) {
+                                       if (vc['object'])
+                                       {
                                                var objects = [];
-                                               $.each(vc['object'], function 
(io, vo) {
+                                               $.each(vc['object'], function 
(io, vo)
+                                               {
                                                        var array_attr = new 
Array();
-                                                       $.each(vo['attrs'], 
function (ia, va) {
+                                                       $.each(vo['attrs'], 
function (ia, va)
+                                                       {
                                                                
array_attr.push({name: va['name'], value: va['value']});
                                                        });
-                                                       if ((vc['value'])) {
+                                                       if ((vc['value']))
+                                                       {
                                                                var value_found 
= 0;
-                                                               
$.each(array_attr, function (i, v) {
-                                                                       if 
(v['name'] == 'value') {
+                                                               
$.each(array_attr, function (i, v)
+                                                               {
+                                                                       if 
(v['name'] == 'value')
+                                                                       {
                                                                                
value_found++;
                                                                        }
                                                                        ;
                                                                });
-                                                               if (value_found 
== 0) {
+                                                               if (value_found 
== 0)
+                                                               {
                                                                        
array_attr.push({name: 'value', value: vd[vc['value']]});
                                                                }
                                                        }
-                                                       if ((vc['checked'])) {
+                                                       if ((vc['checked']))
+                                                       {
                                                                vcc = 
vc['checked'];
-                                                               
$.each(array_attr, function (i, v) {
-                                                                       if 
(v['name'] == 'value') {
-                                                                               
if (typeof (vcc) == 'string') {
-                                                                               
        if (vcc == v['value']) {
+                                                               
$.each(array_attr, function (i, v)
+                                                               {
+                                                                       if 
(v['name'] == 'value')
+                                                                       {
+                                                                               
if (typeof (vcc) == 'string')
+                                                                               
{
+                                                                               
        if (vcc == v['value'])
+                                                                               
        {
                                                                                
                array_attr.push({name: 'checked', value: 'checked'});
                                                                                
        }
-                                                                               
} else {
-                                                                               
        if ((jQuery.inArray(v['value'], vcc) != -1) || 
(jQuery.inArray(v['value'].toString(), vcc) != -1) || 
(jQuery.inArray(parseInt(v['value']), vcc) != -1)) {
+                                                                               
}
+                                                                               
else
+                                                                               
{
+                                                                               
        if ((jQuery.inArray(v['value'], vcc) != -1) || 
(jQuery.inArray(v['value'].toString(), vcc) != -1) || 
(jQuery.inArray(parseInt(v['value']), vcc) != -1))
+                                                                               
        {
                                                                                
                array_attr.push({name: 'checked', value: 'checked'});
                                                                                
        }
                                                                                
}
@@ -863,61 +961,88 @@
                                                        objects.push({type: 
vo['type'], attrs: array_attr});
                                                });
                                                var object = 
createObject(objects);
-                                               $.each(object, function (i, o) {
+                                               $.each(object, function (i, o)
+                                               {
                                                        
tableBodyTrTd.appendChild(o);
                                                });
-                                       } else if (vc['formatter']) {
+                                       }
+                                       else if (vc['formatter'])
+                                       {
                                                vcfa = [];
                                                vcft = 'genericLink';
-                                               if (typeof (vc['formatter']) == 
'function') {
+                                               if (typeof (vc['formatter']) == 
'function')
+                                               {
                                                        vcfa = [];
                                                        vcft = (vc['formatter'] 
== genericLink2) ? 'genericLink2' : 'genericLink';
-                                               } else if (typeof 
(vc['formatter']) == 'object') {
+                                               }
+                                               else if (typeof 
(vc['formatter']) == 'object')
+                                               {
                                                        vcfa = 
vc['formatter']['arguments'];
                                                        vcft = 
vc['formatter']['type'];
                                                }
                                                var k = vc.key;
                                                var link = "";
                                                var label = "";
-                                               if (vcfa.length > 0) {
-                                                       $.each(vcfa, function 
(i, v) {
-                                                               if (typeof (v) 
== 'string') {
+                                               if (vcfa.length > 0)
+                                               {
+                                                       $.each(vcfa, function 
(i, v)
+                                                       {
+                                                               if (typeof (v) 
== 'string')
+                                                               {
                                                                        label = 
v;
                                                                        
label_name = v;
-                                                               } else {
+                                                               }
+                                                               else
+                                                               {
                                                                        label = 
(v['label']) ? v['label'] : vd[k];
                                                                        
label_name = (v['name']) ? v['name'] : '';
                                                                }
-                                                               if (label_name 
== 'Edit' || label_name == 'edit') {
+                                                               if (label_name 
== 'Edit' || label_name == 'edit')
+                                                               {
                                                                        vcfLink 
= 'opcion_edit';
-                                                               } else if 
(label_name == 'Delete' || label_name == 'delete') {
+                                                               }
+                                                               else if 
(label_name == 'Delete' || label_name == 'delete')
+                                                               {
                                                                        vcfLink 
= 'opcion_delete';
-                                                               } else if 
(label_name == 'dellink') {
+                                                               }
+                                                               else if 
(label_name == 'dellink')
+                                                               {
                                                                        vcfLink 
= 'dellink';
                                                                        label = 
'slett';
-                                                               } else {
+                                                               }
+                                                               else
+                                                               {
                                                                        vcfLink 
= '';
                                                                }
                                                                link += (i > 0) 
? '&nbsp;' : '';
                                                                link += (vcft 
== 'genericLink2') ? formatGenericLink2(label, vd[vcfLink]) : 
formatGenericLink(label, vd[vcfLink]);
                                                        });
-                                               } else {
+                                               }
+                                               else
+                                               {
                                                        link = vd[k];
-                                                       if (vcft == 
'genericLink2') {
+                                                       if (vcft == 
'genericLink2')
+                                                       {
                                                                link = 
(vd['dellink']) ? formatGenericLink2('slett', vd[k]) : link;
-                                                       } else {
+                                                       }
+                                                       else
+                                                       {
                                                                link = 
(vd['link']) ? formatGenericLink(vd[k], vd['link']) : link;
                                                        }
                                                }
                                                tableBodyTrTdText = link;
                                                tableBodyTrTd.innerHTML = 
tableBodyTrTdText;
-                                       } else {
+                                       }
+                                       else
+                                       {
                                                var k = vc.key;
                                                tableBodyTrTdText = vd[k];
                                                tableBodyTrTd.innerHTML = 
tableBodyTrTdText;
                                        }
-                                       if (vc.attrs) {
-                                               $.each(vc.attrs, function (i, 
v) {
+                                       if (vc.attrs)
+                                       {
+                                               $.each(vc.attrs, function (i, v)
+                                               {
                                                        
tableBodyTrTd.setAttribute(v.name, v.value);
                                                });
                                        }
@@ -930,17 +1055,22 @@
 }
 
 
-function createObject(object) {
+function createObject(object)
+{
        var obj = "";
        var objs = new Array();
-       if (typeof (object)) {
-               $.each(object, function (i, v) {
+       if (typeof (object))
+       {
+               $.each(object, function (i, v)
+               {
                        type = v['type']
                        var element = document.createElement(type);
-                       $.each(v['attrs'], function (i, v) {
+                       $.each(v['attrs'], function (i, v)
+                       {
                                element.setAttribute(v['name'], v['value']);
                        });
-                       if (i > 0) {
+                       if (i > 0)
+                       {
                                objs.push('&nbsp;');
                        }
                        objs.push(element);
@@ -951,12 +1081,15 @@
 }
 
 
-function populateSelect(url, selection, container, attr) {
+function populateSelect(url, selection, container, attr)
+{
        container.html("");
        var select = document.createElement('select');
        var option = document.createElement('option');
-       if (attr) {
-               $.each(attr, function (i, v) {
+       if (attr)
+       {
+               $.each(attr, function (i, v)
+               {
                        select.setAttribute(v['name'], v['value']);
                })
        }
@@ -964,12 +1097,15 @@
        option.setAttribute('value', '');
        option.text = '-----';
        select.appendChild(option);
-       $.get(url, function (r) {
-               $.each(r.data, function (index, value) {
+       $.get(url, function (r)
+       {
+               $.each(r.data, function (index, value)
+               {
                        var option = document.createElement('option');
                        option.text = value.name;
                        option.setAttribute('value', value.id);
-                       if (value.id == selection) {
+                       if (value.id == selection)
+                       {
                                option.selected = true;
                        }
                        select.appendChild(option);
@@ -977,35 +1113,43 @@
        });
 }
 
-function populateSelect_activityCalendar(url, container, attr) {
+function populateSelect_activityCalendar(url, container, attr)
+{
        container.html("");
        var select = document.createElement('select');
        var option = document.createElement('option');
-       if (attr) {
-               $.each(attr, function (i, v) {
+       if (attr)
+       {
+               $.each(attr, function (i, v)
+               {
                        select.setAttribute(v['name'], v['value']);
                });
        }
        option.setAttribute('value', '');
        option.text = 'Velg gateadresse';
-       $.get(url, function (data) {
+       $.get(url, function (data)
+       {
                var r = data.ResultSet.Result;
-               $.each(r, function (index, value) {
+               $.each(r, function (index, value)
+               {
                        var option = document.createElement('option');
                        option.text = value.name;
                        option.setAttribute('value', value.name);
                        select.appendChild(option);
                });
-               if (r.length > 0) {
+               if (r.length > 0)
+               {
                        container.append(select);
                }
-       }).fail(function () {
+       }).fail(function ()
+       {
                alert("AJAX doesn't work");
        });
 }
 
 
-function createTableSchedule(d, u, c, r, cl, dt) {
+function createTableSchedule(d, u, c, r, cl, dt)
+{
        var container = document.getElementById(d);
        var xtable = document.createElement('table');
        var tableHead = document.createElement('thead');
@@ -1018,7 +1162,8 @@
 
        xtable.setAttribute('class', tableClass);
 
-       $.each(c, function (i, v) {
+       $.each(c, function (i, v)
+       {
                var label = (v.label) ? v.label : "";
                var tableHeadTrTh = document.createElement('th');
                tableHeadTrTh.innerHTML = label;
@@ -1039,33 +1184,44 @@
        container.innerHTML = "";
        container.appendChild(xtable);
 
-       $.get(u, function (data) {
+       $.get(u, function (data)
+       {
                var selected = new Array();
-               if (typeof (r) == 'object') {
+               if (typeof (r) == 'object')
+               {
                        selected = data;
-                       $.each(r, function (i, e) {
+                       $.each(r, function (i, e)
+                       {
                                selected = selected[e['n']];
                        });
-               } else {
+               }
+               else
+               {
                        selected = data[r];
                }
-               if (!selected) {
+               if (!selected)
+               {
                        return;
                }
-               if (selected.length == 0) {
+               if (selected.length == 0)
+               {
                        tableBody.innerHTML = "";
                        tableBodyTr.innerHTML = "";
                        tableBodyTrTd.setAttribute('colspan', c.length);
                        tableBodyTrTd.innerHTML = "No records found";
                        tableBodyTr.appendChild(tableBodyTrTd);
                        tableBody.appendChild(tableBodyTr);
-               } else {
+               }
+               else
+               {
                        tableBody.innerHTML = "";
-                       $.each(selected, function (id, vd) {
+                       $.each(selected, function (id, vd)
+                       {
                                var tableBodyTr = document.createElement('tr');
                                var borderTop = "0";
                                var borderTop2 = "0";
-                               $.each(c, function (ic, vc) {
+                               $.each(c, function (ic, vc)
+                               {
                                        var k = vc.key;
                                        var colorCell = "";
                                        var tableBodyTrTdType = (k == "time") ? 
"th" : "td";
@@ -1075,80 +1231,109 @@
                                        var classes = "";
                                        var tableBodyTrTdText = "";
 
-                                       if (vc['formatter']) {
-                                               if (vc['formatter'] == 
"scheduleResourceColumn") {
-                                                       if (vd[k]) {
+                                       if (vc['formatter'])
+                                       {
+                                               if (vc['formatter'] == 
"scheduleResourceColumn")
+                                               {
+                                                       if (vd[k])
+                                                       {
                                                                
tableBodyTr.setAttribute('resource', vd['resource_id']);
                                                        }
                                                        var resourceLink = 
(date) ? vd['resource_link'] + "#date=" + date : vd['resource_link'];
                                                        tableBodyTrTdText = 
(vd[k]) ? formatGenericLink(vd['resource'], resourceLink) : "";
-                                               } else {
-                                                       if (vd[k]) {
+                                               }
+                                               else
+                                               {
+                                                       if (vd[k])
+                                                       {
                                                                var id = 
vd[k]['id'];
                                                                var name = 
(vd[k]['shortname']) ? formatScheduleShorten(vd[k]['shortname'], 9) : 
formatScheduleShorten(vd[k]['name'], 9);
                                                                var type = 
vd[k]['type'];
-                                                               if 
(vc['formatter'] == "seasonDateColumn") {
+                                                               if 
(vc['formatter'] == "seasonDateColumn")
+                                                               {
                                                                        
tableBodyTrTdText = name;
-                                                                       
tableBodyTrTd.addEventListener('click', function () {
+                                                                       
tableBodyTrTd.addEventListener('click', function ()
+                                                                       {
                                                                                
schedule.newAllocationForm({'id': vd[k]['id']})
                                                                        });
                                                                }
-                                                               if 
(vc['formatter'] == "scheduleDateColumn") {
+                                                               if 
(vc['formatter'] == "scheduleDateColumn")
+                                                               {
                                                                        
tableBodyTrTdText = formatGenericLink(name, null);
                                                                }
-                                                               if 
(vc['formatter'] == "backendScheduleDateColumn") {
+                                                               if 
(vc['formatter'] == "backendScheduleDateColumn")
+                                                               {
                                                                        var 
conflicts = new Array();
-                                                                       if 
(vd[k]['conflicts']) {
-                                                                               
if (vd[k]['conflicts'].length > 0) {
+                                                                       if 
(vd[k]['conflicts'])
+                                                                       {
+                                                                               
if (vd[k]['conflicts'].length > 0)
+                                                                               
{
                                                                                
        conflicts = vd[k]['conflicts'];
                                                                                
}
                                                                        }
                                                                        
tableBodyTrTdText = formatBackendScheduleDateColumn(id, name, type, conflicts);
                                                                        classes 
+= " " + type;
                                                                }
-                                                               if 
(vc['formatter'] == "frontendScheduleDateColumn") {
-                                                                       if 
(vd[k]['is_public'] == 0) {
+                                                               if 
(vc['formatter'] == "frontendScheduleDateColumn")
+                                                               {
+                                                                       if 
(vd[k]['is_public'] == 0)
+                                                                       {
                                                                                
name = formatScheduleShorten('Privat arr.', 9);
                                                                        }
                                                                        
tableBodyTrTdText = name;
                                                                        classes 
+= " cellInfo";
                                                                        classes 
+= " " + type;
-                                                                       
tableBodyTrTd.addEventListener('click', function () {
+                                                                       
tableBodyTrTd.addEventListener('click', function ()
+                                                                       {
                                                                                
schedule.showInfo(vd[k]['info_url'], tableBodyTr.getAttribute('resource'))
                                                                        }, 
false);
                                                                }
                                                                colorCell = 
formatScheduleCellDateColumn(name, type);
                                                                classes += " " 
+ colorCell;
                                                                
tableBodyTrTd.setAttribute('class', classes);
-                                                       } else {
+                                                       }
+                                                       else
+                                                       {
                                                                
tableBodyTrTdText = "free";
-                                                               if 
(vc['formatter'] == "frontendScheduleDateColumn") {
-                                                                       
tableBodyTrTd.addEventListener('click', function () {
+                                                               if 
(vc['formatter'] == "frontendScheduleDateColumn")
+                                                               {
+                                                                       
tableBodyTrTd.addEventListener('click', function ()
+                                                                       {
                                                                                
schedule.newApplicationForm(vc['date'], vd['_from'], vd['_to'], 
tableBodyTr.getAttribute('resource'))
                                                                        });
                                                                }
-                                                               if 
(vc['formatter'] == "backendScheduleDateColumn") {
-                                                                       
tableBodyTrTd.addEventListener('click', function () {
+                                                               if 
(vc['formatter'] == "backendScheduleDateColumn")
+                                                               {
+                                                                       
tableBodyTrTd.addEventListener('click', function ()
+                                                                       {
                                                                                
schedule.newApplicationForm(vc['date'], vd['_from'], vd['_to'])
                                                                        });
                                                                }
-                                                               if 
(vc['formatter'] == "seasonDateColumn") {
-                                                                       
tableBodyTrTd.addEventListener('click', function () {
+                                                               if 
(vc['formatter'] == "seasonDateColumn")
+                                                               {
+                                                                       
tableBodyTrTd.addEventListener('click', function ()
+                                                                       {
                                                                                
schedule.newAllocationForm({'_from': vd['_from'], '_to': vd['_to'], 'wday': 
vc['key']})
                                                                        });
                                                                }
                                                        }
                                                }
-                                       } else {
+                                       }
+                                       else
+                                       {
                                                tableBodyTrTdText = (vd[k]) ? 
vd[k] : "";
                                        }
-                                       if (k == "time") {
+                                       if (k == "time")
+                                       {
                                                borderTop = (vd[k]) ? "2" : "1";
                                        }
-                                       if (ic == 0) {
+                                       if (ic == 0)
+                                       {
                                                borderTop2 = borderTop;
                                                borderTop = (!vd[k]) ? "0" : 
borderTop;
-                                       } else {
+                                       }
+                                       else
+                                       {
                                                borderTop = borderTop2;
                                        }
                                        tableBodyTrTd.setAttribute('style', 
'border-top:' + borderTop + 'px solid #cbcbcb;');
@@ -1161,7 +1346,8 @@
        });
 }
 
-function restartColors() {
+function restartColors()
+{
        colors = [
                'color1', 'color2', 'color3', 'color4', 'color5', 'color6', 
'color7', 'color8', 'color9', 'color10',
                'color11', 'color12', 'color13', 'color14', 'color15', 
'color16', 'color17', 'color18', 'color19', 'color20',
@@ -1173,81 +1359,103 @@
        colorMap = {};
 }
 
-function formatScheduleCellDateColumn(name, type) {
-       if (!colorMap[name]) {
+function formatScheduleCellDateColumn(name, type)
+{
+       if (!colorMap[name])
+       {
                colorMap[name] = colors.length ? colors.shift() : 'color60';
        }
        var color = colorMap[name];
        return color;
 }
-function formatBackendScheduleDateColumn(id, name, type, conflicts) {
+function formatBackendScheduleDateColumn(id, name, type, conflicts)
+{
        var link = "";
        var text = "";
        conflicts = (conflicts) ? conflicts : {};
-       if (type == "booking") {
+       if (type == "booking")
+       {
                link = 'index.php?menuaction=booking.uibooking.edit&id=' + id;
        }
-       else if (type == "allocation") {
+       else if (type == "allocation")
+       {
                link = 'index.php?menuaction=booking.uiallocation.edit&id=' + 
id;
        }
-       else if (type == "event") {
+       else if (type == "event")
+       {
                link = 'index.php?menuaction=booking.uievent.edit&id=' + id;
        }
        text = formatGenericLink(name, link);
-       if (type == "event" && conflicts.length > 0) {
-               $.each(conflicts, function (i, v) {
+       if (type == "event" && conflicts.length > 0)
+       {
+               $.each(conflicts, function (i, v)
+               {
                        var conflict = formatBackendScheduleDateColumn(v['id'], 
formatScheduleShorten(v['name'], 9), v['type']);
                        text += "<p class='conflicts'>conflicts with: " + 
conflict + "</p>";
                });
        }
        return text;
 }
-function formatFrontendScheduleDateColumn() {
+function formatFrontendScheduleDateColumn()
+{
 }
 
-function formatScheduleShorten(text, max) {
-       if (max && text.length > max) {
+function formatScheduleShorten(text, max)
+{
+       if (max && text.length > max)
+       {
                text = text.substr(text, max) + '...';
        }
        return text;
 }
 
-function getUrlData(string) {
-       if (typeof (string) !== "string") {
+function getUrlData(string)
+{
+       if (typeof (string) !== "string")
+       {
                return;
        }
        var n = self.location.href.indexOf("#");
-       if (n > 0) {
+       if (n > 0)
+       {
                var hash = self.location.href.substr(n + 1);
                var states = hash.split("&");
                var l = states.length;
-               for (var i = 0; i < l; i++) {
+               for (var i = 0; i < l; i++)
+               {
                        var tokens = states[i].split("=");
-                       if (tokens.length == 2) {
+                       if (tokens.length == 2)
+                       {
                                var token = tokens[0];
-                               if (token == string) {
+                               if (token == string)
+                               {
                                        return _decodeStringUrl(tokens[1]);
                                }
                        }
                }
-       } else {
+       }
+       else
+       {
                return;
        }
 }
 
-function _decodeStringUrl(string) {
+function _decodeStringUrl(string)
+{
        return decodeURIComponent(string.replace(/\+/g, ' '));
 }
 
 
 
-function genericLink() {
+function genericLink()
+{
        var data = [];
        data['arguments'] = arguments;
        data['type'] = 'genericLink';
        return data;
 }
-function genericLink2() {
+function genericLink2()
+{
        var data = [];
        data['arguments'] = arguments;
        data['type'] = 'genericLink2';
@@ -1255,17 +1463,25 @@
 }
 
 // nl = numero links
-function formatGenericLink(name, link) {
-       if (!name || !link) {
+function formatGenericLink(name, link)
+{
+       if (!name || !link)
+       {
                return name;
-       } else {
+       }
+       else
+       {
                return "<a href='" + link + "'>" + name + "</a>";
        }
 }
-function formatGenericLink2(name, link) {
-       if (!name || !link) {
+function formatGenericLink2(name, link)
+{
+       if (!name || !link)
+       {
                return name;
-       } else {
+       }
+       else
+       {
                return "<a onclick='return confirm(\"Er du sikker på at du vil 
slette denne?\")' href='" + link + "'>" + name + "</a>";
        }
 }
\ No newline at end of file

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2016-02-27 15:43:46 UTC (rev 
14777)
+++ trunk/property/inc/class.uientity.inc.php   2016-02-27 23:36:06 UTC (rev 
14778)
@@ -75,6 +75,7 @@
                        'get_controls_at_component' => true,
                        'get_assigned_history' => true,
                        'get_cases' => true,
+                       'get_checklists'=>true,
                        'get_cases_for_checklist' => true
                );
 
@@ -2188,33 +2189,31 @@
                                                        array('singleSelect' => 
true)
                                                )
                                        );
-                               }
+                                       $_cases = 
$this->get_cases($location_id, $id, date('Y')); // initial search
 
-                               $_cases = $this->get_cases($location_id, $id, 
date('Y')); // initial search
-                               $cases_time_span = $this->cases_time_span;
+                                       $_case_def = array
+                                               (
+                                               array('key' => 'url', 'label' 
=> lang('id'), 'sortable' => false, 'resizeable' => true),
+                                               array('key' => 'type', 'label' 
=> lang('type'), 'sortable' => true, 'resizeable' => true),
+                                               array('key' => 'title', 'label' 
=> lang('title'), 'sortable' => false, 'resizeable' => true),
+                                               array('key' => 'status', 
'label' => lang('status'), 'sortable' => false, 'resizeable' => true),
+                                               array('key' => 'user', 'label' 
=> lang('user'), 'sortable' => true, 'resizeable' => true),
+                                               array('key' => 'entry_date', 
'label' => lang('entry date'), 'sortable' => false,
+                                                       'resizeable' => true),
+                                       );
 
-                               $_case_def = array
-                                       (
-                                       array('key' => 'url', 'label' => 
lang('id'), 'sortable' => false, 'resizeable' => true),
-                                       array('key' => 'type', 'label' => 
lang('type'), 'sortable' => true, 'resizeable' => true),
-                                       array('key' => 'title', 'label' => 
lang('title'), 'sortable' => false, 'resizeable' => true),
-                                       array('key' => 'status', 'label' => 
lang('status'), 'sortable' => false, 'resizeable' => true),
-                                       array('key' => 'user', 'label' => 
lang('user'), 'sortable' => true, 'resizeable' => true),
-                                       array('key' => 'entry_date', 'label' => 
lang('entry date'), 'sortable' => false,
-                                               'resizeable' => true),
-                               );
-
-                               $datatable_def[] = array
-                                       (
-                                       'container' => 'datatable-container_6',
-                                       'requestUrl' => "''",
-                                       'ColumnDefs' => $_case_def,
-                                       'data' => json_encode($_cases),
-                                       'config' => array(
-                                               array('disableFilter' => true),
-                                               array('disablePagination' => 
true)
-                                       )
-                               );
+                                       $datatable_def[] = array
+                                               (
+                                               'container' => 
'datatable-container_6',
+                                               'requestUrl' => "''",
+                                               'ColumnDefs' => $_case_def,
+                                               'data' => json_encode($_cases),
+                                               'config' => array(
+                                                       array('disableFilter' 
=> true),
+                                                       
array('disablePagination' => true)
+                                               )
+                                       );
+                               }
                        }
 
                        //$category['org_unit'] =1;
@@ -3451,7 +3450,7 @@
                                                (
                                                'url' => "<a href=\"{$_link}\" 
> {$check_list_id}</a>",
                                                'type' => $_control_name,
-                                               'title' 
=>$check_item->get_control_item()->get_title(),
+                                               'title' => 
$check_item->get_control_item()->get_title(),
                                                'value' => 
$case->get_measurement(),
                                                'status' => 
$_statustext[$case->get_status()],
                                                'user' => 
$GLOBALS['phpgw']->accounts->get($case->get_user_id())->__toString(),
@@ -3496,10 +3495,27 @@
                        {
                                $year = phpgw::get_var('year', 'int', 
'REQUEST', date('Y'));
                        }
+                       $socheck_list = CreateObject('controller.socheck_list');
 
-                       $from_date_ts = 0;//mktime(0, 0, 0, 1, 1, $year);
-                       $to_date_ts = mktime(23, 59, 59, 12, 31, ($year + 2));
-                       $socheck_list = CreateObject('controller.socheck_list');
+                       $start_and_end = 
$socheck_list->get_start_and_end_for_component($location_id, $id);
+                       $start_year = date('Y', 
$start_and_end['start_timestamp']);
+                       $end_year = date('Y', $start_and_end['end_timestamp']);
+                       if (!$year)
+                       {
+                               $year = $end_year;
+                       }
+
+                       for ($j = $start_year; $j < ($end_year + 1); $j++)
+                       {
+                               $this->cases_time_span[] = array(
+                                       'id' => $j,
+                                       'name' => $j,
+                                       'selected' => $j == date('Y') ? 1 : 0
+                               );
+                       }
+
+                       $from_date_ts = mktime(0, 0, 0, 1, 1, $year);
+                       $to_date_ts = mktime(23, 59, 59, 12, 31, $year);
                        $socontrol = CreateObject('controller.socontrol');
 
                        $control_id_with_check_list_array = 
$socheck_list->get_check_lists_for_component($location_id, $id, $from_date_ts, 
$to_date_ts);

Modified: trunk/property/js/portico/entity.edit.js
===================================================================
--- trunk/property/js/portico/entity.edit.js    2016-02-27 15:43:46 UTC (rev 
14777)
+++ trunk/property/js/portico/entity.edit.js    2016-02-27 23:36:06 UTC (rev 
14778)
@@ -276,15 +276,36 @@
 
 $(document).ready(function ()
 {
-
+       var click_action_on_table = false;
        $("#cases_time_span").change(function ()
        {
-               var oArgs = {menuaction: 'property.uientity.get_cases', 
location_id: location_id, id: item_id, year: $(this).val()};
+               var oArgs = {menuaction: 'property.uientity.get_checklists', 
location_id: location_id, id: item_id, year: $(this).val()};
                var requestUrl = phpGWLink('index.php', oArgs, true);
+               var _oTable = 
JqueryPortico.updateinlineTableHelper('datatable-container_5', requestUrl);
+
+               oArgs = {menuaction: 'property.uientity.get_cases', 
location_id: location_id, id: item_id, year: $(this).val()};
+               requestUrl = phpGWLink('index.php', oArgs, true);
                JqueryPortico.updateinlineTableHelper('datatable-container_6', 
requestUrl);
+
+               if (click_action_on_table == false)
+               {
+                       $(_oTable).on("click", function (e)
+                       {
+                               var aTrs = _oTable.fnGetNodes();
+                               for (var i = 0; i < aTrs.length; i++)
+                               {
+                                       if ($(aTrs[i]).hasClass('selected'))
+                                       {
+                                               var check_list_id = $('td', 
aTrs[i]).eq(0).text();
+                                               updateCaseTable(check_list_id);
+                                       }
+                               }
+                       });
+                       click_action_on_table = true
+               }
+
        });
 
-
        $("#datatable-container_5 tr").on("click", function (e)
        {
                var check_list_id = $('td', this).eq(0).text();
@@ -299,7 +320,6 @@
        {
                return;
        }
-       $("#cases_time_span").hide();
        var oArgs = {menuaction: 'property.uientity.get_cases_for_checklist', 
check_list_id: check_list_id};
        var requestUrl = phpGWLink('index.php', oArgs, true);
        JqueryPortico.updateinlineTableHelper('datatable-container_6', 
requestUrl);

Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl    2016-02-27 15:43:46 UTC (rev 
14777)
+++ trunk/property/templates/base/entity.xsl    2016-02-27 23:36:06 UTC (rev 
14778)
@@ -650,6 +650,15 @@
                                                        <label>
                                                                <xsl:value-of 
select="php:function('lang', 'checklist')" />
                                                        </label>
+                                                       <select id = 
"cases_time_span" name="cases_time_span">
+                                                               <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="php:function('lang', 'select')"/>
+                                                               </xsl:attribute>
+                                                               <option 
value="0">
+                                                                       
<xsl:value-of select="php:function('lang', 'select')"/>
+                                                               </option>
+                                                               
<xsl:apply-templates select="cases_time_span/options"/>
+                                                       </select>
                                                        <xsl:for-each 
select="datatable_def">
                                                                <xsl:if 
test="container = 'datatable-container_5'">
                                                                        
<xsl:call-template name="table_setup">
@@ -668,16 +677,6 @@
                                                        <label>
                                                                <xsl:value-of 
select="php:function('lang', 'cases')" />
                                                        </label>
-                                                       <select id = 
"cases_time_span" name="cases_time_span">
-                                                               <xsl:attribute 
name="title">
-                                                                       
<xsl:value-of select="php:function('lang', 'select')"/>
-                                                               </xsl:attribute>
-                                                               <option 
value="0">
-                                                                       
<xsl:value-of select="php:function('lang', 'select')"/>
-                                                               </option>
-                                                               
<xsl:apply-templates select="cases_time_span/options"/>
-                                                       </select>
-
                                                        <xsl:for-each 
select="datatable_def">
                                                                <xsl:if 
test="container = 'datatable-container_6'">
                                                                        
<xsl:call-template name="table_setup">




reply via email to

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