fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7738]


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [7738]
Date: Tue, 27 Sep 2011 12:57:44 +0000

Revision: 7738
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7738
Author:   erikhl
Date:     2011-09-27 12:57:44 +0000 (Tue, 27 Sep 2011)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.menu.inc.php
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.uicontrol.inc.php
    trunk/controller/inc/model/class.control.inc.php
    trunk/controller/templates/base/control.xsl

Modified: trunk/controller/inc/class.menu.inc.php
===================================================================
--- trunk/controller/inc/class.menu.inc.php     2011-09-27 12:08:33 UTC (rev 
7737)
+++ trunk/controller/inc/class.menu.inc.php     2011-09-27 12:57:44 UTC (rev 
7738)
@@ -24,7 +24,7 @@
                                'control' => array
                                (
                                        'text'  => lang('Control'),
-                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol.index') ),
+                                       'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uicontrol.control_list') ),
                            'image'     => array('property', 'location_1')
                                ),
                                'control_item' => array

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2011-09-27 12:08:33 UTC 
(rev 7737)
+++ trunk/controller/inc/class.socontrol.inc.php        2011-09-27 12:57:44 UTC 
(rev 7738)
@@ -97,19 +97,158 @@
        
        function get_id_field_name($extended_info = false)
        {
+               if(!$extended_info)
+               {
+                       $ret = 'id';
+               }
+               else
+               {
+                       $ret = array
+                       (
+                               'table'                 => 'control', // alias
+                               'field'                 => 'id',
+                               'translated'    => 'id'
+                       );
+               }
                
+               return $ret;
        }
 
        protected function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean $return_count)
        {
+               $clauses = array('1=1');
                
+               $filter_clauses = array();
                
+               // Search for based on search type
+               if($search_for)
+               {
+                       $search_for = $this->marshal($search_for,'field');
+                       $like_pattern = "'%".$search_for."%'";
+                       $like_clauses = array();
+                       switch($search_type){
+                               default:
+                                       $like_clauses[] = 
"controller_control.title $this->like $like_pattern";
+                                       $like_clauses[] = 
"controller_control.description $this->like $like_pattern";
+                                       break;
+                       }
+                       
+                       if(count($like_clauses))
+                       {
+                               $clauses[] = '(' . join(' OR ', $like_clauses) 
. ')';
+                       }
+               }
+               
+               if(isset($filters[$this->get_id_field_name()]))
+               {
+                       $filter_clauses[] = "controller_control.id = 
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+               }
+               
+               if(count($filter_clauses))
+               {
+                       $clauses[] = join(' AND ', $filter_clauses);
+               }
+               
+               
+               $condition =  join(' AND ', $clauses);
+
+               $tables = "controller_control";
+               //$joins = " {$this->left_join} rental_document_types ON 
(rental_document.type_id = rental_document_types.id)";
+               
+               if($return_count)
+               {
+                       $cols = 'COUNT(DISTINCT(controller_control.id)) AS 
count';
+               }
+               else
+               {
+                       $cols = 'id, title, description, start_date, end_date, 
procedure_id, requirement_id, costresponsibility_id, responsibility_id, 
equipment_type_id, equipment_id, location_code, repeat_type, repeat_interval, 
enabled ';
+               }
+               
+               $dir = $ascending ? 'ASC' : 'DESC';
+               if($sort_field == 'title')
+               {
+                       $sort_field = 'controller_control.title';
+               }
+               $order = $sort_field ? "ORDER BY {$this->marshal($sort_field, 
'field')} $dir ": '';
+               
+               return "SELECT {$cols} FROM {$tables} WHERE {$condition} 
{$order}";
+               
        }
        
        function populate(int $control_id, &$control)
        {
+               if($control == null) {
+                       $control = new controller_control((int) $control_id);
+
+                       
$control->set_title($this->unmarshal($this->db->f('title', true), 'string'));
+                       
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
+                       
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
+                       
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
+                       
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true), 
'int'));
+                       
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id', 
true), 'int'));
+                       
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
 true), 'int'));
+                       
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
+                       
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
+//                     
$control->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
+                       
$control->set_equipment_type_id($this->unmarshal($this->db->f('equipment_type_id',
 true), 'int'));
+                       
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true), 
'int'));
+                       
$control->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));
+                       
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+                       
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
+               }
+               
+               return $control;
+       }
        
