271 lines
9.9 KiB
PHP
271 lines
9.9 KiB
PHP
<input type="hidden" id="paczkomat_order_id" name="paczkomat_order_id" value="<?php echo $args['post_id']; ?>">
|
|
|
|
<?php
|
|
|
|
/**
|
|
* @var array $args
|
|
* @var WC_Paczkomaty_Shipping_Method $paczkomaty_shipping_method
|
|
*/
|
|
require_once( WC()->plugin_path() . '/includes/wc-template-functions.php' );
|
|
|
|
$params = array(
|
|
'type' => 'select',
|
|
'options' => array(
|
|
'paczkomaty' => __( 'Paczkomat', 'woocommerce-paczkomaty-inpost' ),
|
|
'polecony' => __( 'Paczka E-Commerce', 'woocommerce-paczkomaty-inpost' ),
|
|
'kurier' => __( 'Kurier', 'woocommerce-paczkomaty-inpost' ),
|
|
),
|
|
'class' => array('first'),
|
|
'custom_attributes' => array('style' => 'width:100%'),
|
|
'label' => __('Usługa', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_usluga', $params, $args['paczkomaty_usluga']);
|
|
|
|
$params = array(
|
|
'type' => 'select',
|
|
'options' => $args['punkty_nadania'],
|
|
'class' => array('first','polecony'),
|
|
'custom_attributes' => array('style' => 'width:100%'),
|
|
'label' => __('Punkt nadania', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
|
|
woocommerce_form_field('paczkomat_punkt_nadania', $params, $args['paczkomat_punkt_nadania']);
|
|
|
|
|
|
$params = array(
|
|
'type' => 'select',
|
|
'options' => $this->adminMachines,
|
|
'class' => array('first','paczkomaty'),
|
|
'custom_attributes' => array('style' => 'width:100%'),
|
|
'label' => __('Wybrany paczkomat', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
|
|
woocommerce_form_field('paczkomat_id', $params, $args['paczkomat_id']);
|
|
|
|
if ($args['select2']) :
|
|
?>
|
|
<script type="text/javascript">
|
|
if ( jQuery().select2 ) {
|
|
jQuery("#paczkomat_id").select2();
|
|
}
|
|
</script>
|
|
<?php
|
|
endif;
|
|
|
|
|
|
$params = array(
|
|
'type' => 'select',
|
|
'options' => $paczkomaty_shipping_method->packageSizes,
|
|
'class' => array('first','paczkomaty'),
|
|
'label' => __('Wybrany rozmiar paczki', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
|
|
woocommerce_form_field('paczkomat_size', $params, $args['paczkomat_size']);
|
|
|
|
$params = array(
|
|
'type' => 'number',
|
|
'class' => array('first','kurier'),
|
|
'label' => __('Długość paczki [mm]', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_length', $params, $args['paczkomat_length']);
|
|
|
|
$params = array(
|
|
'type' => 'number',
|
|
'class' => array('first','kurier'),
|
|
'label' => __('Szerokość paczki [mm]', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_width', $params, $args['paczkomat_width']);
|
|
|
|
$params = array(
|
|
'type' => 'number',
|
|
'class' => array('first','kurier'),
|
|
'label' => __('Wysokość paczki [mm]', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_height', $params, $args['paczkomat_height']);
|
|
|
|
$params = array(
|
|
'type' => 'number',
|
|
'class' => array('first','kurier'),
|
|
'label' => __('Waga paczki [kg]', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_weight', $params, $args['paczkomat_weight']);
|
|
|
|
$params = array(
|
|
'type' => 'text',
|
|
'class' => array('first','paczkomaty','kurier'),
|
|
'defualt' => $args['paczkomat_customer_ref'],
|
|
'label' => __('Numer referencyjny', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field( 'paczkomat_customer_ref', $params, $args['paczkomat_customer_ref'] );
|
|
|
|
$params = array(
|
|
'type' => 'select',
|
|
'options' => $paczkomaty_shipping_method->howToGive,
|
|
'class' => array('first','paczkomaty'),
|
|
'default' => $paczkomaty_shipping_method->get_option( 'self_send', true ),
|
|
'label' => __('Sposób nadania', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
|
|
if(!empty($args['paczkomat_how_to_give'])){
|
|
woocommerce_form_field('paczkomat_how_to_give', $params, $args['paczkomat_how_to_give']);
|
|
}
|
|
else{
|
|
woocommerce_form_field('paczkomat_how_to_give', $params, $paczkomaty_shipping_method->get_option('self_send', 1 ) );
|
|
}
|
|
|
|
$params = array(
|
|
'type' => 'checkbox',
|
|
'class' => array('first','paczkomaty','kurier'),
|
|
'label' => __('Ubezpieczenie', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_ubezpieczenie', $params, $args['paczkomat_ubezpieczenie']);
|
|
|
|
|
|
$key = 'paczkomat_ubezpieczenie_amount';
|
|
$params = array(
|
|
'label' => __( 'Kwota ubezpieczenia', 'woocommerce-paczkomaty-inpost' ),
|
|
'type' => 'number',
|
|
'class' => array( 'first','paczkomaty','kurier' ),
|
|
'custom_attributes' => array(
|
|
'min' => 0,
|
|
'step' => '0.01',
|
|
)
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field( $key, $params, $args['paczkomat_ubezpieczenie_amount'] );
|
|
|
|
|
|
$params = array(
|
|
'type' => 'checkbox',
|
|
'class' => array('first','paczkomaty','kurier'),
|
|
'label' => __('Pobranie', 'woocommerce-paczkomaty-inpost'),
|
|
);
|
|
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field('paczkomat_cod', $params, $args['paczkomat_cod']);
|
|
|
|
$key = 'paczkomat_cod_amount';
|
|
$params = array(
|
|
'label' => __( 'Kwota pobrania', 'woocommerce-paczkomaty-inpost' ),
|
|
'type' => 'number',
|
|
'class' => array( 'first','paczkomaty','kurier' ),
|
|
'custom_attributes' => array(
|
|
'min' => 0,
|
|
'step' => '0.01',
|
|
)
|
|
);
|
|
if (!empty($args['paczkomat_packcode'])){
|
|
$params['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field( $key, $params, $args['paczkomat_cod_amount'] );
|
|
|
|
if (!empty($args['paczkomat_packcode'])):
|
|
?>
|
|
<p class="paczkomaty polecony kurier"><strong>Numer paczki</strong>: <?php echo $args['paczkomat_packcode']; ?></p>
|
|
<?php
|
|
endif;
|
|
|
|
if (!empty($args['paczkomat_shipment_status'])):
|
|
?>
|
|
<p class="kurier"><strong><?php _e( 'Status przesyłki: ', 'woocommerce-paczkomaty-inpost' ); ?></strong>: <?php echo $args['paczkomat_shipment_status_translated']; ?></p>
|
|
<?php
|
|
endif;
|
|
|
|
if ( ( empty($args['paczkomat_packcode']) && ( $args['paczkomaty_usluga'] == 'paczkomaty' || $args['paczkomaty_usluga'] == 'polecony' ) )
|
|
|| ( $args['paczkomaty_usluga'] == 'kurier' && empty($args['paczkomat_shipment_status']) ) ) :
|
|
?>
|
|
<p class="paczkomaty polecony kurier">
|
|
<button class="button-paczkomaty button button-primary" href="#" id="paczkomaty_send_package"><?php _e('Utwórz przesyłkę', 'woocommerce-paczkomaty-inpost') ?></button>
|
|
<span class="spinner paczkomaty-spinner paczkomaty-send-spinner"></span>
|
|
</p>
|
|
<?php else: ?>
|
|
<?php if ( ( !empty($args['paczkomat_packcode']) && ( $args['paczkomaty_usluga'] == 'paczkomaty' || $args['paczkomaty_usluga'] == 'polecony' ) )
|
|
|| ( $args['paczkomaty_usluga'] == 'kurier' && !empty($args['paczkomat_shipment_status']) ) && $args['paczkomat_shipment_status'] != 'created' ) :
|
|
?>
|
|
<p class="paczkomaty polecony kurier">
|
|
<a target="_blank" class="button-paczkomaty button button-primary" href="<?php echo wp_nonce_url(admin_url('?generate_inpost_sticker=true&post=' . $args['post_id']), 'generate_inpost_sticker'); ?>"><?php _e('Pobierz etykietę', 'woocommerce-paczkomaty-inpost') ?></a>
|
|
</p>
|
|
<?php endif; ?>
|
|
<?php if ( $args['paczkomaty_usluga'] == 'kurier' || $args['paczkomaty_usluga'] == 'allegro_polecony' ) : ?>
|
|
<p class="kurier">
|
|
<button class="button-paczkomaty button button-primary" href="#" id="paczkomaty_refresh_package_status"><?php _e('Odśwież status', 'woocommerce-paczkomaty-inpost') ?></button>
|
|
<span class="spinner paczkomaty-spinner paczkomaty-send-spinner"></span>
|
|
<?php if ( !empty($args['paczkomat_shipment_status']) && ( $args['paczkomat_shipment_status'] == 'created' || $args['paczkomat_shipment_status'] == 'offer_selected' ) ) : ?>
|
|
<script type="text/javascript">
|
|
function paczkomaty_auto_refresh_package_status() {
|
|
jQuery('#paczkomaty_refresh_package_status').trigger('click');
|
|
}
|
|
jQuery(document).ready(function(){
|
|
setTimeout( paczkomaty_auto_refresh_package_status, 4000 );
|
|
})
|
|
</script>
|
|
<?php endif; ?>
|
|
</p>
|
|
<?php endif;
|
|
endif;
|
|
?>
|
|
<?php if ( ( empty($args['paczkomat_packcode']) && ( $args['paczkomaty_usluga'] == 'paczkomaty' || $args['paczkomaty_usluga'] == 'polecony' ) )
|
|
|| ( $args['paczkomaty_usluga'] == 'kurier' && empty($args['paczkomat_shipment_status']) ) ):
|
|
?>
|
|
<p class="paczkomaty polecony kurier">
|
|
<button class="button-paczkomaty button" href="#" id="paczkomaty_save_order_box"><?php _e('Zapisz', 'woocommerce-paczkomaty-inpost') ?></button>
|
|
<span class="spinner paczkomaty-spinner paczkomaty-save-spinner"></span>
|
|
</p>
|
|
<?php endif; ?>
|
|
<p id="paczkomat_error" class="error">
|
|
<?php echo $args['paczkomat_error']; ?>
|
|
</p>
|
|
<?php if ( !$echo ) : ?>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function(){
|
|
paczkomaty_fields_change();
|
|
paczkomaty_checkboxes_change();
|
|
<?php if ( $args['paczkomat_error'] != '' ) : ?>
|
|
jQuery('#paczkomat_error').show();
|
|
<?php else : ?>
|
|
jQuery('#paczkomat_error').hide();
|
|
<?php endif; ?>
|
|
})
|
|
</script>
|
|
<?php endif; ?>
|