fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7673]


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [7673]
Date: Tue, 20 Sep 2011 09:01:39 +0000

Revision: 7673
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7673
Author:   erikhl
Date:     2011-09-20 09:01:39 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socontrol_item.inc.php
    trunk/controller/inc/class.uicontrol_item.inc.php
    trunk/controller/inc/model/class.control_item.inc.php
    trunk/controller/setup/tables_current.inc.php
    trunk/controller/templates/base/control_item.xsl
    trunk/controller/templates/base/css/base.css

Modified: trunk/controller/inc/class.socontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol_item.inc.php   2011-09-20 08:53:34 UTC 
(rev 7672)
+++ trunk/controller/inc/class.socontrol_item.inc.php   2011-09-20 09:01:39 UTC 
(rev 7673)
@@ -28,23 +28,37 @@
         */
        function add(&$control_item)
        {
+               $cols = array(
+                               'title',
+                               'required',
+                               'what_to_do',
+                               'how_to_do',
+                               'control_group_id',
+                               'control_area_id'
+               );
                
-               $title = $control_item->get_title();
+               $values = array(
+                       $this->marshal($control_item->get_title(), 'string'),
+                       $this->marshal(($control_item->get_required() ? 'true' 
: 'false'), 'bool'),
+                       $this->marshal($control_item->get_what_to_do(), 
'string'),
+                       $this->marshal($control_item->get_how_to_do(), 
'string'),
+                       $this->marshal($control_item->get_control_group_id(), 
'int'),
+                       $this->marshal($control_item->get_control_area_id(), 
'int')
+               );
                
-               $sql = "INSERT INTO controller_control_item (title) VALUES 
('$title')";
+               $result = $this->db->query('INSERT INTO controller_control_item 
(' . join(',', $cols) . ') VALUES (' . join(',', $values) . ')', 
__LINE__,__FILE__);
                $result = $this->db->query($sql, __LINE__,__FILE__);
 
                if(isset($result)) {
-                       // Set the new party ID
-                       
$control_item->set_id($this->db->get_last_insert_id('controller_control_item', 
'id'));
+                       // return the new control item ID
+                       return 
$this->db->get_last_insert_id('controller_control_item', 'id');
                        // Forward this request to the update method
-                       return $this->update($control_item);
+                       //return $this->update($control_item);
                }
                else
                {
-                       return false;
+                       return 0;
                }
-               
        }
 
        /**
@@ -75,8 +89,8 @@
        /**
         * Get single procedure
         * 
-        * @param       $id     id of the procedure to return
-        * @return a controller_procedure
+        * @param       $id     id of the control_item to return
+        * @return a controller_control_item
         */
        function get_single($id)
        {
@@ -88,11 +102,11 @@
                
                $control_item = new 
controller_control_item($this->unmarshal($this->db->f('id', true), 'int'));
                $control_item->set_title($this->unmarshal($this->db->f('title', 
true), 'string'));
-               
$control_item->set_purpose($this->unmarshal($this->db->f('purpose', true), 
'string'));
-               
$control_item->set_responsibility($this->unmarshal($this->db->f('responsibility',
 true), 'string'));
-               
$control_item->set_description($this->unmarshal($this->db->f('description', 
true), 'string'));
-               
$control_item->set_reference($this->unmarshal($this->db->f('reference', true), 
'string'));
-               
$control_item->set_attachment($this->unmarshal($this->db->f('attachment', 
true), 'string'));
+               
$control_item->set_required($this->unmarshal($this->db->f('required', true), 
'bool'));
+               
$control_item->set_what_to_do($this->unmarshal($this->db->f('what_to_do', 
true), 'string'));
+               
$control_item->set_how_to_do($this->unmarshal($this->db->f('how_to_do', true), 
'string'));
+               
$control_item->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
+               
$control_item->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
 true), 'int'));
                
                return $control_item;
        }

Modified: trunk/controller/inc/class.uicontrol_item.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_item.inc.php   2011-09-20 08:53:34 UTC 
(rev 7672)
+++ trunk/controller/inc/class.uicontrol_item.inc.php   2011-09-20 09:01:39 UTC 
(rev 7673)
@@ -6,7 +6,7 @@
        phpgw::import_class('controller.socontrol_group');
        phpgw::import_class('controller.socontrol_area');
        
