[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [6524] Rental: Added delegate functionality for backe
From: |
Joakim Hop |
Subject: |
[Fmsystem-commits] [6524] Rental: Added delegate functionality for backend users |
Date: |
Fri, 29 Oct 2010 09:55:03 +0000 |
Revision: 6524
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6524
Author: joakim_hop
Date: 2010-10-29 09:55:02 +0000 (Fri, 29 Oct 2010)
Log Message:
-----------
Rental: Added delegate functionality for backend users
Modified Paths:
--------------
trunk/rental/inc/class.menu.inc.php
trunk/rental/setup/phpgw_no.lang
Added Paths:
-----------
trunk/rental/inc/class.uidelegate.inc.php
trunk/rental/inc/class.uiresultunit.inc.php
trunk/rental/templates/base/delegate_list.php
trunk/rental/templates/base/resultunit.php
trunk/rental/templates/base/resultunit_list.php
trunk/rental/templates/base/resultunit_list_partial.php
trunk/rental/templates/portico/images/system-users.png
Modified: trunk/rental/inc/class.menu.inc.php
===================================================================
--- trunk/rental/inc/class.menu.inc.php 2010-10-29 08:30:20 UTC (rev 6523)
+++ trunk/rental/inc/class.menu.inc.php 2010-10-29 09:55:02 UTC (rev 6524)
@@ -92,15 +92,16 @@
'url' => '',
'image' => array('rental',
'x-office-document'),
'children' => $sync_choices
+ ),
+ 'resultunit' => array
+ (
+ 'text' => lang('delegates'),
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'rental.uiresultunit.index','appname' => 'rental') ),
+ 'image' => array('rental',
'system-users')
)
);
}
-
-
-
-
-
$menus['navigation'] = array
(
'contracts' => array
Added: trunk/rental/inc/class.uidelegate.inc.php
===================================================================
--- trunk/rental/inc/class.uidelegate.inc.php (rev 0)
+++ trunk/rental/inc/class.uidelegate.inc.php 2010-10-29 09:55:02 UTC (rev
6524)
@@ -0,0 +1,139 @@
+<?php
+ phpgw::import_class('rental.uicommon');
+
+ class uidelegate extends rental_uicommon
+ {
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'query' => true,
+ 'add_delegate' => true,
+ 'remove_delegate' => true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ self::set_active_menu('rental::delegates');
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('delegates');
+ }
+
+ public function query(){
+ $unit_id = (int)phpgw::get_var('unit_id');
+
+ if (isset($unit_id) && $unit_id > 0) {
+ $delegates_per_org_unit =
frontend_bofrontend::get_delegates($unit_id);
+ }
+
+ $delegates_data = array('results' =>
$delegates_per_org_unit, 'total_records' => count($delegates_per_org_unit));
+
+ $editable = phpgw::get_var('editable') == 'true' ? true
: false;
+
+ return $this->yui_results($resultunit_data,
'total_records', 'results');
+ }
+
+ public function index(){
+ if(isset($_POST['search']))
+ {
+ $username = phpgw::get_var('username');
+ if(!isset($username))
+ {
+ $msglog['error'][] = array('msg' =>
lang('lacking_username'));
+ }
+ else if($username ==
$GLOBALS['phpgw_info']['user']['account_lid'])
+ {
+ $msglog['error'][] = array('msg' =>
lang('searching_for_self'));
+ }
+ else
+ {
+ $account_id =
frontend_bofrontend::delegate_exist($username);
+ if($account_id)
+ {
+ $search =
frontend_bofrontend::get_account_info($account_id);
+ $msglog['message'][] =
array('msg' => lang('user_found_in_PE'));
+ }
+ else
+ {
+ $fellesdata_user =
frontend_bofellesdata::get_instance()->get_user($username);
+ if($fellesdata_user)
+ {
+ $search =
$fellesdata_user;
+ $msglog['message'][] =
array('msg' => lang('user_found_in_Fellesdata'));
+ }
+ else
+ {
+ $msglog['error'][] =
array('msg' => lang('no_hits'));
+ }
+ }
+ }
+ }
+ else if(isset($_POST['add']))
+ {
+ $account_id = phpgw::get_var('account_id');
+
+ $org_units =
frontend_bofellesdata::get_instance()->get_result_units($GLOBALS['phpgw_info']['user']['account_lid']);
+
+ //Parameter to delegate access to only a single
organisational unit
+ $org_unit_id =
$this->header_state['selected_org_unit'];
+ $success = true;
+
+ foreach($org_units as $org_unit)
+ {
+ if($org_unit_id == 'all' ||
$org_unit['ORG_UNIT_ID'] == $org_unit_id)
+ {
+ $res =
$this->add_delegate($account_id,$org_unit['ORG_UNIT_ID'],$org_unit['ORG_NAME']);
+ if(!$res)
+ {
+ $msglog['error'][] =
array('msg' => lang('error_delegating_unit',$org_unit['ORG_NAME']));
+ }
+ $success = $success && $res;
+ }
+ }
+
+ if($success)
+ {
+ $msglog['message'][] = array('msg' =>
lang('delegation_successful'));
+ }
+ else
+ {
+ $msglog['error'][] = array('msg' =>
lang('delegation_error'));
+ }
+ }
+
+
+
+
+
+ $this->render('delegate_list.php');
+ }
+
+ public function add_delegate(int $account_id, $org_unit_id,
$org_name)
+ {
+ if(!isset($account_id) || $account_id == '')
+ {
+ //User is only registered in Fellesdata
+ $username = phpgw::get_var('username');
+ $firstname = phpgw::get_var('firstname');
+ $lastname = phpgw::get_var('lastname');
+ $password = 'TEst1234';
+
+ $account_id =
frontend_bofrontend::create_delegate_account($username, $firstname, $lastname,
$password);
+
+ if(isset($account_id) &&
!is_numeric($account_id))
+ {
+ return false;
+ }
+ }
+ return frontend_bofrontend::add_delegate($account_id,
null, $org_unit_id, $org_name);
+ }
+
+ public function remove_delegate()
+ {
+ $account_id = phpgw::get_var('account_id');
+ $owner_id = phpgw::get_var('owner_id');
+
+
frontend_bofrontend::remove_delegate($account_id,$owner_id);
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'rental.uiresultunit.edit'));
+ }
+ }
\ No newline at end of file
Added: trunk/rental/inc/class.uiresultunit.inc.php
===================================================================
--- trunk/rental/inc/class.uiresultunit.inc.php (rev 0)
+++ trunk/rental/inc/class.uiresultunit.inc.php 2010-10-29 09:55:02 UTC (rev
6524)
@@ -0,0 +1,96 @@
+<?php
+ phpgw::import_class('rental.uicommon');
+ phpgw::import_class('rental.bofellesdata');
+
+ class rental_uiresultunit extends rental_uicommon
+ {
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'edit' => true,
+ 'query' => true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ self::set_active_menu('rental::resultunit');
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('delegates');
+ }
+
+ 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',
'string', 'GET', 'identifier');
+ $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_count = 0;
+
+
+ // get all result unit from fellesdata
+ $bofelles = rental_bofellesdata::get_instance();
+ $result_units = $bofelles->get_result_units();
+
+ foreach($result_units as &$unit) {
+ $delegates_per_org_unit =
frontend_bofrontend::get_delegates($unit['ORG_UNIT_ID']);
+ $number_of_delegates =
count($delegates_per_org_unit);
+ $unit['UNIT_NO_OF_DELEGATES'] =
$number_of_delegates;
+ }
+
+ $resultunit_data = array('results' => $result_units,
'total_records' => count($result_units));
+
+ $editable = phpgw::get_var('editable') == 'true' ? true
: false;
+
+ array_walk($resultunit_data['results'], array($this,
'add_actions'));
+
+ return $this->yui_results($resultunit_data,
'total_records', 'results');
+ }
+
+ /**
+ * View a list of all resultunits
+ */
+ public function index()
+ {
+ $search_for = phpgw::get_var('search_for');
+ if($search_for)
+ {
+ phpgwapi_cache::session_set('rental',
'resultunit_query', $search_for);
+ }
+ $this->render('resultunit_list.php');
+ }
+
+
+ public function add_actions(&$value)
+ {
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uiresultunit.edit',
'id' => $value['unit_id'], 'initial_load' => 'no')));
+ $value['labels'][] = lang('edit_delegate');
+ }
+
+ public function edit(){
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('edit');
+ $unit_id = (int)phpgw::get_var('id');
+
+ if (isset($unit_id) && $unit_id > 0) {
+
+ $bofelles = rental_bofellesdata::get_instance();
+ $unit ;//= $bofelles->get_result_unit($unit_id);
+
+ $this->render('resultunit.php', $unit);
+ }
+ }
+ }
\ No newline at end of file
Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang 2010-10-29 08:30:20 UTC (rev 6523)
+++ trunk/rental/setup/phpgw_no.lang 2010-10-29 09:55:02 UTC (rev 6524)
@@ -161,6 +161,7 @@
date rental no Dato
date_start rental no Gjelder fra
decimal separator rental no Skilletegn for desimaler
+delegates rental no Delegering
delete rental no Slett
department rental no Avdeling
deposit rental no Depositum
@@ -413,6 +414,7 @@
recurrence rental no Gjentakelse
reference rental no Deres ref
regulation rental no Regulering
+related_delegates rental no Delegater
remove rental no Fjern
remove_from_workbench rental no Fjern fra mitt skrivebord
remove_from_all_workbenches rental no Fjern fra alle skrivebord
@@ -429,6 +431,8 @@
responsibility_id rental no Ansvar
Responsibility id must be 6 characters. rental no Ansvar må være
seks tegn.
responsibility_id_not_numeric rental no Ansvar må være et tall
+result_unit_back rental no Resultatsliste
+result_unit rental no Resultatsenhet
result_unit_number rental no Resultatsenhet
Run rental no Kjørt
run by rental no Utført av
@@ -512,6 +516,10 @@
under_dismissal rental no Under oppsigelse
under_planning rental no Under planlegging
units rental no Enheter
+unit_id rental no Enhetsid
+unit_name rental no Enhetsnavn
+unit_leader_name rental no Navn enhetsleder
+unit_no_of_delegates rental no Antall delegater
update rental no Oppdatér
upload rental no Last opp
url rental no Nettsted
Added: trunk/rental/templates/base/delegate_list.php
===================================================================
--- trunk/rental/templates/base/delegate_list.php
(rev 0)
+++ trunk/rental/templates/base/delegate_list.php 2010-10-29 09:55:02 UTC
(rev 6524)
@@ -0,0 +1,87 @@
+<script type="text/javascript">
+ //Add listener resetting form: redirects browser to call index again
+ YAHOO.util.Event.addListener(
+ 'ctrl_reset_button',
+ 'click',
+ function(e)
+ {
+ YAHOO.util.Event.stopEvent(e);
+ window.location =
'index.php?menuaction=rental.uidelegate.index';
+ }
+ );
+
+ // Defining columns for datatable
+ var columnDefs = [{
+ key: "account_lastname",
+ label: "<?php echo lang('account_lastname') ?>",
+ sortable: true
+ },
+ {
+ key: "account_firstname",
+ label: "<?php echo lang('account_firstname') ?>",
+ sortable: true
+ },
+ {
+ key: "actions",
+ hidden: true
+ },
+ {
+ key: "labels",
+ hidden: true
+ },
+ {
+ key: "ajax",
+ hidden: true
+ }];
+
+ // Initiating the data source
+ setDataSource(
+
'index.php?menuaction=rental.uidelegate.query&phpgw_return_as=json<?php
echo $url_add_on; ?>&editable=<?php echo isset($editable) && $editable ?
"true" : "false"; ?>',
+ columnDefs,
+ '<?php echo $list_id ?>_form',
+ '<?php echo $list_id ?>_ctrl_search_query',
+ '<?php echo $list_id ?>_container',
+ '<?php echo $list_id ?>_paginator',
+ '<?php echo $list_id ?>',
+ '<?php echo isset($editor_action) ? $editor_action : '' ?>'
+ );
+
+</script>
+
+<?php
+ if($list_form)
+ {
+?>
+<form id="<?php echo $list_id ?>_form" method="GET">
+ <fieldset>
+
+ <input type="hidden" name="account_id"
value="{search/account_id}"/>
+ <label><?php echo lang('username') ?> </label>
+ <input type="text" name="username"
value="{search/username}"/><input type="submit" name="search" value="<?php echo
lang('btn_search') ?>"/>
+ <br/>
+ <label><?php echo lang('firstname') ?> </label>
+ <input type="text" name="firstname" readonly=""
value="{search/firstname}" style="background-color: #CCCCCC;"/>
+ <br/>
+ <label><?php echo lang('lastname') ?> </label>
+ <input type="text" name="lastname" readonly=""
value="{search/lastname}" style="background-color: #CCCCCC;"/>
+ <br/>
+ <label><?php echo lang('email') ?> </label>
+ <input type="text" name="email" readonly=""
value="{search/email}" style="background-color: #CCCCCC;"/>
+ <br/>
+ <input type="submit" name="add" value="<?php echo
lang('btn_add') ?>"/>
+
+ <!-- Search -->
+ <h3><?php echo lang('search_options') ?></h3>
+ <label for="ctrl_search_query"><?php echo lang('search_for')
?></label>
+ <input id="<?php echo $list_id ?>_ctrl_search_query"
type="text" name="query" autocomplete="off" value="<?php echo isset($q) ? $q :
''?>"/>
+ <input type="submit" id="ctrl_search_button" value="<?php echo
lang('search') ?>" />
+ <input type="button" id="ctrl_reset_button" value="<?php echo
lang('reset') ?>" />
+ </fieldset>
+
+</form>
+<?php
+ } // end if($list_form)
+?>
+
+<div id="<?php echo $list_id ?>_paginator" class="paginator"></div>
+<div id="<?php echo $list_id ?>_container" class="datatable_container"></div>
\ No newline at end of file
Added: trunk/rental/templates/base/resultunit.php
===================================================================
--- trunk/rental/templates/base/resultunit.php (rev 0)
+++ trunk/rental/templates/base/resultunit.php 2010-10-29 09:55:02 UTC (rev
6524)
@@ -0,0 +1,64 @@
+<?php
+ include("common.php");
+ phpgwapi_yui::load_widget('tabview');
+ phpgwapi_yui::tabview_setup('result_unit_tabview');
+ $config = CreateObject('phpgwapi.config','rental');
+ $config->read();
+?>
+
+<!-- ?php echo rental_uicommon::get_page_error($error) ?-->
+<!-- ?php echo
rental_uicommon::get_page_warning($contract->get_validation_warnings()) ?-->
+<!-- ?php echo rental_uicommon::get_page_message($message) ?-->
+
+
+<!-- HOPPET OVER WARNINGS FORELØPIG -->
+
+<div class="identifier-header">
+ <h1><img src="<?php echo RENTAL_TEMPLATE_PATH
?>images/32x32/apps/system-users.png" /> <?php echo lang('result_unit'); ?></h1>
+ <div style="float: left; width: 50%;">
+ <button onclick="javascript:window.location.href ='<?php echo
$cancel_link;?>;'">« <?php echo lang('result_unit_back');
?></button><br/>
+ <label><?php echo lang('unit_id'); ?> </label>
+ <?php if($unit["ORG_UNIT_ID"]){
+ echo $unit["ORG_UNIT_ID"];
+ } ?>
+ <br/>
+ <label><?php echo lang('unit_name'); ?></label>
+ <?php echo $unit["ORG_NAME"]; ?>
+ <br/>
+ <label><?php echo lang('unit_leader_name'); ?></label>
+ <?php echo $unit["UNIT_ID"]; ?>
+ <br/>
+ <label><?php echo lang('unit_no_of_delegates') ?></label>
+ <?php echo $unit["UNIT_NO_OF_DELEGATES"]; ?>
+ </div>
+</div>
+
+<script type="text/javascript" language="JavaScript">
+function loadDatatables(delegates){
+ if(currTab == 'composites'){
+ for(i=0;i<YAHOO.rental.datatables.length;i++){
+ if(YAHOO.rental.datatables[i].tid ==
'included_delegates'){
+ reloadDataSources(YAHOO.rental.datatables[i]);
+ }
+ }
+ }
+}
+</script>
+
+<div id="result_unit_tabview" class="yui-navset">
+ <ul class="yui-nav">
+ <li><a href="#delegates" onclick="javascript:
loadDatatables('delegates');"><em><img src="<?php echo RENTAL_TEMPLATE_PATH
?>images/16x16/apps/system-users.png" alt="icon" /> <?php echo
lang('delegates') ?></em></a></li>
+ </ul>
+ <div class="yui-content">
+ <?php if($unit["ORG_UNIT_ID"] > 0) {?>
+ <div id="delegates">
+ <h3><?php echo lang('related_delegates') ?></h3>
+ <?php
+ $list_form = false;
+ $list_id = 'included_delegates';
+ $url_add_on =
'&type=included_delegates&unit_id='.$unit["ORG_UNIT_ID"];
+ include('delegates_list_partial.php');
?>
+ </div>
+ <?php }?>
+ </div>
+</div>
\ No newline at end of file
Added: trunk/rental/templates/base/resultunit_list.php
===================================================================
--- trunk/rental/templates/base/resultunit_list.php
(rev 0)
+++ trunk/rental/templates/base/resultunit_list.php 2010-10-29 09:55:02 UTC
(rev 6524)
@@ -0,0 +1,12 @@
+<?php
+ include("common.php");
+?>
+
+<h1><img src="<?php echo RENTAL_TEMPLATE_PATH
?>images/32x32/apps/system-users.png" /> <?php echo lang('delegates') ?></h1>
+
+<?php
+$list_form = true;
+$list_id = 'all_result_units';
+$url_add_on = '&type=all_result_units';
+include('resultunit_list_partial.php');
+?>
Added: trunk/rental/templates/base/resultunit_list_partial.php
===================================================================
--- trunk/rental/templates/base/resultunit_list_partial.php
(rev 0)
+++ trunk/rental/templates/base/resultunit_list_partial.php 2010-10-29
09:55:02 UTC (rev 6524)
@@ -0,0 +1,94 @@
+<script type="text/javascript">
+ //Add listener resetting form: redirects browser to call index again
+ YAHOO.util.Event.addListener(
+ 'ctrl_reset_button',
+ 'click',
+ function(e)
+ {
+ YAHOO.util.Event.stopEvent(e);
+ window.location =
'index.php?menuaction=rental.uiresultunit.index';
+ }
+ );
+
+ // Defining columns for datatable
+ var columnDefs = [{
+ key: "unit_id",
+ label: "<?php echo lang('unit_id') ?>",
+ sortable: true
+ },
+ {
+ key: "unit_name",
+ label: "<?php echo lang('unit_name') ?>",
+ sortable: true
+ },
+ {
+ key: "unit_leader_name",
+ label: "<?php echo lang('unit_leader_name') ?>",
+ sortable: true
+ },
+ {
+ key: "unit_no_of_delegates",
+ label: "<?php echo lang('unit_no_of_delegates') ?>",
+ sortable: true
+ },
+ {
+ key: "actions",
+ hidden: true
+ },
+ {
+ key: "labels",
+ hidden: true
+ },
+ {
+ key: "ajax",
+ hidden: true
+ }];
+
+ // Initiating the data source
+ setDataSource(
+
'index.php?menuaction=rental.uiresultunit.query&phpgw_return_as=json<?php
echo $url_add_on; ?>&editable=<?php echo isset($editable) && $editable ?
"true" : "false"; ?>',
+ columnDefs,
+ '<?php echo $list_id ?>_form',
+ '<?php echo $list_id ?>_ctrl_search_query',
+ '<?php echo $list_id ?>_container',
+ '<?php echo $list_id ?>_paginator',
+ '<?php echo $list_id ?>',
+ '<?php echo isset($editor_action) ? $editor_action : '' ?>'
+ );
+
+</script>
+
+<?php
+ if($list_form)
+ {
+?>
+<form id="<?php echo $list_id ?>_form" method="GET">
+<?php
+ $populate = phpgw::get_var('populate_form');
+ //Avoid Notices
+ $q = false;
+ $s_type = false;
+ $status = false;
+ $status_contract = false;
+ if(isset($populate))
+ {
+ $q = phpgwapi_cache::session_get('rental', 'resultunit_query');
+ $s_type = phpgwapi_cache::session_get('rental',
'resultunit_search_type');
+ }
+?>
+ <fieldset>
+ <!-- Search -->
+ <h3><?php echo lang('search_options') ?></h3>
+ <label for="ctrl_search_query"><?php echo lang('search_for')
?></label>
+ <input id="<?php echo $list_id ?>_ctrl_search_query"
type="text" name="query" autocomplete="off" value="<?php echo isset($q) ? $q :
''?>"/>
+ <input type="submit" id="ctrl_search_button" value="<?php echo
lang('search') ?>" />
+ <input type="button" id="ctrl_reset_button" value="<?php echo
lang('reset') ?>" />
+ </fieldset>
+
+</form>
+<?php
+ } // end if($list_form)
+?>
+
+<div id="<?php echo $list_id ?>_paginator" class="paginator"></div>
+<div id="<?php echo $list_id ?>_container" class="datatable_container"></div>
\ No newline at end of file
Added: trunk/rental/templates/portico/images/system-users.png
===================================================================
(Binary files differ)
Property changes on: trunk/rental/templates/portico/images/system-users.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [6524] Rental: Added delegate functionality for backend users,
Joakim Hop <=