Changeset 3205693
- Timestamp:
- 12/10/2024 01:51:39 PM (16 months ago)
- Location:
- eshoplogisticru/trunk
- Files:
-
- 12 edited
-
Http/Controllers/OptionsController.php (modified) (1 diff)
-
Modules/Ajax.php (modified) (3 diffs)
-
Modules/AssetsLoader.php (modified) (2 diffs)
-
Modules/OptionsPage.php (modified) (1 diff)
-
Modules/Unloading.php (modified) (2 diffs)
-
assets/css/admin.css (modified) (2 diffs)
-
assets/js/checkout_frame_v2.js (modified) (1 diff)
-
assets/js/settings.js (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
views/settings.php (modified) (1 diff)
-
views/unloading-form.php (modified) (3 diffs)
-
wc-eshop-logistic.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eshoplogisticru/trunk/Http/Controllers/OptionsController.php
r3028864 r3205693 266 266 267 267 /** 268 * @param string $key 269 * 270 * @return ResponseInterface 271 */ 272 public function saveAddFieldForm($addField) { 273 if(empty($addField)) return $this->json(['status' => 'error', 'msg' => __('Название пустое', WC_ESL_DOMAIN)]); 274 275 $this->options->save([ 276 'wc_esl_shipping' => [ 277 'add_field_form' => $addField 278 ] 279 ]); 280 281 return $this->json([ 282 'status' => 'success', 283 'msg' => __('Данные по выгрузке успешно сохранены', WC_ESL_DOMAIN), 284 'data' => $this->options->getOption('wc_esl_shipping_add_field_form') 285 ]); 286 } 287 288 /** 268 289 * @param string $data 269 290 * -
eshoplogisticru/trunk/Modules/Ajax.php
r3199345 r3205693 74 74 add_action('wp_ajax_wc_esl_shipping_unloading_status_update', [$this, 'unloadingStatusUpdate']); 75 75 add_action('wp_ajax_wc_esl_shipping_unloading_delete', [$this, 'unloadingDelete']); 76 76 add_action('wp_ajax_wc_esl_shipping_get_add_field', [$this, 'getAddField']); 77 add_action('wp_ajax_wc_esl_shipping_save_add_field', [$this, 'saveAddField']); 77 78 } 78 79 … … 253 254 $response->send(); 254 255 } 256 257 public function saveAddField() 258 { 259 $addField = !empty($_POST['result']) ? wc_clean($_POST['result']) : []; 260 $type = !empty($_POST['type']) ? wc_clean($_POST['type']) : []; 261 $addField = stripslashes(html_entity_decode($addField)); 262 $addField = json_decode($addField, true); 263 264 $optionsRepository = new OptionsRepository(); 265 $result = $optionsRepository->getOption('wc_esl_shipping_add_field_form'); 266 267 foreach ($addField as $value){ 268 if(isset($value['name'])) 269 $result[$type][$value['name']] = $value['value']; 270 } 271 272 $optionsController = new OptionsController(); 273 $response = $optionsController->saveAddFieldForm($result); 274 275 $response->send(); 276 } 277 255 278 256 279 public function searchCities() … … 737 760 } 738 761 762 public function getAddField() 763 { 764 $type = isset($_POST['type']) ? wc_clean($_POST['type']) : null; 765 766 $optionsRepository = new OptionsRepository(); 767 $apiKey = $optionsRepository->getOption('wc_esl_shipping_api_key'); 768 769 $additional = array( 770 'key' => $apiKey, 771 'service' => mb_strtolower( $type ), 772 'detail' => true 773 ); 774 775 $eshopLogisticApi = new EshopLogisticApi( new WpHttpClient() ); 776 $additionalFields = $eshopLogisticApi->apiExportAdditional( $additional ); 777 if ( $additionalFields->hasErrors() ) { 778 $html = '<p>Ошибка при получении дополнительных услуг</p>'; 779 } else { 780 $additionalFields = $additionalFields->data(); 781 if ( $additionalFields ){ 782 $additionalFieldsRu = array( 783 'packages' => 'Упаковка', 784 'cargo' => 'Груз', 785 'recipient' => 'Получатель', 786 'other' => 'Другие услуги', 787 788 ); 789 $type = mb_strtolower( $type ); 790 $optionsRepository = new OptionsRepository(); 791 $addFieldSaved = $optionsRepository->getOption('wc_esl_shipping_add_field_form'); 792 793 $html = '<form action="/" method="post" id="eslAddFieldForm" data-type="'.$type.'"><div class="esl-box_add">'; 794 foreach ( $additionalFields as $key => $value) { 795 $title = ( $additionalFieldsRu[ $key ] ) ?? $key; 796 $html .= '<p>'. $title. '</p>'; 797 foreach ( $value as $k => $v ){ 798 if(!isset($v['name'])) 799 continue; 800 801 $valueSaved = '0'; 802 if(isset($addFieldSaved[$type][$k]) && $addFieldSaved[$type][$k] != '0'){ 803 $valueSaved = $addFieldSaved[$type][$k]; 804 } 805 $html .= '<div class="form-field_add">'; 806 $html .= '<label class="label" for="'.$k.'">'.$v['name'].'</label>'; 807 if ( $v['type'] === 'integer' ){ 808 $html .= '<input class="form-value_add" type="number" name="'.$k.'" value="'.$valueSaved.'" max="'.$v['max_value'].'">'; 809 }else{ 810 $check = ''; 811 if($valueSaved != '0') 812 $check = 'checked="checked"'; 813 814 $html .= '<input class="form-value_add" name="'.$k.'" type="checkbox" '.$check.'>'; 815 } 816 $html .= '</div>'; 817 } 818 } 819 $html .= '</div></div>'; 820 }else{ 821 $html = '<p>Дополнительные услуги отсутствуют.</p>'; 822 } 823 824 } 825 826 wp_send_json([ 827 'success' => true, 828 'data' => $html, 829 'msg' => __("", WC_ESL_DOMAIN) 830 ]); 831 } 832 739 833 } -
eshoplogisticru/trunk/Modules/AssetsLoader.php
r3171498 r3205693 175 175 ); 176 176 177 wp_enqueue_style( 178 'wc_esl_modal_css', 179 WC_ESL_PLUGIN_URL . 'assets/css/modal.css', 180 [], 181 WC_ESL_VERSION 182 ); 183 177 184 wp_enqueue_script( 178 185 'wc_esl_bootstrap_js', … … 221 228 filemtime( WC_ESL_PLUGIN_DIR . 'assets/js/html5sortable.js' ), 222 229 false 230 ); 231 232 wp_enqueue_script( 233 'wc_esl_modal_js', 234 WC_ESL_PLUGIN_URL . 'assets/js/modal.js', 235 [ 'jquery' ], 236 WC_ESL_VERSION, 237 true 223 238 ); 224 239 } -
eshoplogisticru/trunk/Modules/OptionsPage.php
r2936599 r3205693 80 80 'status_form' => $this->option->getOption('wc_esl_shipping_plugin_status_form'), 81 81 'status_wp' => $this->unloading->getStatusWp(), 82 'add_field_form' => $this->option->getOption('wc_esl_shipping_add_field_form'), 82 83 ); 83 84 } -
eshoplogisticru/trunk/Modules/Unloading.php
r3201100 r3205693 304 304 } 305 305 306 $optionsRepository = new OptionsRepository(); 307 $addFieldSaved = $optionsRepository->getOption('wc_esl_shipping_add_field_form'); 308 309 306 310 echo View::render( 'unloading-form', [ 307 311 'orderData' => $orderData, … … 316 320 'fieldDelivery' => $fieldDelivery, 317 321 'orderShippingId' => $orderShippingId, 318 'infoApi' => $infoApi 322 'infoApi' => $infoApi, 323 'addFieldSaved' => $addFieldSaved 319 324 ] ); 320 325 } -
eshoplogisticru/trunk/assets/css/admin.css
r2939928 r3205693 61 61 width: 100%; 62 62 max-width: 315px; 63 z-index: 999999; 63 64 } 64 65 … … 263 264 color: rgba(236, 0, 0, 0.66); 264 265 } 266 267 .modal-esl-frame { 268 display: none; 269 position: fixed; 270 left: 0; 271 top: 0; 272 width: 100%; 273 height: 100%; 274 overflow: auto; 275 background-color: rgba(0,0,0,0.6); 276 z-index: 9999; 277 } 278 .modal-esl-frame .modal_content { 279 background-color: #fefefe; 280 margin: 10% auto; 281 padding: 20px; 282 border: 1px solid #888; 283 width: 80%; 284 z-index: 99999; 285 } 286 .modal-esl-frame .modal_content .close_modal_window { 287 color: #aaa; 288 float: right; 289 font-size: 28px; 290 font-weight: bold; 291 cursor: pointer; 292 } 293 294 .modal-esl-frame .title { 295 padding-bottom: 45px; 296 } 297 298 .modal-esl-frame #buttonModalAddField{ 299 position: relative; 300 left: 50%; 301 transform: translate(-50%, 0); 302 height: auto; 303 color: #fff; 304 background-color: #489afa; 305 border-color: #0062cc; 306 margin-top: 15px; 307 } 308 309 .modal-esl-frame #buttonModalAddField:hover{ 310 background-color: #086be1; 311 border-color: #0062cc; 312 } 313 314 315 #modal-esl-add-field .label{ 316 position: static; 317 } 318 319 #modal-esl-add-field input{ 320 border: black !important; 321 height: 15px; 322 margin-left: 2px; 323 } 324 325 #modal-esl-add-field input[type=checkbox]:checked::before { 326 float: unset; 327 } 328 329 #modal-esl-add-field input[type=checkbox] { 330 float: unset; 331 height: 15px; 332 width: 15px !important; 333 border: 1px solid rgba(0, 0, 0, 0.14) !important; 334 margin: 2px auto; 335 } 336 337 #modal-esl-add-field .form-field_add { 338 margin: 10px; 339 display: inline-grid; 340 } -
eshoplogisticru/trunk/assets/js/checkout_frame_v2.js
r3171498 r3205693 1 if(document.getElementById('wc_esl_billing_terminal').value){ 2 window.keyDelivery = 'terminal' 3 }else if(document.getElementById('wc_esl_shipping_terminal').value){ 4 window.keyDelivery = 'terminal' 1 if(document.getElementById('wc_esl_billing_terminal')){ 2 if(document.getElementById('wc_esl_billing_terminal').value){ 3 window.keyDelivery = 'terminal' 4 }else if(document.getElementById('wc_esl_shipping_terminal').value){ 5 window.keyDelivery = 'terminal' 6 }else{ 7 window.keyDelivery = 'door' 8 } 5 9 }else{ 6 10 window.keyDelivery = 'door' 7 11 } 12 8 13 9 14 window.widgetInit = false -
eshoplogisticru/trunk/assets/js/settings.js
r2999459 r3205693 1 1 window.addEventListener('load', function(event) { 2 2 eslRun() 3 4 let modalAddField = document.getElementById("modal-esl-add-field") 5 let contentAjax = document.getElementById("content-add-field_ajax") 6 let span = document.getElementsByClassName("close_modal_window")[0] 7 8 span.onclick = function () { 9 modalAddField.style.display = "none" 10 } 11 12 window.onclick = function (event) { 13 if (event.target === modalAddField) { 14 modalAddField.style.display = "none" 15 } 16 } 17 18 let bindEvents = { 19 clickOnAddField: function (event) { 20 console.log(event) 21 let data = []; 22 data['action'] = 'wc_esl_shipping_get_add_field'; 23 data['type'] = 'sdek'; 24 25 HttpClientEsl.post(data, function(result){ 26 console.log(result) 27 if(result.success === true){ 28 contentAjax.innerHTML = result.data; 29 } 30 }); 31 modalAddField.style.display = "block" 32 }, 33 onCloseModal: function () { 34 console.log('closeModal') 35 }, 36 } 37 38 let els_add_buttons = document.getElementsByClassName('wc-esl-add__button') 39 if (els_add_buttons) { 40 for (let i = 0; i < els_add_buttons.length; i++) { 41 els_add_buttons[i].addEventListener('click', bindEvents.clickOnAddField, false); 42 } 43 44 } 3 45 }); 4 46 … … 32 74 enableFrameCheckbox: document.getElementById('enableFrame'), 33 75 statusSave: document.getElementById('statusSave'), 76 eslAddFieldForm: 'eslAddFieldForm', 77 buttonAddFieldForm: document.getElementById('buttonModalAddField'), 78 eslAddFieldSelector: '.modal-esl-frame .modal_content', 34 79 35 80 init: function () { … … 99 144 })); 100 145 } 146 if(this.buttonAddFieldForm){ 147 this.buttonAddFieldForm.addEventListener('click', this.submitAddFieldForm.bind({ 148 _self: this 149 })); 150 } 151 }, 152 153 submitAddFieldForm: function (event) { 154 event.preventDefault(); 155 156 let _self = this._self; 157 let form = document.getElementById(_self.eslAddFieldForm); 158 let type = form.getAttribute('data-type'); 159 let result = []; 160 let data = new FormData(form); 161 for (let [key, value] of data) { 162 result.push({name:key, value:value}); 163 } 164 165 PreloaderEsl.show(_self.eslAddFieldSelector); 166 _self.changeAddField(result, type); 167 }, 168 169 changeAddField: function (result, type) { 170 let data = []; 171 172 data['action'] = 'wc_esl_shipping_save_add_field'; 173 data['result'] = JSON.stringify(result); 174 data['type'] = type; 175 176 HttpClientEsl.post(data, this.callbackChangeAddField.bind({ 177 _self: this 178 })); 179 }, 180 181 callbackChangeAddField: function (response) { 182 let _self = this._self; 183 PushEsl.addItem(response.status, response.msg); 184 PreloaderEsl.hide(_self.eslAddFieldSelector); 185 console.log(response); 101 186 }, 102 187 … … 592 677 elem.parentNode.remove(); 593 678 } 679 594 680 595 681 (function( $ ) { -
eshoplogisticru/trunk/readme.txt
r3202478 r3205693 4 4 Requires at least: 5.3 5 5 Tested up to: 6.6 6 Stable tag: 2.1.4 36 Stable tag: 2.1.44 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
eshoplogisticru/trunk/views/settings.php
r3186394 r3205693 1561 1561 <?php endif; ?> 1562 1562 1563 <?php if ( $moduleVersion ): ?> 1564 <div class="card wc-esl-settings-status esl-section_add_field"> 1565 <div class="card-header"> 1566 <?php echo __( 'Дополнительные услуги', WC_ESL_DOMAIN ) ?> 1567 </div> 1568 1569 <div class="card-body" id="eslAddFormField"> 1570 <div class="form-group row align-items-center mb-3"> 1571 <div class="col-sm-12"> 1572 1573 <div class="row"> 1574 <div class="esl-inner_add col-sm-6"> 1575 <button type="button" class="wc-esl-add__button" data-mode="sdek">Настройки для СДЭК</button> 1576 </div> 1577 </div> 1578 1579 </div> 1580 </div> 1581 </div> 1582 1583 <div id="modal-esl-add-field" class="modal-esl-frame"> 1584 <div class="modal_content"> 1585 <div class="title"> 1586 <span class="close_modal_window">×</span> 1587 <p><strong>Дополнительные услуги</strong><br></p> 1588 </div> 1589 <div id="content-add-field_ajax"></div> 1590 <div class="footer"> 1591 <input id="buttonModalAddField" class="btn btn-primary" type="button" value="Сохранить"> 1592 </div> 1593 </div> 1594 </div> 1595 1596 </div> 1597 <?php endif; ?> 1598 1563 1599 </div> 1564 1600 </div> -
eshoplogisticru/trunk/views/unloading-form.php
r3202478 r3205693 23 23 $orderShippingId = isset( $orderShippingId ) ? $orderShippingId : ''; 24 24 $infoApi = isset( $infoApi ) ? $infoApi : ''; 25 $addFieldSaved = isset( $addFieldSaved ) ? $addFieldSaved : array(); 25 26 26 27 $fulfillment = false; … … 300 301 if(!isset($v['name'])) 301 302 continue; 303 304 $type = mb_strtolower( $typeMethod['name']); 305 $valueSaved = '0'; 306 if(isset($addFieldSaved[$type][$k]) && $addFieldSaved[$type][$k] != '0'){ 307 $valueSaved = $addFieldSaved[$type][$k]; 308 } 302 309 ?> 303 310 <div class="form-field_add"> … … 305 312 <?php if ( $v['type'] === 'integer' ): ?> 306 313 <input class="form-value_add" name="<?php echo $k ?>" type="number" 307 value="0" max="<?php echo $v['max_value'] ?>"> 308 <?php else: ?> 309 <input class="form-value_add" name="<?php echo $k ?>" type="checkbox"> 314 value="<?php echo $valueSaved ?>" max="<?php echo $v['max_value'] ?>"> 315 <?php else: 316 $check = ''; 317 if($valueSaved != '0') 318 $check = 'checked="checked"'; 319 ?> 320 <input class="form-value_add" name="<?php echo $k ?>" type="checkbox" <?php echo $check ?>> 310 321 <?php endif; ?> 311 322 </div> -
eshoplogisticru/trunk/wc-eshop-logistic.php
r3202478 r3205693 6 6 * 7 7 * @link https://wp.eshoplogistic.ru/ 8 * @since 2.1.4 38 * @since 2.1.44 9 9 * @package WC_Eshop_Logistic 10 10 * … … 13 13 * Plugin URI: https://wp.eshoplogistic.ru/ 14 14 * Description: Несколько служб доставки в одной интеграции: CDEK, DPD, Boxberry, IML, Почта России, Деловые Линии, ПЭК, Dostavista, GTD, Байкал Сервис и др. 15 * Version: 2.1.4 315 * Version: 2.1.44 16 16 * Author: eShopLogistic 17 17 * Author URI: https://eshoplogistic.ru/p747575 … … 41 41 define( 'WC_ESL_PLUGIN_DIR', plugin_dir_path(__FILE__) ); 42 42 43 define( 'WC_ESL_VERSION', '2.1.4 3' );43 define( 'WC_ESL_VERSION', '2.1.44' ); 44 44 45 45 define( 'WC_ESL_DOMAIN', 'wc-esl' );
Note: See TracChangeset
for help on using the changeset viewer.