-       include_class('controller', 'control', 'inc/model/');
+       include_class('controller', 'control_item', 'inc/model/');
 
        class controller_uicontrol_item extends controller_uicommon
        {
@@ -17,8 +17,11 @@
                
                public $public_functions = array
                (
-                       'index' => true,
+                       'index' =>      true,
                        'query' =>      true,
+                       'edit'  =>      true,
+                       'view'  =>      true,
+                       'add'   =>      true,
                        'display_control_items' => true
                );
 
@@ -29,97 +32,254 @@
                        $this->so_control_item = 
CreateObject('controller.socontrol_item');
                        $this->so_control_group = 
CreateObject('controller.socontrol_group');
                        $this->so_control_area = 
CreateObject('controller.socontrol_area');
+                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_item";
                }
                
                public function index()
                {
-                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_item";
-                       
-                       self::set_active_menu('controller::control_item');
+                       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 item'),
+                                                               'href' => 
self::link(array('menuaction' => 'controller.uicontrol_item.add'))
+                                                       ),
+                                                       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_groups',
+                                'text' => lang('Control_group').':',
+                                'list' => 
$this->so_control_group->get_control_group_select_array(),
+                                                       ),
+                                                       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_item.index', 
'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                                       'key' => 'id',
+                                                       'label' => lang('ID'),
+                                                       'sortable'      => true,
+                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                               ),
+                                               array(
+                                                       'key'   =>      'title',
+                                                       'label' =>      
lang('Control item title'),
+                                                       'sotrable'      =>      
false
+                                               ),
+                                               array(
+                                                       'key' => 'what_to_do',
+                                                       'label' => 
lang('Control item what to do'),
+                                                       'sortable'      => false
+                                               ),
+                                               array(
+                                                       'key' => 
'control_group_id',
+                                                       'label' => 
lang('Control group'),
+                                                       '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 method. Forwards the user to edit mode.
+               */
+               public function add()
+               {
+                       $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_item.edit'));
+               }
+               
+               
+               public function edit()
+               {
+                       $control_item_id = phpgw::get_var('id');
+                       if(isset($control_item_id) && $control_item_id > 0)
+                       {
+                               $control_item = 
$this->so_control_item->get_single($control_item_id);
+                       }
+                       else
+                       {
+                               $control_item = new controller_control_item();
+                       }
+
                        if(isset($_POST['save_control_item'])) // The user has 
pressed the save button
                        {
-                               if(isset($control_item)) // Edit control
+                               if(isset($control_item)) // Add new values to 
the control item
                                {
                                        
$control_item->set_title(phpgw::get_var('title'));
-                                       
$control_item->set_required(phpgw::get_var('required'));
-                                       $control_item->set_what_to_do( 
phpgw::get_var('what_to_do') );
-                                       $control_item->set_how_to_do( 
phpgw::get_var('how_to_do') );
-                                       $control_item->set_control_group_id( 
strtoint( phpgw::get_var('control_group_id') ) );
-                                       $control_item->set_control_area_id( 
strtoint( phpgw::get_var('control_area_id') ) );
+                                       
$control_item->set_required(phpgw::get_var('required') == 'on' ? true : false);
+                                       $control_item->set_what_to_do( 
phpgw::get_var('what_to_do','html') );
+                                       $control_item->set_how_to_do( 
phpgw::get_var('how_to_do','html') );
+                                       $control_item->set_control_group_id( 
phpgw::get_var('control_group_id') );
+                                       $control_item->set_control_area_id( 
phpgw::get_var('control_area_id') );
                                                                        
-                                       $this->so->add($control_item);
-                               }
-                               else // Add new control
-                               {
-
-                                       $control_item = new 
controller_control();
+                                       //$this->so->store($control_item);
                                        
-                                       
$control_item->set_title(phpgw::get_var('title'));
-                                       
$control_item->set_required(phpgw::get_var('required'));
-                                       $control_item->set_what_to_desc( 
phpgw::get_var('what_to_do') );
-                                       $control_item->set_how_to_desc( 
phpgw::get_var('how_to_do') );
-                                       $control_item->set_control_group_id( 
strtoint( phpgw::get_var('control_group_id') ) );
-                                       $control_item->set_control_area_id( 
strtoint( phpgw::get_var('control_area_id') ) );
-                                                                       
-                                       $this->so->add($control_item);
+                                       if(isset($control_item_id) && 
$control_item_id > 0)
+                                       {
+                                               $ctrl_item_id = 
$control_item_id;
+                                               
if($this->so_control_item->store($control_item))
+                                               {
+                                                       $message = 
lang('messages_saved_form');
+                                               }
+                                               else
+                                               {
+                                                       $error = 
lang('messages_form_error');
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $ctrl_item_id = 
$this->so_control_item->add($control_item);
+                                               if($ctrl_item_id)
+                                               {
+                                                       $message = 
lang('messages_saved_form');
+                                               }
+                                               else
+                                               {
+                                                       $error = 
lang('messages_form_error');
+                                               }
+                                       }
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_item.view', 'id' => $ctrl_item_id));
                                }
                        }
-                       
-                       $control_area_array = 
$this->so_control_area->get_control_area_array();
-                       $control_group_array = 
$this->so_control_group->get_control_group_array();
-                       
-
-                       if($this->flash_msgs)
+                       else if(isset($_POST['cancel_control_item'])) // The 
user has pressed the cancel button
                        {
-                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
-                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               if(isset($control_item_id) && $control_item_id 
> 0)
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_item.view', 'id' => $control_item_id));                   
                   
+                               }
+                               else
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_item.index'));
+                               }
                        }
-
-                       foreach ($control_area_array as $control_area)
+                       else
                        {
-                               $control_area_options[] = array
+                       
+                               $control_area_array = 
$this->so_control_area->get_control_area_array();
+                               $control_group_array = 
$this->so_control_group->get_control_group_array();
+                               
+       
+                               if($this->flash_msgs)
+                               {
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               }
+       
+                               foreach ($control_area_array as $control_area)
+                               {
+                                       $control_area_options[] = array
+                                       (
+                                               'id'    => 
$control_area->get_id(),
+                                               'name'  => 
$control_area->get_title()
+                                                
+                                       );
+                               }
+       
+                               foreach ($control_group_array as $control_group)
+                               {
+                                       $control_group_options[] = array
+                                       (
+                                               'id'    => 
$control_group->get_id(),
+                                               'name'  => 
$control_group->get_group_name()
+                                                
+                                       );
+                               }
+                               
+                               $control_item_array = $control_item->toArray();
+       
+                               $data = array
                                (
-                                       'id'    => $control_area->get_id(),
-                                       'name'  => $control_area->get_title()
-                                        
+                                       'value_id'                              
=> !empty($control_item) ? $control_item->get_id() : 0,
+                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'editable'                              
=> true,
+                                       'control_item'                  => 
$control_item_array,
+                                       'control_area'                  => 
array('options' => $control_area_options),
+                                       'control_group'                 => 
array('options' => $control_group_options),
                                );
+       
+       
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control_item');
+       
+       
+                               
$GLOBALS['phpgw']->richtext->replace_element('what_to_do');
+                               
$GLOBALS['phpgw']->richtext->replace_element('how_to_do');
+                               $GLOBALS['phpgw']->richtext->generate_script();
+       
+       
+       //                      $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'controller.item', 'controller' );
+       
+                               self::render_template_xsl('control_item', 
$data);
                        }
-
-                       foreach ($control_group_array as $control_group)
-                       {
-                               $control_group_options[] = array
-                               (
-                                       'id'    => $control_group->get_id(),
-                                       'name'  => 
$control_group->get_group_name()
-                                        
-                               );
-                       }
-
-                       $data = array
-                       (
-                               'value_id'                              => 
!empty($control) ? $control->get_id() : 0,
-                               'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                               'editable'                              => true,
-                               'control_area'                  => 
array('options' => $control_area_options),
-                               'control_group'                 => 
array('options' => $control_group_options),
-                       );
-
-
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control_item');
-
-/*
-                       
$GLOBALS['phpgw']->richtext->replace_element('what_to_do');
-                       
$GLOBALS['phpgw']->richtext->replace_element('how_to_do');
-                       $GLOBALS['phpgw']->richtext->generate_script();
-*/
-
-//                     $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'controller.item', 'controller' );
-
-                       self::render_template_xsl('control_item', $data);
                }
 
