fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7490] property: download and filter on status for ag


From: Sigurd Nes
Subject: [Fmsystem-commits] [7490] property: download and filter on status for agreements
Date: Thu, 11 Aug 2011 11:30:49 +0000

Revision: 7490
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7490
Author:   sigurdne
Date:     2011-08-11 11:30:49 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
property: download and filter on status for agreements

Modified Paths:
--------------
    trunk/property/inc/class.boagreement.inc.php
    trunk/property/inc/class.soagreement.inc.php
    trunk/property/inc/class.uiagreement.inc.php
    trunk/property/js/yahoo/agreement.index.js

Modified: trunk/property/inc/class.boagreement.inc.php
===================================================================
--- trunk/property/inc/class.boagreement.inc.php        2011-08-11 08:14:23 UTC 
(rev 7489)
+++ trunk/property/inc/class.boagreement.inc.php        2011-08-11 11:30:49 UTC 
(rev 7490)
@@ -69,62 +69,39 @@
                                $this->use_session = true;
                        }
 
-                       $start  = phpgw::get_var('start', 'int', 'REQUEST', 0);
-                       $query  = phpgw::get_var('query');
-                       $sort   = phpgw::get_var('sort');
-                       $order  = phpgw::get_var('order');
-                       $filter = phpgw::get_var('filter', 'int');
-                       $cat_id = phpgw::get_var('cat_id', 'int');
+                       $start          = phpgw::get_var('start', 'int', 
'REQUEST', 0);
+                       $query          = phpgw::get_var('query');
+                       $sort           = phpgw::get_var('sort');
+                       $order          = phpgw::get_var('order');
+                       $filter         = phpgw::get_var('filter', 'int');
+                       $cat_id         = phpgw::get_var('cat_id', 'int');
                        $vendor_id      = phpgw::get_var('vendor_id', 'int');
                        $allrows        = phpgw::get_var('allrows', 'bool');
-                       $role   = phpgw::get_var('role');
+                       $role           = phpgw::get_var('role');
                        $member_id      = phpgw::get_var('member_id', 'int');
+                       $status_id      = phpgw::get_var('status_id');
 
-
                        $this->role     = $role;
                        $this->so->role = $role;
 
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
+                       $this->status_id                = 
isset($_REQUEST['status_id']) ? $status_id    : $this->status_id;
+                       $this->start                    = 
isset($_REQUEST['start'])     ? $start                : $this->start;
+                       $this->order                    = 
isset($_REQUEST['order'])     ? $order                : $this->order;
+                       $this->sort                             = 
isset($_REQUEST['sort'])              ? $sort                 : $this->sort;
+                       $this->query                    = 
isset($_REQUEST['query'])     ? $query                : $this->query;
+                       $this->vendor_id                = 
isset($_REQUEST['vendor_id']) ? $vendor_id    : $this->vendor_id;
+                       $this->member_id                = 
isset($_REQUEST['member_id']) ? $member_id    : $this->member_id;
+                       $this->cat_id                   = 
isset($_REQUEST['cat_id'])    ? $cat_id               : $this->cat_id;
 
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
                        if(!empty($filter))
                        {
                                $this->filter = $filter;
                        }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
 
-                       $this->order    = isset($order) && $order ? $order : '';
-
-                       if(isset($cat_id))
+                       if($allrows)
                        {
-                               $this->cat_id = $cat_id;
-                       }
-
-                       if(isset($allrows))
-                       {
                                $this->allrows = $allrows;
                        }
-                       if(isset($member_id))
-                       {
-                               $this->member_id = $member_id;
-                       }
-                       if(isset($vendor_id))
-                       {
-                               $this->vendor_id = $vendor_id;
-                       }
                }
 
                function save_sessiondata($data)
@@ -139,7 +116,7 @@
                {
                        $data = 
$GLOBALS['phpgw']->session->appsession('session_data','agreement');
 
-                       //_debug_array($data);
+//                     _debug_array($data);die();
 
                        $this->start    = $data['start'];
                        $this->query    = $data['query'];
@@ -149,7 +126,7 @@
                        $this->cat_id   = $data['cat_id'];
                        $this->vendor_id= $data['vendor_id'];
                        $this->member_id= $data['member_id'];
-                       $this->allrows  = $data['allrows'];
+                       $this->status_id= $data['status_id'];
                }
 
                function check_perms($has, $needed)
