fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8407] property: more on bulk update


From: Sigurd Nes
Subject: [Fmsystem-commits] [8407] property: more on bulk update
Date: Wed, 21 Dec 2011 19:46:07 +0000

Revision: 8407
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8407
Author:   sigurdne
Date:     2011-12-21 19:46:07 +0000 (Wed, 21 Dec 2011)
Log Message:
-----------
property: more on bulk update

Modified Paths:
--------------
    trunk/property/inc/class.boproject.inc.php
    trunk/property/inc/class.menu.inc.php
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/templates/base/project.xsl

Added Paths:
-----------
    trunk/property/js/yahoo/project.bulk_update_status.js

Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php  2011-12-21 15:48:47 UTC (rev 
8406)
+++ trunk/property/inc/class.boproject.inc.php  2011-12-21 19:46:07 UTC (rev 
8407)
@@ -806,8 +806,8 @@
                        $this->so->delete($project_id);
                }
 
-               function bulk_update_status($start_date, $end_date, $status, 
$execute, $type)
+               function bulk_update_status($start_date, $end_date, 
$status_filter, $status_new, $execute, $type, $user_id)
                {
-                       return $this->so->bulk_update_status($start_date, 
$end_date, $status, $execute, $type);
+                       return $this->so->bulk_update_status($start_date, 
$end_date, $status_filter, $status_new, $execute, $type, $user_id);
                }
        }

Modified: trunk/property/inc/class.menu.inc.php
===================================================================
--- trunk/property/inc/class.menu.inc.php       2011-12-21 15:48:47 UTC (rev 
8406)
+++ trunk/property/inc/class.menu.inc.php       2011-12-21 19:46:07 UTC (rev 
8407)
@@ -453,7 +453,7 @@
                                                ),
                                                'project_bulk_update_status'    
=> array
                                                (
-                                                       'text'  => 
lang('project status'),
+                                                       'text'  => 
lang('project bulk update status'),
                                                        'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uiproject.bulk_update_status') )
                                                ),
                                                'project_group' => array

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2011-12-21 15:48:47 UTC (rev 
8406)
+++ trunk/property/inc/class.soproject.inc.php  2011-12-21 19:46:07 UTC (rev 
8407)
@@ -1285,30 +1285,58 @@
                }
 
 
