fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7187] property: events


From: Sigurd Nes
Subject: [Fmsystem-commits] [7187] property: events
Date: Wed, 06 Apr 2011 09:28:29 +0000

Revision: 7187
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7187
Author:   sigurdne
Date:     2011-04-06 09:28:28 +0000 (Wed, 06 Apr 2011)
Log Message:
-----------
property: events

Modified Paths:
--------------
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.soevent.inc.php
    trunk/property/inc/class.soresponsible.inc.php
    trunk/property/inc/class.uievent.inc.php
    trunk/property/templates/base/event.xsl
    trunk/property/templates/base/event_form.xsl

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2011-04-05 20:36:28 UTC (rev 
7186)
+++ trunk/property/inc/class.bocommon.inc.php   2011-04-06 09:28:28 UTC (rev 
7187)
@@ -847,6 +847,7 @@
                                $boevent        = 
CreateObject('property.boevent');
                                $boevent->find_scedules($criteria);
                                $schedules =  $boevent->cached_events;
+//_debug_array($schedules);die();
                                foreach($schedules as $day => $set)
                                {
                                        foreach ($set as $entry)
@@ -856,8 +857,22 @@
                                                        $event['count']++;
                                                }
                                        }
+                                       $event['responsible_id'] = 
$entry['responsible_id'];
                                }
+                               if($event['responsible_id'])
+                               {
+                                       $c = CreateObject('phpgwapi.contacts');
+                                       $qfields = array
+                                       (
+                                               'contact_id' => 'contact_id',
+                                               'per_full_name'  => 
'per_full_name',
+                                       );
 
+                                       $criteria = array('contact_id' => 
$event['responsible_id']);
+                                       $contacts = $c->get_persons($qfields, 
15, 0, '', '', $criteria);
+                                       $event['responsible'] = 
$contacts[0]['per_full_name'];
+                               }
+
                                unset($event_info);
                                unset($job_id);
                                unset($job);

Modified: trunk/property/inc/class.soevent.inc.php
===================================================================
--- trunk/property/inc/class.soevent.inc.php    2011-04-05 20:36:28 UTC (rev 
7186)
+++ trunk/property/inc/class.soevent.inc.php    2011-04-06 09:28:28 UTC (rev 
7187)
@@ -45,7 +45,7 @@
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->_db                      = & 
$GLOBALS['phpgw']->db;
                        $this->_join            = & $this->_db->join;
-                       $this->_left_join               = & 
$this->_db->left_join;
+                       $this->_left_join       = & $this->_db->left_join;
                        $this->_like            = & $this->_db->like;
                }
 
@@ -81,22 +81,31 @@
                                $ordermethod = ' ORDER BY schedule_time ASC';
                        }
 
+                       $where= 'WHERE';
+                       $filtermethod = '';
+                       if($user_id)
+                       {
+                               $user = 
$GLOBALS['phpgw']->accounts->get($user_id);
+                               $filtermethod = " WHERE fm_event.responsible_id 
=" . (int)$user->person_id ;
+                               $where= 'AND';
+                       }
 
-                       $filtermethod = "WHERE location_id = {$location_id}";
+                       $filtermethod .= "$where location_id = {$location_id}";
 
                        if($query)
                        {
                                $query = $this->_db->db_addslashes($query);
 
-                               $querymethod = " AND fm_event.descr 
{$this->_like} '%{$query}%'";
+                               $querymethod = " $where fm_event.descr 
{$this->_like} '%{$query}%'";
                        }
 
                        $sql = "SELECT fm_event.id, fm_event.descr, 
schedule_time, exception_time, location_id, location_item_id,"
-                               ." attrib_id, responsible_id, enabled, 
responsible_id, fm_event.user_id, fm_event_receipt.entry_date as receipt_date"
+                               ." attrib_id, responsible_id, enabled, 
fm_event.user_id, fm_event_receipt.entry_date as receipt_date,account_lid"
                                ." FROM  fm_event"
                                ." {$this->_join} fm_event_schedule ON 