@@ -177,28 +154,25 @@
 
                function read()
                {
-                       $agreement = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
+                       $agreements = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                'filter' => $this->filter,'cat_id' => 
$this->cat_id,'allrows'=>$this->allrows,'member_id'=>$this->member_id,
-                               'vendor_id'=>$this->vendor_id));
+                               'vendor_id'=>$this->vendor_id, 
'status_id'=>$this->status_id));
                        $this->total_records = $this->so->total_records;
 
                        $this->uicols   = $this->so->uicols;
 
-                       for ($i=0; $i<count($agreement); $i++)
+                       foreach ($agreements as &$agreement)
                        {
-                               if($agreement[$i]['start_date'])
+                               if($agreement['start_date'])
                                {
-                                       $agreement[$i]['start_date']  = 
$GLOBALS['phpgw']->common->show_date($agreement[$i]['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       $agreement['start_date']  = 
$GLOBALS['phpgw']->common->show_date($agreement['start_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
                                }
-                               if($agreement[$i]['end_date'])
+                               if($agreement['end_date'])
                                {
-                                       $agreement[$i]['end_date']  = 
$GLOBALS['phpgw']->common->show_date($agreement[$i]['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       $agreement['end_date']  = 
$GLOBALS['phpgw']->common->show_date($agreement['end_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
                                }
-
-                               $agreement[$i]['status']  = 
lang($agreement[$i]['status']);
-
                        }
-                       return $agreement;
+                       return $agreements;
                }
 
                function read_details($id)

Modified: trunk/property/inc/class.soagreement.inc.php
===================================================================
--- trunk/property/inc/class.soagreement.inc.php        2011-08-11 08:14:23 UTC 
(rev 7489)
+++ trunk/property/inc/class.soagreement.inc.php        2011-08-11 11:30:49 UTC 
(rev 7490)
@@ -65,20 +65,18 @@
 
                function read($data)
                {
-                       if(is_array($data))
-                       {
-                               $start                  = 
(isset($data['start'])?$data['start']:0);
-                               $filter                 = 
(isset($data['filter'])?$data['filter']:'none');
-                               $query                  = 
(isset($data['query'])?$data['query']:'');
-                               $sort                   = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order                  = 
(isset($data['order'])?$data['order']:'');
-                               $cat_id                 = 
(isset($data['cat_id'])?$data['cat_id']:'');
-                               $vendor_id              = 
(isset($data['vendor_id'])?$data['vendor_id']:'');
-                               $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
-                               $member_id              = 
(isset($data['member_id'])?$data['member_id']:0);
-                               $agreement_id   = 
(isset($data['agreement_id'])?$data['agreement_id']:'');
-                               $status                 = 
(isset($data['status'])?$data['status']:'');
-                       }
+//_debug_array($data);die();
+                       $start                  = isset($data['start']) && 
$data['start'] ? (int)$data['start'] : 0;
+                       $filter                 = isset($data['filter']) && 
$data['filter'] ? $data['filter'] : 'none';
+                       $query                  = isset($data['query']) ? 
$data['query'] : '';
+                       $sort                   = isset($data['sort']) && 
$data['sort'] ? $data['sort'] : 'DESC';
+                       $order                  = isset($data['order']) ? 
$data['order'] : '';
+                       $cat_id                 = isset($data['cat_id']) ? 
(int) $data['cat_id'] : '';
+                       $vendor_id              = isset($data['vendor_id']) ? 
(int)$data['vendor_id']:'';
+                       $allrows                = isset($data['allrows']) ? 
$data['allrows']:'';
+                       $member_id              = isset($data['member_id']) ? 
(int)$data['member_id']:0;
+                       $agreement_id   = isset($data['agreement_id'])? (int) 
$data['agreement_id']:'';
+                       $status_id              = isset($data['status_id']) ? 
$data['status_id'] : '';
 
                        $filtermethod = '';
                        $querymethod = '';
@@ -91,10 +89,11 @@
                        $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', '.agreement'); 
                        $attribute_filter = " location_id = {$location_id}";
                        $paranthesis ='(';
-                       $joinmethod = " $this->join $category_table ON ( 
$entity_table.category =$category_table.id)";
-                       $joinmethod .= " $this->join  fm_vendor ON ( 
$entity_table.vendor_id =fm_vendor.id ))";
+                       $joinmethod = " {$this->join} {$category_table} ON ( 
{$entity_table}.category = {$category_table}.id)";
+                       $joinmethod .= " {$this->join}  fm_vendor ON ( 
{$entity_table}.vendor_id =fm_vendor.id )";
+                       $joinmethod .= " {$this->join} fm_agreement_status ON ( 
{$entity_table}.status = fm_agreement_status.id))";
 
-                       $cols = $entity_table . ".*,$category_table.descr as 
category, org_name";
+                       $cols = "{$entity_table}.*,{$category_table}.descr as 
category, org_name, fm_agreement_status.descr as status";
 
                        $cols_return[]                          = 'id';
                        $uicols['input_type'][]         = 'text';
@@ -147,25 +146,26 @@
 
                        if ($order)
                        {
-                               if ($order=='id')
+                               switch ($order)
                                {
-                                       $ordermethod = " order by 
$entity_table.$order $sort";
+                                       case 'id':
+                                       case 'status':
+                                               $ordermethod = " ORDER BY 
{$entity_table}.{$order} {$sort}";
+                                               break;
+                                       case 'category':
+                                               $ordermethod = " ORDER BY 
{$category_table}.descr {$sort}";                                     
+                                               break;
+                                       default:
+                                               $ordermethod = " ORDER BY 
{$order} {$sort}";
                                }
-                               else
-                               {
-                                       $ordermethod = " order by $order $sort";
-                               }
                        }
                        else
                        {
-                               $ordermethod = " order by $entity_table.id 
DESC";
+                               $ordermethod = " ORDER BY {$entity_table}.id 
DESC";
                        }
+//_debug_array($ordermethod);
+                       $sql = "SELECT {$cols} FROM {$paranthesis} 
{$entity_table} {$joinmethod}";
 
-
-                       $from = " FROM $paranthesis $entity_table ";
-
-                       $sql = "SELECT $cols $from $joinmethod";
-
                        $i      = count($uicols['name']);
 
                        $user_columns = 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['agreement_columns'
 . 
!!$agreement_id])?$GLOBALS['phpgw_info']['user']['preferences']['property']['agreement_columns'
 . !!$agreement_id]:'';
