fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8958] property: rebuild responsibility


From: Sigurd Nes
Subject: [Fmsystem-commits] [8958] property: rebuild responsibility
Date: Mon, 27 Feb 2012 14:10:41 +0000

Revision: 8958
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8958
Author:   sigurdne
Date:     2012-02-27 14:10:40 +0000 (Mon, 27 Feb 2012)
Log Message:
-----------
property: rebuild responsibility

Modified Paths:
--------------
    trunk/property/inc/class.boresponsible.inc.php
    trunk/property/inc/class.soresponsible.inc.php
    trunk/property/inc/class.uiresponsible.inc.php
    trunk/property/templates/base/responsible.xsl

Added Paths:
-----------
    trunk/property/js/yahoo/responsible.edit.js

Modified: trunk/property/inc/class.boresponsible.inc.php
===================================================================
--- trunk/property/inc/class.boresponsible.inc.php      2012-02-27 08:26:21 UTC 
(rev 8957)
+++ trunk/property/inc/class.boresponsible.inc.php      2012-02-27 14:10:40 UTC 
(rev 8958)
@@ -430,6 +430,21 @@
                }
 
                /**
+                * Read single responsibility
+                *
+                * @param integer $id ID of responsibility type
+                *
+                * @return array holding data of responsibility type
+                */
+
+               public function read_single($id)
+               {
+                       $values = $this->so->read_single($id);
+                       $values['entry_date'] = 
$GLOBALS['phpgw']->common->show_date($values['created_on'], $this->dateformat);
+                       return $values;
+               }
+
+               /**
                 * Read single contact for responsibility type at physical 
location
                 *
                 * @param integer $id ID of responsibility type

Modified: trunk/property/inc/class.soresponsible.inc.php
===================================================================
--- trunk/property/inc/class.soresponsible.inc.php      2012-02-27 08:26:21 UTC 
(rev 8957)
+++ trunk/property/inc/class.soresponsible.inc.php      2012-02-27 14:10:40 UTC 
(rev 8958)
@@ -264,6 +264,54 @@
                }
 
                /**
+                * Read single responsibility type
+                *
+                * @param integer $id ID of responsibility type
+                *
+                * @return array Responsibility type
+                */
+
+               public function read_single($id)
+               {
+                       $sql = 'SELECT * FROM fm_responsibility WHERE id= ' . 
(int) $id;
+
+                       $this->db->query($sql, __LINE__, __FILE__);
+
+                       $values = array();
+
+                       if(     $this->db->next_record())
+                       {
+                               $values = array
+                               (
+                                       'id'                    => 
$this->db->f('id'),
+                                       'name'                  => 
$this->db->f('name', true),
+                                       'descr'                 => 
$this->db->f('descr', true),
+                                       'active'                => 
$this->db->f('active'),
+                                       'cat_id'                => 
$this->db->f('cat_id'),
+                                       'created_by'    => 
$this->db->f('created_by'),
+                                       'created_on'    => 
$this->db->f('created_on'),
+                               );
+
+                               $sql = 'SELECT * FROM fm_responsibility_module 
WHERE responsibility_id= ' . (int) $id;
+                               $this->db->query($sql, __LINE__, __FILE__);
+                               while ($this->db->next_record())
+                               {
+                                       $values['module'][] = array
+                                       (
+                                               'location_id'           => 
$this->db->f('location_id'),
+                                               'cat_id'                        
=> $this->db->f('cat_id'),
+                                               'active'                        
=> $this->db->f('active'),
+                                               'created_on'            => 
$this->db->f('created_on'),
+                                               'created_by'            => 
$this->db->f('created_by'),
+                                       );
+                               }
+                       }
+
+                       return $values;
+               }
+
+
+               /**
                 * Delete responsibility type
                 *
                 * @param integer $id ID of responsibility type

Modified: trunk/property/inc/class.uiresponsible.inc.php
===================================================================
--- trunk/property/inc/class.uiresponsible.inc.php      2012-02-27 08:26:21 UTC 
(rev 8957)
+++ trunk/property/inc/class.uiresponsible.inc.php      2012-02-27 14:10:40 UTC 
(rev 8958)
@@ -107,6 +107,7 @@
                        (
                                'index'                 => true,
                                'contact'               => true,
+                               'edit'                  => true,
                                'edit_type'     => true,
                                'edit_contact'  => true,
                                'no_access'             => true,
@@ -604,6 +605,201 @@
                        $this->_save_sessiondata();
                }
 
+
+               function edit()
+               {
+//_debug_array($_POST); die();
+
+                       if(!$this->acl_add && !$this->acl_edit)
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uilocation.stop', 'perm'=>2, 'acl_location'=> $this->acl_location));
+                       }
+
+                       $id                     = phpgw::get_var('id', 'int');
+                       $location       = phpgw::get_var('location', 'string');
+                       $values         = phpgw::get_var('values');
+
+                       if ((isset($values['save']) && $values['save']) || 
(isset($values['apply']) && $values['apply']))
+                       {
+                               if($GLOBALS['phpgw']->session->is_repost())
+                               {
+       //                              
$receipt['error'][]=array('msg'=>lang('Hmm... looks like a repost!'));
+                               }
+
+
+                               if(!isset($values['location']) || 
!$values['location'])
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('Please select a location!'));
+                               }
+
+                               if(!isset($values['title']) || 
!$values['title'])
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('Please enter a title!'));
+                               }
+
+                               if($id)
+                               {
+                                       $values['id']=$id;
+                               }
+                               else
+                               {
+                                       $id = $values['id'];
+                               }
+
+                               if(!$receipt['error'])
+                               {
+                                       $receipt = $this->bo->save($values);
+                                       $id = $receipt['id'];
+
+                                       if (isset($values['save']) && 
$values['save'])
+                                       {
+                                               
$GLOBALS['phpgw']->session->appsession('session_data','responsible_receipt',$receipt);
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uiresponsible.index', 'app' => $this->appname));
+                                       }
+                               }
+                       }
+
+                       if (isset($values['cancel']) && $values['cancel'])
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'property.uiresponsible.index', 'app' => $this->appname));
+                       }
+
+                       if ($id)
+                       {
+                               $values = $this->bo->read_single($id);
+                               $function_msg = lang('edit responsible');
+/*
+                               $this->acl->set_account_id($this->account);
+                               $grants = 
$this->acl->get_grants('property','.responsible');
+                               
if(!$this->bocommon->check_perms($grants[$values['user_id']], PHPGW_ACL_READ))
+                               {
+                                       $values = array();
+                                       
$receipt['error'][]=array('msg'=>lang('You are not granted sufficient rights 
for this entry'));
+                               }
+
+*/
+                       }
+                       else
+                       {
+                               $function_msg = lang('add responsible');
+                       }
+
+                       $link_data = array
+                               (
+                                       'menuaction'    => 
'property.uiresponsible.edit',
+                                       'id'            => $id,
+                                       'app'           => $this->appname
+                               );
+
+                       $locations = 
$GLOBALS['phpgw']->locations->get_locations(false, $this->appname, false, 
false, true);
+
+                       $selected_location = $location ? $location : 
$values['location'];
+                       if(isset($values['location_id']) && 
$values['location_id'] && !$selected_location)
+                       {
+                               $locations_info = 
$GLOBALS['phpgw']->locations->get_name($values['location_id']);
+                               $selected_location = 
$locations_info['location'];
+                       }
+
+                       $location_list = array();
+                       foreach ( $locations as $location => $descr )
+                       {
+                               $location_list[] = array
+                                       (
+                                               'id'            => $location,
+                                               'name'          => "{$location} 
[{$descr}]",
+                                               'selected'      => $location == 
$selected_location
+                                       );
+                       }
+
+                       $module_def = array
+                       (
+                               array('key' => 'appname',       
'label'=>lang('appname'),'sortable'=>true,'resizeable'=>true),
+                               array('key' => 'location',      
'label'=>lang('location'),'sortable'=>true,'resizeable'=>true),
+                               array('key' => 'category',      
'label'=>lang('category'),'sortable'=>true,'resizeable'=>true),
+                               array('key' => 'active',        
'label'=>lang('active'),'sortable'=>true,'resizeable'=>true),
+                               array('key' => 
'delete_module','label'=>lang('delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')
+                       );
+
+                       $responsibility_module = isset($values['module']) && 
$values['module'] ? $values['module'] : array();
+
+                       foreach($responsibility_module as &$module)
+                       {
+                               $_location_info = 
$GLOBALS['phpgw']->locations->get_name($module['location_id']);
+                               $module['appname'] = $_location_info['appname'];
+                               $module['location'] = 
$_location_info['location'];
+                               $category = 
$this->cats->return_single($module['cat_id']);
+                               $module['category'] = $category[0]['name'];
+
+                               if ($this->acl->check('admin', PHPGW_ACL_EDIT, 
$module['appname']))
+                               {
+                                       $_checked = $module['active'] ? 
'checked = "checked"' : '';
+                                       $module['active'] = "<input 
type='checkbox' name='values[set active][]' {$_checked} 
value='{$module['location_id']}_{$module['cat_id']}' title='".lang('Check to 
set active')."'>";
+                                       $module['delete_module'] = "<input 
type='checkbox' name='values[delete_module][]' 
value='{$module['location_id']}_{$module['cat_id']}' title='".lang('Check to 
delete')."'>";
+                               }
+                       }
+
+                       //---datatable settings--------------------------
+                       $datavalues[0] = array
+                               (
+                                       'name'                                  
=> "0",
+                                       'values'                                
=> json_encode($responsibility_module),
+                                       'total_records'                 => 
count($responsibility_module),
+                                       'is_paginator'                  => 0,
+                                       'footer'                                
=> 0
+                               );                                      
+                       $myColumnDefs[0] = array
+                               (
+                                       'name'          => "0",
+                                       'values'        =>      
json_encode($module_def)
+                               );              
+                       //-----------------------------------------------
+
+                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($receipt);
+
+                       $data = array
+                               (
+                                       'msgbox_data'                           
        => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                                       'form_action'                           
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
+                                       'value_appname'                         
        => $this->appname,
+                                       'value_id'                              
                => $id,
+                                       'value_name'                            
        => $values['name'],
+                                       'value_descr'                           
        => $values['descr'],
+                                       'value_access'                          
        => $values['access'],
+                                       'apps_list'                             
                => array('options' => execMethod('property.bojasper.get_apps', 
$this->appname)), 
+                                       'location_list'                         
        => array('options' => $location_list),
+                                       'td_count'                              
                => '""',
+                                       'base_java_url'                         
        => "{menuaction:'property.uiresponsible.edit'}",
+                                       'property_js'                           
        => 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
+                                       'datatable'                             
                => $datavalues,
+                                       'myColumnDefs'                          
        => $myColumnDefs,
+                                       'lang_category'                         
        => lang('category'),
+                                       'lang_no_cat'                           
        => lang('no category'),
+                                       'cat_select'                            
        => $this->cats->formatted_xslt_list(array
+                                       (
+                                               'select_name' => 
'values[cat_id]',
+                                               'selected' => 
isset($values['cat_id'])?$values['cat_id']:''
+                                       )),
+                               );
+
+                       //---datatable settings--------------------
+                       phpgwapi_yui::load_widget('dragdrop');
+                       phpgwapi_yui::load_widget('datatable');
+                       phpgwapi_yui::load_widget('loader');
+
+                       $GLOBALS['phpgw']->css->validate_file('property');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'responsible.edit', 'property' );
+                       //-----------------------datatable settings---
+
+                       $appname                                                
= 'Responsible';
+
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . "::{$appname}::$function_msg::".lang($this->appname);
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('responsible'));
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+               }
+
+
+
                /**
                 * Add or Edit available responsible types
                 *

Added: trunk/property/js/yahoo/responsible.edit.js
===================================================================
--- trunk/property/js/yahoo/responsible.edit.js                         (rev 0)
+++ trunk/property/js/yahoo/responsible.edit.js 2012-02-27 14:10:40 UTC (rev 
8958)
@@ -0,0 +1,28 @@
+var  myPaginator_0, myDataTable_0
+
+/********************************************************************************/
+this.myParticularRenderEvent = function()
+{
+
+}
+
+/********************************************************************************/
     