(fm_event.id = fm_event_schedule.event_id)"
                                ." {$this->_left_join} fm_event_exception ON 
(fm_event_schedule.event_id = fm_event_exception.event_id AND 
fm_event_schedule.schedule_time = fm_event_exception.exception_time)"
                                ." {$this->_left_join} fm_event_receipt ON 
(fm_event_schedule.event_id = fm_event_receipt.event_id AND 
fm_event_schedule.schedule_time = fm_event_receipt.receipt_time)"
+                               ." {$this->_left_join} phpgw_accounts ON 
(fm_event.responsible_id = phpgw_accounts.person_id)"
                                ." {$filtermethod} {$querymethod}";
                        //_debug_array($sql . $ordermethod);
                        $this->_db->query($sql,__LINE__,__FILE__);
@@ -128,7 +137,7 @@
                                                        'enabled'               
        => $this->_db->f('enabled'),
                                                        'exception'             
        => $this->_db->f('exception_time') ? 'X' :'',
                                                        'receipt_date'          
=> $this->_db->f('receipt_date'),
-                                                       'responsible_id'        
=> $this->_db->f('responsible_id'),
+                                                       'account_lid'           
=> $this->_db->f('account_lid'),
                                                        'user_id'               
        => $this->_db->f('user_id')
                                                );
                                }
@@ -284,7 +293,7 @@
                                                'id'                            
=> $this->_db->f('id'),
                                                'descr'                         
=> $this->_db->f('descr', true),
                                                'start_date'            => 
$start_date,
-                                               'responsible'           => 
$this->_db->f('responsible_id'),
+                                               'responsible_id'        => 
$this->_db->f('responsible_id'),
                                                'action'                        
=> $this->_db->f('action_id'),
                                                'end_date'                      
=> $end_date,
                                                'repeat_type'           => 
$this->_db->f('repeat_type'),
@@ -349,7 +358,7 @@
                                        'user_id',
                                        'entry_date'
                                );
-                       
+                       
                                $repeat_day = 0;
                        if(isset($data['repeat_day']) && 
is_array($data['repeat_day']))
                        {
@@ -366,7 +375,7 @@
                                        $data['attrib_id'],
                                        $data['descr'],                         
                                        $data['start_date'],
-                                       $data['responsible'],
+                                       $data['responsible_id'],
                                        $data['action'],
                                        $data['end_date'],
                                        $data['repeat_type'],                   
        
@@ -380,11 +389,11 @@
                        $this->_db->transaction_begin();
 
                        $id = $this->_db->next_id($table);
-                       $cols[] = 'id';
+                       $cols[] = 'id';
                                $vals[] = $id;
 
-                       $cols   = implode(",", $cols);
-                               $vals   = $this->_db->validate_insert($vals);
+                       $cols   = implode(",", $cols);
+                               $vals   = $this->_db->validate_insert($vals);
 
                                $this->_db->query("INSERT INTO {$table} 
({$cols}) VALUES ({$vals})",__LINE__,__FILE__);
 
@@ -418,7 +427,7 @@
                                (
                                        'descr'                         => 
$this->_db->db_addslashes($data['descr']),
                                        'start_date'            => 
$data['start_date'],
-                                       'responsible_id'        => 
$data['responsible'],
+                                       'responsible_id'        => 
$data['responsible_id'],
                                        'action_id'                     => 
$data['action'],
                                        'end_date'                      => 
$data['end_date'],
                                        'repeat_type'           => 
$data['repeat_type'],
@@ -640,7 +649,7 @@
                                                                $this->account,
                                                                
phpgwapi_datetime::user_localtime(),
                                                        );                      
                        
-                                               $vals   = 
$this->_db->validate_insert($vals);
+                                               $vals   = 
$this->_db->validate_insert($vals);
                                                        
$this->_db->query("INSERT INTO fm_event_exception (event_id, exception_time, 
user_id, entry_date) VALUES ({$vals})",__LINE__,__FILE__);
                                        }
 
@@ -667,7 +676,7 @@
                                                                $this->account,
                                                                
phpgwapi_datetime::user_localtime(),
                                                        );                      
                        
