fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8647]


From: Torstein
Subject: [Fmsystem-commits] [8647]
Date: Mon, 23 Jan 2012 07:28:37 +0000

Revision: 8647
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8647
Author:   vator
Date:     2012-01-23 07:28:36 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.soprocedure.inc.php
    trunk/controller/inc/class.uicheck_list.inc.php
    trunk/controller/inc/class.uicheck_list_for_location.inc.php
    trunk/controller/inc/class.uicontrol.inc.php
    trunk/controller/inc/class.uiprocedure.inc.php
    trunk/controller/inc/helper/class.date_helper.inc.php
    trunk/controller/inc/model/class.control.inc.php
    trunk/controller/templates/base/control/control.xsl

Modified: trunk/controller/inc/class.soprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.soprocedure.inc.php      2012-01-22 19:51:52 UTC 
(rev 8646)
+++ trunk/controller/inc/class.soprocedure.inc.php      2012-01-23 07:28:36 UTC 
(rev 8647)
@@ -242,7 +242,7 @@
                        }
                }
 
-               function get_procedures_by_control_area_id($control_area_id)
+               function get_procedures_by_control_area($control_area_id)
                {
                        $results = array();
 

Modified: trunk/controller/inc/class.uicheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list.inc.php     2012-01-22 19:51:52 UTC 
(rev 8646)
+++ trunk/controller/inc/class.uicheck_list.inc.php     2012-01-23 07:28:36 UTC 
(rev 8647)
@@ -50,14 +50,14 @@
                public $public_functions = array
                (
                        'index' =>      true,
-                       'view_check_lists_for_control'          =>      true,
+               //      'view_check_lists_for_control'          =>      true,
                //      'save_check_list'                                       
=>      true,
-                       'view_check_list'                                       
=>      true,
+               //      'view_check_list'                                       
=>      true,
                //      'edit_check_list'                                       
=>      true,
                        'save_check_items'                                      
=>      true,
                        'save_check_item'                                       
=>      true,
                        'get_check_list_info'                           =>      
true,
-                       'control_calendar_status_overview'      =>      true,
+               //      'control_calendar_status_overview'      =>      true,
                        'add_check_item_to_list'                        =>      
true,
                        'update_check_list'                                     
=>      true,
                        'view_control_items'                            =>      
true,
@@ -241,8 +241,8 @@
                        $completed_date = phpgw::get_var('completed_date');
                        $planned_date = phpgw::get_var('planned_date');
                        
-                       $planned_date_ts = 
date_helper::get_timestamp_from_date( $planned_date ); 
-                       $completed_date_ts = 
date_helper::get_timestamp_from_date( $completed_date );
+                       $planned_date_ts = 
date_helper::get_timestamp_from_date( $planned_date, "d/m-Y" ); 
+                       $completed_date_ts = 
date_helper::get_timestamp_from_date( $completed_date, "d/m-Y" );
                        
                        // Fetches check_list from DB
                        $update_check_list = 
$this->so_check_list->get_single($check_list_id);
@@ -331,7 +331,7 @@
                        }
                        // END as categories
                        $control_area_id = $control_areas_array2[1]['id'];
-                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area_id($control_area_id);
+                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area($control_area_id);
                        $role_array = $this->so_control->get_roles();
                        
                        $data = array

Modified: trunk/controller/inc/class.uicheck_list_for_location.inc.php
===================================================================
--- trunk/controller/inc/class.uicheck_list_for_location.inc.php        
2012-01-22 19:51:52 UTC (rev 8646)
+++ trunk/controller/inc/class.uicheck_list_for_location.inc.php        
2012-01-23 07:28:36 UTC (rev 8647)
@@ -218,13 +218,13 @@
                        $completed_date = phpgw::get_var('completed_date', 
'string');
                                                        
                        if($planned_date != '')
-                               $planned_date_ts = 
date_helper::get_timestamp_from_date( $planned_date );
+                               $planned_date_ts = 
date_helper::get_timestamp_from_date( $planned_date, "d/m-Y" );
 
                        if($deadline_date != '')
-                               $deadline_date_ts = 
date_helper::get_timestamp_from_date( $deadline_date );
+                               $deadline_date_ts = 
date_helper::get_timestamp_from_date( $deadline_date, "d/m-Y" );
                        
                        if($completed_date != '')
-                               $completed_date_ts = 
date_helper::get_timestamp_from_date( $completed_date );
+                               $completed_date_ts = 
date_helper::get_timestamp_from_date( $completed_date, "d/m-Y" );
                        
                        $check_list = new controller_check_list();
                        $check_list->set_location_code($location_code);
@@ -295,7 +295,7 @@
 
                        // Fetches prosedures that are related to first control 
area in list
                        $control_area_id = $control_areas_array2[1]['id'];
-                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area_id($control_area_id);
+                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area($control_area_id);
                        $role_array = $this->so_control->get_roles();
                        
                        $location_code = $check_list->get_location_code();  

Modified: trunk/controller/inc/class.uicontrol.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol.inc.php        2012-01-22 19:51:52 UTC 
(rev 8646)
+++ trunk/controller/inc/class.uicontrol.inc.php        2012-01-23 07:28:36 UTC 
(rev 8647)
@@ -247,8 +247,8 @@
                        $cats   = CreateObject('phpgwapi.categories', -1, 
'controller', '.control');
                        $cats->supress_info     = true;
 
-                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => 
$control_area_id,'globals' => true,'use_acl' => $this->_category_acl));
-                       array_unshift($control_areas['cat_list'],array 
('cat_id'=>'','name'=> lang('select value')));
+                       $control_areas = 
$cats->formatted_xslt_list(array('format'=>'filter','selected' => 
$control->get_control_area_id(),'globals' => true,'use_acl' => 
$this->_category_acl));
+                       
                        $control_areas_array2 = array();
                        foreach($control_areas['cat_list'] as $cat_list)
                        {
@@ -259,13 +259,40 @@
                                );              
                        }
                        // END as categories
