fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11888] som changes to custom datatype event


From: Sigurd Nes
Subject: [Fmsystem-commits] [11888] som changes to custom datatype event
Date: Sun, 06 Apr 2014 18:20:23 +0000

Revision: 11888
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11888
Author:   sigurdne
Date:     2014-04-06 18:20:23 +0000 (Sun, 06 Apr 2014)
Log Message:
-----------
som changes to custom datatype event

Modified Paths:
--------------
    trunk/property/inc/class.boevent.inc.php
    trunk/property/inc/class.interlink.inc.php
    trunk/property/inc/class.soevent.inc.php
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uievent.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/setup/phpgw_no.lang

Modified: trunk/property/inc/class.boevent.inc.php
===================================================================
--- trunk/property/inc/class.boevent.inc.php    2014-04-04 19:01:47 UTC (rev 
11887)
+++ trunk/property/inc/class.boevent.inc.php    2014-04-06 18:20:23 UTC (rev 
11888)
@@ -69,15 +69,13 @@
                var $cat_id;
                var $location_info = array();
                var $cached_events;
-               protected $event_functions = array
-                       (
-                               'send_sms'      => 'send SMS'
-                       );
+               protected $event_functions = array();
 
                var $public_functions = array
                        (
                                'event_schedule_data'           => true,
-                               'event_schedule_week_data'      => true
+                               'event_schedule_week_data'      => true,
+//                             'action'                                        
=> true
                        );
 
 
@@ -88,6 +86,25 @@
                        $this->sbox             = CreateObject('phpgwapi.sbox');
                        $this->asyncservice = 
CreateObject('phpgwapi.asyncservice');
 
