fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15884] more on integration


From: sigurdne
Subject: [Fmsystem-commits] [15884] more on integration
Date: Sat, 22 Oct 2016 10:32:19 +0000 (UTC)

Revision: 15884
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15884
Author:   sigurdne
Date:     2016-10-22 10:32:18 +0000 (Sat, 22 Oct 2016)
Log Message:
-----------
more on integration

Modified Paths:
--------------
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/setup/setup.inc.php
    trunk/property/setup/tables_current.inc.php
    trunk/property/setup/tables_update.inc.php
    trunk/property/templates/base/tts.xsl

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2016-10-22 01:25:07 UTC (rev 
15883)
+++ trunk/property/inc/class.sotts.inc.php      2016-10-22 10:32:18 UTC (rev 
15884)
@@ -845,6 +845,8 @@
                                $ticket['order_sent'] = 
$this->db->f('order_sent');
                                $ticket['order_received'] = 
$this->db->f('order_received');
                                $ticket['order_received_amount'] = 
$this->db->f('order_received_amount');
+                               $ticket['mail_recipients'] = explode(',', 
trim($this->db->f('mail_recipients'), ','));
+                               $ticket['file_attachments'] = explode(',', 
trim($this->db->f('file_attachments'), ','));
 
                                $user_id = (int)$this->db->f('user_id');
 
@@ -1686,6 +1688,39 @@
                                $value_set['ecodimb'] = $ticket['ecodimb'];
                                $value_set['branch_id'] = $ticket['branch_id'];
                                $value_set['tax_code'] = $ticket['tax_code'];
+
+                               if(isset($ticket['vendor_email']) && 
is_array($ticket['vendor_email']))
+                               {
+                                       $vendor_email = array();
+                                       $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
+                                       foreach ($ticket['vendor_email'] as 
$_temp)
+                                       {
+                                               if ($_temp)
+                                               {
+                                                       if 
($validator->check_email_address($_temp))
+                                                       {
+                                                               $vendor_email[] 
= $_temp;
+                                                       }
+                                                       else
+                                                       {
+                                                               
$receipt['error'][] = array('msg' => lang('%1 is not a valid address', $_temp));
+                                                       }
+                                               }
+                                       }
+                                       $value_set['mail_recipients'] = 
implode(',', $vendor_email);
+                                       unset($_temp);
+                               }
+
+                               if(isset($ticket['file_attach']) && 
is_array($ticket['file_attach']))
+                               {
+                                       $file_attachments = array();
+                                       $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
+                                       foreach ($ticket['file_attach'] as 
$_temp)
+                                       {
+                                               $file_attachments[] = 
(int)$_temp;
+                                       }
+                                       $value_set['file_attachments'] = 
implode(',', $file_attachments);
+                               }
                        }
 
                        $value_set = $this->db->validate_update($value_set);

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-10-22 01:25:07 UTC (rev 
15883)
+++ trunk/property/inc/class.uitts.inc.php      2016-10-22 10:32:18 UTC (rev 
15884)
@@ -1598,15 +1598,22 @@
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
                        $values = $this->bo->read_single($id);
 