@@ -244,9 +244,9 @@
                                $where= 'AND';
                        }
 
-                       if ($status)
+                       if ($status_id)
                        {
-                               $filtermethod .= " $where 
$entity_table.status='$status' ";
+                               $filtermethod .= " {$where} 
{$entity_table}.status='{$status_id}' ";
                                $where= 'AND';
                        }
 

Modified: trunk/property/inc/class.uiagreement.inc.php
===================================================================
--- trunk/property/inc/class.uiagreement.inc.php        2011-08-11 08:14:23 UTC 
(rev 7489)
+++ trunk/property/inc/class.uiagreement.inc.php        2011-08-11 11:30:49 UTC 
(rev 7490)
@@ -52,8 +52,8 @@
                                'edit_item'             => true,
                                'view_item'             => true,
                                'view_file'             => true,
-                               'download'                      => true,
-                               'add_activity'          => true
+                               'download'              => true,
+                               'add_activity'  => true
                        );
 
                function property_uiagreement()
@@ -87,6 +87,7 @@
                        $this->vendor_id        = $this->bo->vendor_id;
                        $this->allrows          = $this->bo->allrows;
                        $this->member_id        = $this->bo->member_id;
+                       $this->status_id        = $this->bo->status_id;
                }
 
                function save_sessiondata()
@@ -101,7 +102,8 @@
                                        'cat_id'        => $this->cat_id,
                                        'vendor_id'     => $this->vendor_id,
                                        'allrows'       => $this->allrows,
-                                       'member_id'     => $this->member_id
+                                       'member_id'     => $this->member_id,
+                                       'status_id'     => $this->status_id
                                );
                        $this->bo->save_sessiondata($data);
                }
@@ -177,30 +179,26 @@
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
'property::agreement::pricebook::agreement';
 
                        $datatable = array();