-                                               $vals   = 
$this->_db->validate_insert($vals);
+                                               $vals   = 
$this->_db->validate_insert($vals);
                                                        
$this->_db->query("INSERT INTO fm_event_receipt (event_id, receipt_time, 
user_id, entry_date) VALUES ({$vals})",__LINE__,__FILE__);
                                        }
                                }
@@ -702,7 +711,7 @@
                                                $this->account,
                                                $entry_date,
                                        );                                      
        
-                               $vals   = $this->_db->validate_insert($vals);
+                               $vals   = $this->_db->validate_insert($vals);
                                        $this->_db->query("INSERT INTO 
fm_event_schedule (event_id, schedule_time, user_id, entry_date) VALUES 
({$vals})",__LINE__,__FILE__);
                        }
 
@@ -761,7 +770,7 @@
                                                $this->account,
                                                $entry_date,
                                        );                                      
        
-                               $vals   = $this->_db->validate_insert($vals);
+                               $vals   = $this->_db->validate_insert($vals);
                                        $this->_db->query("INSERT INTO 
fm_event_receipt (event_id, receipt_time, user_id, entry_date) VALUES 
({$vals})",__LINE__,__FILE__);
                                $receipt['message'][] = 
array('msg'=>"{$event_id}::{$schedule_time}");
                        }

