PluginProbe
WPCargo Track & Trace / trunk
WPCargo Track & Trace vtrunk
8.0.5 8.0.3 8.0.4 trunk 6.10.0 6.10.1 6.10.2 6.10.3 6.10.4 6.10.5 6.10.6 6.10.8 6.11.0 6.12.2 6.13.0 6.13.1 6.13.3 6.13.4 6.13.5 6.13.6 6.9.0 6.9.1 6.9.2 6.9.3 6.9.4 All 38 releases
wpcargo / admin / includes / hooks.php

hooks.php in WPCargo Track & Trace trunk, at admin/includes/hooks.php

659 lines 31.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 function wpcargo_email_footer_divider_callback(){
6 $footer_image = WPCARGO_PLUGIN_URL.'admin/assets/images/wpc-email-footer.png';
7 ?>
8 <div class="wpc-footer-devider">
9 <img src="<?php echo esc_url( $footer_image ); ?>" style="width:100%;" />
10 </div>
11 <?php
12 }
13 function wpcargo_fields_option_settings_group_callback( $options ){
14 require_once( WPCARGO_PLUGIN_PATH.'admin/templates/settings-fields-option.tpl.php' );
15 }
16 function wpcargo_plugins_loaded_hook_callback(){
17 add_action( 'wpcargo_fields_option_settings_group', 'wpcargo_fields_option_settings_group_callback', 10, 1 );
18 add_action( 'wpcargo_email_footer_divider', 'wpcargo_email_footer_divider_callback' );
19 if( get_option('shmap_active') && !empty( trim( get_option('shmap_api') ) ) ){
20 add_action('before_wpcargo_shipment_history', 'wpcargo_shipment_history_map_callback', 10, 1 );
21 // Apply the map autocomplete in other addons
22 add_action('wpcsr_create_order_after_form_wrapper', 'wpcargo_shipment_history_map_callback', 10, 1);
23 add_action('wpc_pq_after_form_wrapper', 'wpcargo_shipment_history_map_callback', 10, 1);
24 }
25 if( !function_exists('is_plugin_active') ) {
26 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
27 }
28 if ( !is_plugin_active( 'wpcargo-frontend-manager/wpcargo-frontend-manager.php' ) ) {
29 // Print Label hooks
30 add_action( 'wpcfe_before_invoice_content', 'wpcargo_before_invoice_content_callback', 10, 1 );
31 add_action( 'wpcfe_invoice_site_info', 'wpcargo_invoice_site_info_callback', 10, 1 );
32 add_action( 'wpcfe_invoice_barcode_info', 'wpcargo_invoice_barcode_info_callback', 10, 1 );
33 add_action( 'wpcfe_invoice_shipper_info', 'wpcargo_invoice_shipper_info_callback', 10, 1 );
34 add_action( 'wpcfe_invoice_receiver_info', 'wpcargo_invoice_receiver_info_callback', 10, 1 );
35 add_action( 'wpcfe_end_invoice_section', 'wpcargo_end_invoice_section_callback', 100, 1 );
36 }
37 add_action( 'wpcfe_before_invoice_content', 'wpcargo_before_invoice_font_content_callback', 15, 1 );
38
39 }
40 add_action( 'plugins_loaded', 'wpcargo_plugins_loaded_hook_callback' );
41
42 function wpcargo_activation_setup_settings(){
43 // Set up packages settings
44 $package_settings = array(
45 'wpc_mp_enable_admin' => 1,
46 'wpc_mp_enable_frontend' => 1,
47 'wpc_mp_enable_dimension_unit' => 1,
48 'wpc_mp_dimension_unit' => 'cm',
49 'wpc_mp_weight_unit' => 'kg',
50 'wpc_mp_piece_type' => 'Pallet, Carton, Crate, Loose, Others',
51 );
52 if( !empty( get_option( 'wpc_mp_settings' ) ) ){
53 $package_settings = array(
54 'wpc_mp_enable_admin' => wpcargo_package_settings()->admin_enable,
55 'wpc_mp_enable_frontend' => wpcargo_package_settings()->frontend_enable,
56 'wpc_mp_enable_dimension_unit' => wpcargo_package_settings()->dim_unit_enable,
57 'wpc_mp_dimension_unit' => wpcargo_package_settings()->dim_unit,
58 'wpc_mp_weight_unit' => wpcargo_package_settings()->weight_unit,
59 'wpc_mp_piece_type' => implode(",", wpcargo_package_settings()->peice_types ),
60 );
61 }
62 update_option( 'wpc_mp_settings', $package_settings );
63 // General Settings
64 $general_settings = array(
65 'settings_shipment_type' => 'Air Freight, International Shipping, Truckload, Van Move',
66 'settings_shipment_wpcargo_mode' => 'Sea Transport, Land Shipping, Air Freight',
67 'settings_shipment_status' => implode(",", wpcargo_default_status() ),
68 'settings_shipment_country' => wpcargo_country_list(),
69 'settings_shipment_wpcargo_carrier' => 'DHL, USPS, FedEx',
70 'settings_shipment_wpcargo_payment_mode' => 'CASH, Cheque, BACS',
71 'settings_shipment_ship_logo' => '',
72 'settings_barcode_checkbox' => 1,
73 'wpcargo_title_prefix_action' => 'on',
74 'wpcargo_title_prefix' => 'WPC',
75 'wpcargo_base_color' => '#01ba7c',
76 'wpcargo_tax' => 12,
77 'wpcargo_invoice_display_history' => 'on',
78 'wpcargo_edit_history_role' => array( 'administrator', 'wpc_shipment_manager', ),
79 'wpcargo_email_employee' => false,
80 'wpcargo_email_agent' => false,
81 'wpcargo_email_client' => false,
82 );
83 if( !empty( get_option( 'wpcargo_option_settings' ) ) ){
84 $gen_settings = get_option( 'wpcargo_option_settings' );
85 $barcode_checkbox = array_key_exists('settings_barcode_checkbox', $gen_settings ) ? 1 : false;
86 $prefix_action = array_key_exists('wpcargo_title_prefix_action', $gen_settings ) ? 'on' : false;
87 $display_history = array_key_exists('wpcargo_invoice_display_history', $gen_settings ) ? 'on' : false;
88 $email_employee = array_key_exists('wpcargo_email_employee', $gen_settings ) ? 'on' : false;
89 $email_agent = array_key_exists('wpcargo_email_agent', $gen_settings ) ? 'on' : false;
90 $email_client = array_key_exists('wpcargo_email_client', $gen_settings ) ? 'on' : false;
91 $general_settings = array(
92 'settings_shipment_type' => $gen_settings['settings_shipment_type'],
93 'settings_shipment_wpcargo_mode' => $gen_settings['settings_shipment_wpcargo_mode'],
94 'settings_shipment_status' => $gen_settings['settings_shipment_status'],
95 'settings_shipment_country' => $gen_settings['settings_shipment_country'],
96 'settings_shipment_wpcargo_carrier' => $gen_settings['settings_shipment_wpcargo_carrier'],
97 'settings_shipment_wpcargo_payment_mode' => $gen_settings['settings_shipment_wpcargo_payment_mode'],
98 'settings_shipment_ship_logo' => $gen_settings['settings_shipment_ship_logo'],
99 'settings_barcode_checkbox' => $barcode_checkbox,
100 'wpcargo_title_prefix_action' => $prefix_action,
101 'wpcargo_title_prefix' => $gen_settings['wpcargo_title_prefix'],
102 'wpcargo_base_color' => $gen_settings['wpcargo_base_color'],
103 'wpcargo_tax' => $gen_settings['wpcargo_tax'],
104 'wpcargo_invoice_display_history' => $display_history,
105 'wpcargo_edit_history_role' => $gen_settings['wpcargo_edit_history_role'],
106 'wpcargo_email_employee' => $gen_settings['wpcargo_email_employee'],
107 'wpcargo_email_agent' => $gen_settings['wpcargo_email_agent'],
108 'wpcargo_email_client' => $gen_settings['wpcargo_email_client'],
109 );
110 }
111 update_option( 'wpcargo_option_settings', $general_settings );
112
113 if( empty( get_option('wpcargo_title_suffix') ) ){
114 update_option( 'wpcargo_title_suffix', '-CARGO' );
115 }
116 // Client email settings
117 $client_mail_settings = array(
118 'wpcargo_active_mail' => 1,
119 'wpcargo_mail_to' => '{wpcargo_shipper_email}',
120 'wpcargo_mail_subject' => 'Shipment Notification # {'.wpcargo_track_meta().'}',
121 'wpcargo_mail_message' =>'',
122 'wpcargo_mail_footer' => ''
123 );
124 if( !empty( get_option( 'wpcargo_mail_settings' ) ) ){
125 $c_mail_settings = get_option( 'wpcargo_mail_settings' );
126 $c_active_mail = array_key_exists( 'wpcargo_active_mail', $c_mail_settings ) ? $c_mail_settings['wpcargo_active_mail'] : false;
127 $client_mail_settings = array(
128 'wpcargo_active_mail' => $c_active_mail,
129 'wpcargo_mail_to' => $c_mail_settings['wpcargo_mail_to'],
130 'wpcargo_mail_subject' => $c_mail_settings['wpcargo_mail_subject'],
131 'wpcargo_mail_message' => $c_mail_settings['wpcargo_mail_message'],
132 'wpcargo_mail_footer' => $c_mail_settings['wpcargo_mail_footer']
133 );
134 }
135 update_option( 'wpcargo_mail_settings', $client_mail_settings );
136 if( empty( get_option( 'wpcargo_admin_mail_active' ) ) ){
137 update_option( 'wpcargo_admin_mail_active', 1 );
138 }
139 if( empty( get_option( 'wpcargo_admin_mail_to' ) ) ){
140 update_option( 'wpcargo_admin_mail_to', get_bloginfo('admin_email') );
141 }
142 if( empty( get_option( 'wpcargo_admin_mail_subject' ) ) ){
143 update_option( 'wpcargo_admin_mail_subject', 'Shipment Notification # {'.wpcargo_track_meta().'}' );
144 }
145 }
146 register_activation_hook( WPCARGO_FILE_DIR, 'wpcargo_activation_setup_settings' );
147 function wpcargo_track_shipment_history_details_tbl_responsive(){
148 ?>
149 <style>
150 /*
151 Max width before this PARTICULAR table gets nasty. This query will take effect for any screen smaller than 760px and also iPads specifically.
152 */
153 @media
154 only screen
155 and (max-width: 760px), (min-device-width: 768px)
156 and (max-device-width: 1024px) {
157 /* Force table to not be like tables anymore */
158 #wpcargo-history-section table#shipment-history,
159 #wpcargo-history-section table#shipment-history thead,
160 #wpcargo-history-section table#shipment-history tbody,
161 #wpcargo-history-section table#shipment-history th,
162 #wpcargo-history-section table#shipment-history td,
163 #wpcargo-history-section table#shipment-history tr {
164 display: block;
165 }
166 #wpcargo-history-section table#shipment-history thead tr {
167 position: absolute;
168 top: -9999px;
169 left: -9999px;
170 }
171 #wpcargo-history-section table#shipment-history tr:nth-of-type(odd) {
172 background: #eee;
173 }
174 #wpcargo-history-section table#shipment-history tr { border: 1px solid #ccc; }
175 #wpcargo-history-section table#shipment-history td {
176 /* Behave like a "row" */
177 border: none;
178 border-bottom: 1px solid #eee;
179 position: relative;
180 padding-left: 50%;
181 }
182 #wpcargo-history-section table#shipment-history td:before {
183 position: absolute;
184 top: 6px;
185 left: 6px;
186 width: 45%;
187 padding-right: 10px;
188 white-space: nowrap;
189 }
190 /*
191 Label the data
192 */
193 <?php $counter = 1; ?>
194 <?php foreach ( wpcargo_history_fields() as $value): ?>
195 #wpcargo-history-section table#shipment-history td:nth-of-type(<?php echo esc_html($counter); ?>):before { content: "<?php echo esc_html( $value['label'] ); ?>"; }
196 <?php $counter++; endforeach; ?>
197 }
198 </style>
199 <?php
200 }
201 add_action('wpcargo_after_track_details', 'wpcargo_track_shipment_history_details_tbl_responsive', 10, 1);
202 function wpcargo_track_shipment_history_details( $shipment ) {
203 global $wpdb, $wpcargo;
204 $settings = $wpcargo->settings;
205 $date_format = $wpcargo->date_format;
206 $time_format = $wpcargo->time_format;
207 if( !empty( $settings ) ){
208 if( !array_key_exists( 'wpcargo_invoice_display_history', $settings ) ){
209 if( !( isset( $_POST['wpcfe'] ) || wpcargo_can_track_shipment() ) ){
210 return false;
211 }
212 }
213 }
214 $shmap_active = get_option('shmap_active');
215 $shmap_api = trim( get_option('shmap_api') );
216 if( $shmap_active && !empty( $shmap_api ) ){
217 ?>
218 <div id="shmap-wrapper" style="margin: 12px 0;">
219 <?php do_action('before_wpcargo_shipment_history_map', $shipment->ID); ?>
220 <div id="wpcargo-shmap" style="height: 320px;"></div>
221 <?php do_action('after_wpcargo_shipment_history_map', $shipment->ID); ?>
222 </div>
223 <?php
224 }
225 $template = wpcargo_include_template( 'result-shipment-history.tpl' );
226 require( $template );
227 }
228 add_action('wpcargo_after_track_details', 'wpcargo_track_shipment_history_details', 10, 1);
229 /*
230 * Hooks for Custom Field Add ons
231 */
232 function wpcargo_add_display_client_accounts( $flags ){
233 ?>
234 <tr>
235 <th><?php esc_html_e('Do you want to display it on account page?', 'wpcargo' ); ?></th>
236 <td><input name="display_flags[]" value="account_page" type="checkbox"></td>
237 </tr>
238 <?php
239 }
240 add_action( 'wpc_cf_after_form_field_add', 'wpcargo_add_display_client_accounts' );
241 function wpcargo_edit_display_client_accounts( $flags ){
242 ?>
243 <tr>
244 <th><?php esc_html_e('Do you want to display it on account page?', 'wpcargo' ); ?></th>
245 <td><input name="display_flags[]" value="account_page" type="checkbox" <?php echo is_array($flags) && in_array( 'account_page', $flags) ? 'checked' : ''; ?> /></td>
246 </tr>
247 <?php
248 }
249 add_action( 'wpc_cf_after_form_field_edit', 'wpcargo_edit_display_client_accounts' );
250 add_action('wp_footer', function(){
251 global $post;
252 if ( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'wpcargo_account') || has_shortcode( $post->post_content, 'wpc-ca-account') ) ) {
253 ?>
254 <!-- The Modal -->
255 <div id="view-shipment-modal" class="wpcargo-modal">
256 <!-- Modal content -->
257 <div class="modal-content">
258 <div class="modal-header">
259 <span class="close">&times;</span>
260 </div>
261 <div class="modal-body"></div>
262 <div class="modal-footer"></div>
263 </div>
264 </div>
265 <?php
266 }
267 });
268
269 // Plugin row Hook
270 add_filter( 'plugin_row_meta', 'wpcargo_plugin_row_meta', 10, 2 );
271 function wpcargo_plugin_row_meta( $links, $file ) {
272 if ( strpos( $file, 'wpcargo.php' ) !== false ) {
273 $new_links = array(
274 'settings' => '<a href="'.admin_url('admin.php?page=wpcargo-settings').'">'.esc_html__('Settings', 'wpcargo').'</a>',
275 );
276 $links = array_merge( $links, $new_links );
277 }
278 return $links;
279 }
280 add_action( 'quick_edit_custom_box', 'wpcargo_bulk_update_registered_shipper_custom_box', 10, 2 );
281 add_action( 'bulk_edit_custom_box', 'wpcargo_bulk_update_registered_shipper_custom_box', 10, 2 );
282 function wpcargo_bulk_update_registered_shipper_custom_box( $column_name, $screen_post_type ){
283 global $wpcargo;
284 $shmap_active = get_option('shmap_active');
285 if( $screen_post_type == 'wpcargo_shipment' ){
286 wp_nonce_field( 'reg_shipper_bulk_update_action', 'reg_shipper_bulk_update_nonce' );
287 $user_args = array(
288 'meta_key' => 'first_name',
289 'orderby' => 'meta_value',
290 );
291 $all_users = get_users( $user_args );
292 if( $column_name == 'registered_shipper' ){
293 ?>
294 <fieldset class="inline-edit-col-right">
295 <div class="inline-edit-col">
296 <div class="inline-edit-group wp-clearfix">
297 <label class="inline-edit-registered_shipper">
298 <span class="title"><?php esc_html_e( 'Registered Shipper', 'wpcargo' ); ?></span>
299 <select name="registered_shipper">
300 <option value=""><?php esc_html_e( '— No Change —', 'wpcargo' ); ?></option>
301 <?php
302 foreach($all_users as $user){
303 $user_fullname = apply_filters( 'wpcargo_registered_shipper_option_label', $wpcargo->user_fullname( $user->ID ), $user->ID );
304 echo '<option value="'. (int)esc_html($user->ID).'" >'. esc_html( $user_fullname ).'</option>';
305 }
306 ?>
307 </select>
308 </label>
309 </div>
310 </div>
311 </fieldset>
312 <?php
313 }
314 }
315 }
316 function wpcargo_shipment_registered_shipper_custom_box_bulk_save( $post_id ) {
317 global $wpcargo;
318 if ( !current_user_can( 'edit_post', $post_id ) ) {
319 return;
320 }
321 if( !isset( $_POST["reg_shipper_bulk_update_nonce"] ) ){
322 return;
323 }
324 if ( !wp_verify_nonce( $_POST["reg_shipper_bulk_update_nonce"], 'reg_shipper_bulk_update_action' ) ){
325 return;
326 }
327 $current_user = wp_get_current_user();
328 if ( isset( $_POST['registered_shipper'] ) && $_POST['registered_shipper'] != '' ) {
329 update_post_meta( $post_id, 'registered_shipper', (int)sanitize_text_field($_POST['registered_shipper']) );
330 }
331 }
332 add_action( 'save_post', 'wpcargo_shipment_registered_shipper_custom_box_bulk_save' );
333 // Run this hook when plugin is deactivated
334 function wpcargo_detect_plugin_deactivation( $plugin, $network_activation ) {
335 if( 'wpcargo-client-accounts-addons/wpcargo-client-accounts.php' == $plugin ){
336 add_role('wpcargo_client', 'WPCargo Client', array(
337 'read' => true, // True allows that capability
338 ));
339 }
340 }
341 add_action( 'deactivated_plugin', 'wpcargo_detect_plugin_deactivation', 10, 2 );
342 // Shipment History Map
343 function wpcargo_shipment_history_map_callback( $shipment_id ){
344 global $post, $wpcargo;
345 $shmap_api = get_option('shmap_api');
346 if(!empty($shmap_api)){
347 $shmap_longitude = !empty(get_option('shmap_longitude') ) ? get_option('shmap_longitude') : -87.65;
348 $shmap_latitude = !empty(get_option('shmap_latitude') ) ? get_option('shmap_latitude') : 41.85;
349 $shmap_country_restrict = get_option('shmap_country_restrict');
350 $shmap_active = get_option('shmap_active');
351 $shmap_type = get_option('shmap_type') ? get_option('shmap_type') : 'terrain' ;
352 $shmap_zoom = get_option('shmap_zoom') ? get_option('shmap_zoom') : 15 ;
353 $maplabels = apply_filters('wpcargo_map_labels', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' );
354 $history = wpcargo_history_order( $wpcargo->history( $shipment_id ) );
355 $shipment_addresses = array();
356 $shipment_info = array();
357 if( !empty( $history ) ){
358 foreach ( $history as $value ) {
359 if( empty( $value['location'] ) ){
360 continue;
361 }
362 $shipment_addresses[] = $value['location'];
363 $shipment_info[] = $value;
364 }
365 }
366 $addressLocations = array_reverse( $shipment_addresses );
367 $shipment_info = array_reverse( $shipment_info );
368
369 ?>
370 <script>
371 /*
372 ** Google map Script Auto Complete address
373 */
374 var placeSearch, autocomplete, map, geocoder;
375 var componentForm = {
376 street_number: 'short_name',
377 route: 'long_name',
378 locality: 'long_name',
379 administrative_area_level_1: 'short_name',
380 country: 'long_name',
381 postal_code: 'short_name'
382 };
383 var labels = '<?php echo esc_html($maplabels); ?>';
384 var labelIndex = 0;
385 function wpcSHinitMap() {
386 geocoder = new google.maps.Geocoder();
387 getPlace_dynamic();
388 var map = new google.maps.Map( document.getElementById('wpcargo-shmap'), {
389 zoom: <?php echo esc_html( $shmap_zoom ); ?>,
390 center: {lat: <?php echo esc_html($shmap_latitude); ?>, lng: <?php echo esc_html($shmap_longitude); ?>},
391 mapTypeId: '<?php echo esc_html($shmap_type); ?>',
392 });
393 /* Map script
394 ** Initialize Shipment Locations
395 */
396 var shipmentAddress = <?php echo json_encode( $addressLocations ); ?>;
397 var shipmentData = <?php echo json_encode( $shipment_info ); ?>;
398
399 var flightPlanCoordinates = [];
400 var lastAddress = false;
401 var shipmentlength = shipmentData.length - 1;
402 for (var i = 0; i < shipmentAddress.length; i++ ) {
403 if( i == shipmentlength ){
404 lastAddress = true;
405 }
406 codeAddress( geocoder, map, shipmentAddress[i], flightPlanCoordinates, i, shipmentData, lastAddress );
407 }
408 <?php do_action( 'wpc_after_init_map' ); ?>
409 }
410 function getPlace_dynamic() {
411 var defaultBounds = new google.maps.LatLngBounds(
412 new google.maps.LatLng(-33.8902, 151.1759),
413 new google.maps.LatLng(-33.8474, 151.2631)
414 );
415 var input = document.getElementsByClassName('status_location');
416 var options = {
417 bounds: defaultBounds,
418 types: ['geocode'],
419 <?php if( !empty( $shmap_country_restrict ) ): ?>
420 componentRestrictions: {country: "<?php echo esc_html( $shmap_country_restrict ); ?>"}
421 <?php endif; ?>
422 };
423 for (i = 0; i < input.length; i++) {
424 autocomplete = new google.maps.places.Autocomplete(input[i], options);
425 }
426 <?php do_action( 'wpc_after_get_dynamic_place' ); ?>
427 }
428 function codeAddress( geocoder, map, address, flightPlanCoordinates, index, shipmentData, lastAddress ) {
429 var wpclabelColor = '<?php echo ( get_option('shmap_label_color') ) ? esc_html( get_option('shmap_label_color') ) : '#fff' ; ?>';
430 var wpclabelSize = '<?php echo ( get_option('shmap_label_size') ) ? esc_html( get_option('shmap_label_size') ).'px' : '18px' ; ?>';
431 var wpcMapMarker = '<?php echo ( get_option('shmap_marker') ) ? esc_url( get_option('shmap_marker') ) : esc_url(WPCARGO_PLUGIN_URL.'/admin/assets/images/wpcmarker.png') ; ?>';
432 var wpcCurrMarker = '<?php echo esc_url(apply_filters( 'shmap_current_marker_url', WPCARGO_PLUGIN_URL.'/admin/assets/images/current-map.png' )); ?>';
433 geocoder.geocode({'address': address}, function(results, status) {
434 if (status === 'OK') {
435 var geolatlng = { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng() };
436 var mapLabel = {text: labels[index % labels.length], color: wpclabelColor, fontSize: wpclabelSize };
437 flightPlanCoordinates[index] = geolatlng;
438 if( lastAddress === true ){
439 map.setCenter( geolatlng );
440 wpcMapMarker = wpcCurrMarker;
441 mapLabel = '';
442 }
443 var marker = new google.maps.Marker({
444 map: map,
445 label: mapLabel,
446 position: results[0].geometry.location,
447 icon: wpcMapMarker
448 });
449
450 /*
451 ** Marker Information window
452 */
453 // shipmentData
454 var sAddressDate = shipmentData[index].date;
455 var sAddresstime = shipmentData[index].time;
456 var sAddresslocation = shipmentData[index].location;
457 var sAddressstatus = shipmentData[index].status;
458 var shipemtnInfo = '<strong><?php esc_html_e('Date', 'wpcargo'); ?>:</strong> '+sAddressDate+' '+sAddresstime+'</br>'+
459 '<strong><?php esc_html_e('Location', 'wpcargo'); ?>:</strong> '+sAddresslocation+'</br>'+
460 '<strong><?php esc_html_e('Status', 'wpcargo'); ?>:</strong> '+sAddressstatus;
461 var infowindow = new google.maps.InfoWindow({
462 content: shipemtnInfo
463 });
464 marker.addListener('click', function() {
465 infowindow.open(map, marker);
466 });
467 }
468 });
469 }
470 </script>
471 <?php
472 echo wpcargo_map_script( 'wpcSHinitMap' );
473 }
474 }
475 function wpcargo_track_shipment_status_result( $shimpment_details ){
476 $shipment_status = esc_html( get_post_meta( $shimpment_details->ID, 'wpcargo_status', true ) );
477 $class_status = strtolower( $shipment_status );
478 $class_status = str_replace(' ', '_', $class_status );
479 ?>
480 <div id="shipment-status" class="wpcargo-row <?php echo esc_attr($class_status);?>" style="text-align:center;">
481 <p id="result-status-header"><?php echo esc_html(apply_filters( 'wpcargo_track_shipment_status_result_title', __( 'Shipment Status: ', 'wpcargo' ) )); ?><?php echo esc_html($shipment_status); ?></p>
482 </div>
483 <?php
484 }
485 add_action( 'wpcargo_before_shipment_details', 'wpcargo_track_shipment_status_result', 10, 1 );
486 // Print Invoice hook callback
487 function wpcargo_before_invoice_font_content_callback(){
488 $print_fonts = wpcargo_print_fonts();
489 $ffamily = get_option('wpcargo_print_ffamily');
490 $fsize = get_option('wpcargo_print_fsize') ? get_option('wpcargo_print_fsize') : 12 ;
491 ?>
492 <style type="text/css">
493 <?php if( $ffamily && array_key_exists( $ffamily, $print_fonts ) ): ?>
494 @import url('<?php echo esc_url( $print_fonts[$ffamily]['url'] ); ?>');
495 #wpcargo-result-print *{
496 font-family: <?php echo esc_html( $print_fonts[$ffamily]['fontfamily'] ); ?> !important;
497 font-size: <?php echo esc_html($fsize); ?>px;
498 }
499 @media print{
500 @import url('<?php echo esc_url( $print_fonts[$ffamily]['url'] ); ?>');
501 *{
502 font-family: <?php echo esc_html($print_fonts[$ffamily]['fontfamily']); ?> !important;
503 font-size: <?php echo esc_html($fsize); ?>px;
504 }
505 }
506 <?php endif; ?>
507 </style>
508 <?php
509 }
510 function wpcargo_before_invoice_content_callback(){
511 ?>
512 <style>
513 table{
514 border-collapse: collapse;
515 }
516 table td{
517 vertical-align:top;
518 padding: 8px;
519 }
520 table td *{
521 margin:0;
522 padding:0;
523 }
524 table#package-table td,
525 table#package-table th{
526 border:1px solid #000;
527 padding: 6px;
528 font-size: 12px;
529 }
530 table#package-table th{
531 white-space:nowrap;
532 }
533 .border-bottom{
534 border-bottom: 1px solid #000;
535 }
536 .space-topbottom{
537 padding-top:18px;
538 padding-bottom:18px;
539 }
540 img#log{
541 width:50% !important;
542 }
543 h2, h1{
544 font-size: 14px;
545 }
546 p{
547 font-size:12px;
548 }
549 </style>
550 <?php
551 }
552 function wpcargo_invoice_site_info_callback( $shipmentDetails ){
553 ?>
554 <section style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>"><?php echo wp_kses( $shipmentDetails['siteInfo'], 'post' ); ?></section>
555 <?php
556 }
557 function wpcargo_invoice_shipper_info_callback( $shipmentDetails ){
558 global $WPCCF_Fields, $wpcargo;
559 ?>
560 <p style="font-size:1.2rem;margin-bottom:18px;"><strong><?php esc_html_e('SHIPPER DETAILS:', 'wpcargo'); ?></strong></p>
561 <?php
562 if( class_exists( 'WPCCF_Fields' ) ){
563 echo wp_kses($WPCCF_Fields->get_fields_data( 'shipper_info', esc_html($shipmentDetails['shipmentID'])), 'post');
564 }else{
565 ?>
566 <p><?php esc_html_e( 'Shipper Name', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_shipper_name', true ) ); ?></p>
567 <p><?php esc_html_e( 'Phone Number', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_shipper_phone', true ) ); ?></p>
568 <p><?php esc_html_e( 'Address', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_shipper_address', true ) ); ?></p>
569 <p><?php esc_html_e( 'Email', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_shipper_email', true ) ); ?></p>
570 <?php
571 }
572
573 }
574 function wpcargo_invoice_receiver_info_callback( $shipmentDetails ){
575 global $WPCCF_Fields, $wpcargo;
576 ?>
577 <p style="font-size:1.2rem;margin-bottom:18px;"><strong><?php esc_html_e('RECEIVER DETAILS:', 'wpcargo'); ?></strong></p>
578 <section id="section-to">
579 <?php
580 if( class_exists( 'WPCCF_Fields' ) ){
581 echo wp_kses($WPCCF_Fields->get_fields_data( 'receiver_info', esc_html($shipmentDetails['shipmentID'])), 'post');
582 }else{
583 ?>
584 <p><?php esc_html_e( 'Receiver Name', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_receiver_name', true ) ); ?></p>
585 <p><?php esc_html_e( 'Phone Number', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_receiver_phone', true ) ); ?></p>
586 <p><?php esc_html_e( 'Address', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_receiver_address', true ) ); ?></p>
587 <p><?php esc_html_e( 'Email', 'wpcargo'); ?>: <?php echo esc_html( get_post_meta( $shipmentDetails['shipmentID'], 'wpcargo_receiver_email', true ) ); ?></p>
588 <?php
589 }
590 ?>
591 </section>
592 <?php
593 }
594 function wpcargo_invoice_barcode_info_callback( $shipmentDetails ){
595 global $wpcargo;
596 $barcode_height = wpcargo_print_barcode_sizes()['invoice']['height']? : 60;
597 $barcode_width = wpcargo_print_barcode_sizes()['invoice']['width']? : 200;
598 ?>
599 <section style="text-align:center;" >
600 <img id="admin-invoice-barcode" class="invoice-barcode" style="height: <?php echo absint( esc_html($barcode_height) ).'px'; ?>; width: <?php echo absint( esc_html($barcode_width) ).'px'; ?>" src="<?php echo esc_html( $wpcargo->barcode_url( $shipmentDetails['shipmentID'] ) ); ?>">
601 <p style="font-size:18px;"><?php echo esc_html( get_the_title( $shipmentDetails['shipmentID']) ); ?><p>
602 </section>
603 <?php
604 }
605 function wpcargo_end_invoice_section_callback( $shipmentDetails ){
606 if( empty(wpcargo_get_package_data( $shipmentDetails['shipmentID'] ))){
607 return false;
608 }
609 if( !wpcargo_package_settings()->frontend_enable ){
610 return false;
611 }
612 $shipment = new stdClass;
613 $shipment->ID = $shipmentDetails['shipmentID'];
614 $shipment->post_title = esc_html( get_the_title( $shipmentDetails['shipmentID'] ) );
615 ?>
616 <tr>
617 <td colspan="2">
618 <h1 style="margin-bottom:18px;"><?php esc_html_e('PACKAGE DETAILS:', 'wpcargo'); ?></h1>
619 <table id="package-table" style="width:100%;margin-bottom:18px;">
620 <thead>
621 <tr>
622 <?php foreach ( wpcargo_package_fields() as $key => $value): ?>
623 <?php if( in_array( $key, wpcargo_package_dim_meta() ) && !wpcargo_package_settings()->dim_unit_enable ){ continue; }
624 ?>
625 <th><?php echo esc_html( $value['label'] ); ?></th>
626 <?php endforeach; ?>
627 </tr>
628 </thead>
629 <tbody>
630 <?php foreach ( wpcargo_get_package_data( $shipmentDetails['shipmentID'] ) as $data_key => $data_value): ?>
631 <tr>
632 <?php foreach ( wpcargo_package_fields() as $field_key => $field_value): ?>
633 <?php if( in_array( $field_key, wpcargo_package_dim_meta() ) && !wpcargo_package_settings()->dim_unit_enable ){ continue; } ?>
634 <td>
635 <?php
636 $package_data = array_key_exists( $field_key, $data_value ) ? $data_value[$field_key] : '' ;
637 echo is_array( $package_data ) ? implode(',', esc_html($package_data) ) : esc_html( $package_data );
638 ?>
639
640 </td>
641 <?php endforeach; ?>
642 </tr>
643 <?php endforeach; ?>
644 </tbody>
645 </table>
646 <?php do_action( 'wpcargo_after_package_totals', $shipment ); ?>
647 </td>
648 </tr>
649 <?php
650 }
651 add_action('wpc_add_settings_nav','wpc_email_settings_navigation',15);
652 function wpc_email_settings_navigation(){
653
654 $view = sanitize_text_field($_GET['page']);
655 ?>
656 <a class="nav-tab <?php echo ( $view == 'wpcargo-email-settings') ? 'nav-tab-active' : '' ; ?>" href="<?php echo esc_url(admin_url().'admin.php?page=wpcargo-email-settings'); ?>" ><?php echo esc_html( wpcargo_client_email_settings_label() ); ?></a>
657 <a class="nav-tab <?php echo ( $view == 'wpcargo-admin-email-settings') ? 'nav-tab-active' : '' ; ?>" href="<?php echo esc_url(admin_url().'admin.php?page=wpcargo-admin-email-settings'); ?>" ><?php echo esc_html( wpcargo_admin_email_settings_label() ); ?></a>
658 <?php
659 }