fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [6533] Rental: Added delegate functionality for backe


From: Joakim Hop
Subject: [Fmsystem-commits] [6533] Rental: Added delegate functionality for backend users
Date: Tue, 02 Nov 2010 07:34:47 +0000

Revision: 6533
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6533
Author:   joakim_hop
Date:     2010-11-02 07:34:47 +0000 (Tue, 02 Nov 2010)
Log Message:
-----------
Rental: Added delegate functionality for backend users

Modified Paths:
--------------
    trunk/rental/inc/class.bofellesdata.inc.php
    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_partial.php

Modified: trunk/rental/inc/class.bofellesdata.inc.php
===================================================================
--- trunk/rental/inc/class.bofellesdata.inc.php 2010-11-02 07:33:17 UTC (rev 
6532)
+++ trunk/rental/inc/class.bofellesdata.inc.php 2010-11-02 07:34:47 UTC (rev 
6533)
@@ -157,6 +157,52 @@
                        return $result_units;
                }
                
+               public function get_result_units_with_leader($search_for, 
$search_type)
+               {
+                       
+                       $columns = "V_ORG_ENHET.ORG_ENHET_ID, 
V_ORG_ENHET.ORG_NAVN, V_ORG_PERSON.FORNAVN, V_ORG_PERSON.ETTERNAVN, 
V_ORG_PERSON.BRUKERNAVN";
+                       $tables = "V_ORG_ENHET, V_ORG_PERSON";
+                       $joins =        "LEFT JOIN V_ORG_PERSON_ENHET ON 
(V_ORG_PERSON_ENHET.ORG_ENHET_ID = V_ORG_ENHET.ORG_ENHET_ID) ".
+                                       "LEFT JOIN V_ORG_PERSON ON 
(V_ORG_PERSON.ORG_PERSON_ID = V_ORG_PERSON_ENHET.ORG_PERSON_ID)";
+                       $sql = "SELECT $columns FROM $tables $joins WHERE 
V_ORG_ENHET.ORG_NIVAA = 4";
+                       if($search_for){
+                               $selector = "";
+                               switch($search_type){
+                                       case 'unit_leader':
+                                                       $selector = "";
+                                               break;
+                                       default:
+                                                       $selector = "ORG_NAVN 
LIKE '%".$search_for."%'";
+                                               break; 
+                               }
+                               $sql = "$sql AND $selector";
+                       }
+                       $order_by = "ORDER BY V_ORG_ENHET.RESULTATENHET ASC";
+                       $sql = "$sql $order_by";
+                       
+                       
+                       $db = $this->get_db();
+                       $db->query($sql,__LINE__,__FILE__);                     
+               
+                       $result_units = array();
+                       while($db->next_record())
+                       {
+                               
+                               $full_name = $db->f('FORNAVN'). 
$db->f('ETTERNAVN');
+                               
+                               $result_units[] = array(
+                                               "ORG_UNIT_ID" => 
(int)$db->f('ORG_ENHET_ID'),
+                                               "ORG_UNIT_NAME" => 
$db->f('ORG_NAVN'),
+                                               "LEADER_FIRSTNAME" => 
$db->f('FORNAVN'),
+                                               "LEADER_LASTNAME" => 
$db->f('ETTERNAVN'),
+                                               "LEADER_FULLNAME" => $full_name,
+                                               "LEADER_USERNAME" => 
$db->f('BRUKERNAVN')
+                                       );
+                       }
+                       return $result_units;
+               }
+               
+               
                public function is_connected()
                {
                        return $this->connected;

Modified: trunk/rental/inc/class.uidelegate.inc.php
===================================================================
--- trunk/rental/inc/class.uidelegate.inc.php   2010-11-02 07:33:17 UTC (rev 
6532)
+++ trunk/rental/inc/class.uidelegate.inc.php   2010-11-02 07:34:47 UTC (rev 
6533)
@@ -1,5 +1,6 @@
 <?php
        phpgw::import_class('rental.uicommon');
+       phpgw::import_class('frontend.bofrontend');
        
        class uidelegate extends rental_uicommon
        {
@@ -22,15 +23,18 @@
                public function query(){
                        $unit_id = (int)phpgw::get_var('unit_id');
                        
+                       $delegates_data = array();
+                       
                        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;
+                               $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');
+                       return $this->yui_results($delegates_data, 
'total_records', 'results');
                }
                
                public function index(){

Modified: trunk/rental/inc/class.uiresultunit.inc.php
===================================================================
--- trunk/rental/inc/class.uiresultunit.inc.php 2010-11-02 07:33:17 UTC (rev 
6532)
+++ trunk/rental/inc/class.uiresultunit.inc.php 2010-11-02 07:34:47 UTC (rev 
6533)
@@ -1,6 +1,7 @@
 <?php
        phpgw::import_class('rental.uicommon');
        phpgw::import_class('rental.bofellesdata');
+       phpgw::import_class('frontend.bofrontend');
        
        class rental_uiresultunit extends rental_uicommon
        {
@@ -36,18 +37,22 @@
                        // Form variables
                        $search_for     = phpgw::get_var('query');
                        $search_type    = phpgw::get_var('search_option');
+                       
+                       phpgwapi_cache::session_set('rental', 
'composite_query', $search_for);
+                       phpgwapi_cache::session_set('rental', 
'composite_search_type', $search_type);
+                       
                        // 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();
-                       
+
+                       $result_units = 
$bofelles->get_result_units_with_leader($search_for, $search_type);
+
                        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;
+                               $unit['UNIT_NO_OF_DELEGATES'] = 
count($delegates_per_org_unit);
                        }
                        
                        $resultunit_data = array('results' => $result_units, 
'total_records' => count($result_units));
@@ -76,7 +81,7 @@
                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['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 'rental.uiresultunit.edit', 
'id' => $value['ORG_UNIT_ID'], 'initial_load' => 'no')));
                        $value['labels'][] = lang('edit_delegate');
                }
                
