fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11793] controller: update component list on add case


From: Sigurd Nes
Subject: [Fmsystem-commits] [11793] controller: update component list on add case
Date: Fri, 07 Mar 2014 13:59:22 +0000

Revision: 11793
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11793
Author:   sigurdne
Date:     2014-03-07 13:59:22 +0000 (Fri, 07 Mar 2014)
Log Message:
-----------
controller: update component list on add case

Modified Paths:
--------------
    trunk/controller/inc/class.uicase.inc.php
    trunk/controller/js/controller/case.js
    trunk/controller/js/controller/check_list.js
    trunk/controller/js/controller/check_list_update_status.js

Modified: trunk/controller/inc/class.uicase.inc.php
===================================================================
--- trunk/controller/inc/class.uicase.inc.php   2014-03-07 09:32:30 UTC (rev 
11792)
+++ trunk/controller/inc/class.uicase.inc.php   2014-03-07 13:59:22 UTC (rev 
11793)
@@ -66,20 +66,22 @@
            private $edit;
            private $delete;
    
-               var $public_functions = array(
-                       'add_case'                              => true,
-                       'save_case'                     => true,
-                       'save_case_ajax'                => true,
-                       'create_case_message'   => true,
-                       'view_case_message'     => true,
-                       'send_case_message'     => true,
-                       'updateStatusForCases'  => true,
-                       'delete_case'                   => true,
-                       'close_case'                    => true,
-                       'open_case'                     => true,
-                       'view_open_cases'               => true,
-                       'view_closed_cases'     => true
-               );
+               var $public_functions = array
+                       (
+                               'add_case'                              => true,
+                               'save_case'                     => true,
+                               'save_case_ajax'                => true,
+                               'create_case_message'   => true,
+                               'view_case_message'     => true,
+                               'send_case_message'     => true,
+                               'updateStatusForCases'  => true,
+                               'delete_case'                   => true,
+                               'close_case'                    => true,
+                               'open_case'                     => true,
+                               'view_open_cases'               => true,
+                               'view_closed_cases'     => true,
+                               'get_case_data_ajax'    => true
+                       );
 
                function __construct()
                {
@@ -103,7 +105,7 @@
                        $this->delete  = 
$GLOBALS['phpgw']->acl->check('.checklist', PHPGW_ACL_DELETE, 'controller');//8 
                }       
                
-        function add_case()
+               private function _get_case_data()
                {
                        $check_list_id = phpgw::get_var('check_list_id');
                        $case_location_code = phpgw::get_var('location_code');
@@ -252,14 +254,7 @@
                                }
 
                        }
-                       
 
-                       $level = 
$this->location_finder->get_location_level($location_code);
-                       $year = date("Y", $check_list->get_deadline());
-                       $month = date("n", $check_list->get_deadline());
-                                                       
-                       $user_role = true;
-
                        $data = array
                        (
                                'control'                                       
                => $control,
@@ -269,12 +264,36 @@
                                'component_array'                               
        => $component_array,
                                'control_groups_with_items_array'       => 
$control_groups_with_items_array,
                                'type'                                          
                => $type,
+                               'location_code'                                 
        => $location_code
+                       );
+
+                       return $data;
+               }
+
+               function add_case()
+               {
+                       $case_data = $this->_get_case_data();
+                       $check_list = $case_data['check_list'];
+
+                       $level = 
$this->location_finder->get_location_level($case_data['location_code']);
+                       $year = date("Y", $check_list->get_deadline());
+                       $month = date("n", $check_list->get_deadline());
+                                                       
+                       $user_role = true;
+
+                       $data = array
+                       (
+                               'control'                                       
                => $case_data['control'],
+                               'check_list'                                    
        => $check_list,
+                               'buildings_on_property'                         
=> $case_data['buildings_on_property'],
+                           'location_array'                                    
=> $case_data['location_array'],
+                               'component_array'                               
        => $case_data['component_array'],
+                               'control_groups_with_items_array'       => 
$case_data['control_groups_with_items_array'],
+                               'type'                                          
                => $case_data['type'],
                                'location_level'                                
        => $level,
-       //                      'building_location_code'                        
=> $building_location_code,
                                'current_year'                                  
        => $year,
                                'current_month_nr'                              
        => $month,
                            'cases_view'                                        
        => 'add_case',
-               //          'location_required'                                 
=> true
                        );
                        
                        phpgwapi_jquery::load_widget('core');
@@ -290,6 +309,16 @@
                                                                          
'check_list/fragments/select_buildings_on_property'), $data);
                }
     
+               public function get_case_data_ajax()
+               {
+                       $check_list_id = phpgw::get_var('check_list_id');
+                       $case_location_code = phpgw::get_var('location_code');
+                       $case_data = $this->_get_case_data();
+                       
+                       $control_groups_with_items_array;
+                       return json_encode( array( 
"control_groups_with_items_array" => 
$case_data['control_groups_with_items_array'] ) );
+                       
+               }
                function save_case_ajax()
                {
                        if(!$this->add && !$this->edit)

Modified: trunk/controller/js/controller/case.js
===================================================================
--- trunk/controller/js/controller/case.js      2014-03-07 09:32:30 UTC (rev 
11792)
+++ trunk/controller/js/controller/case.js      2014-03-07 13:59:22 UTC (rev 
11793)
@@ -64,6 +64,58 @@
                                        }
                                }
                        });