-               function bulk_update_status($start_date, $end_date, $status, 
$execute, $type)
+               function bulk_update_status($start_date, $end_date, 
$status_filter, $status_new, $execute, $type, $user_id = 0)
                {
                        $start_date = 
phpgwapi_datetime::date_to_timestamp($start_date);
                        $end_date = 
phpgwapi_datetime::date_to_timestamp($end_date);
 
-                       $this->db->query("SELECT id FROM fm_project WHERE 
start_date > $start_date AND start_date < $end_date",__LINE__,__FILE__);
-                       $projects = array();
-                       while ($this->db->next_record())
+                       $filter = '';
+                       if($user_id)
                        {
-                               $projects[] = array('project_id' => 
$this->db->f('id'));
+                               $user_id = (int) $user_id;
+                               $filter = "AND user_id = $user_id";
                        }
-                       
-                       foreach($projects as &$project)
+
+                       if($status_filter)
                        {
-                               $this->db->query("SELECT id FROM fm_workorder 
WHERE project_id = {$project['project_id']}",__LINE__,__FILE__);
-                               while ($this->db->next_record())
-                               {
-                                       $project['workorder'][] = 
$this->db->f('id');
-                               }
+                               $user_id = (int) $user_id;
+                               $filter .= "AND status = '{$status_filter}'";
                        }
 
-                       return $projects;
+                       switch($type)
+                       {
+                               case 'project':
+                                       $table = 'fm_project';
+                                       $status_table = 'fm_project_status';
+                                       $title_field = 'fm_project.name as 
title';
+                                       break;
+                               case 'workorder':
+                                       $table = 'fm_workorder';
+                                       $status_table = 'fm_workorder_status';
+                                       $title_field = 'fm_workorder.title';
+                                       break;
+                               default:
+                                       return array();
+                       }
 
+                       $sql = "SELECT {$table}.id, $status_table.descr as 
status ,{$title_field} FROM {$table}"
+                       . " {$this->join} {$status_table} ON  {$table}.status = 
{$status_table}.id  WHERE start_date > {$start_date} AND start_date < 
{$end_date} {$filter}";
+//_debug_array($sql);                  
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $values = array();
+                       while ($this->db->next_record())
+                       {
+                               $values[] = array
+                               (
+                                       'id'            => $this->db->f('id'),
+                                       'title'         => 
$this->db->f('title',true),
+                                       'status'        => 
$this->db->f('status',true)
+                               );
+                       }
 
+                       return $values;
+
+
                        $this->db->transaction_begin();
 
 

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2011-12-21 15:48:47 UTC (rev 
8406)
+++ trunk/property/inc/class.uiproject.inc.php  2011-12-21 19:46:07 UTC (rev 
8407)
@@ -1890,8 +1890,8 @@
                        phpgwapi_yui::load_widget('paginator');
                        phpgwapi_yui::load_widget('animation');
 
-                       $template_vars = array();
-                       $template_vars['datatable'] = $datatable;
+//                     $template_vars = array();
+//                     $template_vars['datatable'] = $datatable;
 
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
 
@@ -1962,10 +1962,12 @@
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
'property::admin::project_bulk_update_status';
                        $start_date     = phpgw::get_var('start_date');
                        $end_date               = phpgw::get_var('end_date');
-                       $confirm                = phpgw::get_var('confirm', 
'bool', 'POST');
+                       $get_list               = phpgw::get_var('get_list', 
'bool', 'POST');
                        $execute                = phpgw::get_var('execute', 
'bool', 'POST');
-                       $status                 = phpgw::get_var('status');
+                       $status_filter  = phpgw::get_var('status_filter');
+                       $status_new     = phpgw::get_var('status_new');
                        $type                   = phpgw::get_var('type');
+                       $user_id                = phpgw::get_var('user_id', 
'int');
 
                        $link_data = array
                        (
@@ -1977,13 +1979,63 @@
                        $jscal->add_listener('values_end_date');
 
 
-                       if(($execute || $confirm) && $type)
+                       if(($execute || $get_list) && $type)
                        {
-                               $list = 
$this->bo->bulk_update_status($start_date, $end_date, $status, $execute, $type);
+                               $list = 
$this->bo->bulk_update_status($start_date, $end_date, $status_filter, 
$status_new, $execute, $type, $user_id);
                        }
 
+/*
+                                       'id'            => $this->db->f('id'),
+                                       'title'         => 
$this->db->f('title',true),
+                                       'status'        => 
$this->db->f('status',true)
+
+*/
 //                     _debug_array($list);
 
+
+                       $datavalues[0] = array
+                               (
+                                       'name'                                  
=> "0",
+                                       'values'                                
=> json_encode($list),
+                                       'total_records'                 => 
count($list),
+                                       'edit_action'                   => 
json_encode($GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
"property.ui{$type}.edit"))),
+                                       'is_paginator'                  => 1,
+                                       'footer'                                
=> 0
+                               );
+
+                       $myColumnDefs[0] = array
+                               (
+                                       'name'          => "0",
+                                       'values'        =>      
json_encode(array(      array('key' => 
'id','label'=>lang('id'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
+                                                                               
                                array('key' => 
'title','label'=>lang('title'),'sortable'=>true,'resizeable'=>true),
+                                                                               
                                array('key' => 
'status','label'=>lang('status'),'sortable'=>true,'resizeable'=>true)
+                                                                               
                                ))
+
+                               );
+
+
+
+                       $user_list      = 
$this->bocommon->get_user_list('select',$user_id,$extra=false,$default=false,$start=-1,$sort='ASC',$order='account_lastname',$query='',$offset=-1);
+                       foreach ($user_list as &$entry)
+                       {
+                               $entry['id'] = $entry['user_id'];
+                       }
+                       unset($entry);
+
+                       switch($type)
+                       {
+                               case 'project':
+                                       $status_list_filter = 
execMethod('property.bogeneric.get_list', array('type' => 'project_status',     
  'selected' => $status_filter));
+                                       $status_list_new = 
execMethod('property.bogeneric.get_list', array('type' => 'project_status',  
'selected' => $status_new));
+                                       break;
+                               case 'workorder':
+                                       $status_list_filter = 
execMethod('property.bogeneric.get_list', array('type' => 'workorder_status',   
  'selected' => $status_filter));
+                                       $status_list_new = 
execMethod('property.bogeneric.get_list', array('type' => 'workorder_status',   
     'selected' => $status_new));
+                                       break;
+                               default:
+                                       $status_list_filter = array();
+                       }
+
                        $type_array = array
                        (
                                array
@@ -2003,24 +2055,53 @@
                                )
                        );
 
+                       foreach ($type_array as &$entry)
+                       {
+                               $entry['selected'] = $entry['id'] == $type ? 1 
: 0;
+                       }
+
                        $data = array
                        (
-                               'done_action'           => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
-                               'update_action'         => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiproject.bulk_update_status')),
-                               'img_cal'                       => 
$GLOBALS['phpgw']->common->image('phpgwapi','cal'),
-                               'confirm'                       => $confirm,
-                               'status_list'           => array('options' => 
$this->bo->select_status_list('select',$status)),
-                               'type_list'                     => 
array('options' => $type_array),
-                               'start_date'            => $start_date,
-                               'end_date'                      => $end_date,   
                        
+                               'property_js'                   => 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
+                               'datatable'                             => 
$datavalues,
+                               'myColumnDefs'                  => 
$myColumnDefs,
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'update_action'                 => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiproject.bulk_update_status')),
+                               'img_cal'                               => 
$GLOBALS['phpgw']->common->image('phpgwapi','cal'),
+                               'status_list_filter'    => array('options' => 
$status_list_filter),
+                               'status_list_new'               => 
array('options' => $status_list_new),
+                               'type_list'                             => 
array('options' => $type_array),
+                               'user_list'                             => 
array('options' => $user_list),
+                               'start_date'                    => $start_date,
+                               'end_date'                              => 
$end_date,
                        );
 
-                       $GLOBALS['phpgw']->xslttpl->add_file(array('project'));
 
                        $appname                        = lang('project');
                        $function_msg           = lang('bulk update status');
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
+                       phpgwapi_yui::load_widget('dragdrop');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('menu');
+                       phpgwapi_yui::load_widget('connection');
+                       phpgwapi_yui::load_widget('loader');
+                       phpgwapi_yui::load_widget('tabview');
+                       phpgwapi_yui::load_widget('paginator');
+                       phpgwapi_yui::load_widget('animation');
+
+                       $GLOBALS['phpgw']->css->validate_file('datatable');
+                       $GLOBALS['phpgw']->css->validate_file('property');
+                       
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+
+                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'project.bulk_update_status', 'property' );
+
+
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('project'));
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('bulk_update_status' => 
$data));
                }
 