-               public function display_control_items()
+/*             public function display_control_items()
                {
                        //$GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_item_list";
                        
@@ -244,8 +404,9 @@
 
                        self::render_template_xsl('datatable', $data);
                }
-
-               public function display_control_items_json()
+*/
+               
+/*             public function display_control_items_json()
                {
                        $params = array(
                                'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
@@ -290,10 +451,101 @@
 
                        return $this->yui_results($results);
                }
+*/
                
                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
+                       );
+
+                       $user_rows_per_page = 10;
+                       
+                       // 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_item_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_item_id = phpgw::get_var('control_item_id');
+                       if(isset($control_item_id))
+                       {
+                               $control_item = 
rental_socontract::get_instance()->get_single($control_item_id);
+                       }
+                       
+                       $result_objects = 
controller_socontrol_item::get_instance()->get($start_index, $num_of_objects, 
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+                                                               
+                       $results = array();
+                       
+                       foreach($result_objects as $control_item_obj)
+                       {
+                               $results['results'][] = 
$control_item_obj->serialize(); 
+                       }
+
+                       array_walk($results["results"], array($this, 
"_add_links"), "controller.uicontrol_item.view");
+
+                       return $this->yui_results($results);
+               }
+               
+               /**
+                * Public method. Called when a user wants to view information 
about a control item.
+                * @param HTTP::id      the control_item ID
+                */
+               public function view()
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= 
'::'.lang('view');
+                       //Retrieve the control_item object
+                       $control_item_id = (int)phpgw::get_var('id');
+                       if(isset($_POST['edit_control_item']))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_item.edit', 'id' => 
$control_item_id));
+                       }
+                       else
+                       {
+                               if(isset($control_item_id) && $control_item_id 
> 0)
+                               {
+                                       $control_item = 
$this->so_control_item->get_single($control_item_id);
+                               }
+                               else
+                               {
+                                       
$this->render('permission_denied.php',array('error' => 
lang('invalid_request')));
+                                       return;
+                               }
+                               //var_dump($control_item);
+                               
+                               if($this->flash_msgs)
+                               {
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               }
+                               
+                               $control_item_array = $control_item->toArray();
        
+                               $data = array
+                               (
+                                       'value_id'                              
=> !empty($control_item) ? $control_item->get_id() : 0,
+                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'control_item'                  => 
$control_item_array,
+                               );
+       
+       
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control item');
+       
+                               self::render_template_xsl('control_item', 
$data);
+                       }
                }
                