+                       $file_attachments = isset($values['file_attachments']) 
&& is_array($values['file_attachments']) ? $values['file_attachments'] : 
array();
+
                        $content_files = array();
 
                        foreach ($values['files'] as $_entry)
                        {
-                               $content_files[] = array
-                                       (
+                               $_checked = '';
+                               if (in_array($_entry['file_id'], 
$file_attachments))
+                               {
+                                       $_checked = 'checked="checked"';
+                               }
+
+                               $content_files[] = array(
                                        'file_name' => '<a href="' . 
$link_view_file . '&amp;file_id=' . $_entry['file_id'] . '" target="_blank" 
title="' . lang('click to view file') . '">' . $_entry['name'] . '</a>',
                                        'delete_file' => '<input 
type="checkbox" name="values[file_action][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to delete file') . '">',
-                                       'attach_file' => '<input 
type="checkbox" name="values[file_attach][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to attach file') . '">'
+                                       'attach_file' => '<input 
type="checkbox"' .$_checked . ' name="values[file_attach][]" value="' . 
$_entry['file_id'] . '" title="' . lang('Check to attach file') . '">'
                                );
                        }
 
@@ -2149,33 +2156,11 @@
 
                        if(!empty($values['send_order']))
                        {
-                               $vendor_email = array();
-                               $validator = 
CreateObject('phpgwapi.EmailAddressValidator');
-                               if (isset($values['vendor_email']) && 
is_array($values['vendor_email']))
-                               {
-                                       foreach ($values['vendor_email'] as 
$_temp)
-                                       {
-                                               if ($_temp)
-                                               {
-                                                       if 
($validator->check_email_address($_temp))
-                                                       {
-                                                               $vendor_email[] 
= $_temp;
-                                                       }
-                                                       else
-                                                       {
-                                                               
$receipt['error'][] = array('msg' => lang('%1 is not a valid address', $_temp));
-                                                       }
-                                               }
-                                       }
-                               }
-                               unset($_temp);
-                               $file_attach = !empty($values['file_attach']) ? 
$values['file_attach'] : array();
                                $send_order_format = 
!empty($values['send_order_format']) ? $values['send_order_format'] : 'html';
                                $purchase_grant_checked = 
!empty($values['purchase_grant_checked']) ? true : false;
                                $purchase_grant_error = 
!empty($values['purchase_grant_error']) ? true : false;
 
-                               $this->_send_order($ticket, $send_order_format, 
$file_attach, $vendor_email, $purchase_grant_checked, $purchase_grant_error);
-
+                               $this->_send_order($ticket, $send_order_format, 
$purchase_grant_checked, $purchase_grant_error);
                        }
 
                        $additional_notes = 
$this->bo->read_additional_notes($id);
@@ -2296,14 +2281,26 @@
 
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
 
-                       for ($z = 0; $z < count($ticket['files']); $z++)
+
+                       $file_attachments = isset($ticket['file_attachments']) 
&& is_array($ticket['file_attachments']) ? $ticket['file_attachments'] : 
array();
+
+                       $content_files = array();
+
+                       foreach ($ticket['files'] as $_entry)
                        {
-                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $ticket['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$ticket['files'][$z]['name'] . '</a>';
-                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$ticket['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') . 
'">';
-                               $content_files[$z]['attach_file'] = '<input 
type="checkbox" name="values[file_attach][]" value="' . 
$ticket['files'][$z]['file_id'] . '" title="' . lang('Check to attach file') . 
'">';
+                               $_checked = '';
+                               if (in_array($_entry['file_id'], 
$file_attachments))
+                               {
+                                       $_checked = 'checked="checked"';
+                               }
+
+                               $content_files[] = array(
+                                       'file_name' => '<a href="' . 
$link_view_file . '&amp;file_id=' . $_entry['file_id'] . '" target="_blank" 
title="' . lang('click to view file') . '">' . $_entry['name'] . '</a>',
+                                       'delete_file' => '<input 
type="checkbox" name="values[file_action][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to delete file') . '">',
+                                       'attach_file' => '<input 
type="checkbox"' .$_checked . ' name="values[file_attach][]" value="' . 
$_entry['file_id'] . '" title="' . lang('Check to attach file') . '">'
+                               );
                        }
 
-
                        $attach_file_def = array
                                (
                                array('key' => 'file_name', 'label' => 
lang('Filename'), 'sortable' => false,
@@ -2333,6 +2330,20 @@
 
                        $content_email = 
$this->bocommon->get_vendor_email(isset($ticket['vendor_id']) ? 
$ticket['vendor_id'] : 0);
 
+                       if (isset($ticket['mail_recipients']) && 
is_array($ticket['mail_recipients']))
+                       {
+                               $_recipients_found = array();
+                               foreach ($content_email as &$vendor_email)
+                               {
+                                       if 
(in_array($vendor_email['value_email'], $ticket['mail_recipients']))
+                                       {
+                                               $vendor_email['value_select'] = 
str_replace("type='checkbox'", "type='checkbox' checked='checked'", 
$vendor_email['value_select']);
+                                               $_recipients_found[] = 
$vendor_email['value_email'];
+                                       }
+                               }
+                               $value_extra_mail_address = implode(',', 
array_diff($ticket['mail_recipients'], $_recipients_found));
+                       }
+
                        $datatable_def[] = array
                                (
                                'container' => 'datatable-container_3',
@@ -2876,7 +2887,8 @@
                                'tabs' => 
phpgwapi_jquery::tabview_generate($tabs, $active_tab),
                                'value_order_sent'      => 
!!$ticket['order_sent'],
                                'value_order_received'  => 
$ticket['order_received'] ? 
$GLOBALS['phpgw']->common->show_date($ticket['order_received']) : '[ DD/MM/YYYY 
- H:i ]',
-                               'value_order_received_amount' => (int) 
$ticket['order_received_amount']
+                               'value_order_received_amount' => (int) 
$ticket['order_received_amount'],
+                               'value_extra_mail_address' => 
$value_extra_mail_address,
                        );
 
                        phpgwapi_jquery::load_widget('numberformat');
@@ -3527,15 +3539,17 @@
                        return $user_list;
                }
 
-               private function _send_order( $ticket, $send_order_format, 
$file_attach, $vendor_email, $purchase_grant_checked = false, 
$purchase_grant_error = false )
+               private function _send_order( $ticket, $send_order_format, 
$purchase_grant_checked = false, $purchase_grant_error = false )
                {
+                       $_to = !empty($ticket['mail_recipients'][0]) ? 
implode(';', $ticket['mail_recipients']) : '';
+
                        $subject = lang('workorder') . ": 
{$ticket['order_id']}";
 
-                       if ($vendor_email)
+                       if ($_to)
                        {
-                               if ($file_attach)
+                               if (isset($ticket['file_attachments']) && 
is_array($ticket['file_attachments']))
                                {
-                                       $attachments = 
CreateObject('property.bofiles')->get_attachments($file_attach);
+                                       $attachments = 
CreateObject('property.bofiles')->get_attachments($ticket['file_attachments']);
                                        $_attachment_log = array();
                                        foreach ($attachments as $_attachment)
                                        {
@@ -3593,8 +3607,6 @@
                                        $cc = 
$contact_data['value_contact_email'];
                                }
 
-                               $_to = implode(';', $vendor_email);
-
                                if (empty($purchase_grant_checked))
                                {
                                        $_budget_amount = 
$this->_get_budget_amount($id);

Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php  2016-10-22 01:25:07 UTC (rev 15883)
+++ trunk/property/setup/setup.inc.php  2016-10-22 10:32:18 UTC (rev 15884)
@@ -11,7 +11,7 @@
         * @version $Id$
        */
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.708';
+       $setup_info['property']['version']              = '0.9.17.709';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2016-10-22 01:25:07 UTC (rev 
15883)
+++ trunk/property/setup/tables_current.inc.php 2016-10-22 10:32:18 UTC (rev 
15884)
@@ -1170,6 +1170,8 @@
                                'order_sent' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
                                'order_received' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
                                'order_received_amount' => array('type' => 
'decimal', 'precision' => '20', 'scale' => '2', 'nullable' => True, 'default' 
=> '0.00'),
+                               'mail_recipients' => array('type' => 'varchar', 
'precision' => 255, 'nullable' => True),
+                               'file_attachments' => array('type' => 
'varchar', 'precision' => 255, 'nullable' => True),
                        ),
                        'pk' => array('id'),
                        'ix' => array(),

Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php  2016-10-22 01:25:07 UTC (rev 
15883)
+++ trunk/property/setup/tables_update.inc.php  2016-10-22 10:32:18 UTC (rev 
15884)
@@ -9405,4 +9405,34 @@
                        return $GLOBALS['setup_info']['property']['currentver'];
                }
        }
-       
\ No newline at end of file
+
+       /**
+       * Update property version from 0.9.17.708 to 0.9.17.709
+       *
+       */
+       $test[] = '0.9.17.708';
+
+       function property_upgrade0_9_17_708()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               $GLOBALS['phpgw_setup']->oProc->AddColumn('fm_tts_tickets', 
'mail_recipients', array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => True
+                       )
+               );
+               $GLOBALS['phpgw_setup']->oProc->AddColumn('fm_tts_tickets', 
'file_attachments', array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => True
+                       )
+               );
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.709';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+

Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl       2016-10-22 01:25:07 UTC (rev 
15883)
+++ trunk/property/templates/base/tts.xsl       2016-10-22 10:32:18 UTC (rev 
15884)
@@ -1108,7 +1108,7 @@
                                                                                
                        </label>
                                                                                
                </td>
                                                                                
                <td>
-                                                                               
                        <input type="text" name="values[vendor_email][]" 
value="">
+                                                                               
                        <input type="text" name="values[vendor_email][]" 
value="{value_extra_mail_address}">
                                                                                
                                <xsl:attribute name="title">
                                                                                
                                        <xsl:value-of 
select="php:function('lang', 'The order will also be sent to this one')"/>
                                                                                
                                </xsl:attribute>




reply via email to

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