Added: trunk/property/js/yahoo/project.bulk_update_status.js
===================================================================
--- trunk/property/js/yahoo/project.bulk_update_status.js                       
        (rev 0)
+++ trunk/property/js/yahoo/project.bulk_update_status.js       2011-12-21 
19:46:07 UTC (rev 8407)
@@ -0,0 +1,37 @@
+var  myPaginator_0, myDataTable_0
+
+/********************************************************************************/
+       YAHOO.widget.DataTable.formatLink = function(elCell, oRecord, oColumn, 
oData)
+       {
+               elCell.innerHTML = "<a 
href="+datatable[0][0]["edit_action"]+"&id="+oData+">" + oData + "</a>";
+       };
+
+
+
+
+/********************************************************************************/
     
+       var FormatterRight = function(elCell, oRecord, oColumn, oData)
+       {
+               elCell.innerHTML = "<div align=\"right\">"+oData+"</div>";
+       }       
+       
+/********************************************************************************/
     
+       this.myParticularRenderEvent = function()
+       {
+       }
+
+/********************************************************************************/
+
+YAHOO.util.Event.addListener(window, "load", function()
+{
+       loader = new YAHOO.util.YUILoader();
+       loader.addModule({
+               name: "anyone",
+               type: "js",
+           fullpath: property_js
+           });
+
+       loader.require("anyone");
+    loader.insert();
+});
+

Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl   2011-12-21 15:48:47 UTC (rev 
8406)
+++ trunk/property/templates/base/project.xsl   2011-12-21 19:46:07 UTC (rev 
8407)
@@ -1275,10 +1275,26 @@
                                </tr>
                                <tr>
                                        <td>
