fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15842] more on integration with accounting


From: sigurdne
Subject: [Fmsystem-commits] [15842] more on integration with accounting
Date: Mon, 17 Oct 2016 14:46:52 +0000 (UTC)

Revision: 15842
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15842
Author:   sigurdne
Date:     2016-10-17 14:46:51 +0000 (Mon, 17 Oct 2016)
Log Message:
-----------
more on integration with accounting

Modified Paths:
--------------
    trunk/property/inc/class.socommon.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_data_til_Agresso.php
    trunk/property/js/portico/tts.view.js

Modified: trunk/property/inc/class.socommon.inc.php
===================================================================
--- trunk/property/inc/class.socommon.inc.php   2016-10-17 08:40:36 UTC (rev 
15841)
+++ trunk/property/inc/class.socommon.inc.php   2016-10-17 14:46:51 UTC (rev 
15842)
@@ -166,12 +166,83 @@
                        return $this->db->affected_rows();
                }
 
+               /**
+                * unquote (stripslashes) recursivly the whole array
+                *
+                * @param $arr array to unquote (var-param!)
+                */
+               public function unquote(&$arr)
+               {
+                       if (!is_array($arr))
+                       {
+                               $arr = stripslashes($arr);
+                               return;
+                       }
+                       foreach($arr as $key => $value)
+                       {
+                               if (is_array($value))
+                               {
+                                       $this->unquote($arr[$key]);
+                               }
+                               else
+                               {
+                                       $arr[$key] = stripslashes($value);
+                               }
+                       }
+               }
+
                function create_preferences( $app = '', $user_id = '' )
                {
-                       $this->db->query("SELECT preference_value FROM 
phpgw_preferences where preference_app = '$app' AND preference_owner=" . 
(int)$user_id);
-                       $this->db->next_record();
-                       $value = unserialize($this->db->f('preference_value'));
-                       return $value;
+                       $this->db->query("SELECT preference_value, 
preference_owner FROM phpgw_preferences where preference_app = '{$app}'"
+                       . " AND preference_owner IN (-1,-2," . (int)$user_id 
.')', __LINE__, __FILE__);
+                       $forced = $default = $user = array();
+                       while($this->db->next_record())
+                       {
+                               // The following ereg is required for 
PostgreSQL to work
+                               $value = 
unserialize($this->db->f('preference_value'));
+                               $this->unquote($value);
+                               if (!is_array($value))
+                               {
+                                       continue;
+                               }
+                               switch($this->db->f('preference_owner'))
+                               {
+                                       case -1:        // forced
+                                               $forced[$app] = $value;
+                                               break;
+                                       case -2:        // default
+                                               $default[$app] = $value;
+                                               break;
+                                       default:        // user
+                                               $user[$app] = $value;
+                                               break;
+                               }
+                       }
+                       $data = $user;
+
+                       // now use defaults if needed (user-value unset or 
empty)
+                       //
+                       foreach($default as $app => $values)
+                       {
+                               foreach($values as $var => $value)
+                               {
+                                       if (!isset($data[$app][$var]) || 
$data[$app][$var] === '')
+                                       {
+                                               $data[$app][$var] = $value;
+                                       }
+                               }
+                       }
+                       // now set/force forced values
+                       //
+                       foreach($forced as $app => $values)
+                       {
+                               foreach($values as $var => $value)
+                               {
+                                       $data[$app][$var] = $value;
+                               }
+                       }
+
+                       return $data[$app];
                }
 
                function read_single_tenant( $id )

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-10-17 08:40:36 UTC (rev 
15841)
+++ trunk/property/inc/class.uitts.inc.php      2016-10-17 14:46:51 UTC (rev 
15842)
@@ -3077,6 +3077,7 @@
        //              $id ='013000';
 
                        $amount =phpgw::get_var('amount', 'int');
+                       $ticket_id =phpgw::get_var('ticket_id', 'int');
 
                        if($check_external_register && $id)
                        {
@@ -3139,7 +3140,7 @@
                                $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
                        }
 