+               
        }

Modified: trunk/controller/inc/model/class.control_item.inc.php
===================================================================
--- trunk/controller/inc/model/class.control_item.inc.php       2011-09-20 
08:53:34 UTC (rev 7672)
+++ trunk/controller/inc/model/class.control_item.inc.php       2011-09-20 
09:01:39 UTC (rev 7673)
@@ -101,5 +101,33 @@
                                                
                        return $result;
                }
+               
+       public function toArray()
+               {
+
+// Alternative 1
+//                     return get_object_vars($this);
+
+// Alternative 2
+                       $exclude = array
+                       (
+                               'get_field', // feiler (foreldreklassen)
+                               'get_so',//unødvendig 
+                       );
+                       
+                       $class_methods = get_class_methods($this);
+                       $control_item_arr = array();
+                       foreach ($class_methods as $class_method)
+                       {
+                               if( stripos($class_method , 'get_' ) === 0  && 
!in_array($class_method, $exclude))
+                               {
+                                       $_class_method_part = explode('get_', 
$class_method);
+                                       
$control_item_arr[$_class_method_part[1]] = $this->$class_method();
+                               }
+                       }
+
+//                     _debug_array($control_item_arr);
+                       return $control_item_arr;
+               }
        }
 ?>
\ No newline at end of file

Modified: trunk/controller/setup/tables_current.inc.php
===================================================================
--- trunk/controller/setup/tables_current.inc.php       2011-09-20 08:53:34 UTC 
(rev 7672)
+++ trunk/controller/setup/tables_current.inc.php       2011-09-20 09:01:39 UTC 
(rev 7673)
@@ -40,8 +40,8 @@
                                'id' => array('type' => 'auto','precision' => 
4,'nullable' => False),
                                'title' => array('type' => 
'varchar','precision' => '100','nullable' => false),
                                'required' => array('type' => 'bool','nullable' 
=> true,'default' => 'false'),
-                               'what_to_do' => array('type' => 
'varchar','precision' => '255','nullable' => false),
-                               'how_to_do' => array('type' => 
'varchar','precision' => '255','nullable' => false),
+                               'what_to_do' => array('type' => 
'text','nullable' => false),
+                               'how_to_do' => array('type' => 
'text','nullable' => false),
                                'control_group_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
                                'control_area_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True)
                        ),