+                                               <xsl:value-of 
select="php:function('lang', 'user')" />
+                                       </td>
+                                       <td>
+                                               <select name="user_id">
+                                                       <xsl:attribute 
name="title">
+                                                               <xsl:value-of 
select="php:function('lang', 'select user')" />
+                                                       </xsl:attribute>
+                                                       <option value="0">
+                                                               <xsl:value-of 
select="php:function('lang', 'select')" />
+                                                       </option>
+                                                       <xsl:apply-templates 
select="user_list/options"/>
+                                               </select>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>
                                                <xsl:value-of 
select="php:function('lang', 'type')" />
                                        </td>
                                        <td>
-                                               <select name="status" >
+                                               <select name="type" 
onChange="this.form.submit();">
                                                        <xsl:attribute 
name="title">
                                                                <xsl:value-of 
select="php:function('lang', 'select type')" />
                                                        </xsl:attribute>
@@ -1289,29 +1305,82 @@
 
                                <tr>
                                        <td>
-                                               <xsl:value-of 
select="php:function('lang', 'status')" />
+                                               <xsl:value-of 
select="php:function('lang', 'status filter')" />
                                        </td>
                                        <td>
-                                               <select name="status" >
+                                               <select name="status_filter" >
                                                        <xsl:attribute 
name="title">
                                                                <xsl:value-of 
select="php:function('lang', 'select status')" />
                                                        </xsl:attribute>
                                                        <option value="0">
                                                                <xsl:value-of 
select="php:function('lang', 'select status')" />
                                                        </option>
-                                                       <xsl:apply-templates 
select="status_list/options"/>
+                                                       <xsl:apply-templates 
select="status_list_filter/options"/>
                                                </select>
                                        </td>
                                </tr>
+                               <tr>
+                                       <td>
+                                               <xsl:value-of 
select="php:function('lang', 'status new')" />
+                                       </td>
+                                       <td>
+                                               <select name="status_new" >
+                                                       <xsl:attribute 
name="title">
+                                                               <xsl:value-of 
select="php:function('lang', 'select status')" />
+                                                       </xsl:attribute>
+                                                       <option value="0">
+                                                               <xsl:value-of 
select="php:function('lang', 'select status')" />
+                                                       </option>
+                                                       <xsl:apply-templates 
select="status_list_new/options"/>
+                                               </select>
+                                       </td>
+                               </tr>
 
+               <tr>
+                       <td>
+                               <div id="paging_0"> </div>
+                               <div id="datatable-container_0"></div>
+                       </td>
+               </tr>
+
                        </table>
-                       <input type="text" id="execute" name="execute" 
value="{confirm}" />
-                       <input type="submit" name="confirm">
+                       <input type="submit" name="get_list">
                                <xsl:attribute name="value">
-                                       <xsl:value-of 
select="php:function('lang', 'update')" />
+                                       <xsl:value-of 
select="php:function('lang', 'get')" />
                                </xsl:attribute>
                        </input>
+                       <input type="submit" name="execute">
+                               <xsl:attribute name="value">
+                                       <xsl:value-of 
select="php:function('lang', 'submit')" />
+                               </xsl:attribute>
+                       </input>
                </form>
+
+                                       <!--  DATATABLE DEFINITIONS-->
+                                       <script type="text/javascript">
+                                               var property_js = <xsl:value-of 
select="property_js" />;
+                                       //      var base_java_url = 
<xsl:value-of select="base_java_url" />;
+                                               var datatable = new Array();
+                                               var myColumnDefs = new Array();
+
+                                               <xsl:for-each 
select="datatable">
+                                                       datatable[<xsl:value-of 
select="name"/>] = [
+                                                       {
+                                                       values                  
:       <xsl:value-of select="values"/>,
+                                                       total_records   :       
<xsl:value-of select="total_records"/>,
+                                                       edit_action             
:       <xsl:value-of select="edit_action"/>,
+                                                       is_paginator    :       
<xsl:value-of select="is_paginator"/>,
+                                                       footer                  
:       <xsl:value-of select="footer"/>
+                                                       }
+                                                       ]
+                                               </xsl:for-each>
+
+                                               <xsl:for-each 
select="myColumnDefs">
+                                                       
myColumnDefs[<xsl:value-of select="name"/>] = <xsl:value-of select="values"/>
+                                               </xsl:for-each>
+                                       </script>
+
+
        </xsl:template>
 
 




reply via email to

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