+                       $this->save_sessiondata();
 
                        if( phpgw::get_var('phpgw_return_as') != 'json' )
                        {
                                $datatable['menu']                              
        = $this->bocommon->get_menu();
                                $datatable['config']['base_url'] = 
$GLOBALS['phpgw']->link('/index.php', array
-                                       (
-                                               'menuaction'    => 
'property.uiagreement.index',
-                                               'sort'                  
=>$this->sort,
-                                               'order'                 
=>$this->order,
-                                               'cat_id'                
=>$this->cat_id,
-                                               'filter'                
=>$this->filter,
-                                               'query'                 
=>$this->query,
-                                               'role'                  => 
$this->role,
-                                               'member_id'             => 
$this->member_id
-                                       ));
+                               (
+                                       'menuaction'    => 
'property.uiagreement.index',
+                                       'sort'                  =>$this->sort,
+                                       'order'                 =>$this->order,
+                                       'cat_id'                =>$this->cat_id,
+                                       'filter'                =>$this->filter,
+                                       'query'                 =>$this->query,
+                                       'role'                  => $this->role,
+                                       'member_id'             => 
$this->member_id,
+                                       'status_id'             => 
$this->status_id
+                               ));
 
                                $datatable['config']['base_java_url'] = 
"menuaction:'property.uiagreement.index',"
-                                       ."sort:'{$this->sort}',"
-                                       ."order:'{$this->order}',"
-                                       ."cat_id: '{$this->cat_id}',"
-                                       ."filter:'{$this->filter}',"
-                                       ."query:'{$this->query}',"
-                                       ."role:'{$this->role}',"
-                                       ."member_id:'{$this->member_id}'";
+                                       ."status_id:'{$this->status_id}'";
 
                                $datatable['config']['allow_allrows'] = true;
 
@@ -213,7 +211,8 @@
                                                'filter'        =>$this->filter,
                                                'query'         =>$this->query,
                                                'role'          => $this->role,
-                                               'member_id'     => 
$this->member_id
+                                               'member_id'     => 
$this->member_id,
+                                               'status_id'             => 
$this->status_id
                                        );
 
                                $values_combo_box[0] = 
$this->cats->formatted_xslt_list(array('selected' => $this->member_id,'globals' 
=> true,'link_data' =>$link_data));
@@ -228,6 +227,10 @@
                                $default_value = array 
('id'=>'','name'=>lang('no vendor'));
                                array_unshift 
($values_combo_box[2],$default_value);
 
+                               $values_combo_box[3]  = 
$this->bo->select_status_list('filter',$this->status_id);
+                               $default_value = array 
('id'=>'','name'=>lang('no status'));
+                               array_unshift 
($values_combo_box[3],$default_value);
+
                                //_debug_array($values_combo_box[0]);die;
 
                                $datatable['actions']['form'] = array(
@@ -241,12 +244,13 @@
                                                        'filter'                
=> $this->filter,
                                                        'query'                 
=> $this->query,
                                                        'role'                  
=> $this->role,
-                                                       'member_id'             
=> $this->member_id
+                                                       'member_id'             
=> $this->member_id,
+                                                       'status_id'             
=> $this->status_id
                                                )
                                        ),
                                        'fields'        => array(
                                                'field' => array(
-                                                       array( //boton  CATEGORY
+                                                       array( //boton  member
                                                                'id' => 
'btn_member_id',
                                                                'name' => 
'member_id',
                                                                'value' => 
lang('Member'),
@@ -254,7 +258,7 @@
                                                                'style' => 
'filter',
                                                                'tab_index' => 1
                                                        ),
-                                                       array( //boton  STATUS
+                                                       array( //boton  CATEGORY
                                                                'id' => 
'btn_cat_id',
                                                                'name' => 
'category_id',
                                                                'value' => 
lang('Category'),
@@ -262,7 +266,7 @@
                                                                'style' => 
'filter',
                                                                'tab_index' => 2
                                                        ),
-                                                       array( //boton  HOUR 
CATEGORY
+                                                       array( //boton  vendor
                                                                'id' => 
'btn_vendor_id',
                                                                'name' => 
'vendor_id',
                                                                'value' => 
lang('Vendor'),
@@ -270,18 +274,26 @@
                                                                'style' => 
'filter',
                                                                'tab_index' => 3
                                                        ),
+                                                       array( //boton  STATUS
+                                                               'id' => 
'btn_status_id',
+                                                               'name' => 
'status_id',
+                                                               'value' => 
lang('status'),
+                                                               'type' => 
'button',
+                                                               'style' => 
'filter',
+                                                               'tab_index' => 4
+                                                       ),
                                                        array(
                                                                'type'  => 
'button',
                                                                'id'    => 
'btn_new',
                                                                'value' => 
lang('add'),
-                                                               'tab_index' => 8
+                                                               'tab_index' => 7
                                                        ),
                                                        array( //boton     
SEARCH
                                                                'id' => 
'btn_search',
                                                                'name' => 
'search',
                                                                'value'    => 
lang('search'),
                                                                'type' => 
'button',
-                                                               'tab_index' => 7
+                                                               'tab_index' => 6
                                                        ),
                                                        array( // TEXT INPUT
                                                                'name'     => 
'query',
@@ -290,7 +302,7 @@
                                                                'type' => 
'text',
                                                                'onkeypress' => 
'return pulsar(event)',
                                                                'size'    => 28,
-                                                               'tab_index' => 6
+                                                               'tab_index' => 5
                                                        ),
                                                        array(
                                                                'type' => 
'link',
@@ -302,7 +314,14 @@
                                                                        'role'  
        => $this->role
                                                                
))."','','width=300,height=600,scrollbars=1')",
                                                                'value' => 
lang('columns'),
-                                                               'tab_index' => 9
+                                                               'tab_index' => 8
+                                                       ),
+                                                       array
+                                                       (
+                                                               'type'  => 
'button',
+                                                               'id'    => 
'btn_export',
+                                                               'value' => 
lang('download'),
+                                                               'tab_index' => 
10
                                                        )
                                                ),
                                                'hidden_value' => array(
@@ -317,6 +336,10 @@
                                                        array( //div values  
combo_box_2
                                                                'id' => 
'values_combo_box_2',
                                                                'value' => 
$this->bocommon->select2String($values_combo_box[2])
+                                                       ),
+                                                       array( //div values  
combo_box_3
+                                                               'id' => 
'values_combo_box_3',
+                                                               'value' => 
$this->bocommon->select2String($values_combo_box[3])
                                                        )
                                                )
                                        )
@@ -467,12 +490,13 @@
                                                
$datatable['headers']['header'][$i]['sortable']         = true;
                                                
$datatable['headers']['header'][$i]['sort_field']       = $uicols['name'][$i];
                                        }