+var FormatterCenter = function(elCell, oRecord, oColumn, oData)
+{
+       elCell.innerHTML = "<center>"+oData+"</center>";
+}
+
+ 
/********************************************************************************/
+
+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/responsible.xsl
===================================================================
--- trunk/property/templates/base/responsible.xsl       2012-02-27 08:26:21 UTC 
(rev 8957)
+++ trunk/property/templates/base/responsible.xsl       2012-02-27 14:10:40 UTC 
(rev 8958)
@@ -1,6 +1,9 @@
   <!-- $Id$ -->
        <xsl:template name="app_data">
                <xsl:choose>
+                       <xsl:when test="edit">
+                               <xsl:apply-templates select="edit"/>
+                       </xsl:when>
                        <xsl:when test="edit_type">
                                <xsl:apply-templates select="edit_type"/>
                        </xsl:when>
@@ -16,6 +19,199 @@
                </xsl:choose>
        </xsl:template>
 
+
+       <!-- add / edit  -->
+       <xsl:template xmlns:php="http://php.net/xsl"; match="edit">
+               <xsl:variable name="form_action">
+                       <xsl:value-of select="form_action"/>
+               </xsl:variable>
+               <table cellpadding="2" cellspacing="2" width="80%" 
align="center">
+                       <tr>
+                               <td>
+                                       <table cellpadding="2" cellspacing="2" 
align="left">
+                                               <xsl:choose>
+                                                       <xsl:when 
test="msgbox_data != ''">
+                                                               <tr>
+                                                                       <td 
align="left" colspan="3">
+                                                                               
<xsl:call-template name="msgbox"/>
+                                                                       </td>
+                                                               </tr>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                               <xsl:choose>
+                                                       <xsl:when 
test="value_id != ''">
+                                                               <tr>
+                                                                       <td 
valign="top">
+                                                                               
<xsl:value-of select="php:function('lang', 'id')"/>
+                                                                       </td>
+                                                                       <td>
+                                                                               
<xsl:value-of select="value_id"/>
+                                                                       </td>
+                                                               </tr>
+                                                       </xsl:when>
+                                               </xsl:choose>
+                                               <form name="form_app" 
method="post" action="{$form_action}">
+                                                       <tr>
+                                                               <td>
+                                                                       
<xsl:value-of select="php:function('lang', 'application')"/>
+                                                               </td>
+                                                               <td 
align="left">
+                                                                       <select 
name="appname" onChange="this.form.submit();">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'application')"/>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:apply-templates select="apps_list/options"/>
+                                                                       
</select>
+                                                               </td>
+                                                       </tr>
+                                               </form>
+                                               <form name="form_location" 
method="post" action="{$form_action}">
+                                                       <tr>
+                                                               <td>
+                                                                       <input 
type="hidden" name="appname" value="{value_appname}"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'location')"/>
+                                                               </td>
+                                                               <td 
align="left">
+                                                                       <select 
name="location" onChange="this.form.submit();">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'Select submodule')"/>
+                                                                               
</xsl:attribute>
+                                                                               
<option value="">
+                                                                               
        <xsl:value-of select="php:function('lang', 'No location')"/>
