Changeset 3199525
- Timestamp:
- 11/29/2024 03:17:05 PM (16 months ago)
- Location:
- wc-yabi/trunk
- Files:
-
- 6 edited
-
content/product-invoice.php (modified) (2 diffs)
-
content/product.php (modified) (1 diff)
-
includes/ajax.php (modified) (2 diffs)
-
includes/transaction.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
wc-yabi.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wc-yabi/trunk/content/product-invoice.php
r3121708 r3199525 3 3 { 4 4 text-align: right; 5 } 6 .reenviar 7 { 8 display: none; 5 9 } 6 10 </style> … … 134 138 </td> 135 139 </tr> 140 141 <tr> 142 <th></th> 143 <td> 144 <button class="button" id="yabi-reenviar" name="reenviar">Reenviar factura</button> 145 </td> 146 </tr> 147 148 <tr class="reenviar"> 149 <th>Nombre</th> 150 <td> 151 <input class="regular-text" type="text" id="yabi-nombre" name="nombre" value="" /> 152 </td> 153 </tr> 154 155 <tr class="reenviar"> 156 <th>Correo electrónico</th> 157 <td> 158 <input class="regular-text" type="email" id="yabi-email" name="email" value="" /> 159 </td> 160 </tr> 161 162 <tr class="reenviar"> 163 <th></th> 164 <td> 165 <button class="button button-primary" id="yabi-enviar" name="enviar">Enviar</button> 166 167 <div id="thespiner" class="spinner" style="float:none;width:auto;height:auto;padding:10px 0 10px 30px;background-position:0;"></div> 168 169 </td> 170 </tr> 136 171 137 172 </table> 173 174 <div id="response"></div> 175 176 <script type="application/javascript"> 177 178 jQuery( document ).ready(function(){ 179 180 jQuery( '#yabi-reenviar' ).on( 'click', function(e){ 181 182 e.preventDefault(); 183 184 jQuery( '.reenviar' ).toggle( 200 ); 185 186 } ); 187 188 jQuery( '#yabi-enviar' ).on( 'click', function(e){ 189 190 e.preventDefault(); 191 192 yabiSend(); 193 194 } ); 195 196 }); 197 198 function yabiMessage( type, message, show ) 199 { 200 jQuery( '#thespiner' ).removeClass( 'is-active' ); 201 jQuery( '#response' ).html( '<div class="notice notice-'+ type +' inline"><p>'+ message +'</p></div>' ); 202 203 if( show ) 204 { 205 jQuery( '#yabi-enviar' ).attr( 'disabled', false ); 206 } 207 } 208 209 function yabiSend() 210 { 211 jQuery( '#thespiner' ).addClass( 'is-active' ); 212 jQuery( '#response' ).empty(); 213 jQuery( '#yabi-enviar' ).attr( 'disabled', true ); 214 215 const post_id = jQuery( '#post_ID' ).val(); 216 const name = jQuery( '#yabi-nombre' ).val(); 217 const email = jQuery( '#yabi-email' ).val(); 218 219 jQuery.post( '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', { 'action': 'yabi_send_invoice', 'post_id': post_id, 'nombre': name, 'email': email } ) 220 .done(function( data ) { 221 console.log( data ); 222 if( 'FAIL' == data ) 223 { 224 yabiMessage( 'error', 'Saved data!. Unexpected error on invoice, try again later.!', true ); 225 } 226 else 227 { 228 var obj = JSON.parse( data ); 229 230 if( parseInt( obj.error ) == 1 ) 231 { 232 yabiMessage( 'error', obj.message, true ); 233 } 234 else 235 { 236 yabiMessage( 'success', obj.message, false ); 237 } 238 } 239 }); 240 } 241 242 </script> -
wc-yabi/trunk/content/product.php
r3130228 r3199525 254 254 <input id="button-yabi-2" class="button-primary" type="button" name="submit" value="<?php echo __( 'Save & Generate','yabi-wc' ); ?>" onClick="yabiSave(1)" /> 255 255 256 <div id="thespiner" class="spinner" style="float:none;width:auto;height:auto;padding:10px 0 10px 257 30px;background-position:0;"></div> 256 <div id="thespiner" class="spinner" style="float:none;width:auto;height:auto;padding:10px 0 10px 30px;background-position:0;"></div> 258 257 </td> 259 258 </tr> -
wc-yabi/trunk/includes/ajax.php
r3121708 r3199525 3 3 add_action( 'wp_ajax_yabi_generate_invoice', 'yabi_generate_invoice' ); 4 4 add_action( 'wp_ajax_yabi_save_data', 'yabi_save_data' ); 5 5 add_action( 'wp_ajax_yabi_send_invoice', 'yabi_send_invoice' ); 6 6 7 7 function yabi_generate_invoice() … … 75 75 wp_die(); 76 76 } 77 78 function yabi_send_invoice() 79 { 80 $response = 'FAIL'; 81 82 if( isset( $_POST[ 'post_id' ] ) && isset( $_POST[ 'nombre' ] ) && isset( $_POST[ 'email' ] ) ) 83 { 84 $post_id = sanitize_key( $_POST[ 'post_id' ] ); 85 $nombre = sanitize_text_field( $_POST[ 'nombre' ] ); 86 $email = sanitize_text_field( $_POST[ 'email' ] ); 87 88 $response = yabi_send_email( $post_id, $email, $name ); 89 } 90 91 echo $response; 92 93 wp_die(); 94 } -
wc-yabi/trunk/includes/transaction.php
r3121708 r3199525 888 888 } 889 889 } 890 891 function yabi_send_email( $post_id, $email, $name ) 892 { 893 $graphQL = yabi_send_email_graph( $post_id, $email, $name ); 894 895 $response = yabi_send_data( $graphQL ); 896 897 if( !empty( $response ) ) 898 { 899 if( isset( $response[ 'errors' ] ) ) 900 { 901 $response = json_encode( array( 'error' => 1, 'message' => $response[ 'errors' ][ 0 ][ 'message' ] ) ); 902 } 903 else 904 { 905 $response = json_encode( array( 'error' => 0, 'message' => 'Reenviada factura!' ) ); 906 } 907 } 908 909 return $response; 910 } 911 912 913 function yabi_send_email_graph( $post_id, $email, $name ) 914 { 915 $yabi_settings = get_option( 'yabi_settings' ); 916 $businessUnitUuid = $yabi_settings[ 'businessunituuid' ]; 917 918 $yabi_invoice = get_post_meta( $post_id, 'yabi_invoice', true ); 919 920 $toothers = ''; 921 922 if( !empty( $email ) && !empty( $name ) ) 923 { 924 $toothers = 'toOtherRecipients: [ 925 { 926 email:"'. $email .'" 927 name:"'. $name .'" 928 } 929 ]'; 930 } 931 932 $graphQL = 'mutation { 933 resendDocumentEmail( 934 email: { 935 documentType: INVOICE 936 documentUid: "'. $yabi_invoice[ 'serial' ] .'" 937 organizationalUnitId: "'. $businessUnitUuid .'" 938 toRegisteredRecipient: true 939 '. $toothers .' 940 } 941 ) { 942 email { 943 to { 944 name 945 email 946 } 947 bcc{ 948 name 949 email 950 } 951 notificationStatus { 952 code 953 description 954 } 955 transactions { 956 application 957 applicationResponse 958 documentId 959 insertedAt 960 requestedAt 961 respondedAt 962 transactionChannel 963 transactionFrom 964 transactionId 965 transactionStage 966 transactionStatus { 967 message 968 title 969 warningsAndErrors 970 } 971 transactionTo 972 transactionType 973 updatedAt 974 } 975 documentType 976 documentUid 977 } 978 errors { 979 helpText 980 id 981 language 982 message 983 subType 984 title 985 type 986 } 987 warnings { 988 helpText 989 id 990 language 991 message 992 subType 993 title 994 type 995 } 996 notifications { 997 helpText 998 id 999 language 1000 message 1001 subType 1002 title 1003 type 1004 } 1005 } 1006 }'; 1007 1008 return $graphQL; 1009 } -
wc-yabi/trunk/readme.txt
r3161538 r3199525 73 73 74 74 == Changelog == 75 = 1.0.0 = 76 * Initial release 77 = 1.1.0 = 78 * Fixed problem with decimal numbers in purchases of more than one item 79 = 1.1.1 = 80 * Timeout was increased as Yabi servers started experiencing service delays 75 = 3.1.0 = 76 * Added forward email to registered email or new one of invoice 77 = 3.0.5 = 78 * Added validation to identifier, the field must contain a positive number of at least 5 digits. 79 = 3.0.4 = 80 * Fixed old version display 81 = 3.0.3.1 = 82 * Change required version of PHP 83 = 3.0.3 = 84 * Fixed php warning of undefined array key when first installed 85 = 3.0.2 = 86 * Fixed php warning of undefined array key 87 = 3.0.1 = 88 * Fixed display position of fields and names 89 = 3.0.0 = 90 * New implementation of plugin, now you have access to credit 91 = 2.0.1 = 92 * The field to write the URL of the connection to Yabi was enabled 93 = 2.0.0 = 94 * Update to 2.0 Version of Yabi 95 * Tested in last WP Version 96 = 1.8.0 = 97 * Better error report, database save mutation for debug 98 * Tested in last WP Version 99 = 1.7.0 = 100 * The shipping price is now taken into account in the invoice 101 = 1.6.1 = 102 * Tested in last WP Version 103 = 1.6.0 = 104 * In properties you can configure the account as a natural person or as a company, with the respective change the invoices will be generated depending on the type chosen 105 = 1.5.1 = 106 * Fixed decimal problem on discount coupon 107 = 1.5.0 = 108 * Include observations to the invoice 109 = 1.4.0 = 110 * Discount coupon validation 111 = 1.3.1 = 112 * The taxscheme field was deleted, the field is no longer required 113 = 1.3.0 = 114 * A selection box was created to be able to select the city code 115 * Change default tax level code for natural person 81 116 = 1.2.0 = 82 117 * Update to 1.8 Version of Yabi 83 118 * Change numeric variables to strings 84 = 1.3.0 = 85 * A selection box was created to be able to select the city code 86 * Change default tax level code for natural person 87 = 1.3.1 = 88 * The taxscheme field was deleted, the field is no longer required 89 = 1.4.0 = 90 * Discount coupon validation 91 = 1.5.0 = 92 * Include observations to the invoice 93 = 1.5.1 = 94 * Fixed decimal problem on discount coupon 95 = 1.6.0 = 96 * In properties you can configure the account as a natural person or as a company, with the respective change the invoices will be generated depending on the type chosen 97 = 1.6.1 = 98 * Tested in last WP Version 99 = 1.7.0 = 100 * The shipping price is now taken into account in the invoice 101 = 1.8.0 = 102 * Better error report, database save mutation for debug 103 * Tested in last WP Version 104 = 2.0.0 = 105 * Update to 2.0 Version of Yabi 106 * Tested in last WP Version 107 = 2.0.1 = 108 * The field to write the URL of the connection to Yabi was enabled 109 = 3.0.0 = 110 * New implementation of plugin, now you have access to credit 111 = 3.0.1 = 112 * Fixed display position of fields and names 113 = 3.0.2 = 114 * Fixed php warning of undefined array key 115 = 3.0.3 = 116 * Fixed php warning of undefined array key when first installed 117 = 3.0.3.1 = 118 * Change required version of PHP 119 = 3.0.4 = 120 * Fixed old version display 121 = 3.0.5 = 122 * Add validation to identifier, the field must contain a positive number of at least 5 digits. 119 = 1.1.1 = 120 * Timeout was increased as Yabi servers started experiencing service delays 121 = 1.1.0 = 122 * Fixed problem with decimal numbers in purchases of more than one item 123 = 1.0.0 = 124 * Initial release 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 -
wc-yabi/trunk/wc-yabi.php
r3161538 r3199525 9 9 * Plugin URI: https://mireunion.com/yabi 10 10 * Description: Create your electronic invoices of purchases made in woocommerce with Yabi 11 * Version: 3. 0.511 * Version: 3.1.0 12 12 * Author: Mex Avila 13 13 * Author URI: https://datakun.com/
Note: See TracChangeset
for help on using the changeset viewer.