Changeset 2742574
- Timestamp:
- 06/15/2022 04:22:16 AM (4 years ago)
- Location:
- ourivesweb-api/trunk
- Files:
-
- 5 edited
-
ourivesweb.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
src/Activators/Install.php (modified) (1 diff)
-
src/Plugin.php (modified) (3 diffs)
-
src/Views/settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ourivesweb-api/trunk/ourivesweb.php
r2726965 r2742574 4 4 * Plugin URI: https://wordpress.org/plugins/OurivesWeb-api/ 5 5 * Description: Integração do OurivesWeb com o WooCommerce. 6 * Version: 1.1. 06 * Version: 1.1.1 7 7 * Requires at least: 5.2 8 8 * Requires PHP: 7.3 … … 18 18 if (!defined('ABSPATH')) { 19 19 exit; 20 } 21 22 if (!defined('OURIVES_VERSION')) { 23 define('OURIVES_VERSION', '1.1.1'); 20 24 } 21 25 -
ourivesweb-api/trunk/readme.txt
r2726965 r2742574 3 3 Contributors: ponto25,wesleydeveloper 4 4 Tags: Invoicing, Faturação, Encomendas, Orders 5 Stable tag: 1.1. 05 Stable tag: 1.1.1 6 6 Requires at least: 4.6 7 Tested up to: 5.97 Tested up to: 6.0 8 8 Requires PHP: 7.3 9 9 License: GPLv2 or later … … 63 63 64 64 == Changelog == 65 * Fixed autoload errors 66 * Replaced deprecated functions 67 * Added pvpiva1, pvpiva2, pvpiva3 fields in price selection 68 * Fixed auto sync option 69 * Fixed logout route 65 * Corrigindo bugs e funções depreciadas 66 * Corrigindo função terminar sessão 67 * Adicionando opções IVA nas seleções de preço 68 * Resolvendo problemas de sincronização automática 70 69 71 70 == Upgrade Notice == -
ourivesweb-api/trunk/src/Activators/Install.php
r2726965 r2742574 91 91 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description) VALUES('document_type', 'Escolha o tipo de documentos que deseja emitir')"); 92 92 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description) VALUES('vat_field', 'Número de contribuinte')"); 93 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description,selected) VALUES(' Ourives_stock_sync', 'Sincronizar Stocks','0')");94 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description,selected) VALUES(' Ourives_stock_sync_time', 'Tempo de sincronização automatica dos stocks','21600')");93 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description,selected) VALUES('ourivesweb_stock_sync', 'Sincronizar Stocks','0')"); 94 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description,selected) VALUES('ourivesweb_stock_sync_time', 'Tempo de sincronização automatica dos stocks','21600')"); 95 95 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description) VALUES('OURIVESWEB_ACCESS_TOKEN', 'Token criado no login do utilizador')"); 96 96 $wpdb->query("INSERT INTO `OurivesWeb_api_config`(config, description,selected) VALUES('IMPORT_STATUS', 'Artigos sincronizados são guardados como Rascunho ou publicados','1')"); -
ourivesweb-api/trunk/src/Plugin.php
r2726965 r2742574 22 22 Cat_meta_data::run(); 23 23 $this->crons(); 24 } 25 26 private function crons() 27 { 28 remove_action("woocommerce_update_product", __CLASS__ . '::productUpdated'); 29 add_action('woocommerce_update_product', __CLASS__ . '::productUpdated'); 30 31 add_action('woocommerce_Ourives_Sync_product', 'OurivesWeb\Plugin::syncProductCron'); 32 33 34 if ((!wp_next_scheduled('woocommerce_Ourives_Sync_product'))) { 35 global $wpdb; 36 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'Ourives_stock_sync'"); 37 38 if ($results[0]->selected == 1) { 39 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'Ourives_stock_sync_time'"); 40 41 if (!empty($results)) { 42 $value = $results[0]->selected; 43 } else { 44 $value = 1000; 45 } 46 return wp_schedule_single_event(time() + $value, 'woocommerce_Ourives_Sync_product'); 47 } 48 } 49 50 51 add_action('woocommerce_order_status_changed', '\OurivesWeb\Plugin::autoDoc', 10, 3); 52 } 53 54 public static function defines() 55 { 56 57 if (isset($_REQUEST['page']) && sanitize_text_field($_REQUEST['page']) == 'OurivesWeb') { 58 //Wordpress EnQueue Styles 59 wp_enqueue_style('Bootstrap', plugins_url('assets/Includes/bootstrap.min.css', OURIVES_FILE)); 60 //Wordpress EnQueue JavaScripts 61 wp_enqueue_script('Bootstrap.min.js', plugins_url('assets/Includes/bootstrap.min.js', OURIVES_FILE)); 62 wp_enqueue_script('bootstrap.bundle.min.js', plugins_url('assets/Includes/bootstrap.bundle.min.js', OURIVES_FILE)); 63 } 64 } 65 66 public static function productUpdated($product_id) 67 { 68 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) 69 return; 70 remove_action("woocommerce_update_product", __CLASS__ . "::productUpdated"); 71 update_post_meta(intval($product_id), "date_modified", strtotime("now")); 72 73 add_action('woocommerce_update_product', __CLASS__ . "::productUpdated"); 74 return TRUE; 24 $this->update(); 75 25 } 76 26 … … 173 123 } 174 124 175 private function removeOrder($orderId) 176 { 177 $document = new Documents($orderId); 178 $document->RemoveDocument(); 179 } 180 181 private function createDocument($Soap_Client, $orderId) 182 { 183 $document = new Documents($orderId); 184 $document->createDocument(); 185 186 if ($document->document_id) { 187 $document = Documents::showDocument($Soap_Client, $orderId, "Documento gerado!", "success"); 188 $viewUrl = ' <a href="' . admin_url('admin.php?page=OurivesWeb&action=getInvoice&id=' . $document->document_id) . '" target="_BLANK">Ver documento</a>'; 189 add_settings_error('OurivesWeb', 'OurivesWeb-document-created-success', 'O documento foi gerado!' . $viewUrl, 'updated'); 190 } 191 192 return $document; 125 public static function defines() 126 { 127 128 if (isset($_REQUEST['page']) && sanitize_text_field($_REQUEST['page']) == 'OurivesWeb') { 129 //Wordpress EnQueue Styles 130 wp_enqueue_style('Bootstrap', plugins_url('assets/Includes/bootstrap.min.css', OURIVES_FILE)); 131 //Wordpress EnQueue JavaScripts 132 wp_enqueue_script('Bootstrap.min.js', plugins_url('assets/Includes/bootstrap.min.js', OURIVES_FILE)); 133 wp_enqueue_script('bootstrap.bundle.min.js', plugins_url('assets/Includes/bootstrap.bundle.min.js', OURIVES_FILE)); 134 } 135 } 136 137 public static function productUpdated($product_id) 138 { 139 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) 140 return; 141 remove_action("woocommerce_update_product", __CLASS__ . "::productUpdated"); 142 update_post_meta(intval($product_id), "date_modified", strtotime("now")); 143 144 add_action('woocommerce_update_product', __CLASS__ . "::productUpdated"); 145 return TRUE; 193 146 } 194 147 … … 209 162 (new Product())->Update_OurivesWeb_ToWC(); 210 163 } 164 165 private function crons() 166 { 167 remove_action("woocommerce_update_product", __CLASS__ . '::productUpdated'); 168 add_action('woocommerce_update_product', __CLASS__ . '::productUpdated'); 169 170 add_action('woocommerce_Ourives_Sync_product', 'OurivesWeb\Plugin::syncProductCron'); 171 172 173 if ((!wp_next_scheduled('woocommerce_Ourives_Sync_product'))) { 174 global $wpdb; 175 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync'"); 176 177 if ($results[0]->selected == 1) { 178 $results = $wpdb->get_results("SELECT selected FROM OurivesWeb_api_config WHERE config = 'ourivesweb_stock_sync_time'"); 179 180 if (!empty($results)) { 181 $value = $results[0]->selected; 182 } else { 183 $value = 1000; 184 } 185 return wp_schedule_single_event(time() + $value, 'woocommerce_Ourives_Sync_product'); 186 } 187 } 188 189 190 add_action('woocommerce_order_status_changed', '\OurivesWeb\Plugin::autoDoc', 10, 3); 191 } 192 193 private function removeOrder($orderId) 194 { 195 $document = new Documents($orderId); 196 $document->RemoveDocument(); 197 } 198 199 private function createDocument($Soap_Client, $orderId) 200 { 201 $document = new Documents($orderId); 202 $document->createDocument(); 203 204 if ($document->document_id) { 205 $document = Documents::showDocument($Soap_Client, $orderId, "Documento gerado!", "success"); 206 $viewUrl = ' <a href="' . admin_url('admin.php?page=OurivesWeb&action=getInvoice&id=' . $document->document_id) . '" target="_BLANK">Ver documento</a>'; 207 add_settings_error('OurivesWeb', 'OurivesWeb-document-created-success', 'O documento foi gerado!' . $viewUrl, 'updated'); 208 } 209 210 return $document; 211 } 212 213 private function update(){ 214 if(OURIVES_VERSION === '1.1.1') { 215 global $wpdb; 216 $wpdb->query("UPDATE OurivesWeb_api_config SET config='ourivesweb_stock_sync' WHERE config = 'Ourives_stock_sync'"); 217 $wpdb->query("UPDATE OurivesWeb_api_config SET config='ourivesweb_stock_sync_time' WHERE config = 'Ourives_stock_sync_time'"); 218 } 219 } 220 211 221 } -
ourivesweb-api/trunk/src/Views/settings.php
r2726965 r2742574 352 352 </div> 353 353 <h3 class="border rounded text-center p-3 mb-3 ">Sincronização Automática</h3> 354 <div class="d-block my-3" id="ourivesweb_stock_sync" name='opt[ourivesweb_stock_sync]'>354 <div class="d-block my-3" id="ourivesweb_stock_sync"> 355 355 356 356 <label class="btn btn-primary btn-block"> 357 357 <?php 358 if (defined(' PLUGIN_STOCK_SYNC') && PLUGIN_STOCK_SYNC == "1") {358 if (defined('OURIVESWEB_STOCK_SYNC') && OURIVESWEB_STOCK_SYNC == "1") { 359 359 $ifselectedAuto = "checked"; 360 360 $ifselected = ""; … … 415 415 </style> 416 416 417 <div class="d-block my-3" id="ourivesweb_stock_sync_time" name='opt[ourivesweb_stock_sync_time]'>417 <div class="d-block my-3" id="ourivesweb_stock_sync_time"> 418 418 419 419 <label class="slidecontainer">
Note: See TracChangeset
for help on using the changeset viewer.