Files
2026-04-28 15:13:50 +02:00

83 lines
3.1 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Provide a admin area view for the plugin
*
* This file is used to markup the admin-facing aspects of the plugin.
*
* @link https://polkurier.pl
* @since 1.0.0
*
* @package Polkurier
* @subpackage Polkurier/admin/partials
*/
require_once (dirname(__FILE__).'/../../includes/PolkurierPackage.php');
$packages = get_option('polkurier_packages');
if ($_SERVER['REQUEST_METHOD']=='POST') {
// zapisujemy informacje o nowej templatce
$package = new PolkurierPackage();
$package->width = $_POST['polkurier_width'];
$package->height = $_POST['polkurier_height'];
$package->depth = $_POST['polkurier_depth'];
$package->weight = $_POST['polkurier_weight'];
$package->count = $_POST['polkurier_count'];
$package->nonstandard = isset($_POST['polkurier_nonstandard']);
$package->type = $_POST['polkurier_type'];
$api = $this->get_polkurier_api();
$data = $api->orderValuation($package);
?><h2>Wycena - <?php echo $package ?></h2>
<ul>
<?php if (empty($data)): ?>
<li><?php echo $api->lastError ?></li>
<?php endif; ?>
<?php foreach ($data as $carrier): ?>
<li><strong><?php echo $carrier["serviceName"] ?></strong> - netto: <?php echo $carrier["netprice"] ?>, brutto <?php echo $carrier["grossprice"] ?></li>
<?php endforeach; ?>
<?php
if( wp_get_referer() )
echo '<a href="'.wp_get_referer().'" >Wstecz</a>';
} else {
?>
<form action="admin.php?page=polkurier_valuation" method="post">
<h2>Wycena paczki</h2>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="polkurier_height">Wysokość (cm)</label></th>
<td><input required type="number" name="polkurier_height" id="polkurier_height" value=""> </td>
</tr>
<tr>
<th scope="row"><label for="polkurier_width">Szerokość (cm)</label></th>
<td><input required type="number" name="polkurier_width" id="polkurier_width" value=""> </td>
</tr>
<tr>
<th scope="row"><label for="polkurier_depth">Głębokość (cm)</label></th>
<td><input required type="number" name="polkurier_depth" id="polkurier_depth" value=""> </td>
</tr>
<tr>
<th scope="row"><label for="polkurier_weight">Waga (kg)</label></th>
<td><input required type="number" name="polkurier_weight" id="polkurier_weight" value=""> </td>
</tr>
<tr>
<th scope="row"><label for="polkurier_count">Ilość</label></th>
<td><input required type="number" name="polkurier_count" id="polkurier_count" value=""> </td>
</tr>
<tr>
<th scope="row"><label for="polkurier_nonstandard">Niestandardowa</label></th>
<td><input type="checkbox" name="polkurier_nonstandard" id="polkurier_nonstandard" value="1"> </td>
</tr>
<tr>
<th scope="row"><label for="polkurier_type">Typ przesyłki</label></th>
<td>
<input type="radio" name="polkurier_type" id="polkurier_type_1" value="koperta">
<label for="polkurier_type_1">koperta</label><br/>
<input type="radio" name="polkurier_type" id="polkurier_type_2" value="paczka" checked>
<label for="polkurier_type_2">paczka</label><br/>
<input type="radio" name="polkurier_type" id="polkurier_type_3" value="paleta">
<label for="polkurier_type_3">paleta</label>
</td>
</tr>
</tbody></table>
<?php submit_button("Wyceń"); ?>
</form>
<?php } ?>