Modified: trunk/property/inc/class.soresponsible.inc.php
===================================================================
--- trunk/property/inc/class.soresponsible.inc.php      2011-04-05 20:36:28 UTC 
(rev 7186)
+++ trunk/property/inc/class.soresponsible.inc.php      2011-04-06 09:28:28 UTC 
(rev 7187)
@@ -670,10 +670,10 @@
                public function get_contact_user_id($person_id)
                {
                        $person_id = (int) $person_id;
-                       $sql = "SELECT account_id FROM phpgw_accounts WHERE 
person_id ={$person_id} AND person_id > 0";
+                       $sql = "SELECT account_id FROM phpgw_accounts WHERE 
person_id ={$person_id}";
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
-                       return $this->db->f('account_id');
+                       return (int)$this->db->f('account_id');
                }
 
                /**

Modified: trunk/property/inc/class.uievent.inc.php
===================================================================
--- trunk/property/inc/class.uievent.inc.php    2011-04-05 20:36:28 UTC (rev 
7186)
+++ trunk/property/inc/class.uievent.inc.php    2011-04-06 09:28:28 UTC (rev 
7187)
@@ -321,6 +321,14 @@
                        $uicols['formatter'][]  = '';
                        $uicols['input_type'][] = '';
 
+                       $uicols['name'][]               = 'account_lid';
+                       $uicols['descr'][]              = lang('account');
+                       $uicols['sortable'][]   = true;
+                       $uicols['sort_field'][] = 'account_lid';
+                       $uicols['format'][]             = '';
+                       $uicols['formatter'][]  = '';
+                       $uicols['input_type'][] = '';
+
                        $uicols['name'][]               = 'descr';
                        $uicols['descr'][]              = lang('Descr');
                        $uicols['sortable'][]   = false;
@@ -612,13 +620,13 @@
                                return;
                        }
 
-                       $location       = phpgw::get_var('location');
-                       $attrib_id      = phpgw::get_var('attrib_id');
-                       $item_id        = phpgw::get_var('item_id');//might be 
bigint
-                       $id                     = phpgw::get_var('id', 'int');
-                       $values         = phpgw::get_var('values');
+                       $location                                       = 
phpgw::get_var('location');
+                       $attrib_id                                      = 
phpgw::get_var('attrib_id');
+                       $item_id                                        = 
phpgw::get_var('item_id');//might be bigint
+                       $id                                                     
= phpgw::get_var('id', 'int');
+                       $values                                         = 
phpgw::get_var('values');
+                       $values['responsible_id']       = 
phpgw::get_var('contact', 'int', 'POST');
 
-
                        //                      
$GLOBALS['phpgw_info']['apps']['manual']['section'] = 'general.edit.' . $type;
 
                        $GLOBALS['phpgw']->xslttpl->add_file(array('event'));
@@ -638,9 +646,9 @@
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('Please enter a description'));           
                                                        
                                        }
-                                       if(!isset($values['responsible']) || 
!$values['responsible'])
+                                       if(!isset($values['responsible_id']) || 
!$values['responsible_id'])
                                        {
-               //                              
$receipt['error'][]=array('msg'=>lang('Please select a responsible'));          
                                                        
+                                               
$receipt['error'][]=array('msg'=>lang('Please select a responsible'));          
                                                        
                                        }
                                        if(!isset($values['action']) || 
!$values['action'])
                                        {
@@ -694,7 +702,7 @@
                                                unset($id);
                                        }
                                }
-                               else
+                               else if ((isset($values['cancel']) && 
$values['cancel']))
                                {
                                        
$GLOBALS['phpgw']->js->add_event('load', "window.close();");
                                }
@@ -749,8 +757,14 @@
 
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);
 
+                       
$contact_data=$this->bocommon->initiate_ui_contact_lookup(array(
+                               'contact_id'            => 
$values['responsible_id'],
+                               'field'                         => 'contact',
+                               'type'                          => 'form'));
+
                        $data = array
                                (
+                                       'contact_data'                          
        => $contact_data,
                                        'link_schedule'                         
        => $GLOBALS['phpgw']->link('/index.php',$link_schedule_data),
                                        'img_cal'                               
                => $GLOBALS['phpgw']->common->image('phpgwapi','cal'),
                                        'lang_datetitle'                        
=> lang('Select date'),

Modified: trunk/property/templates/base/event.xsl
===================================================================
--- trunk/property/templates/base/event.xsl     2011-04-05 20:36:28 UTC (rev 
7186)
+++ trunk/property/templates/base/event.xsl     2011-04-06 09:28:28 UTC (rev 
7187)
@@ -48,6 +48,8 @@
                                                                        
</textarea>
                                                                </td>
                                                        </tr>
+                                                       <xsl:call-template 
name="contact_form"/>
+<!--
                                                        <tr>
                                                                <td 
valign="top">
                                                                        
<xsl:value-of select="lang_responsible"/>
@@ -56,6 +58,7 @@
                                                                        
<xsl:value-of disable-output-escaping="yes" select="responsible"/>
                                                                </td>
                                                        </tr>
+-->
                                                        <tr>
                                                                <td 
valign="top">
                                                                        
<xsl:value-of select="lang_action"/>

Modified: trunk/property/templates/base/event_form.xsl
===================================================================
--- trunk/property/templates/base/event_form.xsl        2011-04-05 20:36:28 UTC 
(rev 7186)
+++ trunk/property/templates/base/event_form.xsl        2011-04-06 09:28:28 UTC 
(rev 7187)
@@ -51,6 +51,13 @@
                                                                <xsl:when 
test="next!=''">
                                                                        <tr>
                                                                                
<td>
+                                                                               
        <xsl:value-of select="php:function('lang', 'responsible')" />
+                                                                               
        <xsl:text>: </xsl:text>
+                                                                               
        <xsl:value-of select="responsible"/>
+                                                                               
</td>
+                                                                       </tr>
+                                                                       <tr>
+                                                                               
<td>
                                                                                
        <xsl:value-of select="lang_next_run"/>
                                                                                
        <xsl:text>: </xsl:text>
                                                                                
        <xsl:value-of select="next"/>




reply via email to

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