fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15887] More on integration


From: sigurdne
Subject: [Fmsystem-commits] [15887] More on integration
Date: Mon, 24 Oct 2016 10:35:03 +0000 (UTC)

Revision: 15887
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15887
Author:   sigurdne
Date:     2016-10-24 10:35:03 +0000 (Mon, 24 Oct 2016)
Log Message:
-----------
More on integration

Modified Paths:
--------------
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
    trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
    trunk/property/setup/phpgw_no.lang

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2016-10-24 10:31:36 UTC (rev 
15886)
+++ trunk/property/inc/class.bocommon.inc.php   2016-10-24 10:35:03 UTC (rev 
15887)
@@ -2552,10 +2552,10 @@
                        $filter = array('active' => 1);
                        $values = $sogeneric->read(array('filter' => 
$filter,'query' => $query));
 
-                       foreach ($values as &$value)
-                       {
-                               $value['name'] = "{$value['id']} 
{$value['name']}";
-                       }
+//                     foreach ($values as &$value)
+//                     {
+//                             $value['name'] = "{$value['id']} 
{$value['name']}";
+//                     }
 
                        return array('ResultSet' => array('Result' => $values));
                }

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2016-10-24 10:31:36 UTC (rev 
15886)
+++ trunk/property/inc/class.sotts.inc.php      2016-10-24 10:35:03 UTC (rev 
15887)
@@ -845,8 +845,10 @@
                                $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'), ','));
+                               $mail_recipients = 
trim($this->db->f('mail_recipients'), ',');
+                               $ticket['mail_recipients'] = $mail_recipients ? 
explode(',', $mail_recipients) : array();
+                               $file_attachments = 
trim($this->db->f('file_attachments'), ',');
+                               $ticket['file_attachments'] = $file_attachments 
? explode(',', $file_attachments) : array();
 
                                $user_id = (int)$this->db->f('user_id');
 

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-10-24 10:31:36 UTC (rev 
15886)
+++ trunk/property/inc/class.uitts.inc.php      2016-10-24 10:35:03 UTC (rev 
15887)
@@ -3545,108 +3545,110 @@
 
                        $subject = lang('workorder') . ": 
{$ticket['order_id']}";
 