+       /**
+        * Get single control
+        * 
+        * @param       $id     id of the control to return
+        * @return a controller_control
+        */
+       function get_single($id)
+       {
+               $id = (int)$id;
+               
+               $sql = "SELECT c.* FROM controller_control c WHERE c.id = " . 
$id;
+               $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
+               $this->db->next_record();
+               
+               $control = new controller_control((int) $id);
+
+               $control->set_title($this->unmarshal($this->db->f('title', 
true), 'string'));
+               
$control->set_description($this->unmarshal($this->db->f('description', true), 
'boolean'));
+               
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
+               
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
+               
$control->set_procedure_id($this->unmarshal($this->db->f('procedure_id', true), 
'int'));
+               
$control->set_requirement_id($this->unmarshal($this->db->f('requirement_id', 
true), 'int'));
+               
$control->set_costresponsibility_id($this->unmarshal($this->db->f('costresponsibility_id',
 true), 'int'));
+               
$control->set_responsibility_id($this->unmarshal($this->db->f('responsibility_id',
 true), 'int'));
+               
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
+//                     
$control->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
+               
$control->set_equipment_type_id($this->unmarshal($this->db->f('equipment_type_id',
 true), 'int'));
+               
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true), 
'int'));
+               
$control->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'int'));
+               
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+               
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
+               
+               return $control;
        }
        
+/*             public function populate($control){
+                                               
+                       $control->set_title(phpgw::get_var('title', 'string'));
+                       $control->set_description(phpgw::get_var('description', 
'string'));
+                       $control->set_start_date( strtotime( 
phpgw::get_var('start_date_hidden', 'int')));
+                       $control->set_end_date( strtotime( 
phpgw::get_var('end_date_hidden', 'int')));
+                       $control->set_repeat_type( 
phpgw::get_var('repeat_type', 'string'));
+                       $control->set_repeat_interval( 
phpgw::get_var('repeat_interval', 'string'));
+                       $control->set_procedure_id( 
phpgw::get_var('procedure_id', 'int'));
+                       $control->set_enabled( true );
+                       
+                       return $control;
+                       
+               }*/
        
+       
 }

Modified: trunk/controller/inc/class.uicontrol.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol.inc.php        2011-09-27 12:08:33 UTC 
(rev 7737)
+++ trunk/controller/inc/class.uicontrol.inc.php        2011-09-27 12:57:44 UTC 
(rev 7738)
@@ -24,7 +24,9 @@
                
                public $public_functions = array
                (
-                       'index' =>      true
+                       'index' =>      true,
+                       'control_list'  =>      true,
+                       'view'  =>      true
                );
 
                public function __construct()
@@ -42,6 +44,108 @@
                        self::set_active_menu('controller::control');
                }
                