+
+                       var check_list_id = 
$(thisForm).find("input[name=check_list_id]").val();
+                       var oArgs = {menuaction: 
'controller.uicase.get_case_data_ajax', check_list_id: check_list_id, 
location_code: location_code};
+                       var requestUrl = phpGWLink('index.php', oArgs, true);
+
+                       var htmlString = "";
+
+                       $.ajax({
+                               type: 'POST',
+                               dataType: 'json',
+                               url: requestUrl,
+                               success: function(data) {
+                                       if (data != null) {
+                                               var obj = 
jQuery.parseJSON(data);
+
+                                               $.each(obj, function(i, 
control_group) {
+
+                                                       $.each(control_group, 
function(j, control_item)
+                                                       {
+                                                               if (typeof 
(control_item.components_at_location) != 'undefined')
+                                                               {
+                                                                       if 
(control_group_id != control_item.control_group.id)
+                                                                       {
+                                                                               
return;
+                                                                       }
+
+                                                                       
htmlString = "";
+
+                                                                       var 
component_options = control_item.components_at_location;
+                                                                       
$.each(component_options, function(k, options) {
+
+                                                                               
$.each(options, function(k, option) {
+
+                                                                               
        var selected = '';
+
+                                                                               
        if (option.id == component_id)
+                                                                               
        {
+                                                                               
                selected = ' selected';
+                                                                               
        }
+
+                                                                               
        htmlString += "<option value='" + component_location_id + '_' + 
option.id + "'" + selected + ">" + option.id + ' - ' + 
option['short_description'] + "</option>";
+
+                                                                               
});
+                                                                       });
+
+                                                                       
$("#component_at_control_group_" + control_group_id).html(htmlString);
+                                                               }
+                                                       });
+                                               });
+                                       }
+                               }
+                       });
                }
        });
 

Modified: trunk/controller/js/controller/check_list.js
===================================================================
--- trunk/controller/js/controller/check_list.js        2014-03-07 09:32:30 UTC 
(rev 11792)
+++ trunk/controller/js/controller/check_list.js        2014-03-07 13:59:22 UTC 
(rev 11793)
@@ -29,7 +29,8 @@
        // Display submit button on click
        $("#frm_add_check_list").live("click", function(e){
                var thisForm = $(this);
-               var submitBnt = $(thisForm).find("input[type='submit']");       
        $(submitBnt).removeClass("not_active");
+               var submitBnt = $(thisForm).find("input[type='submit']");
+               $(submitBnt).removeClass("not_active");
        });
 
        

Modified: trunk/controller/js/controller/check_list_update_status.js
===================================================================
--- trunk/controller/js/controller/check_list_update_status.js  2014-03-07 
09:32:30 UTC (rev 11792)
+++ trunk/controller/js/controller/check_list_update_status.js  2014-03-07 
13:59:22 UTC (rev 11793)
@@ -1,44 +1,44 @@
-$(document).ready(function(){
-  
-  // UPDATE CHECKLIST STATUS
-       $("#update-check-list-status").live("submit", function(e){
-    e.preventDefault();
-    
-       var thisForm = $(this);
-    
-       var statusClass = $(thisForm).attr("class");
-               
-       var requestUrl = $(thisForm).attr("action");
+$(document).ready(function() {
 
-       var submitBnt = $(thisForm).find("input[type='submit']");
-               
-     $.ajax({
-                         type: 'POST',
-                         url: requestUrl + "&" + $(thisForm).serialize(),
-                          success: function(data) {
-                                 if(data){
-                                 var jsonObj = jQuery.parseJSON(data);
+       // UPDATE CHECKLIST STATUS
+       $("#update-check-list-status").live("submit", function(e) {
+               e.preventDefault();
 
-                                 if(jsonObj.status == 'not_saved')
-                                 {
-                                               $(submitBnt).val("feil ved 
lagring");
-                                 }
-                                 else if(jsonObj.status == '1')
-                                 {
-                                       $(submitBnt).val("Utført");
-                                       
$("#update-check-list-status-value").val(0);
-                 //          
$("#update-check-list-status-icon.not_done").hide();
-             //                
$("#update-check-list-status-icon-done.done").show();
-                             }
-                             else
-                             {
-                                       $(submitBnt).val("Ikke utført");
-                                       
$("#update-check-list-status-value").val(1);
-                      //         
$("#update-check-list-status-icon.not_done").show();
-                  //         
$("#update-check-list-status-icon-done.done").hide();
-                             }
-                                 }
+               var thisForm = $(this);
+
+               var statusClass = $(thisForm).attr("class");
+
+               var requestUrl = $(thisForm).attr("action");
+
+               var submitBnt = $(thisForm).find("input[type='submit']");
+
+               $.ajax({
+                       type: 'POST',
+                       url: requestUrl + "&" + $(thisForm).serialize(),
+                       success: function(data) {
+                               if (data) {
+                                       var jsonObj = jQuery.parseJSON(data);
+
+                                       if (jsonObj.status == 'not_saved')
+                                       {
+                                               $(submitBnt).val("feil ved 
lagring");
+                                       }
+                                       else if (jsonObj.status == '1')
+                                       {
+                                               $(submitBnt).val("Utført");
+                                               
$("#update-check-list-status-value").val(0);
+                                               //          
$("#update-check-list-status-icon.not_done").hide();
+                                               //              
$("#update-check-list-status-icon-done.done").show();
+                                       }
+                                       else
+                                       {
+                                               $(submitBnt).val("Ikke utført");
+                                               
$("#update-check-list-status-value").val(1);
+                                               //         
$("#update-check-list-status-icon.not_done").show();
+                                               //         
$("#update-check-list-status-icon-done.done").hide();
+                                       }
                                }
-               });     
+                       }
+               });
        });
 });




reply via email to

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