+                                                                               
</option>
+                                                                               
<xsl:apply-templates select="location_list/options"/>
+                                                                       
</select>
+                                                               </td>
+                                                       </tr>
+                                               </form>
+                                       </table>
+                                       <tr>
+                                               <td>
+                                                       <form name="form" 
method="post" action="{$form_action}">
+                                                               <table 
cellpadding="2" cellspacing="2" align="left">
+                                                                       <tr>
+                                                                               
<td>
+                                                                               
        <input type="hidden" name="values[appname]" value="{value_appname}"/>
+                                                                               
        <input type="hidden" name="values[location]" value="{value_location}"/>
+                                                                               
        <xsl:value-of select="php:function('lang', 'category')"/>
+                                                                               
</td>
+                                                                               
<td>
+                                                                               
        <xsl:call-template name="categories"/>
+                                                                               
</td>
+                                                                       </tr>
+                                                                       <tr>
+                                                                               
<td>
+                                                                               
        <xsl:value-of select="php:function('lang', 'name')"/>
+                                                                               
</td>
+                                                                               
<td>
+                                                                               
        <input type="text" name="values[name]" value="{value_name}" size="60">
+                                                                               
                <xsl:attribute name="title">
+                                                                               
                        <xsl:value-of select="php:function('lang', 'name')"/>