+               public function control_list()
+               {
+                       if(phpgw::get_var('phpgw_return_as') == 'json') {
+                               return $this->query();
+                       }
+                       self::add_javascript('controller', 'yahoo', 
'datatable.js');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('paginator');
+
+                       $data = array(
+                               'form' => array(
+                                       'toolbar' => array(
+                                               'item' => array(
+                                                       array(
+                                                               'type' => 
'link',
+                                                               'value' => 
lang('New control'),
+                                                               'href' => 
self::link(array('menuaction' => 'controller.uicontrol.index'))
+                                                       ),
+                                                       array('type' => 
'filter', 
+                                                               'name' => 
'status',
+                                'text' => lang('Status').':',
+                                'list' => array(
+                                    array(
+                                        'id' => 'none',
+                                        'name' => lang('Not selected')
+                                    ), 
+                                    array(
+                                        'id' => 'NEW',
+                                        'name' => lang('NEW')
+                                    ), 
+                                    array(
+                                        'id' => 'PENDING',
+                                        'name' =>  lang('PENDING')
+                                    ), 
+                                    array(
+                                        'id' => 'REJECTED',
+                                        'name' => lang('REJECTED')
+                                    ), 
+                                    array(
+                                        'id' => 'ACCEPTED',
+                                        'name' => lang('ACCEPTED')
+                                    )
+                                )
+                            ),
+                                                       array('type' => 
'filter',
+                                                               'name' => 
'control_areas',
+                                'text' => lang('Control_area').':',
+                                'list' => 
$this->so_control_area->get_control_area_select_array(),
+                                                       ),
+                                                       array('type' => 'text', 
+                                'text' => lang('searchfield'),
+                                                               'name' => 
'query'
+                                                       ),
+                                                       array(
+                                                               'type' => 
'submit',
+                                                               'name' => 
'search',
+                                                               'value' => 
lang('Search')
+                                                       ),
+                                                       array(
+                                                               'type' => 
'link',
+                                                               'value' => 
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
+                                                               'href' => 
self::link(array('menuaction' => $this->url_prefix.'.toggle_show_inactive'))
+                                                       ),
+                                               ),
+                                       ),
+                               ),
+                               'datatable' => array(
+                                       'source' => 
self::link(array('menuaction' => 'controller.uicontrol.control_list', 
'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => lang('ID'),
+                                                       'sortable'      => true,
+                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                               ),
+                                               array(
+                                                       'key'   =>      'title',
+                                                       'label' =>      
lang('Control title'),
+                                                       'sortable'      =>      
false
+                                               ),
+                                               array(
+                                                       'key' => 'description',
+                                                       'label' => 
lang('description'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 
'control_area_id',
+                                                       'label' => 
lang('Control area'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 'link',
+                                                       'hidden' => true
+                                               )
+                                       )
+                               ),
+                       );
+//_debug_array($data);
+
+                       self::render_template_xsl('datatable', $data);
+               }
+               
                public function index()
                {
                        if( isset($_POST['save_control']) )
@@ -91,6 +195,9 @@
                        
                        phpgwapi_yui::tabview_setup('control_tabview');
                        
+                       
$GLOBALS['phpgw']->richtext->replace_element('description');
+                       $GLOBALS['phpgw']->richtext->generate_script();
+                       
                        $data = array
                        (
                                'tabs'                                          
=> phpgwapi_yui::tabview_generate($tabs, 'details'),
@@ -98,7 +205,7 @@
                                'end_date'                                      
=> 
$GLOBALS['phpgw']->yuical->add_listener('end_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
 time())),
                                'value_id'                                      
=> !empty($control) ? $control->get_id() : 0,
                                'img_go_home'                           => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                               'editable'                                      
=> true,
+                               'editable'                                      
=> true,
                                'control_area_options'          => 
array('options' => $control_area_options),
                                'procedure_options'                     => 
array('options' => $procedure_options)
                        );
@@ -329,21 +436,122 @@
                
                public function query()
                {
+                       $params = array(
+                               'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
+                               'results' => phpgw::get_var('results', 'int', 
'REQUEST', null),
+                               'query' => phpgw::get_var('query'),
+                               'sort'  => phpgw::get_var('sort'),
+                               'dir'   => phpgw::get_var('dir'),
+                               'filters' => $filters
+                       );
                        
-               }       
-               
-               public function populate($control){
-                                               
-                       $control->set_title(phpgw::get_var('title', 'string'));
-                       $control->set_description(phpgw::get_var('description', 
'string'));
-                       $control->set_start_date( strtotime( 
phpgw::get_var('start_date_hidden', 'int')));
-                       $control->set_end_date( strtotime( 
phpgw::get_var('end_date_hidden', 'int')));
-                       $control->set_repeat_type( 
phpgw::get_var('repeat_type', 'string'));
-                       $control->set_repeat_interval( 
phpgw::get_var('repeat_interval', 'string'));
-                       $control->set_procedure_id( 
phpgw::get_var('procedure_id', 'int'));
-                       $control->set_enabled( true );
+                       $search_for = phpgw::get_var('query');
+
+                       
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
+                       {
+                               $user_rows_per_page = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       }
+                       else {
+                               $user_rows_per_page = 10;
+                       }
                        
-                       return $control;
+                       // YUI variables for paging and sorting
+                       $start_index    = phpgw::get_var('startIndex', 'int');
+                       $num_of_objects = phpgw::get_var('results', 'int', 
'GET', $user_rows_per_page);
+                       $sort_field             = phpgw::get_var('sort');
+                       if($sort_field == null)
+                       {
+                               $sort_field = 'control_group_id';
+                       }
+                       $sort_ascending = phpgw::get_var('dir') == 'desc' ? 
false : true;
+                       //Create an empty result set
+                       $records = array();
                        
+                       //Retrieve a contract identifier and load corresponding 
contract
+                       $control_id = phpgw::get_var('control_id');
+                       if(isset($control_id))
+                       {
+                               $control = $this->so->get_single($control_id);
+                       }
+
+                       $result_objects = $this->so->get($start_index, 
$num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, 
$filters);
+                       //var_dump($result_objects);
+                                                               
+                       $results = array();
+                       
+                       foreach($result_objects as $control_obj)
+                       {
+                               $results['results'][] = 
$control_obj->serialize();      
+                       }
+
+                       array_walk($results["results"], array($this, 
"_add_links"), "controller.uicontrol.view");
+
+                       return $this->yui_results($results);
                }
+               
+               public function view()
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= 
'::'.lang('view');
+                       //Retrieve the procedure object
+                       $control_id = (int)phpgw::get_var('id');
+                       if(isset($_POST['edit_control']))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol.edit_control', 'id' => 
$control_id));
+                       }
+                       else
+                       {
+                               if(isset($control_id) && $control_id > 0)
+                               {
+                                       $control = 
$this->so->get_single($control_id);
+                               }
+                               else
+                               {
+                                       
$this->render('permission_denied.php',array('error' => 
lang('invalid_request')));
+                                       return;
+                               }
+                               
+                               $control_array = $control->toArray();
+                               //var_dump($control);
+                       
+                               $tabs = array
+                               (
+                                       'details'       => array('label' => 
lang('Details'), 'link' => '#details'),
+                                       'control_groups'                => 
array('label' => lang('Control_groups'), 'link' => '#control_groups'),
+                                       'control_items'         => 
array('label' => lang('Control_items'), 'link' => '#control_items')
+                               );
+                               
+                               $add_document_link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uiexample.index') );
+                                       
+                               $procedure_array = 
$this->so_proc->get_procedure_array();
+                                       
+                               foreach ($procedure_array as $procedure)
+                               {
+                                       $procedure_options[] = 
$procedure->toArray();
+                               }
+                                       
+                               $control_area_array = 
$this->so_control_area->get_control_area_array();
+                               
+                               foreach ($control_area_array as $control_area)
+                               {
+                                       $control_area_options[] = 
$control_area->toArray();
+                               }
+                               
+                               phpgwapi_yui::tabview_setup('control_tabview');
+                               
+                               $data = array
+                               (
+                                       'tabs'                                  
        => phpgwapi_yui::tabview_generate($tabs, 'details'),
+                                       'start_date'                            
=> 
$GLOBALS['phpgw']->yuical->add_listener('start_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
 time())),
+                                       'end_date'                              
        => 
$GLOBALS['phpgw']->yuical->add_listener('end_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
 time())),