@@ -88,9 +93,12 @@
                        if (isset($unit_id) && $unit_id > 0) {
                                
                                $bofelles = rental_bofellesdata::get_instance();
-                               $unit ;//= $bofelles->get_result_unit($unit_id);
+                               $unit = $bofelles->get_result_unit($unit_id);
                                
-                               $this->render('resultunit.php', $unit);
+                               $delegates_per_org_unit = 
frontend_bofrontend::get_delegates($unit_id);
+                               $unit['UNIT_NO_OF_DELEGATES'] = 
count($delegates_per_org_unit);
+                               
+                               $this->render('resultunit.php', array ('unit' 
=> $unit));
                        }
                }
        }
\ No newline at end of file

Modified: trunk/rental/templates/base/delegate_list.php
===================================================================
--- trunk/rental/templates/base/delegate_list.php       2010-11-02 07:33:17 UTC 
(rev 6532)
+++ trunk/rental/templates/base/delegate_list.php       2010-11-02 07:34:47 UTC 
(rev 6533)
@@ -69,13 +69,6 @@
                <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>

Modified: trunk/rental/templates/base/resultunit.php
===================================================================
--- trunk/rental/templates/base/resultunit.php  2010-11-02 07:33:17 UTC (rev 
6532)
+++ trunk/rental/templates/base/resultunit.php  2010-11-02 07:34:47 UTC (rev 
6533)
@@ -26,7 +26,7 @@
                <?php echo $unit["ORG_NAME"]; ?>
                 <br/>
                <label><?php echo lang('unit_leader_name'); ?></label>
-               <?php echo $unit["UNIT_ID"]; ?>
+               <?php echo $unit["LEADER_FULLNAME"]; ?>
                <br/>
                <label><?php echo lang('unit_no_of_delegates') ?></label>
                <?php echo $unit["UNIT_NO_OF_DELEGATES"]; ?>
@@ -35,11 +35,9 @@
 
 <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]);
-                       }
+       for(i=0;i<YAHOO.rental.datatables.length;i++){
+               if(YAHOO.rental.datatables[i].tid == 'included_delegates'){
+                       reloadDataSources(YAHOO.rental.datatables[i]);
                }
        }
 }
@@ -47,17 +45,17 @@
 
 <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>
+               <li class="selected"><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_form = true;
                                        $list_id = 'included_delegates';
                                        $url_add_on = 
'&amp;type=included_delegates&amp;unit_id='.$unit["ORG_UNIT_ID"];
-                                       include('delegates_list_partial.php'); 
?>
+                                       include('delegate_list.php'); ?>
                        </div>
                <?php }?>
        </div>

Modified: trunk/rental/templates/base/resultunit_list_partial.php
===================================================================
--- trunk/rental/templates/base/resultunit_list_partial.php     2010-11-02 
07:33:17 UTC (rev 6532)
+++ trunk/rental/templates/base/resultunit_list_partial.php     2010-11-02 
07:34:47 UTC (rev 6533)
@@ -12,22 +12,22 @@
 
        // Defining columns for datatable
        var columnDefs = [{
-                       key: "unit_id",
+                       key: "ORG_UNIT_ID",
                        label: "<?php echo lang('unit_id') ?>",
                        sortable: true
                },
                {
-                       key: "unit_name",
+                       key: "ORG_UNIT_NAME",
                        label: "<?php echo lang('unit_name') ?>",
                        sortable: true
                },
                {
-                       key: "unit_leader_name",
+                       key: "LEADER_FULLNAME",
                        label: "<?php echo lang('unit_leader_name') ?>",
                    sortable: true
                },
                {
-                       key: "unit_no_of_delegates",
+                       key: "UNIT_NO_OF_DELEGATES",
                        label: "<?php echo lang('unit_no_of_delegates') ?>",
                    sortable: true
                },
@@ -49,7 +49,7 @@
                
'index.php?menuaction=rental.uiresultunit.query&amp;phpgw_return_as=json<?php 
echo $url_add_on; ?>&amp;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 ?>_ctrl_search_query'],
                '<?php echo $list_id ?>_container',
                '<?php echo $list_id ?>_paginator',
                '<?php echo $list_id ?>',
@@ -68,8 +68,6 @@
        //Avoid Notices
        $q = false;
        $s_type = false;
-       $status = false;
-       $status_contract = false;
        if(isset($populate))
        {
                $q = phpgwapi_cache::session_get('rental', 'resultunit_query');
@@ -81,6 +79,11 @@
                <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 : 
''?>"/>
+               <label for="ctrl_search_option"><?php echo lang('search_where') 
?></label>
+               <select name="search_option" id="<?php echo $list_id 
?>_ctrl_search_option">
+                       <option value="unit_name" <?php echo ($s_type == 
'unit_name') ? 'selected' : ''?>><?php echo lang('unit_name') ?></option>
+                       <option value="unit_leader" <?php echo ($s_type == 
'unit_leader') ? 'selected' : ''?>><?php echo lang('unit_leader') ?></option>
+               </select>
                <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>




reply via email to

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