-                       return $this->get_supervisor_email($supervisor_id);
+                       return $this->get_supervisor_email($supervisor_id, 
$ticket_id);
                }
 
                public function check_external_register($param)
@@ -3184,19 +3185,38 @@
                        return json_decode($result, true);
                }
 
-               protected function get_supervisor_email($supervisor_id)
+               protected function get_supervisor_email($supervisor_id, 
$ticket_id)
                {
                        $need_approval = 
isset($this->bo->config->config_data['workorder_approval']) ? 
$this->bo->config->config_data['workorder_approval'] : '';
                        $supervisor_email = array();
                        if ($supervisor_id && $need_approval)
                        {
+
+                               $pending_action = 
CreateObject('property.sopending_action');
+
+                               $action_params = array(
+                                       'appname' => 'property',
+                                       'location' => '.ticket',
+                                       'id'            => $ticket_id,
+                                       'responsible' => $supervisor_id,
+                                       'responsible_type' => 'user',
+                                       'action' => 'approval',
+                                       'deadline' => '',
+                                       'created_by' => '',
+                                       'allrows' => false
+                               );
+
+                               $approval = 
$pending_action->get_pending_action($action_params);
+
                                $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
                                if (isset($prefs['email']) && $prefs['email'])
                                {
                                        $supervisor_email[] = array(
                                                'id' => $supervisor_id,
                                                'address' => $prefs['email'],
-                                               'required'      => true
+                                               'required'      => true,
+                                               'approved'      => 
!!$approval['action_performed'],
+                                               'is_user'       => 
$supervisor_id == $this->account ? true : false
                                        );
                                }
                                else
@@ -3210,6 +3230,20 @@
 
                                if (isset($prefs['approval_from']) && 
$prefs['approval_from'])
                                {
+                                       $action_params = array(
+                                               'appname' => 'property',
+                                               'location' => '.ticket',
+                                               'id'            => $ticket_id,
+                                               'responsible' => $supervisor_id,
+                                               'responsible_type' => 'user',
+                                               'action' => 'approval',
+                                               'deadline' => '',
+                                               'created_by' => '',
+                                               'allrows' => false
+                                       );
+
+                                       $approval = 
$pending_action->get_pending_action($action_params);
+
                                        $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
 
                                        if (isset($prefs2['email']) && 
$prefs2['email'])
@@ -3217,7 +3251,9 @@
                                                $supervisor_email[] = array(
                                                        'id' => 
$prefs['approval_from'],
                                                        'address' => 
$prefs2['email'],
-                                                       'required'      => false
+                                                       'required'      => 
false,
+                                                       'approved'      => 
!!$approval['action_performed'],
+                                                       'is_user'       => 
$prefs['approval_from'] == $this->account ? true : false
                                                );
                                                $supervisor_email = 
array_reverse($supervisor_email);
                                        }
@@ -3225,6 +3261,10 @@
                                }
                                unset($prefs);
                        }
+
+
+
+
                        return $supervisor_email;
                }
 

Modified: 
trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
===================================================================
--- trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2016-10-17 08:40:36 UTC (rev 15841)
+++ trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2016-10-17 14:46:51 UTC (rev 15842)
@@ -60,7 +60,7 @@
                         */
        //              $fellesdata->update_agresso_prosjekt(); //for mange 
treff
        //              $fellesdata->update_art();                              
//for mange treff
-                       $fellesdata->update_tjeneste();
+       //              $fellesdata->update_tjeneste();
                        $fellesdata->update_dimb(); // ansvar
                        $fellesdata->get_org_unit_ids_from_top();
 

Modified: trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
===================================================================
--- trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php      
2016-10-17 08:40:36 UTC (rev 15841)
+++ trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php      
2016-10-17 14:46:51 UTC (rev 15842)
@@ -95,10 +95,10 @@
                        );
 
                        $DetailInfo = array();
