Changeset 1424167
- Timestamp:
- 05/25/2016 04:38:09 PM (10 years ago)
- Location:
- woocommerce-superfaktura/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
class-wc-superfaktura.php (modified) (15 diffs)
-
wc-superfaktura.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-superfaktura/trunk/README.txt
r1418635 r1424167 5 5 Requires at least: 4.0 6 6 Tested up to: 4.5.2 7 Stable tag: 1.5. 07 Stable tag: 1.5.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 64 64 == 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 65 71 66 72 = 1.5.0 = -
woocommerce-superfaktura/trunk/class-wc-superfaktura.php
r1418635 r1424167 24 24 * @var string 25 25 */ 26 protected $version = '1.5. 0';26 protected $version = '1.5.4'; 27 27 28 28 /** … … 67 67 add_action('admin_init', array($this, 'admin_init')); 68 68 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 69 73 // Load public-facing style sheet and JavaScript. 70 74 //add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); … … 150 154 wp_safe_redirect(admin_url('post.php?post='.$order_id.'&action=edit')); 151 155 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 152 194 } 153 195 } … … 178 220 } 179 221 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 ); 181 223 //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 ); 183 225 } 184 226 … … 241 283 $ic_dph = get_post_meta($order->id, 'billing_company_wi_vat', true); 242 284 $dic = get_post_meta($order->id, 'billing_company_wi_tax', true); 243 $variable = $order->get_order_number();244 285 //$constant = get_option('woocommerce_sf_constant'); 245 286 //$specific = get_option('woocommerce_sf_specific'); … … 289 330 //vsetky polozky su nepovinne, v pripade ze nie su uvedene, budu doplnene automaticky 290 331 // 'name' => 'nazov faktury', 291 'variable' => $variable, //variabilný symbol332 // 'variable' => $variable, //variabilný symbol 292 333 // 'constant' => $constant, //konštantný symbol 293 334 // 'specific' => $specific, //specificky symbol … … 307 348 ); 308 349 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 309 355 if ( $order->get_total_discount() ) 310 356 { … … 405 451 'unit' => '', 406 452 '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), 408 454 )); 409 455 } … … 485 531 else 486 532 { 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) : ''; 488 534 489 535 $api->setInvoice(array( … … 665 711 array( 666 712 '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]'), 668 714 'id' => 'woocommerce_sf_invoice_regular_id', 669 715 'default' => '[YEAR][MONTH][COUNT]', … … 672 718 array( 673 719 '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]'), 675 721 'id' => 'woocommerce_sf_invoice_proforma_id', 676 722 'default' => 'ZAL[YEAR][MONTH][COUNT]', … … 752 798 'desc' => '', 753 799 '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 ), 754 810 ), 755 811 array( … … 1034 1090 } 1035 1091 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 1038 1096 $invoice_id = get_post_meta($order_id, 'wc_sf_invoice_'.$key.'_id', true); 1039 1097 if(!empty($invoice_id)) … … 1053 1111 1054 1112 $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 ) ); 1063 1121 1064 1122 update_post_meta($order_id, 'wc_sf_invoice_'.$key.'_id', $invoice_id); … … 1079 1137 } 1080 1138 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 } 1088 1159 } 1089 1160 -
woocommerce-superfaktura/trunk/wc-superfaktura.php
r1418635 r1424167 11 11 * Plugin URI: http://www.platobnebrany.sk/ 12 12 * 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. 013 * Version: 1.5.4 14 14 * Author: Webikon (Ján Bočínec) 15 15 * Author URI: http://www.webikon.sk
Note: See TracChangeset
for help on using the changeset viewer.