-
-                       echo "Control area id: " . 
$control->get_control_area_id();
-                       
-                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area_id($control->get_control_area_id());
+               
+                       $procedures_array = 
$this->so_procedure->get_procedures_by_control_area($control->get_control_area_id());
                        $role_array = $this->so->get_roles();
                        
-                       $tabs = array( array(
+                       $repeat_type_array = array(
+                                                                       
array('id'      => "0", 'value' => "Dag"),
+                                                                       
array('id'      => "1", 'value' => "Uke"),
+                                                                       
array('id'      => "2", 'value' => "Måned"),
+                                                                       
array('id'      => "3", 'value' => "År")
+                                                               );
+                                                               
+                       if( $control != null )
+                       {
+                               $tabs = array(
+                                               array(
+                                                       'label' => "1: " . 
lang('Details'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.view_control_details', 
+                                                                               
                                                                                
   'id' => $control->get_id()))
+                                               ),array(
+                                                       'label' => "2: " . 
lang('Choose_control_groups'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.view_control_groups', 
+                                                                               
                                                                                
   'control_id' => $control->get_id())) 
+                                               ),array(
+                                                       'label' => "3: " . 
lang('Choose_control_items'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.view_control_items', 
+                                                                               
                                                                                
   'control_id' => $control->get_id()))
+                                               ),array('label' => "4: " . 
lang('Sort_check_list')
+                                               )
+                                               
+                                       );      
+                       }
+                       else
+                       {
+                               $tabs = array( array(
                                                        'label' => "1: " . 
lang('Details')
                                                ), array(
                                                        'label' => "2: " . 
lang('Choose_control_groups')
@@ -273,7 +300,8 @@
                                                        'label' => "3: " . 
lang('Choose_control_items')
                                                ), array(
                                                        'label' => "4: " . 
lang('Sort_check_list')
-                                               ));
+                                               ));     
+                       }
                        
                        $data = array
                        (
@@ -281,9 +309,10 @@
                                'view'                                          
=> "control_details",
                                'editable'                                      
=> true,
                                'control'                                       
=> $control->toArray(),
-                               'control_areas_array2'          => 
array('options' => $control_areas_array2),
+                               'control_areas_array2'          => 
$control_areas_array2,
                                'procedures_array'                      => 
$procedures_array,
-                               'role_array'                            => 
$role_array
+                               'role_array'                            => 
$role_array,
+                               'repeat_type_array'                     => 
$repeat_type_array
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
@@ -336,7 +365,7 @@
                                $saved_control_group_ids[] = 
$control_group->get_id();
                        }
                        