+                                                                               
                </xsl:attribute>
+                                                                               
        </input>
+                                                                               
</td>
+                                                                       </tr>
+                                                                       <tr>
+                                                                               
<td valign="top">
+                                                                               
        <xsl:value-of select="php:function('lang', 'descr')"/>
+                                                                               
</td>
+                                                                               
<td>
+                                                                               
        <textarea cols="60" rows="10" name="values[descr]">
+                                                                               
                <xsl:attribute name="title">
+                                                                               
                        <xsl:value-of select="php:function('lang', 'descr')"/>
+                                                                               
                </xsl:attribute>
+                                                                               
                <xsl:value-of select="value_descr"/>
+                                                                               
        </textarea>
+                                                                               
</td>
+                                                                       </tr>
+                                                                       <tr>
+                                                                               
<td class="th_text" valign="top">
+                                                                               
        <xsl:value-of select="php:function('lang', 'details')"/>
+                                                                               
</td>
+                                                                               
<td>
+                                                                               
        <table width="100%" cellpadding="2" cellspacing="2" align="center">
+                                                                               
                <!--  DATATABLE 0-->
+                                                                               
                <td>
+                                                                               
                        <div id="paging_0"/>
+                                                                               
                        <div id="datatable-container_0"/>
+                                                                               
                </td>