-                       if ($_to)
+                       if (!$_to)
                        {
-                               if (isset($ticket['file_attachments']) && 
is_array($ticket['file_attachments']))
+                               phpgwapi_cache::message_set(lang('missing 
recipient for order %1', $ticket['order_id']),'error' );
+                               return false;
+                       }
+
+                       if (isset($ticket['file_attachments']) && 
is_array($ticket['file_attachments']))
+                       {
+                               $attachments = 
CreateObject('property.bofiles')->get_attachments($ticket['file_attachments']);
+                               $_attachment_log = array();
+                               foreach ($attachments as $_attachment)
                                {
-                                       $attachments = 
CreateObject('property.bofiles')->get_attachments($ticket['file_attachments']);
-                                       $_attachment_log = array();
-                                       foreach ($attachments as $_attachment)
-                                       {
-                                               $_attachment_log[] = 
$_attachment['name'];
-                                       }
-                                       $attachment_log = ' ' . 
lang('attachments') . ' : ' . implode(', ', $_attachment_log);
+                                       $_attachment_log[] = 
$_attachment['name'];
                                }
+                               $attachment_log = ' ' . lang('attachments') . ' 
: ' . implode(', ', $_attachment_log);
+                       }
 
-                               if ($send_order_format == 'pdf')
+                       if ($send_order_format == 'pdf')
+                       {
+                               $pdfcode = $this->_pdf_order($id);
+                               if ($pdfcode)
                                {
-                                       $pdfcode = $this->_pdf_order($id);
-                                       if ($pdfcode)
+                                       $dir = 
"{$GLOBALS['phpgw_info']['server']['temp_dir']}/pdf_files";
+
+                                       //save the file
+                                       if (!file_exists($dir))
                                        {
-                                               $dir = 
"{$GLOBALS['phpgw_info']['server']['temp_dir']}/pdf_files";
-
-                                               //save the file
-                                               if (!file_exists($dir))
-                                               {
-                                                       mkdir($dir, 0777);
-                                               }
-                                               $fname = tempnam($dir . '/', 
'PDF_') . '.pdf';
-                                               $fp = fopen($fname, 'w');
-                                               fwrite($fp, $pdfcode);
-                                               fclose($fp);
-
-                                               $attachments[] = array
-                                                       (
-                                                       'file' => $fname,
-                                                       'name' => 
"order_{$id}.pdf",
-                                                       'type' => 
'application/pdf'
-                                               );
+                                               mkdir($dir, 0777);
                                        }
-                                       $body = lang('order') . '.</br></br>' . 
lang('see attachment');
-                               }
-                               else
-                               {
-                                       $body = $this->_html_order($id);
-                               }
+                                       $fname = tempnam($dir . '/', 'PDF_') . 
'.pdf';
+                                       $fp = fopen($fname, 'w');
+                                       fwrite($fp, $pdfcode);
+                                       fclose($fp);
 
-                               if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
-                               {
-                                       phpgwapi_cache::message_set(lang('SMTP 
server is not set! (admin section)'),'error' );
+                                       $attachments[] = array
+                                               (
+                                               'file' => $fname,
+                                               'name' => "order_{$id}.pdf",
+                                               'type' => 'application/pdf'
+                                       );
                                }
-                               if (!is_object($GLOBALS['phpgw']->send))
-                               {
-                                       $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
-                               }
+                               $body = lang('order') . '.</br></br>' . 
lang('see attachment');
+                       }
+                       else
+                       {
+                               $body = $this->_html_order($id);
+                       }
 
-                               $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
-                               $coordinator_email = 
"{$coordinator_name}<{$GLOBALS['phpgw_info']['user']['preferences']['property']['email']}>";
-                               $cc = '';
-                               $bcc = $coordinator_email;
-                               if (isset($contact_data['value_contact_email']) 
&& $contact_data['value_contact_email'])
-                               {
-                                       $cc = 
$contact_data['value_contact_email'];
-                               }
+                       if 
(empty($GLOBALS['phpgw_info']['server']['smtp_server']))
+                       {
+                               phpgwapi_cache::message_set(lang('SMTP server 
is not set! (admin section)'),'error' );
+                       }
+                       if (!is_object($GLOBALS['phpgw']->send))
+                       {
+                               $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                       }
 
-                               if (empty($purchase_grant_checked))
+                       $coordinator_name = 
$GLOBALS['phpgw_info']['user']['fullname'];
+                       $coordinator_email = 
"{$coordinator_name}<{$GLOBALS['phpgw_info']['user']['preferences']['property']['email']}>";
+                       $cc = '';
+                       $bcc = $coordinator_email;
+                       if (isset($contact_data['value_contact_email']) && 
$contact_data['value_contact_email'])
+                       {
+                               $cc = $contact_data['value_contact_email'];
+                       }
+
+                       if (empty($purchase_grant_checked))
+                       {
+                               $_budget_amount = 
$this->_get_budget_amount($id);
+
+                               $purchase_grant_error = false;
+                               $check_purchase = 
$this->bo->check_purchase_right($ticket['ecodimb'], $_budget_amount, $id);
+                               foreach ($check_purchase as $purchase_grant)
                                {
-                                       $_budget_amount = 
$this->_get_budget_amount($id);
-
-                                       $purchase_grant_error = false;
-                                       $check_purchase = 
$this->bo->check_purchase_right($ticket['ecodimb'], $_budget_amount, $id);
-                                       foreach ($check_purchase as 
$purchase_grant)
+                                       if(!$purchase_grant['is_user'] && 
($purchase_grant['required'] && !$purchase_grant['approved']))
                                        {
-                                               if(!$purchase_grant['is_user'] 
&& ($purchase_grant['required'] && !$purchase_grant['approved']))
-                                               {
-                                                       $purchase_grant_error = 
true;
-                                                       
phpgwapi_cache::message_set(lang('approval from %1 is required',
-                                                                       
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString()),
-                                                                       'error'
-                                                       );
-                                               }
+                                               $purchase_grant_error = true;
+                                               
phpgwapi_cache::message_set(lang('approval from %1 is required',
+                                                               
$GLOBALS['phpgw']->accounts->get($purchase_grant['id'])->__toString()),
+                                                               'error'
+                                               );
                                        }
                                }
+                       }
 
 //                             _debug_array($check_purchase); die();
 
-                               if(!$purchase_grant_error)
+                       if(!$purchase_grant_error)
+                       {
+                               try
                                {
-                                       try
+                                       $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_to, $subject, stripslashes($body), '', 
$cc, $bcc, $coordinator_email, $coordinator_name, 'html', '', $attachments, 
true);
+                                       if ($rcpt)
                                        {
-                                               $rcpt = 
$GLOBALS['phpgw']->send->msg('email', $_to, $subject, stripslashes($body), '', 
$cc, $bcc, $coordinator_email, $coordinator_name, 'html', '', $attachments, 
true);
-                                               if ($rcpt)
-                                               {
-                                                       
phpgwapi_cache::message_set(lang('%1 is notified', $_address),'message' );
-                                                       $historylog->add('M', 
$id, "{$_to}{$attachment_log}");
-                                                       
phpgwapi_cache::message_set(lang('Workorder is sent by email!'),'message' );
-                                               }
+                                               
phpgwapi_cache::message_set(lang('%1 is notified', $_address),'message' );
+                                               $historylog->add('M', $id, 
"{$_to}{$attachment_log}");
+                                               
phpgwapi_cache::message_set(lang('Workorder is sent by email!'),'message' );
                                        }
-                                       catch (Exception $exc)
-                                       {
-                                               
phpgwapi_cache::message_set($exc->getMessage(),'error' );
-                                       }
                                }
+                               catch (Exception $exc)
+                               {
+                                       
phpgwapi_cache::message_set($exc->getMessage(),'error' );
+                               }
                        }
-
                }
 
                private function _get_budget_amount($id)

Modified: 
trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
===================================================================
--- trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2016-10-24 10:31:36 UTC (rev 15886)
+++ trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2016-10-24 10:35:03 UTC (rev 15887)
@@ -357,7 +357,7 @@
                function update_agresso_prosjekt()
                {
                        //det er for mange...16396 stk...
-                       return;
+                       //return;
                        //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt
 
                        $url = 
'http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt';
@@ -371,9 +371,37 @@
                        {
                                echo $exc->getTraceAsString();
                        }
+/**
+            [tab] => A
+            [dimValue] => A00001
+            [description] => ADM.BYGG VEDTATT BUDSJETT 2001
+            [periodFrom] => 200612
+            [periodTo] => 209912
+            [status] => N
 
-                       _debug_array($values);
+ */
+                       if($values)
+                       {
+                               $GLOBALS['phpgw']->db->query("UPDATE 
fm_external_project SET active = 0" , __LINE__, __FILE__);
+                       }
 
+                       foreach ($values as $entry)
+                       {
+                               $active = $entry['status'] == 'C' ? 0 : 1;
+                               $GLOBALS['phpgw']->db->query("SELECT id FROM 
fm_external_project WHERE id ='{$entry['dimValue']}'", __LINE__, __FILE__);
+                               if($GLOBALS['phpgw']->db->next_record())
+                               {
+                                       $sql = "UPDATE fm_external_project SET 
name = '{$entry['dimValue']} {$entry['description']}', active = {$active} WHERE 
id = '{$entry['dimValue']}'";
+                               }
+                               else
+                               {
+                                       $name = 
$GLOBALS['phpgw']->db->db_addslashes("{$entry['dimValue']} 
{$entry['description']}");
+                                       $sql = "INSERT INTO fm_external_project 
(id, name, active)"
+                                               . " VALUES 
('{$entry['dimValue']}', '{$name}',  {$active})";
+                               }
+                               $GLOBALS['phpgw']->db->query($sql, __LINE__, 
__FILE__);
+                       }
+
                }
                function update_art()
                {

Modified: 
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
===================================================================
--- 
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php    
    2016-10-24 10:31:36 UTC (rev 15886)
+++ 
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php    
    2016-10-24 10:35:03 UTC (rev 15887)
@@ -76,7 +76,7 @@
 
                                $amount += $budget['amount'];
                        }
-                       return $amount;
+                       return $amount ? $amount : 1;
                }
 
                private function _get_ordered_workorder_amount($id)
@@ -116,7 +116,7 @@
                                'lines' => array(
                                        array(
                                                'UnitCode' => 'STK',
-                                               'Quantity' => 
($this->ordered_amount/$received_amount),
+                                               'Quantity' => 
($received_amount/$this->ordered_amount),
                                        )
                                )
                        );

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2016-10-24 10:31:36 UTC (rev 15886)
+++ trunk/property/setup/phpgw_no.lang  2016-10-24 10:35:03 UTC (rev 15887)
@@ -2068,4 +2068,5 @@
 update ticket  property        no      Oppdater melding
 make relation  property        no      Opprett kopling
 request for approval   property        no      Anmodning om godkjenning
-approval from %1 is required   property        no      Godkjenning fra %1 er 
påkrevd
\ No newline at end of file
+approval from %1 is required   property        no      Godkjenning fra %1 er 
påkrevd
+missing recipient for order %1 property        no      Mangler mottaker for 
ordre %1
\ No newline at end of file




reply via email to

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