-                       // Fetches  control groups based on selected control 
area                                               
+                       // Fetches control groups based on selected control 
area                                                
                        $control_area = $this->so_control_area->get_single( 
$control->get_control_area_id );            
                        $control_groups_as_array = 
$this->so_control_group->get_control_groups_as_array($control->get_control_area_id());
                        

Modified: trunk/controller/inc/class.uiprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.uiprocedure.inc.php      2012-01-22 19:51:52 UTC 
(rev 8646)
+++ trunk/controller/inc/class.uiprocedure.inc.php      2012-01-23 07:28:36 UTC 
(rev 8647)
@@ -377,7 +377,7 @@
                {
                        $control_area_id = phpgw::get_var('control_area_id');
 
-                       $procedures_array = 
$this->so->get_procedures_by_control_area_id($control_area_id);
+                       $procedures_array = 
$this->so->get_procedures_by_control_area($control_area_id);
 
                        if(count($procedures_array)>0)
                                return json_encode( $procedures_array );

Modified: trunk/controller/inc/helper/class.date_helper.inc.php
===================================================================
--- trunk/controller/inc/helper/class.date_helper.inc.php       2012-01-22 
19:51:52 UTC (rev 8646)
+++ trunk/controller/inc/helper/class.date_helper.inc.php       2012-01-23 
07:28:36 UTC (rev 8647)
@@ -3,16 +3,22 @@
        
        public function __construct(){}
                
-       public static function get_timestamp_from_date( $date_string ){
-               $pos_day = strpos($date_string, "/"); 
-               $day =  substr($date_string, 0, $pos_day);
+       public static function get_timestamp_from_date( $date_string, $format  
){
                
-               $pos_month = strpos($date_string, "-");
-               $len_month = $pos_month - $pos_day -1;
-               $month = substr($date_string, $pos_day+1, $len_month);
-               
-               $year = substr($date_string, $pos_month + $len_month-1, 
strlen($date_string)-1);
-               
-               return mktime(0, 0, 0, $month, $day, $year);
+               if( $format == "d/m-Y" ){
+                       $pos_day = strpos($date_string, "/"); 
+                       $day = date_helper::substring($date_string, 0, 
$pos_day);
+                       
+                       $pos_month = strpos($date_string, "-");
+                       $month = date_helper::substring($date_string, 
$pos_day+1, $pos_month);
+                       
+                       $year = date_helper::substring($date_string, 
$pos_month+1, strlen($date_string));
+
+                       return mktime(0, 0, 0, $month, $day, $year);
+               }
        }
+       
+       public function substring($string, $from, $to){
+       return substr($string, $from, $to - $from);
+       }
 }
\ No newline at end of file

Modified: trunk/controller/inc/model/class.control.inc.php
===================================================================
--- trunk/controller/inc/model/class.control.inc.php    2012-01-22 19:51:52 UTC 
(rev 8646)
+++ trunk/controller/inc/model/class.control.inc.php    2012-01-23 07:28:36 UTC 
(rev 8647)
@@ -29,6 +29,7 @@
        */
 
        include_class('controller', 'model', 'inc/model/');
+       include_class('controller', 'date_helper', 'inc/helper/');
 
        class controller_control extends controller_model
        {
@@ -228,12 +229,21 @@
                {
                                
$this->set_title(phpgw::get_var('title','string'));
                                
$this->set_description(phpgw::get_var('description','html'));
-                               $this->set_start_date(strtotime( 
phpgw::get_var('start_date_hidden','string') ));
-                               $this->set_end_date(strtotime( 
phpgw::get_var('end_date_hidden','string') ));
+                               
+                               $start_date_ts = 
date_helper::get_timestamp_from_date( phpgw::get_var('start_date','string'), 
"d/m-Y" );
+                               $this->set_start_date($start_date_ts);
+                               
+                               if( phpgw::get_var('end_date','string') != ""){
+                                       $end_date_ts = 
date_helper::get_timestamp_from_date( phpgw::get_var('end_date','string'), 
"d/m-Y" );
+                                       $this->set_end_date( $end_date_ts );
+                               }else{
+                                       $this->set_end_date( 0 );
+                               }
+                               
+                               
$this->set_repeat_type(phpgw::get_var('repeat_type','int'));
+                               
$this->set_repeat_interval(phpgw::get_var('repeat_interval','int'));
                                
$this->set_procedure_id(phpgw::get_var('procedure_id','int'));
                                
$this->set_control_area_id(phpgw::get_var('control_area_id','int'));
-                               
$this->set_repeat_type(phpgw::get_var('repeat_type','int'));
-                               
$this->set_repeat_interval(phpgw::get_var('repeat_interval','int'));
                                
$this->set_responsibility_id(phpgw::get_var('responsibility_id','int'));
                }
                

Modified: trunk/controller/templates/base/control/control.xsl
===================================================================
--- trunk/controller/templates/base/control/control.xsl 2012-01-22 19:51:52 UTC 
(rev 8646)
+++ trunk/controller/templates/base/control/control.xsl 2012-01-23 07:28:36 UTC 
(rev 8647)
@@ -4,6 +4,8 @@
 <xsl:variable name="control_id"><xsl:value-of 
select="control/id"/></xsl:variable>
 <xsl:variable name="control_area_id"><xsl:value-of 
select="control/control_area_id"/></xsl:variable>
 <xsl:variable name="control_procedure_id"><xsl:value-of 
select="control/procedure_id"/></xsl:variable>
+<xsl:variable name="control_repeat_type"><xsl:value-of 
select="control/repeat_type"/></xsl:variable>
+<xsl:variable name="control_role"><xsl:value-of 
select="control/responsibility_id"/></xsl:variable>
 <xsl:variable name="date_format">d/m-Y</xsl:variable>
 
 <script>
@@ -34,7 +36,21 @@
                                <xsl:choose>
                                        <xsl:when test="editable">
                                                <select id="control_area_id" 
name="control_area_id">
-                                                       <xsl:apply-templates 
select="control_areas_array2/options"/>
+                                               <option value="">Velg 
kontrollområde</option>
+                                                       <xsl:for-each 
select="control_areas_array2">
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="id != control/control_area_id">
+                                                                               
<option value="{id}">
+                                                                               
        <xsl:value-of disable-output-escaping="yes" select="name"/>
+                                                                               
</option>
+                                                                       
</xsl:when>
+                                                                       
<xsl:otherwise>
+                                                                               
<option value="{id}" selected="selected">
+                                                                               
        <xsl:value-of disable-output-escaping="yes" select="name"/>
+                                                                               
</option>
+                                                                       
</xsl:otherwise>
+                                                               </xsl:choose>   
                                                        
+                                                       </xsl:for-each>
                                                </select>
                                        </xsl:when>
                                        <xsl:otherwise>
@@ -49,6 +65,7 @@
                                <xsl:choose>
                                        <xsl:when test="editable">
                                                <select id="procedure_id" 
name="procedure_id">
+                                                       <option value="">Velg 
prosedyre</option>
                                                        <xsl:for-each 
select="procedures_array">
                                                                <xsl:choose>
                                                                        
<xsl:when test="id != $control_procedure_id">
@@ -87,10 +104,7 @@
                                        <label 
for="start_date">Startdato</label>
                                </dt>
                                <dd>
-                                       <input>
-                                     <xsl:attribute 
name="id">start_date</xsl:attribute>
-                                     <xsl:attribute 
name="name">start_date</xsl:attribute>
-                                     <xsl:attribute 
name="type">text</xsl:attribute>
+                                       <input id="start_date" 
name="start_date" type="text">
                                      <xsl:if test="control/start_date != ''">
                                        <xsl:attribute 
name="value"><xsl:value-of select="php:function('date', $date_format, 
number(control/start_date))"/></xsl:attribute>
                                      </xsl:if>
@@ -100,10 +114,7 @@
                                        <label for="end_date">Sluttdato</label>
                                </dt>
                                <dd>
-                                       <input>
-                                     <xsl:attribute 
name="id">end_date</xsl:attribute>
-                                     <xsl:attribute 
name="name">end_date</xsl:attribute>
-                                     <xsl:attribute 
name="type">text</xsl:attribute>
+                                       <input id="end_date" name="end_date" 
type="text">
                                      <xsl:if test="control/end_date != 0">
                                        <xsl:attribute 
name="value"><xsl:value-of select="php:function('date', $date_format, 
number(control/end_date))"/></xsl:attribute>
                                      </xsl:if>