+                       if(isset($GLOBALS['phpgw_info']['user']['apps']['sms']))
+                       {
+                               $this->event_functions[1] = array
+                               (
+                                       'id' => 1,
+                                       'name' => 'Send SMS',
+                                       'action' => 'property.boevent.send_sms'
+                               );
+                       }
+
+                       
if(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server'])
+                       {
+                               $this->event_functions[2] = array
+                               (
+                                       'id' => 2,
+                                       'name' => 'Send Email',
+                                       'action' => 
'property.boevent.send_email'
+                               );
+                       }
                        if ($session)
                        {
                                $this->read_sessiondata();
@@ -241,7 +258,7 @@
                {
                        $data['start_date'] = 
phpgwapi_datetime::date_to_timestamp($data['start_date']);
                        $data['end_date'] = 
phpgwapi_datetime::date_to_timestamp($data['end_date']);
-
+//                     _debug_array($data);die();
                        if (isset($data['id']) && $data['id'] > 0 && 
$this->so->read_single($data['id']))
                        {
                                $receipt = $this->so->edit($data);
@@ -250,11 +267,11 @@
                        {
                                $receipt = $this->so->add($data);
                        }
-
+/*
                        $action_object          = 
CreateObject('property.sogeneric');
                        $action_object->get_location_info('event_action',false);
                        $action = $action_object->read_single(array('id'=> 
$data['action']),$values = array());
-
+*/
                        $rpt_day = array
                                (
                                        1               => 0, //'Sunday',
@@ -364,11 +381,13 @@
 
                        $timer_data = array
                                (
-                                       'start'         => $data['start_date'],
-                                       'enabled'       => true,
-                                       'owner'         => $account_id,
-                                       'enabled'       => !! $data['enabled'],
-                                       'action'        => $action['action']
+                                       'start'                 => 
$data['start_date'],
+                                       'enabled'               => true,
+                                       'owner'                 => $account_id,
+                                       'enabled'               => !! 
$data['enabled'],
+//                                     'action'                => 
$action['action'],
+                                       'action'                => 
$this->event_functions[$data['action']]['action'],
+                                       'action_data'   => 
array('responsible_id' => $data['responsible_id'])
                                );
 
                        if($data['end_date'])
@@ -385,7 +404,7 @@
 
                        $location       = phpgw::get_var('location');
 
-                       $id = 
"property{$location}::{$data['item_id']}::{$data['attrib_id']}";
+                       $id = 
"property{$location}::{$data['item_id']}::{$receipt['id']}";
                        $timer_data['id'] = $id;
 
                        $this->asyncservice->cancel_timer($id);
@@ -509,28 +528,85 @@
                        $values                                 = 
$action_object->read(array('allrows'=> true));
  */
                        $list = array(0 => lang('none'));
-/*
-                       foreach($values as $entry)
+
+                       foreach($this->event_functions as $entry)
                        {
                                $list[$entry['id']] = $entry['name'];
                        }
- */
-                       $list = array_merge($list,$this->event_functions);
 
                        return $this->sbox->getArrayItem('values[action]', 
$selected, $list, true);
                }
 
-               protected function send_sms()
+               public function send_sms($data)
                {
+                       $parts = explode('::',$data['id']);
+                       $id = $parts[1];
+                       $location_arr = explode($parts[0]);
+                       $interlink      = CreateObject('property.interlink');
+                       $relation_link = 
$interlink->get_relation_link($location_arr[1], $id, 'view', true);
+
+                       $responsible_id = 
isset($data['action_data']['responsible_id']) ? 
$data['action_data']['responsible_id'] : 0;
+                       if(!$responsible_id)
+                       {
+                               return false;
+                       }
+                       $comms = 
execMethod('addressbook.boaddressbook.get_comm_contact_data',$responsible_id);
+
+                       $number = $comms[$entry['contact_id']]['mobile (cell) 
phone'];
+                       $subject = lang('reminder');
+                       $message = '<a href ="{$relation_link}">' . 
lang('record').' #' .$id .'</a>'."\n";
+
                        $data = array
                                (
-                                       'p_num_text'    => 'xxxxxxxx',//number
-                                       'message'               => 'dette er en 
melding'
+                                       'p_num_text'    => $number,
+                                       'message'               => 
"{$subject}:\n{$message}"
                                );
 
                        execMethod('sms.bosms.send_sms', $data);
                }
 
+               public function send_email($data)
+               {
+                       $parts = explode('::',$data['id']);
+                       $id = $parts[1];
+                       $location_arr = explode($parts[0]);
+                       $interlink      = CreateObject('property.interlink');
+                       $relation_link = 
$interlink->get_relation_link($location_arr[1], $id, 'view', true);
+
+                       $responsible_id = 
isset($data['action_data']['responsible_id']) ? 
$data['action_data']['responsible_id'] : 0;
+                       if(!$responsible_id)
+                       {
+                               return false;
+                       }
+                       $comms = 
execMethod('addressbook.boaddressbook.get_comm_contact_data',$responsible_id);
+
+                       $_address = $comms[$entry['contact_id']]['work email'];
+                       $subject = lang('reminder');
+                       $message = '<a href ="{$relation_link}">' . 
lang('record').' #' .$id .'</a>'."\n";
+                       if (!is_object($GLOBALS['phpgw']->send))
+                       {
+                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                       }
+                       try
+                       {
+                               $GLOBALS['phpgw']->send->msg('email', 
$_address, $subject, stripslashes($message), '', $cc, $bcc, $coordinator_email, 
$coordinator_name, 'html');
+                       }
+                       catch (phpmailerException $e)
+                       {
+                               $receipt['error'][] = array('msg' => 
$e->getMessage());
+                               $GLOBALS['phpgw']->log->error(array(
+                                       'text' => 
'property_boevent::send_email() failed with %1',
+                                       'p1'   => $e->getMessage(),
+                                       'p2'     => '',
+                                       'line' => __LINE__,
+                                       'file' => __FILE__
+                               ));
+
+                               return false;
+
+                       }
+
+               }
                /**
                 * Find recurring events
                 *

Modified: trunk/property/inc/class.interlink.inc.php
===================================================================
--- trunk/property/inc/class.interlink.inc.php  2014-04-04 19:01:47 UTC (rev 
11887)
+++ trunk/property/inc/class.interlink.inc.php  2014-04-06 18:20:23 UTC (rev 
11888)
@@ -249,7 +249,7 @@
                 * @return string the linkt to the the related item
                 */
 
-               public function get_relation_link($linkend_location, $id, 
$function = 'edit')
+               public function get_relation_link($linkend_location, $id, 
$function = 'edit', $external = false)
                {
                        $link = array();
 
@@ -339,7 +339,14 @@
                                        );
                        }
 
-                       return $GLOBALS['phpgw']->link('/index.php',$link);     
+                       if($external)
+                       {
+                               return 
$GLOBALS['phpgw']->link('/index.php',$link, false, true);                       
                 
+                       }
+                       else
+                       {
+                               return 
$GLOBALS['phpgw']->link('/index.php',$link);     
+                       }
                }
 
                /**

Modified: trunk/property/inc/class.soevent.inc.php
===================================================================
--- trunk/property/inc/class.soevent.inc.php    2014-04-04 19:01:47 UTC (rev 
11887)
+++ trunk/property/inc/class.soevent.inc.php    2014-04-06 18:20:23 UTC (rev 
11888)
@@ -168,7 +168,7 @@
                        $filtermethod = "WHERE fm_event.id = {$id}";
 
                        $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, 
responsible_id, fm_event.user_id, fm_event_receipt.entry_date as receipt_date, 
fm_event_receipt.user_id as receipt_user_id"
                                ." 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)"
@@ -193,6 +193,7 @@
                                                'enabled'                       
=> $this->_db->f('enabled'),
                                                'exception'                     
=> $this->_db->f('exception_time') ? 'X' :'',
                                                'receipt_date'          => 
$this->_db->f('receipt_date'),
+                                               'receipt_user_id'       => 
$this->_db->f('receipt_user_id'),
                                                'responsible_id'        => 
$this->_db->f('responsible_id'),
                                                'user_id'                       
=> $this->_db->f('user_id')
                                        );
@@ -405,12 +406,12 @@
 
                        $id = $this->_db->next_id($table);
                        $cols[] = 'id';
-                               $vals[] = $id;
+                       $vals[] = $id;
 
                        $cols   = implode(",", $cols);
-                               $vals   = $this->_db->validate_insert($vals);
+                       $vals   = $this->_db->validate_insert($vals);
 
-                               $this->_db->query("INSERT INTO {$table} 
({$cols}) VALUES ({$vals})",__LINE__,__FILE__);
+                       $this->_db->query("INSERT INTO {$table} ({$cols}) 
VALUES ({$vals})",__LINE__,__FILE__);
 
                        if($this->_db->transaction_commit())
                        {

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2014-04-04 19:01:47 UTC (rev 
11887)
+++ trunk/property/inc/class.sotts.inc.php      2014-04-06 18:20:23 UTC (rev 
11888)
@@ -1382,13 +1382,6 @@
                                                }
                                        }
 
-                                       if(isset($ticket['extra']) && 
is_array($ticket['extra']))
-                                       {
-                                               foreach ($ticket['extra'] as 
$column => $value)
-                                               {
-                                                       $value_set[$column]     
= $value;
-                                               }
-                                       }
 
                                        $value_set      = 
$this->db->validate_update($value_set);
 
@@ -1424,7 +1417,6 @@
 
                        $value_set['modified_date']     = time();
 
-
                        // check order-rights
                        
                        $order_add      = 
$GLOBALS['phpgw']->acl->check('.ticket.order', PHPGW_ACL_ADD, 'property');
@@ -1443,6 +1435,20 @@
                        $value_set      = 
$this->db->validate_update($value_set);
                        $this->db->query("UPDATE fm_tts_tickets SET $value_set 
WHERE id={$id}",__LINE__,__FILE__);
 
+                       $value_set      = array();
+
+                       if(isset($ticket['extra']) && 
is_array($ticket['extra']))
+                       {
+                               foreach ($ticket['extra'] as $column => $value)
+                               {
+                                       $value_set[$column]     = $value;
+                               }
+                       }
+
+                       $value_set      = 
$this->db->validate_update($value_set);
+
+                       $this->db->query("UPDATE fm_tts_tickets SET $value_set 
WHERE id={$id}",__LINE__,__FILE__);
+
                        $this->db->transaction_commit();
 
                        if (isset($this->fields_updated) && 
$this->fields_updated)

Modified: trunk/property/inc/class.uievent.inc.php
===================================================================
--- trunk/property/inc/class.uievent.inc.php    2014-04-04 19:01:47 UTC (rev 
11887)
+++ trunk/property/inc/class.uievent.inc.php    2014-04-06 18:20:23 UTC (rev 
11888)
@@ -143,7 +143,7 @@
                                $datatable['config']['base_java_url'] = 
"menuaction:'property.uievent.index',"
                                        ."location_id:'{$this->location_id}',"
                                        ."user_id:'{$this->user_id}',"
-                                       ."status_id:'{$this->status_id}'";      
                                
+                                       ."status_id:'{$this->status_id}'";
 
                                $values_combo_box = array();
 
@@ -289,7 +289,7 @@
                                                        )
                                                )
                                        )
-                               );                              
+                               );
                                $dry_run = true;
                        }
 
@@ -523,7 +523,7 @@
 
                        if($dry_run)
                        {
-                               $datatable['pagination']['records_returned'] = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];           
         
+                               $datatable['pagination']['records_returned'] = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
                        }
                        else
                        {
@@ -667,16 +667,24 @@
                                {
                                        if(!isset($values['descr']) || 
!$values['descr'])
                                        {
-                                               
$receipt['error'][]=array('msg'=>lang('Please enter a description'));           
                                                        
+                                               
$receipt['error'][]=array('msg'=>lang('Please enter a description'));
                                        }
                                        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'])
                                        {
-               //                              
$receipt['error'][]=array('msg'=>lang('Please select an action'));              
                                                        
+                                               
$receipt['error'][]=array('msg'=>lang('Please select an action'));
                                        }
+                                       if(!isset($values['start_date']) || 
!$values['start_date'])
+                                       {
+                                               
$receipt['error'][]=array('msg'=>lang('Please select a start date'));
+                                       }
+                                       if(!isset($values['repeat_type']) || 
!$values['repeat_type'])
+                                       {
+                                               
$receipt['error'][]=array('msg'=>lang('Please select a repeat type'));
+                                       }
 
 /*                                     if(isset($values['repeat_day']))
                                        {
@@ -698,6 +706,7 @@
 
                                                $js = 
"opener.document.form.{$field_name}.value = '{$receipt['id']}';\n";
                                                $js .= 
"opener.document.form.{$field_name}_descr.value = '{$values['descr']}';\n";
+                                               $js .= 
"opener.document.form.submit();\n";
 
                                                if (isset($values['save']) && 
$values['save'])
                                                {
@@ -825,7 +834,7 @@
                                        'value_id'                              
                => isset($values['id']) ? $values['id'] : '',
 
                                        'lang_next_run'                         
        => lang('next run'),
-                                       'value_next_run'                        
        => isset($values['next']) ? $values['next'] : '',                       
        
+                                       'value_next_run'                        
        => isset($values['next']) ? $values['next'] : '',
                                        'value_descr'                           
        => $values['descr'],
                                        'lang_descr_text'                       
        => lang('Enter a description of the record'),
                                        'lang_save_text'                        
        => lang('Save the record'),
@@ -931,6 +940,7 @@
                                                'number'                        
=> $i,
                                                'time'                          
=> $GLOBALS['phpgw']->common->show_date($entry['schedule_time'],$dateformat),
                                                'performed'                     
=> $GLOBALS['phpgw']->common->show_date($entry['receipt_date'],$dateformat),
+                                               'user'                          
=> $entry['receipt_user_id'] ? 
$GLOBALS['phpgw']->accounts->get($entry['receipt_user_id'])->__toString() : '',
                                                'alarm_id'                      
=> $GLOBALS['phpgw']->common->show_date($entry['schedule_time'],'Ymd'),
                                                'enabled'                       
=> isset($entry['exception']) && $entry['exception']==true ? '' : 1,
                                                'location_id'           => 
$entry['location_id'],
@@ -972,7 +982,7 @@
                        {
                                if(count($values))
                                {
-                                       _debug_array($values);
+//                                     _debug_array($values);
                                        return json_encode($values);
                                }
                                else
@@ -998,11 +1008,12 @@
                        $myColumnDefs[0] = array
                                (
                                        'name'   => "0",
-                                       'values'  => json_encode(array( 
+                                       'values'  => json_encode(array(
                                                array('key' => 'number', 
'label'=>'#', 'sortable'=>true,'resizeable'=>true,'width'=>20),
                                                array('key' => 'time', 
'label'=>lang('plan'), 'sortable'=>true,'resizeable'=>true,'width'=>80),
-                                               array('key' => 'performed', 
'label'=>lang('performed'), 'sortable'=>true,'resizeable'=>true,'width'=>80),   
                                    
-                                               array('key' => 'remark', 
'label'=>lang('remark'), 'sortable'=>true,'resizeable'=>true,'width'=>140),     
                               
+                                               array('key' => 'performed', 
'label'=>lang('performed'), 'sortable'=>true,'resizeable'=>true,'width'=>80),
+                                               array('key' => 'user', 
'label'=>lang('user'), 'sortable'=>true,'resizeable'=>true,'width'=>80),
+                                               array('key' => 'remark', 
'label'=>lang('remark'), 'sortable'=>true,'resizeable'=>true,'width'=>140),
                                                array('key' => 
'enabled','label'=> 
lang('enabled'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterCenter','width'=>30),
                                                array('key' => 
'alarm_id','label'=> 
'alarm_id','sortable'=>true,'resizeable'=>true,'hidden'=>false),
                                                array('key' => 
'select','label'=> lang('select'), 
'sortable'=>false,'resizeable'=>false,'formatter'=>'myFormatterCheck','width'=>30)))
@@ -1011,7 +1022,7 @@
                        $myButtons[0] = array
                                (
                                        'name'   => "0",
-                                       'values'  => json_encode(array( 
+                                       'values'  => json_encode(array(
                                                array('id' 
=>'values[set_receipt]','type'=>'buttons', 'value'=>'Receipt', 'label'=> 
lang('Receipt'), 'funct'=> 'onActionsClick' , 'classname'=> 'actionButton', 
'value_hidden'=>""),
                                                array('id' 
=>'values[delete_receipt]','type'=>'buttons', 'value'=>'Delete Receipt', 
'label'=> lang('Delete receipt'), 'funct'=> 'onActionsClick' , 'classname'=> 
'actionButton', 'value_hidden'=>""),
                                                array('id' 
=>'values[enable_alarm]','type'=>'buttons', 'value'=>'Enable', 'label'=> 
lang('enable'), 'funct'=> 'onActionsClick' , 'classname'=> 'actionButton', 
'value_hidden'=>""),

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2014-04-04 19:01:47 UTC (rev 
11887)
+++ trunk/property/inc/class.uitts.inc.php      2014-04-06 18:20:23 UTC (rev 
11888)
@@ -1790,8 +1790,9 @@
                        if ((isset($values['save']) && $values['save']) || 
(isset($values['apply']) && $values['apply']))
                        {
                                $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
-                               $insert_record_entity = 
$GLOBALS['phpgw']->session->appsession('insert_record_entity','property');
 
+                               $insert_record_entity = 
$GLOBALS['phpgw']->session->appsession('insert_record_values' . 
$this->acl_location,'property');
+
                                if(isset($insert_record_entity) && 
is_array($insert_record_entity))
                                {
                                        for 
($j=0;$j<count($insert_record_entity);$j++)
@@ -2363,7 +2364,7 @@
                                }
 
                                $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
-                               $insert_record_entity = 
$GLOBALS['phpgw']->session->appsession('insert_record_entity','property');
+                               $insert_record_entity = 
$GLOBALS['phpgw']->session->appsession('insert_record_values' . 
$this->acl_location,'property');
 
                                if(isset($insert_record_entity) && 
is_array($insert_record_entity))
                                {
@@ -2432,7 +2433,7 @@
                                {
                                        $values['assignedto'] = $this->account;
                                }
-
+/*
                                if(isset($values_attribute) && 
is_array($values_attribute))
                                {
                                        foreach ($values_attribute as 
$attribute )
@@ -2443,7 +2444,7 @@
                                                }
                                        }
                                }
-
+*/
                                $receipt = 
$this->bo->update_ticket($values,$id, $receipt, $values_attribute);
 
                                if ( (isset($values['send_mail']) && 
$values['send_mail']) 

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2014-04-04 19:01:47 UTC (rev 11887)
+++ trunk/property/setup/phpgw_no.lang  2014-04-06 18:20:23 UTC (rev 11888)
@@ -388,6 +388,8 @@
 periodization  property        no      Periodisering
 periodization start    property        no      Startperiode
 periodization outline  property        no      Periodiseringsfordeling
+delete receipt property        no      Slett kvittering
+plan   property        no      Tidsplan
 planned year   property        no      Planlagt år
 planning       property        no      Planlagt
 planning date  property        no      Dato planlagt disponering




reply via email to

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