+                                                                               
        </table>
+                                                                               
</td>
+                                                                       </tr>
+                                                                       <tr>
+                                                                               
<td colspan="2">
+                                                                               
        <table cellpadding="2" cellspacing="2" width="50%" align="center">
+                                                                               
                <xsl:variable name="lang_save">
+                                                                               
                        <xsl:value-of select="php:function('lang', 'save')"/>
+                                                                               
                </xsl:variable>
+                                                                               
                <xsl:variable name="lang_apply">
+                                                                               
                        <xsl:value-of select="php:function('lang', 'apply')"/>
+                                                                               
                </xsl:variable>
+                                                                               
                <xsl:variable name="lang_cancel">
+                                                                               
                        <xsl:value-of select="php:function('lang', 'cancel')"/>
+                                                                               
                </xsl:variable>
+                                                                               
                <tr height="50">
+                                                                               
                        <td>
+                                                                               
                                <input type="submit" name="values[save]" 
value="{$lang_save}">
+                                                                               
                                        <xsl:attribute name="title">
+                                                                               
                                                <xsl:value-of 
select="php:function('lang', 'save')"/>
+                                                                               
                                        </xsl:attribute>
+                                                                               
                                </input>
+                                                                               
                        </td>
+                                                                               
                        <td>
+                                                                               
                                <input type="submit" name="values[apply]" 
value="{$lang_apply}">
+                                                                               
                                        <xsl:attribute name="title">
+                                                                               
                                                <xsl:value-of 
select="php:function('lang', 'apply')"/>
+                                                                               
                                        </xsl:attribute>
+                                                                               
                                </input>
+                                                                               
                        </td>
+                                                                               
                        <td>
+                                                                               
                                <input type="submit" name="values[cancel]" 
value="{$lang_cancel}">
+                                                                               
                                        <xsl:attribute name="title">
+                                                                               
                                                <xsl:value-of 
select="php:function('lang', 'cancel')"/>
+                                                                               
                                        </xsl:attribute>
+                                                                               
                                </input>
+                                                                               
                        </td>
+                                                                               
                </tr>
+                                                                               
        </table>
+                                                                               
</td>
+                                                                       </tr>
+                                                               </table>
+                                                       </form>
+                                               </td>
+                                       </tr>
+                               </td>
+                       </tr>
+               </table>
+               <!--  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();
+                       var myButtons = new Array();
+                       var td_count = <xsl:value-of select="td_count"/>;
+
+                       <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"/>,
+                                               is_paginator:  <xsl:value-of 
select="is_paginator"/>,
+                                       <!--permission:<xsl:value-of 
select="permission"/>, -->
+                                               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>
+                       <xsl:for-each select="myButtons">
+                               myButtons[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
+                       </xsl:for-each>
+               </script>
+       </xsl:template>
+
        <!-- New template-->
        <xsl:template match="list_type">
                <xsl:variable name="responsible_action">
@@ -677,3 +873,14 @@
                        </form>
                </div>
        </xsl:template>
+
+       <!-- New template-->
+       <xsl:template match="options">
+               <option value="{id}">
+                       <xsl:if test="selected != 0">
+                               <xsl:attribute name="selected" 
value="selected"/>
+                       </xsl:if>
+                       <xsl:value-of disable-output-escaping="yes" 
select="name"/>
+               </option>
+       </xsl:template>
+




reply via email to

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