Modified: trunk/controller/templates/base/control_item.xsl
===================================================================
--- trunk/controller/templates/base/control_item.xsl    2011-09-20 08:53:34 UTC 
(rev 7672)
+++ trunk/controller/templates/base/control_item.xsl    2011-09-20 09:01:39 UTC 
(rev 7673)
@@ -19,48 +19,114 @@
                                                <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_item/title}" />
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:value-of 
select="control_item/title"/>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                        </dd>
                                        <dt>
                                                <label 
for="required">Obligatorisk</label>
                                        </dt>
                                        <dd>
-                                               <input type="checkbox" value="" 
/>
+                                       <xsl:variable 
name="required_item"><xsl:value-of select="control_item/required" 
/></xsl:variable>
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="$required_item=1">
+                                                                       <input 
type="checkbox" name="required" id="required" checked="true"/>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       <input 
type="checkbox" name="required" id="required"/>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="$required_item=1">
+                                                                       <input 
type="checkbox" name="required" id="required" checked="true" disabled="true"/>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       <input 
type="checkbox" name="required" id="required" disabled="true" />
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                        </dd>
                                        <dt>
                                                <label for="what_to_do">Hva 
skal utføres</label>
                                        </dt>
                                        <dd>
-                                               <textarea id="what_to_do" 
rows="5" cols="60"></textarea>
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <textarea 
name="what_to_do" id="what_to_do" rows="5" cols="60"><xsl:value-of 
select="control_item/what_to_do" disable-output-escaping="yes" /></textarea>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:value-of 
select="control_item/what_to_do" disable-output-escaping="yes" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                        </dd>
                                        <dt>
                                                <label 
for="how_to_do">Utførelsesbeskrivelse</label>
                                        </dt>
                                        <dd>
-                                               <textarea id="how_to_do" 
rows="5" cols="60"></textarea>
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <textarea 
name="how_to_do" id="how_to_do" rows="5" cols="60"><xsl:value-of 
select="control_item/how_to_do" disable-output-escaping="yes" /></textarea>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:value-of 
select="control_item/how_to_do" disable-output-escaping="yes" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                        </dd>
                                        <dt>
                                                <label 
for="control_group">Kontrollgruppe</label>
                                        </dt>
                                        <dd>
-                                               <select id="control_group" 
name="control_group">
-                                                       <xsl:apply-templates 
select="control_group/options"/>
-                                               </select>
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <select 
id="control_group" name="control_group">
+                                                               
<xsl:apply-templates select="control_group/options"/>
+                                                       </select>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:value-of 
select="control_item/control_group_id" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                        </dd>
                                        <dt>
                                                <label 
for="control_area">Kontrollområde</label>
                                        </dt>
                                        <dd>
-                                               <select id="control_area" 
name="control_area">
-                                                       <xsl:apply-templates 
select="control_area/options"/>
-                                               </select>
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <select 
id="control_area" name="control_area">
+                                                               
<xsl:apply-templates select="control_area/options"/>
+                                                       </select>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:value-of 
select="control_item/control_area_id" />
+                                               </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}">
-                                       </input>
+                                       <xsl:choose>
+                                               <xsl:when test="editable">
+                                                       <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
+                                                       <xsl:variable 
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')" 
/></xsl:variable>
+                                                       <input type="submit" 
name="save_control_item" value="{$lang_save}" title = "{$lang_save}" />
+                                                       <input type="submit" 
name="cancel_control_item" value="{$lang_cancel}" title = "{$lang_cancel}" />
+                                               </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_item" value="{$lang_edit}" title = "{$lang_edit}" />
+                                               </xsl:otherwise>
+                                       </xsl:choose>
                                </div>
                                
                        </form>

Modified: trunk/controller/templates/base/css/base.css
===================================================================
--- trunk/controller/templates/base/css/base.css        2011-09-20 08:53:34 UTC 
(rev 7672)
+++ trunk/controller/templates/base/css/base.css        2011-09-20 09:01:39 UTC 
(rev 7673)
@@ -464,4 +464,9 @@
 dd ol li {
        list-style: decimal;
        list-style-position: inside;
+}
+
+dd ul li {
+       list-style: disc;
+       list-style-position: inside;
 }
\ No newline at end of file




reply via email to

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