+                                       'value_id'                              
        => !empty($control) ? $control->get_id() : 0,
+                                       'img_go_home'                           
=> 'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'control'                               
        => $control_array,
+                                       'control_area_options'          => 
array('options' => $control_area_options),
+                                       'procedure_options'                     
=> array('options' => $procedure_options)
+                               );
+                               
+                               self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                               self::render_template_xsl(array('control_tabs', 
'control', 'control_groups', 'control_items'), $data);
+                       }
+               }
        }
\ No newline at end of file

Modified: trunk/controller/inc/model/class.control.inc.php
===================================================================
--- trunk/controller/inc/model/class.control.inc.php    2011-09-27 12:08:33 UTC 
(rev 7737)
+++ trunk/controller/inc/model/class.control.inc.php    2011-09-27 12:57:44 UTC 
(rev 7738)
@@ -12,8 +12,15 @@
                protected $end_date;
                protected $repeat_type;
                protected $repeat_interval;
-               protected $procedure_uid;
+               protected $procedure_id;
                protected $enabled;
+               protected $requirement_id;
+               protected $costresponsibility_id;
+               protected $responsibility_id;
+               protected $equipment_id;
+               protected $equipment_type_id;
+               protected $location_code;
+               protected $control_area_id;
                                
                /**
                 * Constructor.  Takes an optional ID.  If a contract is 
created from outside
@@ -95,7 +102,56 @@
                }
                
                public function get_enabled() { return $this->enabled; }
-                               
+               
+               public function set_requirement_id($requirement_id)
+               {
+                       $this->requirement_id = $requirement_id;
+               }
+               
+               public function get_requirement_id() { return 
$this->requirement_id; }
+               
+               public function 
set_costresponsibility_id($costresponsibility_id)
+               {
+                       $this->costresponsibility_id = $costresponsibility_id;
+               }
+               
+               public function get_costresponsibility_id() { return 
$this->costresponsibility_id; }
+               
+               public function set_responsibility_id($responsibility_id)
+               {
+                       $this->responsibility_id = $responsibility_id;
+               }
+               
+               public function get_responsibility_id() { return 
$this->responsibility_id; }
+               
+               public function set_equipment_id($equipment_id)
+               {
+                       $this->equipment_id = $equipment_id;
+               }
+               
+               public function get_equipment_id() { return 
$this->equipment_id; }
+               
+               public function set_equipment_type_id($equipment_type_id)
+               {
+                       $this->equipment_type_id = $equipment_type_id;
+               }
+               
+               public function get_equipment_type_id() { return 
$this->equipment_type_id; }
+               
+               public function set_location_code($location_code)
+               {
+                       $this->location_code = $location_code;
+               }
+               
+               public function get_location_code() { return 
$this->location_code; }
+               
+               public function set_control_area_id($control_area_id)
+               {
+                       $this->control_area_id = $control_area_id;
+               }
+               
+               public function get_control_area_id() { return 
$this->control_area_id; }
+               
                /**
                 * Get a static reference to the storage object associated with 
this model object
                 * 
@@ -109,5 +165,18 @@
                        
                        return self::$so;
                }
+               
+               public function serialize()
+               {
+                       return array(
+                               'id' => $this->get_id(),
+                               'title' => $this->get_title(),
+                               'description' => $this->get_description(),
+                               'start_date' => $this->get_start_date(),
+                               'end_date' => $this->get_end_date(),
+                               'procedure_id' => $this->get_procedure_id(),
+                               'control_area_id' => 
$this->get_control_area_id()
+                               );
+               }
        }
 ?>
\ No newline at end of file

Modified: trunk/controller/templates/base/control.xsl
===================================================================
--- trunk/controller/templates/base/control.xsl 2011-09-27 12:08:33 UTC (rev 
7737)
+++ trunk/controller/templates/base/control.xsl 2011-09-27 12:57:44 UTC (rev 
7738)
@@ -6,7 +6,6 @@
        <xsl:value-of select="php:function('lang', 'Control')" />
 </h1>
 </div>
-
 <div class="yui-content">
        <div id="details">
                <form action="#" method="post">
@@ -16,44 +15,72 @@
                                <dt>
                                        <label>Kontrollområde</label>
                                </dt>
-                               <dd>                                    
-                                       <select id="control_area_id" 
name="control_area_id">
-                                               <xsl:for-each 
select="control_area_options/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="title"/>
-                                                       </option>
-                                           </xsl:for-each>
-                                       </select>
+                               <dd>
+                               <xsl:choose>
+                                       <xsl:when test="editable">              
                        
+                                               <select id="control_area_id" 
name="control_area_id">
+                                                       <xsl:for-each 
select="control_area_options/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="title"/>
+                                                               </option>
+                                                   </xsl:for-each>
+                                               </select>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of 
select="control/control_area_id" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
                                </dd>
                                <dt>
                                        <label>Prosedyre</label>
                                </dt>
                                <dd>
-                                       <select id="procedure_id" 
name="procedure_id">
-                                               <xsl:for-each 
select="procedure_options/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="title"/>
-                                                       </option>
-                                           </xsl:for-each>
-                                       </select>
+                               <xsl:choose>
+                                       <xsl:when test="editable">
+                                               <select id="procedure_id" 
name="procedure_id">
+                                                       <xsl:for-each 
select="procedure_options/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="title"/>
+                                                               </option>
+                                                   </xsl:for-each>
+                                               </select>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of 
select="control/procedure_id" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
                                </dd>
                                <dt>
                                        <label for="title">Tittel</label>
                                </dt>
                                <dd>
-                                       <input type="text" name="title" 
id="title" value="" />
+                               <xsl:choose>
+                                       <xsl:when test="editable">
+                                               <input type="text" name="title" 
id="title" value="{control/title}" />
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of 
select="control/title" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
                                </dd>
                                <dt>
                                        <label 
for="description">Beskrivelse</label>
                                </dt>
                                <dd>
-                                       <textarea cols="70" rows="5" 
name="description" id="description" value=""></textarea>
+                               <xsl:choose>
+                                       <xsl:when test="editable">
+                                               <textarea cols="70" rows="5" 
name="description" id="description"><xsl:value-of select="control/description" 
/></textarea>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of 
select="control/description" disable-output-escaping="yes"/>
+                                       </xsl:otherwise>
+                               </xsl:choose>
                                </dd>
                                <dt>
                                        <label 
for="start_date">Startdato</label>
@@ -84,13 +111,28 @@
                                        <label>Frekvens</label>
                                </dt>
                                <dd>
-                                       <input size="2" type="text" 
name="repeat_interval" value="2" />
+                               <xsl:choose>
+                                       <xsl:when test="editable">
+                                               <input size="2" type="text" 
name="repeat_interval" value="{control/repeat_interval}" />
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of 
select="control/repeat_interval" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
                                </dd>
                        </dl>
                        
                        <div class="form-buttons">
-                               <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
-                               <input type="submit" name="save_control" 
value="{$lang_save}" title = "{$lang_save}" />
+                               <xsl:choose>
+                                       <xsl:when test="editable">
+                                               <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
+                                               <input type="submit" 
name="save_control" value="{$lang_save}" title = "{$lang_save}" />
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:variable 
name="lang_edit"><xsl:value-of select="php:function('lang', 'edit')" 
/></xsl:variable>
+                                               <input type="submit" 
name="edit_control" value="{$lang_edit}" title = "{$lang_edit}" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
                        </div>
                </form>                                 
        </div>




reply via email to

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