Changeset 2482785
- Timestamp:
- 02/27/2021 08:12:38 PM (3 years ago)
- Location:
- deliveo/trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
deliveo/trunk/inc/deliveo-api.class.php
r2373889 r2482785 78 78 public function session_start() 79 79 { 80 session_start(); 80 if(!session_id()) { 81 session_start(); 82 } 81 83 } 82 84 } -
deliveo/trunk/inc/deliveo-filter.class.php
r2464819 r2482785 27 27 $deliveo_api = new Deliveo_API(new MAV_IT_Deliveo_Settings()); 28 28 $options = new MAV_IT_Deliveo_Settings(); 29 // var_dump($options);30 29 $shipping_options = $deliveo_api->get_shipping_options(); 31 30 … … 49 48 public function add_deliveo_columns_header($columns) 50 49 { 51 52 50 $new_columns = array(); 53 51 $index = 0; … … 84 82 $opts = json_decode(get_option('mav_it_deliveo_settings'))->shipping_options; 85 83 echo "<input type='hidden' name='order[" . $post->ID . "][id]' value='" . $post->ID . "'>"; 86 echo '<select data-id="' . $post->ID . '" style="max-width:100%" name="order[' . $post->ID . '][option]" title=" Válasszon szállítási módot">';84 echo '<select data-id="' . $post->ID . '" style="max-width:100%" name="order[' . $post->ID . '][option]" title="">'; 87 85 foreach ($opts as $option) { 88 86 if ($deliveo_api->api_settings_obj->deliveo_settings["delivery"] == $option->value) { … … 107 105 if ($column == 'packaging_unit') { 108 106 $exported = get_metadata('post', $post->ID, '_deliveo_exported', true); 109 107 110 108 $packaking_unit = json_decode(get_option('mav_it_deliveo_settings'))->packaging_unit; 111 109 if ($exported != 'true') { … … 131 129 public function not_exported_products_filter($post_type) 132 130 { 133 if (isset($_GET['post_type'])) { 134 $post_type = $_GET['post_type']; 135 } 131 $post_type = Deliveo_Request_Filter::getInstance() 132 ->getPostType(INPUT_GET, 'post_type'); 136 133 137 134 $selected_1 = ''; 138 135 $selected_2 = ''; 139 136 140 if (isset($_GET['deliveo_exported'])) { 141 switch ($_GET['deliveo_exported']) { 137 $deliveoExported = Deliveo_Request_Filter::getInstance() 138 ->getDeliveoExported(INPUT_GET, 'deliveo_exported'); 139 if ($deliveoExported !== null) { 140 switch ($deliveoExported) { 142 141 case 'not_exported': 143 142 $selected_1 = 'selected'; … … 165 164 $meta_key_query = array(); 166 165 167 if ($query->is_admin && $pagenow == 'edit.php' && isset($_GET['deliveo_exported']) && $_GET['deliveo_exported'] != '' && $_GET['post_type'] == 'shop_order') { 168 switch ($_GET['deliveo_exported']) { 166 $postType = Deliveo_Request_Filter::getInstance() 167 ->getPostType(INPUT_GET, 'post_type'); 168 $deliveoExported = Deliveo_Request_Filter::getInstance() 169 ->getDeliveoExported(INPUT_GET, 'deliveo_exported'); 170 171 if ($query->is_admin && $pagenow == 'edit.php' && $deliveoExported !== null && $postType == 'shop_order') { 172 switch ($deliveoExported) { 169 173 case 'not_exported': 170 174 $query_filters = array( … … 195 199 global $post_type; 196 200 197 if ($_GET['post_type'] == 'shop_order') { 198 ?> 201 $postType = Deliveo_Request_Filter::getInstance() 202 ->getPostType(INPUT_GET, 'post_type'); 203 204 if ($postType == 'shop_order') { 205 ?> 199 206 <script type="text/javascript"> 200 jQuery(document).ready(function () {201 jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_send'> Deliveo API feladás</option>");202 jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_export'> Deliveo API export</option>");207 jQuery(document).ready(function() { 208 jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_send'></option>"); 209 jQuery('select[name="action"]').append("<option style='font-weight:bold;' value='deliveo_export'></option>"); 203 210 }); 204 211 </script> 205 <?php 206 } 207 } 212 <?php 213 } 214 } 215 208 216 function custom_bulk_action() 209 217 { … … 221 229 $failed = 0; 222 230 $failed_message = []; 223 foreach ($_GET['order'] as $order) { 224 if (in_array($order['id'], $_GET['post'])) { 225 $send = $deliveo->send_by_api((int) $order['id'], $order['option'], $order['unit']); 231 232 $orderArray = Deliveo_Request_Filter::getInstance() 233 ->getOrderArray(INPUT_GET, 'order'); 234 $postArray = Deliveo_Request_Filter::getInstance() 235 ->getIntegerArray(INPUT_GET, 'post'); 236 237 foreach ($orderArray as $order) { 238 if (in_array($order['id'], $postArray)) { 239 $send = $deliveo->send_by_api((int)$order['id'], $order['option'], $order['unit']); 226 240 227 241 if ($send->type == "success") { … … 230 244 if ($send->type == "warning") { 231 245 $failed++; 232 $failed_message[] = 'Rendelés ID: ' . $order['id'] . ' - ' . $send->msg . ": " . ($send->field ?? '');246 $failed_message[] = : ' . $order['id'] . ' - ' . $send->msg . ": " . ($send->field ?? ''); 233 247 } 234 248 } … … 241 255 ); 242 256 243 // echo "<pre>";244 // var_dump($feedback);245 // die;246 247 257 $sendback = add_query_arg($feedback, wp_get_referer()); 248 258 … … 251 261 $deliveo = new MAV_IT_Deliveo(new MAV_IT_Deliveo_Settings()); 252 262 $ids = []; 253 if ($_GET['order']) { 254 255 foreach ($_GET['order'] as $order) { 263 $orderArray = Deliveo_Request_Filter::getInstance() 264 ->getOrderArray(INPUT_GET, 'order'); 265 if (count($orderArray)>0) { 266 267 foreach ($orderArray as $order) { 256 268 $ids[] = $order['id']; 257 269 } -
deliveo/trunk/inc/deliveo-settings.class.php
r2373889 r2482785 3 3 class MAV_IT_Deliveo_Settings 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 5 33 public function __construct() 6 34 { … … 14 42 private function init_deliveo_settings() 15 43 { 16 $init_settings = array( 17 'api_key' => '', 18 'licence_key' => '', 19 'sender' => '', 20 'sender_country_code' => '', 21 'sender_zip' => '', 22 'sender_city' => '', 23 'sender_address' => '', 24 'sender_apartment' => '', 25 'sender_phone' => '', 26 'sender_email' => '', 27 'x' => '', 28 'y' => '', 29 'z' => '', 30 'priority' => '', 31 'saturday' => '', 32 'insurance' => '', 33 'freight' => '', 34 'delivery' => '', 35 'deliveo_settings' => '', 36 'reference_id_is_order_id' => '', 37 'delivered_status' => '', 38 'currency_multiplier' => '', 39 'tracking__id_is_order_id' => '', 40 'shipping_options' => '', 41 'packaging_unit' => '', 42 ); 44 $init_settings = []; 45 foreach (self::$deliveoSettingsKeyList as $key => $value) { 46 $init_settings[$key] = ''; 47 } 43 48 44 49 $init_settings = json_encode($init_settings); … … 115 120 </td> 116 121 <tr> 117 <td colspan="2"><h2> Szállítási paraméterek | <small>Ezekkel a paraméterekkel lesz feladva minden csomag.</small></h2></td>122 <td colspan="2"><h2></h2></td> 118 123 </tr> 119 124 <tr> … … 167 172 </tr> 168 173 <tr> 169 <td colspan="2"><h2> Csomagolási egység</small></h2></td>174 <td colspan="2"><h2></small></h2></td> 170 175 </tr> 171 176 <tr> 172 177 <td>' . __('Csomagok száma', 'mav-it') . '</td> 173 178 <td><select name="packaging_unit"> 174 <option ' . ($settings['packaging_unit'] == 0 ? 'selected' : '') . ' value="0"> Mindig egy</option>175 <option ' . ($settings['packaging_unit'] == 1 ? 'selected' : '') . ' value="1"> Tételenként egy</option>176 <option ' . ($settings['packaging_unit'] == 2 ? 'selected' : '') . ' value="2"> Mindig manuálisan adom meg</option>179 <option ' . ($settings['packaging_unit'] == 0 ? 'selected' : '') . ' value="0"></option> 180 <option ' . ($settings['packaging_unit'] == 1 ? 'selected' : '') . ' value="1"></option> 181 <option ' . ($settings['packaging_unit'] == 2 ? 'selected' : '') . ' value="2"></option> 177 182 </select> 178 183 </td> 179 184 </tr> 180 185 <tr> 181 <td colspan="2"><h2> Szállítási mód</small></h2></td>186 <td colspan="2"><h2></small></h2></td> 182 187 </tr> 183 188 <tr> … … 235 240 public function save_deliveo_settings() 236 241 { 237 if (isset($_POST['deliveo_settings'])) { 242 $deliveoSettings = Deliveo_Request_Filter::getInstance() 243 ->getDeliveoSettings(INPUT_POST, 'deliveo_settings'); 244 245 if ($deliveoSettings !== null) { 238 246 $deliveo_api = new Deliveo_API(new MAV_IT_Deliveo_Settings()); 239 247 $shipping_options = $deliveo_api->get_shipping_options(); 240 $ _POST['shipping_options'] = $shipping_options;241 242 $settings = json_encode($ _POST);248 $['shipping_options'] = $shipping_options; 249 250 $settings = json_encode($); 243 251 update_option('mav_it_deliveo_settings', $settings); 244 252 } 245 253 246 if (isset($_POST['action']) && $_POST['action'] == 'save_api_key_and_licence') { 254 $action = Deliveo_Request_Filter::getInstance() 255 ->filterBasicCode(INPUT_POST, 'action'); 256 257 if ($action !== null && $action == 'save_api_key_and_licence') { 247 258 $settings = $this->get_deliveo_settings(); 248 259 249 $settings['api_key'] = $_POST['api_key']; 250 $settings['licence_key'] = $_POST['licence_key']; 260 $settings['api_key'] = Deliveo_Request_Filter::getInstance() 261 ->filterBasicCode(INPUT_POST, 'api_key'); 262 $settings['licence_key'] = Deliveo_Request_Filter::getInstance() 263 ->filterBasicCode(INPUT_POST, 'licence_key'); 251 264 252 265 $this->admin_notice__success(); -
deliveo/trunk/inc/mav-it-deliveo.class.php
r2464819 r2482785 23 23 24 24 add_action('admin_notices', array($this, 'deliveo_success_msg')); 25 26 27 28 29 30 31 32 25 33 } 26 34 … … 74 82 } 75 83 76 if (isset($_GET['order'])) { 84 $orderArray = Deliveo_Request_Filter::getInstance() 85 ->getOrderArray(INPUT_GET, 'order'); 86 87 if (is_array($orderArray) && count($orderArray) > 0) { 77 88 $order_id = $orderID; 78 89 … … 112 123 "weight" => $weight ?: 1, 113 124 "item_no" => $sku ?: '', 114 // "item_no" => '',115 116 125 ); 117 126 } … … 182 191 public function deliveo_success_msg() 183 192 { 184 if (isset($_GET['deliveo_ok'])) { 193 $deliveoOk = Deliveo_Request_Filter::getInstance() 194 ->getFilteredVar(INPUT_POST, 'deliveo_ok'); 195 $succeded = Deliveo_Request_Filter::getInstance() 196 ->getFilteredVar(INPUT_GET, 'succeded'); 197 $failed = Deliveo_Request_Filter::getInstance() 198 ->getFilteredVar(INPUT_GET, 'failed'); 199 $failedMessages = Deliveo_Request_Filter::getInstance() 200 ->getFilteredVar(INPUT_GET, 'failed_messages'); 201 $deliveoExportFailed = Deliveo_Request_Filter::getInstance() 202 ->getFilteredVar(INPUT_GET, 'deliveo_export_failed'); 203 204 if ($deliveoOk) { 185 205 echo '<div class="notice notice-success is-dismissible"> 186 <p><strong><h2> Deliveo csomagfeladás befejezve</h2></strong> Sikeres: ' . $_GET['succeded'] . ', sikertelen: ' . $_GET['failed']. '.</p>206 <p><strong><h2> . '.</p> 187 207 </div>'; 188 208 } 189 if ( isset($_GET['failed_messages'])) {190 foreach ($ _GET['failed_messages']as $msg) {209 if () { 210 foreach ($ as $msg) { 191 211 echo '<div class="notice notice-error is-dismissible"> 192 212 <p>' . $msg . '</p> … … 195 215 } 196 216 197 if ( isset($_GET['deliveo_export_failed'])) {217 if () { 198 218 echo '<div class="notice notice-error is-dismissible"> 199 <p><strong><h2> Deliveo Export hiba</h2></strong>Nem sikerült exportálni a rendeléseket. A korábban feladott rendeléseket már nem tölthetjük le!</p>219 <p><strong><h2></p> 200 220 </div>'; 201 221 } … … 228 248 public function init_export_details_for_api($order_id) 229 249 { 230 231 $allSelected = explode(',', $_GET['generate_deliveo_csv']); 250 $generateDeliveoCsv = Deliveo_Request_Filter::getInstance() 251 ->getFilteredVar(INPUT_GET, 'generate_deliveo_csv'); 252 253 $allSelected = explode(',', $generateDeliveoCsv); 232 254 $shipping = ''; 233 255 … … 412 434 public function label_download() 413 435 { 436 437 438 414 439 $settings = $this->deliveo_settings; 415 $label_url = "https://deliveo.nanosoft.hu/api/package/v2/label/" . $ _POST["group_id"]. "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];416 $package_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $ _POST["group_id"]. "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];440 $label_url = "https://deliveo.nanosoft.hu/api/package/v2/label/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"]; 441 $package_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"]; 417 442 418 443 $tmpfile = download_url($label_url, $timeout = 300); 419 444 420 445 $check_signature = json_decode(wp_remote_fopen($package_url), true); 421 if ($check_signature['data'][0]['group_id'] == $ _POST["group_id"]) {422 $permfile = $ _POST['group_id']. '.pdf';423 $destfile = wp_get_upload_dir()['path'] . "/" . $ _POST['group_id']. '.pdf';424 $dest_url = wp_get_upload_dir()['url'] . "/" . $ _POST['group_id']. '.pdf';446 if ($check_signature['data'][0]['group_id'] == $) { 447 $permfile = $ . '.pdf'; 448 $destfile = wp_get_upload_dir()['path'] . "/" . $ . '.pdf'; 449 $dest_url = wp_get_upload_dir()['url'] . "/" . $ . '.pdf'; 425 450 copy($tmpfile, $destfile); 426 451 unlink($tmpfile); 427 452 $package = 428 '<a target="blank" href="' . $dest_url . '"><img title=" Csomagcímke letöltése ehhez a csoportkódhoz: ' . $_POST['group_id']. '" style="vertical-align:middle;height:36px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" ></a>';453 '<a target="blank" href="' . $dest_url . '"><img title=" . '" style="vertical-align:middle;height:36px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" ></a>'; 429 454 echo $package; 430 455 } else { 431 456 $package = 432 '<img title=" Csomagcímke nem található ehhez a csoportkódhoz: ' . $_POST['group_id']. '" style="vertical-align:middle;height:36px;filter:grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" >';457 '<img title=" . '" style="vertical-align:middle;height:36px;filter:grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-package-barcode.png" >'; 433 458 echo $package; 434 459 } … … 438 463 public function view_signature() 439 464 { 465 466 467 440 468 $settings = $this->deliveo_settings; 441 $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $ _POST["group_id"]. "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];469 $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"]; 442 470 443 471 $tmpfile = download_url($signature_url, $timeout = 300); … … 447 475 $response = array( 448 476 "error" => "no_signature", 449 "img" => '<img title=" Nem tartozik aláíráslap ehhez a csoportkódhoz: ' . $_POST['group_id']. '" style="vertical-align:middle;height:24px; filter: grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>',477 "img" => '<img title=" . '" style="vertical-align:middle;height:24px; filter: grayscale(100%);" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>', 450 478 ); 451 479 echo json_encode($response); 452 480 } else { 453 $permfile = $ _POST['group_id']. '_sign.pdf';454 $destfile = wp_get_upload_dir()['path'] . "/" . $ _POST['group_id']. '_sign.pdf';455 $dest_url = wp_get_upload_dir()['url'] . "/" . $ _POST['group_id']. '_sign.pdf';481 $permfile = $. '_sign.pdf'; 482 $destfile = wp_get_upload_dir()['path'] . "/" . $ . '_sign.pdf'; 483 $dest_url = wp_get_upload_dir()['url'] . "/" . $ . '_sign.pdf'; 456 484 copy($tmpfile, $destfile); 457 485 unlink($tmpfile); 458 486 $package = array( 459 487 'url' => $dest_url, 460 'img' => '<a href="' . $dest_url . '" target="blank"><img title=" Aláíráslap letöltése ehhez a csoportkódhoz: ' . $_POST['group_id']. '" style="vertical-align:middle;height:24px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>',488 'img' => '<a href="' . $dest_url . '" target="blank"><img title=" . '" style="vertical-align:middle;height:24px;" src="' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-signature.png" ></a>', 461 489 ); 462 490 echo json_encode($package); … … 467 495 public function view_package_log() 468 496 { 497 498 469 499 $settings = $this->deliveo_settings; 470 $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package_log/" . $ _POST["group_id"]. "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];500 $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package_log/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"]; 471 501 472 502 $package_log = json_decode(wp_remote_fopen($package_log_url), true)['data']; … … 475 505 $row = '<h4>Csomagnapló</h4>'; 476 506 } else { 477 $row = '<h4 style="background-color:red"> A csomagnapló nem található</h4>';507 $row = '<h4 style="background-color:red"></h4>'; 478 508 } 479 509 … … 500 530 public function package_details() 501 531 { 532 533 534 502 535 $settings = $this->deliveo_settings; 503 $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $ _POST["group_id"]. "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];504 // $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $ _POST["group_id"]. "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"];536 $package_log_url = "https://deliveo.nanosoft.hu/api/package/v2/package/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"]; 537 // $signature_url = "https://deliveo.nanosoft.hu/api/package/v2/signature/" . $ . "?licence=" . $settings["licence_key"] . "&api_key=" . $settings["api_key"]; 505 538 506 539 $package_details = json_decode(wp_remote_fopen($package_log_url), true)['data']; 507 540 if ($package_details[0]['dropped_off'] != null) { 508 $delivered = 'Átvette(' . $package_details[0]['dropped_off'] . ')';509 } else { 510 $delivered = 'A csomag átvétele még nem történt meg!';541 $delivered = (' . $package_details[0]['dropped_off'] . ')'; 542 } else { 543 $delivered = ; 511 544 } 512 545 if (isset($package_details[0])) { … … 515 548 echo '<div class="group_info" style="background-image:url(' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-icon.png' . ')">'; 516 549 517 echo '<h4> Címzett</h4>';550 echo '<h4></h4>'; 518 551 echo '<div class="content">[' . $package_details[0]['consignee_zip'] . '] ' . $package_details[0]['consignee_city'] . '</div>'; 519 552 echo '<div class="content">' . $package_details[0]['consignee_address'] . ' ' . $package_details[0]['consignee_apartment'] . '</div>'; … … 524 557 } else { 525 558 echo '<div class="group_info" style="background-image:url(' . MAV_IT_DELIVEO_DIR_URL . 'images/deliveo-icon.png' . ')">'; 526 echo '<h4> A csomag nem található a Deliveo rendszerben!</h4>';559 echo '<h4></h4>'; 527 560 echo '</div>'; 528 561 } -
deliveo/trunk/readme.txt
r2480126 r2482785 1 1 === Deliveo plugin for WordPress === 2 2 3 3 4 Plugin Name: Deliveo 4 5 Description: Deliveo plugin for WordPress … … 9 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 11 Tested up to: 5.6 12 13 14 15 11 16 12 17 == Description == … … 22 27 5. Click *Install Plugin*. 23 28 6. Done. :) 29 30 31 32 33 34 35 36 37 -
deliveo/trunk/wordpress-mav-it-deliveo.php
r2480126 r2482785 11 11 * Text Domain: mav-it 12 12 * Version: 2.2.0 13 13 14 * 14 15 * License: GNU General Public License v3.0 … … 20 21 21 22 include_once __DIR__ . '/inc/helpers.php'; 23 22 24 include_once __DIR__ . '/inc/mav-it-deliveo.class.php'; 23 25 include_once __DIR__ . '/inc/csv-export.class.php'; … … 30 32 } 31 33 34 35 36 37 38 39 32 40 if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { 33 41 define('MAV_IT_DELIVEO_DIR_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset
for help on using the changeset viewer.