+//                     $DetailInfo[] = array(
+//                             'TaxCode' => $param['tax_code'] // Moms kode
+//                     );
                        $DetailInfo[] = array(
-                               'TaxCode' => $param['tax_code'] // Moms kode
-                       );
-                       $DetailInfo[] = array(
                                'ReferenceCode' => array(
                                        'Code' => 'A0',
                                        'Value' => $param['dim0'] // Art
@@ -140,14 +140,14 @@
                                        'Value' => $param['dim6'] // Aktivitet
                                )
                        );
-/*
+
                        $DetailInfo[] = array(
                                'ReferenceCode' => array(
                                        'Code' => 'A1',
                                        'Value' => $param['tax_code'] // Moms 
kode
                                )
                        );
-*/
+
                        $Detail = array();
                        $i = 1;
                        foreach ($param['lines'] as $line)
@@ -161,7 +161,7 @@
                                        'UnitCode' => 'STK',
                                        'Quantity' => 1,
                                        'Price' => $line['price'],
-                                       'Linetotal'=> $line['price'],
+                                       'LineTotal'=> $line['price'],
                                        'DetailInfo' => $DetailInfo
                                );
 

Modified: trunk/property/js/portico/tts.view.js
===================================================================
--- trunk/property/js/portico/tts.view.js       2016-10-17 08:40:36 UTC (rev 
15841)
+++ trunk/property/js/portico/tts.view.js       2016-10-17 14:46:51 UTC (rev 
15842)
@@ -389,7 +389,7 @@
        var total_amount = Number(amount) + Number($('#budget').val());
        $("#order_received_amount").val(total_amount);
 
-       var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb, amount: total_amount};
+       var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb, amount: total_amount, ticket_id:location_item_id};
        var requestUrl = phpGWLink('index.php', oArgs, true);
        var htmlString = "";
 
@@ -401,7 +401,7 @@
                {
                        if (data != null)
                        {
-                               htmlString = "<table>";
+                               htmlString = "<table><thead><th>Be om 
godkjenning</th><th>Adresse</th><th>Godkjenn</th></thead><tbody>";
                                var obj = data;
                                var required = '';
 
@@ -411,18 +411,41 @@
 
                                        htmlString += "<tr><td>";
 
-                                       if (obj[i].required == true)
+                                       if (obj[i].required === true)
                                        {
-                                               htmlString += "<input 
type=\"hidden\" name=\"values[approval][" + obj[i].id + "]\" value=\"" + 
obj[i].address + "\"></input>";
-                                               required = 'checked="checked" 
disabled="disabled"';
+                                               if(obj[i].approved === true)
+                                               {
+                                                       required = 
'disabled="disabled"';
+                                               }
+                                               else
+                                               {
+                                                       htmlString += "<input 
type=\"hidden\" name=\"values[approval][" + obj[i].id + "]\" value=\"" + 
obj[i].address + "\"></input>";
+                                                       required = 
'checked="checked" disabled="disabled"';
+                                               }
                                        }
                                        htmlString += "<input type=\"checkbox\" 
name=\"values[approval][" + obj[i].id + "]\" value=\"" + obj[i].address + "\"" 
+ required + "></input>";
                                        htmlString += "</td><td 
valign=\"top\">";
                                        htmlString += obj[i].address;
-                                       htmlString += "</td></tr>";
+                                       htmlString += "</td>";
+                                       htmlString += "<td>";
+
+                                       if (obj[i].approved === true)
+                                       {
+                                               htmlString + "X";
+                                       }
+                                       else
+                                       {
+                                               if (obj[i].is_user === true)
+                                               {
+                                                       htmlString += "<input 
type=\"checkbox\" name=\"values[do_approve][" + obj[i].id + "]\" value=\"" + 
obj[i].id + "\"></input>";
+                                               }
+                                       }
+                                       htmlString += "</td>";
+                                       
+                                       htmlString += "</tr>";
                                });
-                               htmlString += "</table>";
-
+                               htmlString += "</tbody></table>";
+//console.log(htmlString);
                                $("#approval_container").html(htmlString);
                        }
                }




reply via email to

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