-
+/*
                                        if($uicols['name'][$i]=='category')
                                        {
                                                
$datatable['headers']['header'][$i]['sortable']         = true;
                                                
$datatable['headers']['header'][$i]['sort_field']       = 'org_name';
                                        }
+*/
                                }
                        }
 
@@ -1498,7 +1522,14 @@
                function download()
                {
                        $id     = phpgw::get_var('id', 'int');
-                       $list = $this->bo->read_details($id);
+                       if($id)
+                       {
+                               $list = $this->bo->read_details($id);
+                       }
+                       else
+                       {
+                               $list = $this->bo->read($id);
+                       }
                        $uicols         = $this->bo->uicols;
                        
$this->bocommon->download($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
                }

Modified: trunk/property/js/yahoo/agreement.index.js
===================================================================
--- trunk/property/js/yahoo/agreement.index.js  2011-08-11 08:14:23 UTC (rev 
7489)
+++ trunk/property/js/yahoo/agreement.index.js  2011-08-11 11:30:49 UTC (rev 
7490)
@@ -2,18 +2,20 @@
 // Declaration of location.index vars
 //--------------------------------------------------------
        //define SelectButton
-       var oMenuButton_0, oMenuButton_1, oMenuButton_2;
+       var oMenuButton_0, oMenuButton_1, oMenuButton_2, oMenuButton_3;
        var selectsButtons = [
        {order:0, 
var_URL:'member_id',name:'btn_member_id',style:'categorybutton',dependiente:''},
        {order:1, 
var_URL:'cat_id',name:'btn_cat_id',style:'districtbutton',dependiente:''},
-       {order:2, 
var_URL:'vendor_id',name:'btn_vendor_id',style:'partOFTownbutton',dependiente:''}
+       {order:2, 
var_URL:'vendor_id',name:'btn_vendor_id',style:'partOFTownbutton',dependiente:''},
+       {order:3, 
var_URL:'status_id',name:'btn_status_id',style:'partOFTownbutton',dependiente:''}
        ];
 
        // define buttons
-       var oNormalButton_0, oNormalButton_1;
+       var oNormalButton_0, oNormalButton_1, oNormalButton_2;
        var normalButtons = [
        {order:0, name:'btn_search', funct:"onSearchClick"},
-       {order:1, name:'btn_new', funct:"onNewClick"}
+       {order:1, name:'btn_new', funct:"onNewClick"},
+       {order:2, name:'btn_export', funct:"onDownloadClick"}
        ];
 
        // define Text buttons




reply via email to

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