Plugin Directory

Changeset 1424167


Ignore:
Timestamp:
05/25/2016 04:38:09 PM (10 years ago)
Author:
JohnnyPea
Message:

v1.5.4

Location:
woocommerce-superfaktura/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • woocommerce-superfaktura/trunk/README.txt

    r1418635 r1424167  
    55Requires at least: 4.0
    66Tested up to: 4.5.2
    7 Stable tag: 1.5.0
     7Stable tag: 1.5.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363
    6464== Changelog ==
     65
     66= 1.5.4 =
     67* Pri číslovaní faktúr je teraz možné použiť aj číslo objednávky (ORDER_NUMBER)
     68* Pridaná možnosť určiť si variabilný symbol
     69* Pridaná informácia pre SuperFaktúru o poslaní faktúry emailom
     70* Opravené formátovanie textu v emailoch
    6571
    6672= 1.5.0 =
  • woocommerce-superfaktura/trunk/class-wc-superfaktura.php

    r1418635 r1424167  
    2424     * @var     string
    2525     */
    26     protected $version = '1.5.0';
     26    protected $version = '1.5.4';
    2727
    2828    /**
     
    6767        add_action('admin_init', array($this, 'admin_init'));
    6868
     69        // Register hooks for warnings about problematic configuration
     70        add_action( 'admin_notices', array( __CLASS__, 'order_number_notice_all' ) );
     71        add_action( 'woocommerce_settings_wc_superfaktura', array( __CLASS__, 'order_number_notice' ) );
     72
    6973        // Load public-facing style sheet and JavaScript.
    7074        //add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     
    150154            wp_safe_redirect(admin_url('post.php?post='.$order_id.'&action=edit'));
    151155            die();
     156        }
     157    }
     158
     159    static function order_number_notice_all()
     160    {
     161        // avoid double notice on superfaktura settings tab
     162        if ( isset( $_GET['page'], $_GET['tab'] ) && 'wc-settings' === $_GET['page'] && 'wc_superfaktura' === $_GET['tab'] ) {
     163            return;
     164        }
     165
     166        self::order_number_notice();
     167    }
     168
     169    static function order_number_notice()
     170    {
     171        // display warning if we use custom numbering + [ORDER_NUMBER] variable
     172        // and do not have active plugin Woocommerce Sequential Order Numbers
     173        if ( ! is_admin() || defined('DOING_AJAX') && DOING_AJAX ) {
     174            return;
     175        }
     176
     177        if ( is_plugin_active( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php' ) ) {
     178            return;
     179        }
     180
     181        if ( 'no' === get_option( 'woocommerce_sf_invoice_custom_num' ) ) {
     182            return;
     183        }
     184
     185        $tmpl1 = get_option( 'woocommerce_sf_invoice_regular_id' ) ?: '';
     186        $tmpl2 = get_option( 'woocommerce_sf_invoice_proforma_id' ) ?: '';
     187        if ( false !== strpos( $tmpl1 . $tmpl2, '[ORDER_NUMBER]' ) )
     188        {
     189            ?>
     190            <div class="notice notice-error is-dismissible">
     191            <p><b>Woocommerce SuperFaktúra</b>: <?php printf( __( 'You use variable %1$s in your invoice nr. or proforma invoice nr., but the plugin "%2$s" is not activated. This may cause that your invoice numbers will not be sequential.', 'wc-superfaktura' ), '[ORDER_NUMBER]', 'WooCommerce Sequential Order Numbers' ) ?></p>
     192            </div>
     193            <?php
    152194        }
    153195    }
     
    178220        }
    179221
    180         add_action( 'woocommerce_email_order_meta', array( $this, 'sf_invoice_link' ) );
     222        add_action( 'woocommerce_email_order_meta', array( $this, 'sf_invoice_link' ), 10, 3 );
    181223        //add_action( 'woocommerce_order_status_on-hold_notification', array( 'WC_Email_Customer_Completed_Order', 'trigger' ) );
    182         add_action( 'woocommerce_thankyou', array( $this, 'sf_invoice_link' ), 10 );
     224        add_action( 'woocommerce_thankyou', array( $this, 'sf_invoice_link' ), 10, 3 );
    183225    }
    184226
     
    241283        $ic_dph = get_post_meta($order->id, 'billing_company_wi_vat', true);
    242284        $dic = get_post_meta($order->id, 'billing_company_wi_tax', true);
    243         $variable = $order->get_order_number();
    244285        //$constant = get_option('woocommerce_sf_constant');
    245286        //$specific = get_option('woocommerce_sf_specific');
     
    289330            //vsetky polozky su nepovinne, v pripade ze nie su uvedene, budu doplnene automaticky
    290331            // 'name'                 => 'nazov faktury',
    291             'variable'              => $variable, //variabilný symbol
     332            // 'variable'              => $variable, //variabilný symbol
    292333            // 'constant'             => $constant, //konštantný symbol
    293334            // 'specific'             => $specific, //specificky symbol
     
    307348        );
    308349
     350        if ( 'order_nr' === get_option( 'woocommerce_sf_variable_symbol' ) ) {
     351            $set_invoice_data['variable'] = $order->get_order_number();
     352        }
     353        // else: pole `variable' zostane prazdne a VS bude cislo novej FA (@SF)
     354
    309355        if ( $order->get_total_discount() )
    310356        {
     
    405451                        'unit'        => '',
    406452                        'unit_price'  => $fee['line_total'],
    407                         'tax' => round(($fee['line_tax']/$fee['line_total'])*100), 
     453                        'tax' => round(($fee['line_tax']/$fee['line_total'])*100),
    408454                    ));
    409455            }
     
    485531            else
    486532            {
    487                 $invoice_id = get_option('woocommerce_sf_invoice_custom_num')=='yes' ? $this->generate_invoice_id($order->id,$type) : '';
     533                $invoice_id = get_option('woocommerce_sf_invoice_custom_num')=='yes' ? $this->generate_invoice_id($order,$type) : '';
    488534
    489535                $api->setInvoice(array(
     
    665711            array(
    666712                'title' => __('Invoice Nr.', 'wc-superfaktura'),
    667                 'desc' => sprintf(__('Available Tags: %s'), '[YEAR], [MONTH], [DAY], [COUNT]'),
     713                'desc' => sprintf(__('Available Tags: %s'), '[YEAR], [MONTH], [DAY], [COUNT], [ORDER_NUMBER]'),
    668714                'id' => 'woocommerce_sf_invoice_regular_id',
    669715                'default' => '[YEAR][MONTH][COUNT]',
     
    672718            array(
    673719                'title' => __('Proforma Invoice Nr.', 'wc-superfaktura'),
    674                 'desc' => sprintf(__('Available Tags: %s'), '[YEAR], [MONTH], [DAY], [COUNT]'),
     720                'desc' => sprintf(__('Available Tags: %s'), '[YEAR], [MONTH], [DAY], [COUNT], [ORDER_NUMBER]'),
    675721                'id' => 'woocommerce_sf_invoice_proforma_id',
    676722                'default' => 'ZAL[YEAR][MONTH][COUNT]',
     
    752798                'desc' => '',
    753799                'id' => 'woocommerce_wi_invoice_title3'
     800            ),
     801            array(
     802                'title' => __('Variable symbol', 'wc-superfaktura'),
     803                'id' => 'woocommerce_sf_variable_symbol',
     804                'type' => 'radio',
     805                'default' => 'invoice_nr',
     806                'options' => array(
     807                    'invoice_nr' => __( 'Use invoice number', 'wc-superfaktura' ),
     808                    'order_nr' => __( 'Use order number', 'wc-superfaktura' ),
     809                ),
    754810            ),
    755811            array(
     
    10341090    }
    10351091
    1036     function generate_invoice_id($order_id,$key='regular')
    1037     {
     1092    function generate_invoice_id( $order, $key = 'regular' )
     1093    {
     1094        $order_id = $order->id;
     1095
    10381096        $invoice_id = get_post_meta($order_id, 'wc_sf_invoice_'.$key.'_id', true);
    10391097        if(!empty($invoice_id))
     
    10531111
    10541112        $date = current_time('timestamp');
    1055         $year = date('Y', $date);
    1056         $month = date('m', $date);
    1057         $day = date('d', $date);
    1058 
    1059         $invoice_id = str_replace('[YEAR]', $year, $invoice_id_template);
    1060         $invoice_id = str_replace('[MONTH]', $month, $invoice_id);
    1061         $invoice_id = str_replace('[DAY]', $day, $invoice_id);
    1062         $invoice_id = str_replace('[COUNT]', $count, $invoice_id);
     1113
     1114        $invoice_id = strtr( $invoice_id_template, array(
     1115            '[YEAR]' => date( 'Y', $date ),
     1116            '[MONTH]' => date( 'm', $date ),
     1117            '[DAY]' => date( 'd', $date ),
     1118            '[COUNT]' => $count,
     1119            '[ORDER_NUMBER]' => $order->get_order_number(),
     1120        ) );
    10631121
    10641122        update_post_meta($order_id, 'wc_sf_invoice_'.$key.'_id', $invoice_id);
     
    10791137    }
    10801138
    1081     function sf_invoice_link($order)
    1082     {
    1083         $order_id = is_int($order) ? $order : $order->id;
    1084         if ( $pdf = get_post_meta($order_id,'wc_sf_invoice_regular', true) )
    1085             echo '<h2>Faktúra na stiahnutie: </h2><a href="'.$pdf.'">'.$pdf.'</a>';
    1086         elseif ( $pdf = get_post_meta($order_id,'wc_sf_invoice_proforma', true) )
    1087             echo '<h2>Proforma faktúra na stiahnutie: </h2><a href="'.$pdf.'">'.$pdf.'</a>';
     1139    function sf_invoice_link( $order, $sent_to_admin = false, $plain_text = false )
     1140    {
     1141        $order_id = is_int( $order ) ? $order : $order->id;
     1142        if ( $pdf = get_post_meta( $order_id, 'wc_sf_invoice_regular', true ) ) {
     1143            echo "<h2>Faktúra na stiahnutie:</h2>\n\n"
     1144                . '<a href="' . esc_attr( $pdf ) . '">' . esc_html( $pdf ) . "</a>\n\n";
     1145        }
     1146        elseif ( $pdf = get_post_meta( $order_id, 'wc_sf_invoice_proforma', true ) ) {
     1147            echo "<h2>Proforma faktúra na stiahnutie:</h2>\n\n"
     1148                . '<a href="' . esc_attr( $pdf ) . '">' . esc_html( $pdf ) . "</a>\n\n";
     1149        }
     1150
     1151        if ( ! $sent_to_admin && ! empty( $pdf ) ) {
     1152            $invoice_id = (int) get_post_meta( $order_id, 'wc_sf_internal_id', true );
     1153            try {
     1154                $this->sf_api()->markAsSent( $invoice_id, wc_get_order( $order_id )->billing_email );
     1155            } catch (Exception $e) {
     1156                // do not report anything
     1157            }
     1158        }
    10881159    }
    10891160
  • woocommerce-superfaktura/trunk/wc-superfaktura.php

    r1418635 r1424167  
    1111 * Plugin URI:  http://www.platobnebrany.sk/
    1212 * Description: WooCommerce integrácia služby <a href="http://www.superfaktura.sk/api/">SuperFaktúra.sk</a> Máte s modulom technický problém? Napíšte nám na <a href="mailto:[email protected]">[email protected]</a>
    13  * Version:     1.5.0
     13 * Version:     1.5.4
    1414 * Author:      Webikon (Ján Bočínec)
    1515 * Author URI:  http://www.webikon.sk
Note: See TracChangeset for help on using the changeset viewer.