@@ -114,11 +125,21 @@
                                </dt>
                                <dd>
                                        <select id="repeat_type" 
name="repeat_type">
-                                               <option value="0">Ikke 
angitt</option>
-                                               <option value="1">Dag</option>
-                                               <option value="2">Uke</option>
-                                               <option value="3">Måned</option>
-                                               <option value="5">År</option>
+                                               <option value="">Velg 
frekvenstype</option>
+                                               <xsl:for-each 
select="repeat_type_array">
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="id = $control_repeat_type">
+                                                                       <option 
value="{id}" selected="selected">
+                                                                               
<xsl:value-of disable-output-escaping="yes" select="value"/>
+                                                                       
</option>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       <option 
value="{id}">
+                                                                               
<xsl:value-of disable-output-escaping="yes" select="value"/>
+                                                                       
</option>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>           
                                                
+                                               </xsl:for-each>
                                        </select>
                                </dd>
                                <dt>
@@ -141,10 +162,20 @@
                                <xsl:choose>
                                        <xsl:when test="editable">
                                                <select id="responsibility_id" 
name="responsibility_id">
+                                                       <option value="">Velg 
rolle</option>
                                                        <xsl:for-each 
select="role_array">
-                                                               <option 
value="{id}">
-                                                                       
<xsl:value-of disable-output-escaping="yes" select="name"/>
-                                                               </option>
+                                                               <xsl:choose>
+                                                                       
<xsl:when test="id = $control_role">
+                                                                               
<option value="{id}" selected="selected">
+                                                                               
        <xsl:value-of disable-output-escaping="yes" select="name"/>
+                                                                               
</option>
+                                                                       
</xsl:when>
+                                                                       
<xsl:otherwise>
+                                                                               
<option value="{id}">
+                                                                               
        <xsl:value-of disable-output-escaping="yes" select="name"/>
+                                                                               
</option>
+                                                                       
</xsl:otherwise>
+                                                               </xsl:choose>   
                                                        
                                                        </xsl:for-each>
                                                </select>
                                        </xsl:when>
@@ -183,14 +214,4 @@
                </form>                                 
        </div>
 </div>
-</xsl:template>
-
-<xsl:template match="options">
-       <option value="{id}">
-               <xsl:if test="selected != 0">
-                       <xsl:attribute name="selected" value="selected" />
-               </xsl:if>
-               <xsl:value-of disable-output-escaping="yes" select="name"/>
-       </option>
-</xsl:template>
-
+</xsl:template>
\ No newline at end of file




reply via email to

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