fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15283] property: more on integration


From: sigurdne
Subject: [Fmsystem-commits] [15283] property: more on integration
Date: Tue, 14 Jun 2016 09:21:39 +0000 (UTC)

Revision: 15283
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15283
Author:   sigurdne
Date:     2016-06-14 09:21:39 +0000 (Tue, 14 Jun 2016)
Log Message:
-----------
property: more on integration

Modified Paths:
--------------
    trunk/property/inc/class.uitts.inc.php
    trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
    trunk/property/js/portico/tts.view.js
    trunk/property/templates/base/tts.xsl

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-06-14 09:21:02 UTC (rev 
15282)
+++ trunk/property/inc/class.uitts.inc.php      2016-06-14 09:21:39 UTC (rev 
15283)
@@ -55,7 +55,8 @@
                        'get_b_account' => true,
                        'get_external_project'=> true,
                        'get_unspsc_code'=> true,
-                       'receive_order' => true
+                       'receive_order' => true,
+                       'check_purchase_right'=> true
                );
 
                /**
@@ -1937,36 +1938,7 @@
 
                                $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)
-                               {
-                                       $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
-                                       if (isset($prefs['email']) && 
$prefs['email'])
-                                       {
-                                               $supervisor_email[] = array
-                                                       (
-                                                       'id' => $supervisor_id,
-                                                       'address' => 
$prefs['email'],
-                                               );
-                                       }
-
-                                       if (isset($prefs['approval_from']) && 
$prefs['approval_from'])
-                                       {
-                                               $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
-
-                                               if (isset($prefs2['email']) && 
$prefs2['email'])
-                                               {
-                                                       $supervisor_email[] = 
array
-                                                               (
-                                                               'id' => 
$prefs['approval_from'],
-                                                               'address' => 
$prefs2['email'],
-                                                       );
-                                                       $supervisor_email = 
array_reverse($supervisor_email);
-                                               }
-                                               unset($prefs2);
-                                       }
-                                       unset($prefs);
-                               }
+                               $supervisor_email = 
$this->get_supervisor_email($supervisor_id,  $need_approval);
                                // approval                                     
                        }
 
@@ -2885,6 +2857,111 @@
                        return $this->bocommon->get_vendor_contract($vendor_id, 
$selected);
                }
 
+
+               public function check_purchase_right()
+               {
+                       $config         = CreateObject('admin.soconfig', 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket'));
+                       $check_external_register= 
!!$config->config_data['external_register']['check_external_register'];
+                       $id =  phpgw::get_var('ecodimb');
+
+                       if($check_external_register && $id)
+                       {
+                               $url            = 
$config->config_data['external_register']['url'];
+                               $username       = 
$config->config_data['external_register']['username'];
+                               $password       = 
$config->config_data['external_register']['password'];
+                               $sub_check = 'objekt';
+                               return $this->check_external_register(array(
+                                       'url'           => $url,
+                                       'username'      => $username,
+                                       'password'      => $password,
+                                       'sub_check'     => $sub_check,
+                                       'id'            => $id
+                                       )
+                               );
+                       }
+                       else
+                       {
+                               $supervisor_id = 
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
+                               return 
$this->get_supervisor_email($supervisor_id);
+                       }
+               }
+
+               public function check_external_register($param)
+               {
+                       $id = 1101;//$param['id'];
+       //              $url = 
"http://tjenester.usrv.ubergenkom.no/api/tilskudd/{$sub_check}";;
+                       $url = "{$param['url']}/{$param['sub_check']}";
+                       $extravars = array
+                       (
+                               'id'            => $id,
+                       );
+
+                       $url .= '?' . http_build_query($extravars, null, '&');
+
+                       $post_data = array();
+
+                       $ch = curl_init();
+       //              curl_setopt($ch, CURLOPT_PROXY, $proxy);
+                       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
+                       curl_setopt($ch, CURLOPT_URL, $url);
+                       curl_setopt($ch, CURLOPT_USERPWD, 
"{$param['username']}:{$param['password']}");
+                       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+                       // Set The Response Format to Json
+                       curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
'Content-Type: application/json'));
+                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+                       //set data to be posted
+                       if($post_data)
+                       {
+                               $post_items = array();
+                               foreach ( $post_data as $key => $value)
+                               {
+                                       $post_items[] = "{$key}={$value}";
+                               }
+                               curl_setopt($ch, CURLOPT_POSTFIELDS, implode 
('&', $post_items));
+                       }
+
+                       $result = curl_exec($ch);
+
+                       $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+                       curl_close($ch);
+
+                       return $result;
+               }
+
+               protected function get_supervisor_email($supervisor_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)
+                       {
+                               $prefs = 
$this->bocommon->create_preferences('property', $supervisor_id);
+                               if (isset($prefs['email']) && $prefs['email'])
+                               {
+                                       $supervisor_email[] = array(
+                                               'id' => $supervisor_id,
+                                               'address' => $prefs['email'],
+                                       );
+                               }
+
+                               if (isset($prefs['approval_from']) && 
$prefs['approval_from'])
+                               {
+                                       $prefs2 = 
$this->bocommon->create_preferences('property', $prefs['approval_from']);
+
+                                       if (isset($prefs2['email']) && 
$prefs2['email'])
+                                       {
+                                               $supervisor_email[] = array(
+                                                       'id' => 
$prefs['approval_from'],
+                                                       'address' => 
$prefs2['email'],
+                                               );
+                                               $supervisor_email = 
array_reverse($supervisor_email);
+                                       }
+                                       unset($prefs2);
+                               }
+                               unset($prefs);
+                       }
+                       return $supervisor_email;
+               }
+
                /**
                 * Gets vendor canidated to be used as vendor - called as ajax 
from edit form
                 *

Modified: trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
===================================================================
--- trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php      
2016-06-14 09:21:02 UTC (rev 15282)
+++ trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php      
2016-06-14 09:21:39 UTC (rev 15283)
@@ -94,6 +94,9 @@
 
                        $DetailInfo = array();
                        $DetailInfo[] = array(
+                               'TaxCode' => $param['tax_code'] // Moms kode
+                       );
+                       $DetailInfo[] = array(
                                'ReferenceCode' => array(
                                        'Code' => 'A0',
                                        'Value' => $param['dim0'] // Art
@@ -135,13 +138,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)
@@ -154,6 +158,8 @@
                                        'BuyerProductDescr' => $line['descr'], 
//'Kopipapir',
                                        'UnitCode' => 'STK',
                                        'Quantity' => 100,
+                                       'Price' =>'',
+                                       'Linetotal'=> '',
                                        'DetailInfo' => $DetailInfo
                                );
 
@@ -163,7 +169,7 @@
 
                        $Orders['Order'][] = array(
                                'OrderNo' => $param['order_id'],
-                               'VoucherType' => 'IV',
+                               'VoucherType' => 'P3',
                                'TransType' => 41,
                                'Header' => array($Header),
                                'Details' => array('Detail' => $Detail)

Modified: trunk/property/js/portico/tts.view.js
===================================================================
--- trunk/property/js/portico/tts.view.js       2016-06-14 09:21:02 UTC (rev 
15282)
+++ trunk/property/js/portico/tts.view.js       2016-06-14 09:21:39 UTC (rev 
15283)
@@ -186,7 +186,7 @@
 
        if ($("#vendor_id").val() != vendor_id)
        {
-               var oArgs = {menuaction: 
'property.uitts.get_vendor_contract',vendor_id:$("#vendor_id").val()};
+               var oArgs = {menuaction: 'property.uitts.get_vendor_contract', 
vendor_id: $("#vendor_id").val()};
                var requestUrl = phpGWLink('index.php', oArgs, true);
                var htmlString = "";
 
@@ -204,7 +204,7 @@
                                                return;
                                        }
 
-                                       htmlString = "<option>" + data.length + 
" kontrakter funnet</option>"
+                                       htmlString = "<option>" + data.length + 
" kontrakter funnet</option>";
                                        var obj = data;
 
                                        $.each(obj, function (i)
@@ -288,7 +288,7 @@
        var oArgs = {
                menuaction: 'property.uitts.receive_order',
                id: order_id,
-               received_percent:$( "#slider-range-min" ).slider( "value" )
+               received_percent: $("#slider-range-min").slider("value")
        };
        var strURL = phpGWLink('index.php', oArgs, true);
        $.ajax({
@@ -321,16 +321,88 @@
        });
 }
 
-  $(function() {
-    $( "#slider-range-min" ).slider({
-      range: "min",
-      value: $( "#value_order_received_percent" ).val() || 0,
-      min: 0,
-      max: 100,
-      step: 10,
-      slide: function( event, ui ) {
-        $( "#order_received_percent" ).val( ui.value + " %");
-      }
-    });
-    $( "#order_received_percent" ).val( $( "#slider-range-min" ).slider( 
"value" )  + " %");
-  });
+$(function ()
+{
+       $("#slider-range-min").slider({
+               range: "min",
+               value: $("#value_order_received_percent").val() || 0,
+               min: 0,
+               max: 100,
+               step: 10,
+               slide: function (event, ui)
+               {
+                       $("#order_received_percent").val(ui.value + " %");
+               }
+       });
+       $("#order_received_percent").val($("#slider-range-min").slider("value") 
+ " %");
+});
+
+var ecodimb_selection = "";
+
+$(window).load(function ()
+{
+       ecodimb = $('#ecodimb').val();
+       var selection = [];
+       if (ecodimb)
+       {
+               populateTableChkApproval(ecodimb, selection);
+//             populateTableChkRegulations(building_id, 
initialDocumentSelection, resources);
+               ecodimb_selection = ecodimb;
+       }
+       $("#ecodimb_name").on("autocompleteselect", function (event, ui)
+       {
+               var ecodimb = ui.item.value;
+               if (ecodimb != ecodimb_selection)
+               {
+                       populateTableChkApproval(ecodimb, selection);
+               }
+       });
+});
+
+function populateTableChkApproval(ecodimb, selection)
+{
+//     oArgs = {menuaction: 'bookingfrontend.uiresource.index_json', sort: 
'name', filter_building_id: 1, sub_activity_id: $("#field_activity").val()};
+//     var url = phpGWLink('bookingfrontend/', oArgs, true);
+//     var container = 'approval_container';
+//     var colDefs = [
+//             {label: '', object: [{type: 'input', attrs: [
+//                                             {name: 'type', value: 
'checkbox'}, {name: 'name', value: 'values[approval][]'}, {name: 'class', 
value: 'chkRegulations'}
+//                                     ]}
+//                     ], value: 'id', checked: selection},
+//             {key: 'name', label: lang['Name']},
+//             {key: 'type', label: lang['Address']}
+//     ];
+//     createTable(container, url, colDefs, 'results');
+
+       var oArgs = {menuaction: 'property.uitts.check_purchase_right', 
ecodimb: ecodimb};
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+       var htmlString = "";
+
+       $.ajax({
+               type: 'POST',
+               dataType: 'json',
+               url: requestUrl,
+               success: function (data)
+               {
+                       if (data != null)
+                       {
+                               htmlString = "<table>";
+                               var obj = data;
+
+                               $.each(obj, function (i)
+                               {
+                                       htmlString += "<tr><td>"
+                                       htmlString += "<input type=\"checkbox\" 
name=\"values[approval][" + obj[i].id + "]\" value=\"" + obj[i].address 
+"\"></input>";
+                                       htmlString += "</td><td 
valign=\"top\">";
+                                       htmlString += obj[i].address;
+                                       htmlString += "</td></tr>";
+                               });
+                               htmlString += "</table>";
+
+                               $("#approval_container").html(htmlString);
+                       }
+               }
+       });
+
+}
+;

Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl       2016-06-14 09:21:02 UTC (rev 
15282)
+++ trunk/property/templates/base/tts.xsl       2016-06-14 09:21:39 UTC (rev 
15283)
@@ -282,6 +282,10 @@
                var base_java_url = <xsl:value-of select="base_java_url"/>;
                var location_item_id = '<xsl:value-of 
select="location_item_id"/>';
 
+       //      var initialSelection = <xsl:value-of select="resources_json"/>;
+               var lang = <xsl:value-of select="php:function('js_lang',  
'Name', 'Address')"/>
+
+
        </script>
        <dl>
                <xsl:choose>
@@ -954,34 +958,8 @@
                                                                                
                <label>
                                                                                
                        <xsl:value-of select="php:function('lang', 'ask for 
approval')"/>
                                                                                
                </label>
-
-                                                                               
                <xsl:choose>
-                                                                               
                        <xsl:when test="value_approval_mail_address!=''">
-                                                                               
                                <div class="pure-table pure-u-md-1-2">
-                                                                               
                                        <table>
-                                                                               
                                                <xsl:for-each 
select="value_approval_mail_address">
-                                                                               
                                                        <tr>
-                                                                               
                                                                <td>
-                                                                               
                                                                        <input 
type="checkbox" name="values[approval][{id}]" value="{address}">
-                                                                               
                                                                                
<xsl:attribute name="title">
-                                                                               
                                                                                
        <xsl:value-of select="php:function('lang', 'ask for approval')"/>
-                                                                               
                                                                                
</xsl:attribute>
-                                                                               
                                                                        </input>
-                                                                               
                                                                </td>
-                                                                               
                                                                <td 
valign="top">
-                                                                               
                                                                        
<xsl:value-of select="address"/>
-                                                                               
                                                                </td>
-                                                                               
                                                        </tr>
-                                                                               
                                                </xsl:for-each>
-                                                                               
                                        </table>
-                                                                               
                                </div>
-                                                                               
                        </xsl:when>
-                                                                               
                        <xsl:otherwise>
-                                                                               
                                <b>
-                                                                               
                                        <xsl:value-of 
select="php:function('lang', 'address not defined')"/>
-                                                                               
                                </b>
-                                                                               
                        </xsl:otherwise>
-                                                                               
                </xsl:choose>
+                                                                               
                <div id="approval_container" class="pure-table pure-u-md-1-2">
+                                                                               
                </div>
                                                                                
        </div>
                                                                                
</xsl:when>
                                                                        
</xsl:choose>




reply via email to

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