fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11862] property: more on autosplit of vouchers based


From: Sigurd Nes
Subject: [Fmsystem-commits] [11862] property: more on autosplit of vouchers based on downloaded templates
Date: Mon, 24 Mar 2014 21:10:11 +0000

Revision: 11862
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11862
Author:   sigurdne
Date:     2014-03-24 21:10:09 +0000 (Mon, 24 Mar 2014)
Log Message:
-----------
property: more on autosplit of vouchers based on downloaded templates

Modified Paths:
--------------
    trunk/property/inc/class.uiinvoice2.inc.php
    trunk/property/js/portico/ajax_invoice.js
    trunk/property/templates/base/invoice.xsl
    trunk/property/templates/base/invoice2.xsl

Modified: trunk/property/inc/class.uiinvoice2.inc.php
===================================================================
--- trunk/property/inc/class.uiinvoice2.inc.php 2014-03-24 17:46:51 UTC (rev 
11861)
+++ trunk/property/inc/class.uiinvoice2.inc.php 2014-03-24 21:10:09 UTC (rev 
11862)
@@ -57,7 +57,8 @@
                        'get_single_line'                                       
=> true,
                        'update_voucher'                                        
=> true,
                        'get_first_line'                                        
=> true,
-                       'get_split_template'                            => true
+                       'get_split_template'                            => true,
+                       'split_voucher'                                         
=> true
                );
 
                function __construct()
@@ -203,8 +204,38 @@
                        
                }
 
