fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7627]


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [7627]
Date: Fri, 16 Sep 2011 08:34:49 +0000

Revision: 7627
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7627
Author:   erikhl
Date:     2011-09-16 08:34:49 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/templates/base/procedure_item.xsl

Added Paths:
-----------
    trunk/controller/inc/class.uiprocedure.inc.php

Added: trunk/controller/inc/class.uiprocedure.inc.php
===================================================================
--- trunk/controller/inc/class.uiprocedure.inc.php                              
(rev 0)
+++ trunk/controller/inc/class.uiprocedure.inc.php      2011-09-16 08:34:49 UTC 
(rev 7627)
@@ -0,0 +1,281 @@
+<?php
+       phpgw::import_class('controller.uicommon');
+       phpgw::import_class('controller.soprocedure');
+       
+       include_class('controller', 'procedure', 'inc/model/');
+
+       class controller_uiprocedure extends controller_uicommon
+       {
+               private $so;
+               
+               public $public_functions = array
+               (
+                       'index' =>      true,
+                       'query' =>      true,
+                       'edit'  =>      true,
+                       'view'  =>      true,
+                       'add'   =>      true
+               );
+
+               public function __construct()
+               {
+                       parent::__construct();
+
+                       $this->so = CreateObject('controller.soprocedure');
+                       $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::procedure";
+                       //$this->bo = CreateObject('property.boevent',true);
+               }
+               
+               public function index()
+               {
+                       $this->render('procedure_list.php');
+               }
+               
+               public function edit()
+               {
+                       $procedure_id = phpgw::get_var('id');
+                       if(isset($procedure_id) && $procedure_id > 0)
+                       {
+                               $procedure = 
$this->so->get_single($procedure_id);
+                       }
+                       else
+                       {
+                               $procedure = new controller_procedure();
+                       }
+                       
+
+                       if(isset($_POST['save_procedure'])) // The user has 
pressed the save button
+                       {
+                               if(isset($procedure)) // Edit procedure
+                               {
+                                       
$procedure->set_title(phpgw::get_var('title'));
+                                       
$procedure->set_purpose(phpgw::get_var('purpose'));
+                                       
$procedure->set_responsibility(phpgw::get_var('responsibility'));
+                                       
$procedure->set_description(phpgw::get_var('description'));
+                                       
$procedure->set_reference(phpgw::get_var('reference'));
+                                       
$procedure->set_attachment(phpgw::get_var('attachment'));
+                                       
+                                       if(isset($procedure_id) && 
$procedure_id > 0)
+                                       {
+                                               if($this->so->store($procedure))
+                                               {
+                                                       $message = 
lang('messages_saved_form');
+                                               }
+                                               else
+                                               {
+                                                       $error = 
lang('messages_form_error');
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $proc_id = 
$this->so->add($procedure);
+                                               if($proc_id)
+                                               {
+                                                       $message = 
lang('messages_saved_form');
+                                               }
+                                               else
+                                               {
+                                                       $error = 
lang('messages_form_error');
+                                               }
+                                       }
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uiprocedure.view', 'id' => $proc_id));
+                               }
+                       }
+                       else if(isset($_POST['cancel_procedure'])) // The user 
has pressed the cancel button
+                       {
+                               if(isset($procedure_id) && $procedure_id > 0)
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uiprocedure.view', 'id' => $procedure_id));                         
           
+                               }
+                               else
+                               {
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uiprocedure.index'));
+                               }
+                       }
+                       else
+                       {
+                               if($this->flash_msgs)
+                               {
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               }
+                               
+                               $procedure_array = $procedure->toArray();
+                               //_debug_array($procedure_array);
+       
+                               $data = array
+                               (
+                                       'value_id'                              
=> !empty($procedure) ? $procedure->get_id() : 0,
+                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'editable'                              
=> true,
+                                       'procedure'                             
=> $procedure_array,
+                               );
+       
+       
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Procedure');
+       
+       
+                               
$GLOBALS['phpgw']->richtext->replace_element('purpose');
+                               
$GLOBALS['phpgw']->richtext->replace_element('description');
+                               $GLOBALS['phpgw']->richtext->generate_script();
+       
+       
+       //                      $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'controller.item', 'controller' );
+       
+                               self::render_template_xsl('procedure_item', 
$data);
+                       }
+               }
+               
+               /**
+               * Public method. Forwards the user to edit mode.
+               */
+               public function add()
+               {
+                       $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uiprocedure.edit'));
+               }
+               
+               /**
+                * Public method. Called when a user wants to view information 
about a procedure.
+                * @param HTTP::id      the procedure ID
+                */
+               public function view()
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= 
'::'.lang('view');
+                       //Retrieve the procedure object
+                       $procedure_id = (int)phpgw::get_var('id');
+                       if(isset($_POST['edit_procedure']))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uiprocedure.edit', 'id' => $procedure_id));
+                       }
+                       else
+                       {
+                               if(isset($procedure_id) && $procedure_id > 0)
+                               {
+                                       $procedure = 
$this->so->get_single($procedure_id);
+                               }
+                               else
+                               {
+                                       
$this->render('permission_denied.php',array('error' => 
lang('invalid_request')));
+                                       return;
+                               }
+                               
+                               if($this->flash_msgs)
+                               {
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               }
+                               
+                               $procedure_array = $procedure->toArray();
+                               //_debug_array($procedure_array);
+       
+                               $data = array
+                               (
+                                       'value_id'                              
=> !empty($procedure) ? $procedure->get_id() : 0,
+                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'procedure'                             
=> $procedure_array,
+                               );
+       
+       
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Procedure');
+       
+                               self::render_template_xsl('procedure_item', 
$data);
+                       }
+               }
+                                       
+               public function 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;
+                       }
+                       // 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');
+                       $sort_ascending = phpgw::get_var('dir') == 'desc' ? 
false : true;
+                       // Form variables
+                       $search_for     = phpgw::get_var('query');
+                       $search_type    = phpgw::get_var('search_option');
+                       // Create an empty result set
+                       $result_objects = array();
+                       $result_count = 0;
+                       
+                       //Retrieve a contract identifier and load corresponding 
contract
+                       $procedure_id = phpgw::get_var('procedure_id');
+                       
+                       $exp_param      = phpgw::get_var('export');
+                       $export = false;
+                       if(isset($exp_param)){
+                               $export=true;
+                               $num_of_objects = null;
+                       }
+                       
+                       //Retrieve the type of query and perform type specific 
logic
+                       $query_type = phpgw::get_var('type');
+                       switch($query_type)
+                       {
+                               case 'all_procedures': // ... all composites, 
filters (active and vacant)
+                                       
phpgwapi_cache::session_set('controller', 'procedure_query', $search_for);
+                                       $filters = array();
+                                       $result_objects = 
$this->so->get($start_index, $num_of_objects, $sort_field, $sort_ascending, 
$search_for, $search_type, $filters);
+                                       $object_count = 
$this->so->get_count($search_for, $search_type, $filters);
+                                       break;
+                       }
+
+                       //Create an empty row set
+                       $rows = array();
+                       foreach($result_objects as $result) {
+                               if(isset($result))
+                               {
+                                       $rows[] = $result->serialize();
+                               }
+                       }
+                       
+                       // ... add result data
+                       $result_data = array('results' => $rows, 
'total_records' => $object_count);
+                       
+                       $editable = phpgw::get_var('editable') == 'true' ? true 
: false;
+                       
+                       if(!$export){
+                               //Add action column to each row in result table
+                               array_walk(
+                                       $result_data['results'],
+                                       array($this, 'add_actions'), 
+                                       array(                                  
                                                                // Parameters 
(non-object pointers)
+                                               $procedure_id,                  
                                                        // [1] The procedure id
+                                               $editable,                      
                                                                // [2] Editable 
flag                    
+                                       )
+                               );
+                       }
+
+                       return $this->yui_results($result_data, 
'total_records', 'results');
+
+               }
+
+                       public function add_actions(&$value, $key, $params)
+               {
+                       //Defining new columns
+                       $value['ajax'] = array();
+                       $value['actions'] = array();
+                       $value['labels'] = array();
+
+                       // Get parameters
+                       $procedure_id = $params[0];
+                       $editable = $params[1];
+                       
+                       // Depending on the type of query: set an ajax flag and 
define the action and label for each row
+                       switch($type)
+                       {
+                               default:
+                                       $value['ajax'][] = false;
+                                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uiprocedure.view', 'id' => $value['id'])));
+                                       $value['labels'][] = lang('show');
+                                       $value['ajax'][] = false;
+                                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uiprocedure.edit', 'id' => $value['id'])));
+                                       $value['labels'][] = lang('edit');
+                       }
+               }
+       }
\ No newline at end of file

Modified: trunk/controller/templates/base/procedure_item.xsl
===================================================================
--- trunk/controller/templates/base/procedure_item.xsl  2011-09-16 08:29:49 UTC 
(rev 7626)
+++ trunk/controller/templates/base/procedure_item.xsl  2011-09-16 08:34:49 UTC 
(rev 7627)
@@ -99,7 +99,9 @@
                                        <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_procedure" value="{$lang_save}" title = "{$lang_save}" />
+                                                       <input type="submit" 
name="cancel_procedure" 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>




reply via email to

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