-               function split_voucher($voucher_id)
+               function split_voucher()
                {
+                       $GLOBALS['phpgw_info']['flags']['noframework'] =  true;
+                       $voucher_id     = phpgw::get_var('voucher_id', 'int');
+                       if($_FILES)
+                       {
+                               $this->_split_voucher($voucher_id);
+                       }
+
+                       if( $receipt = phpgwapi_cache::session_get('phpgwapi', 
'phpgw_messages'))
+                       {
+                               phpgwapi_cache::session_clear('phpgwapi', 
'phpgw_messages');
+                       }
+
+                       $data = array
+                       (
+                                       'redirect'                              
=> $redirect ? $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uiinvoice.list_sub', 'user_lid' => $user_lid, 'voucher_id' => 
$voucher_id, 'paid' => $paid)) : null,
+                                       'msgbox_data'                   => 
$GLOBALS['phpgw']->common->msgbox($GLOBALS['phpgw']->common->msgbox_data($receipt)),
+                                       'form_action'                   => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction' => 
'property.uiinvoice2.split_voucher', 'voucher_id' => $voucher_id)),
+                                       'voucher_id'                    => 
$voucher_id
+                       );
+
+                       phpgwapi_jquery::load_widget('core');
+                       self::add_javascript('property', 'portico', 
'ajax_invoice.js');
+
+                       $GLOBALS['phpgw']->xslttpl->add_file('invoice');
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('split_voucher' => $data));
+               }
+
+
+               private function _split_voucher($voucher_id)
+               {
                        $error = false;
 
                        $data = array();
@@ -218,7 +249,8 @@
                        }
                        else
                        {
-                               phpgwapi_cache::message_set('Ingen file er 
valgt', 'error');
+                               phpgwapi_cache::message_set('Ingen fil er 
valgt', 'error');
+                               return;
                        }
 
                        switch ($file['type'])
@@ -266,7 +298,7 @@
                        {
                                phpgwapi_cache::message_set(lang('voucher is 
updated'), 'message');
                        }
-
+/*
                        $result =  array
                        (
                                'status'        => $error ? 'error' : 'updated',
@@ -287,6 +319,8 @@
                        {
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uiinvoice2.index', 'voucher_id' => $voucher_id, 
'line_id' => $line_id));
                        }
+ */
+
                }
 
                function update_voucher()
@@ -297,12 +331,6 @@
 
                        if($values = phpgw::get_var('values'))
                        {
-
-                               if($_FILES)
-                               {
-                                       return 
$this->split_voucher($voucher_id);
-                               }
-
                                if($values['order_id'] != 
$values['order_id_orig'])
                                {
                                        return $this->reassign_order($line_id, 
$values['order_id'], $voucher_id);

Modified: trunk/property/js/portico/ajax_invoice.js
===================================================================
--- trunk/property/js/portico/ajax_invoice.js   2014-03-24 17:46:51 UTC (rev 
11861)
+++ trunk/property/js/portico/ajax_invoice.js   2014-03-24 21:10:09 UTC (rev 
11862)
@@ -17,7 +17,7 @@
                update_voucher_filter();
        });
 
-       $("#template").click(function(e){
+       $("#get_template").click(function(e){
                var oArgs_template = 
{menuaction:'property.uiinvoice2.get_split_template', voucher_id: 
$("#voucher_id").val()};
                var requestUrl_template = phpGWLink('index.php', 
oArgs_template);
                window.open(requestUrl_template);
@@ -324,13 +324,18 @@
                                $("#voucher_id").val( voucher[0].voucher_id );
                                if( voucher[0].voucher_out_id )
                                {
-                                       $("#voucher_id_text").html( 
voucher[0].voucher_out_id );
+                                       var     voucher_id_text =  
voucher[0].voucher_out_id;
                                }
                                else
                                {
-                                       $("#voucher_id_text").html( 
voucher[0].voucher_id );
+                                       var     voucher_id_text =  
voucher[0].voucher_id;
                                }
+                               $("#voucher_id_text").html( voucher_id_text );
 
+                               var htmlString_split  =  " <a 
href=\"javascript:load_split(" + voucher[0].voucher_id + ");\" title=\"" +  
voucher_id_text  + "\" > Splitt " + voucher_id_text +"</a>";
+
+                               $("#split_text").html( htmlString_split );
+
                                $("#order_id").val( voucher[0].order_id );
                                $("#order_id_orig").val( voucher[0].order_id );
 
@@ -648,34 +653,51 @@
 function load_order( id ){
        var oArgs = {menuaction: 'property.uiinvoice.view_order', order_id: id, 
nonavbar: true, lean: true};
        var requestUrl = phpGWLink('index.php', oArgs);
+       TINY.box.show({iframe:requestUrl, 
boxid:'frameless',width:750,height:450,fixed:false,maskid:'darkmask',maskopacity:40,
 mask:true, animate:true, close: true,closejs:function(){closeJS_local();}});
+}
 
-       TINY.box.show({iframe:requestUrl, 
boxid:'frameless',width:750,height:450,fixed:false,maskid:'darkmask',maskopacity:40,
 mask:true, animate:true, close: true,closejs:function(){closeJS_local()}});
-//     $("#curtain").show();
-//     $("#popupBox").fadeIn("slow");
-//     var htmlString = "";
-//     htmlString += "<iframe  width=\"100%\" height=\"100%\" src = \"" + 
requestUrl + "\" ><p>Your browser does not support iframes.</p></iframe>";
-//     $("#popupBox").html( htmlString );
+function load_split( voucher_id ){
+       var oArgs = {menuaction: 'property.uiinvoice2.split_voucher', 
voucher_id: voucher_id, nonavbar: true, lean: true};
+       var requestUrl = phpGWLink('index.php', oArgs);
+       TINY.box.show({iframe:requestUrl, 
boxid:'frameless',width:750,height:450,fixed:false,maskid:'darkmask',maskopacity:40,
 mask:true, animate:true, close: 
true,closejs:function(){reset_table(voucher_id);}});
 }
 
+function reset_table(voucher_id)
+{
+       var oArgs = {menuaction:'property.uiinvoice2.get_first_line', 
voucher_id: voucher_id};
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+       var line_id = 0;
+
+       $.ajax({
+               type: 'POST',
+               dataType: 'json',
+               url: requestUrl,
+               success: function(data) {
+                       if( data != null)
+                       {
+                               line_id = data['line_id'];
+                               base_java_url['line_id'] = line_id;
+                               base_java_url['voucher_id_filter'] = voucher_id;
+                               execute_async(myDataTable_0);
+                               update_form_values(line_id, 0);
+                       }
+               }
+               });
+
+}
+
 function closeJS_local()
 {
        var line_id = $("#line_id").val( );
        var voucher_id_orig = $("#voucher_id").val();
        $("#curtain").hide();
        $("#popupBox").hide();
-       update_form_values(line_id, voucher_id_orig)
+       update_form_values(line_id, voucher_id_orig);
 }
 
 function closeJS_remote()
 {
        TINY.box.hide();
-/*
-       var line_id = $("#line_id").val( );
-       var voucher_id_orig = $("#voucher_id").val();
-       $("#curtain").hide();
-       $("#popupBox").hide();
-       update_form_values(line_id, voucher_id_orig)
-*/
 }
 
 function hide_popupBox( ){

Modified: trunk/property/templates/base/invoice.xsl
===================================================================
--- trunk/property/templates/base/invoice.xsl   2014-03-24 17:46:51 UTC (rev 
11861)
+++ trunk/property/templates/base/invoice.xsl   2014-03-24 21:10:09 UTC (rev 
11862)
@@ -25,6 +25,52 @@
                </xsl:choose>
        </xsl:template>
 
+<xsl:template match="split_voucher" xmlns:php="http://php.net/xsl";>
+       <h2>
+               <xsl:value-of select="php:function('lang', 'upload file')"/>
+       </h2>
+       <form action="{form_action}" name="split_voucher_form" 
id="split_voucher_form" method="post" ENCTYPE="multipart/form-data">
+               <br/>
+               <br/>
+               <input type="hidden" name="voucher_id" id="voucher_id" 
value="{voucher_id}"/>
+
+               <table align = "center" valign = "center" width="95%">
+                               <xsl:choose>
+                                       <xsl:when test="msgbox_data != ''">
+                                               <tr>
+                                                       <td align="left" 
colspan="2">
+                                                               
<xsl:call-template name="msgbox"/>
+                                                       </td>
+                                               </tr>
+                                       </xsl:when>
+                               </xsl:choose>
+
+                       <tr>
+                               <td >
+                                       <xsl:variable name="lang_submit">
+                                               <xsl:value-of 
select="php:function('lang', 'upload file')"/>
+                                       </xsl:variable>
+                                       <input type="submit" name="submit" 
value="{$lang_submit}">
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="$lang_submit"/>
+                                               </xsl:attribute>
+                                       </input>
+                               </td>
+                               <td>
+                                       <input type="file" id="file" 
name="file" size="40">
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="php:function('lang', 'Select file to upload')"/>
+                                               </xsl:attribute>
+                                       </input>
+                                       <xsl:variable 
name="lang_template"><xsl:value-of select="php:function('lang', 'template')" 
/></xsl:variable>
+                                       <input type="button" id = 
"get_template" name="get_template" value="{$lang_template}" title = 
"{$lang_template}" />
+                               </td>
+                       </tr>
+               </table>
+       </form>
+
+</xsl:template>
+
        <!-- New template-->
        <xsl:template match="remark">
                <table width="100%" cellpadding="2" cellspacing="2" 
align="center">

Modified: trunk/property/templates/base/invoice2.xsl
===================================================================
--- trunk/property/templates/base/invoice2.xsl  2014-03-24 17:46:51 UTC (rev 
11861)
+++ trunk/property/templates/base/invoice2.xsl  2014-03-24 21:10:09 UTC (rev 
11862)
@@ -113,22 +113,12 @@
                                                                                
<xsl:apply-templates select="datatable"/>
                                                                        </td>
                                                                </tr>
-<!--
                                                                <tr>
                                                                        <td 
valign="top">
-                                                                               
<xsl:value-of select="php:function('lang', 'upload file')"/>
+                                                                               
<div id = 'split_text'>
+                                                                               
</div>
                                                                        </td>
-                                                                       <td>
-                                                                               
<input type="file" id="file" name="file" size="40">
-                                                                               
        <xsl:attribute name="title">
-                                                                               
                <xsl:value-of select="php:function('lang', 'Select file to 
upload')"/>
-                                                                               
        </xsl:attribute>
-                                                                               
</input>
-                                                                               
<xsl:variable name="lang_template"><xsl:value-of select="php:function('lang', 
'template')" /></xsl:variable>
-                                                                               
<input type="button" id = "template" name="template" value="{$lang_template}" 
title = "{$lang_template}" />
-                                                                       </td>
                                                                </tr>
--->
                                                                <tr>
                                                                        <td 
colspan = '6'>
                                                                                
<xsl:variable name="label_submit"><xsl:value-of select="php:function('lang', 
'save')" /></xsl:variable>




reply via email to

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