299 lines
16 KiB
PHP
299 lines
16 KiB
PHP
<?php use_helper('stAdminGenerator', 'stAllegro', 'stAllegroParameter', 'stAllegroDelivery', 'stPartial');?>
|
|
|
|
<fieldset>
|
|
<h2><?php echo __('Format sprzedaży') ?></h2>
|
|
<div class="content">
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[selling_mode][price][amount]', __("Cena"), $offer->getSellingMode()->price ? $offer->getSellingMode()->price->amount : 0, 'input_tag', array(
|
|
'class' => 'number-type update-pricing-fee-preview',
|
|
'required' => true,
|
|
'size' => 10,
|
|
'data-precision' => 2,
|
|
'data-min' => 0,
|
|
'data-max' => 10000000,
|
|
'postfix' => $offer->getSellingMode()->price ? $offer->getSellingMode()->price->currency : 'PLN'
|
|
)) ?>
|
|
<?php echo input_hidden_tag('allegro_api_offer[selling_mode][price][currency]', $offer->getSellingMode() && $offer->getSellingMode()->price ? $offer->getSellingMode()->price->currency : 'PLN'); ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[stock]', __("Ilość"), $offer->getStock(), '_edit_stock', array('maxlength' => 50, 'size' => 60, 'required' => true, 'product' => $offer->getAllegroAuction()->getProduct())) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[publication][duration]', __("Czas trwania"), $offer->getPublication() ? $offer->getPublication()->duration : null, 'st_allegro_duration_time_select_tag', array('required' => true, 'disabled' => $offer->getPublication() && isset($offer->getPublication()->status) && $offer->getPublication()->status != stAllegroApi::STATUS_INACTIVE)) ?>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Dostawa i płatność') ?></h2>
|
|
<div class="content">
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[delivery][shipping_rates][id]', __("Cennik dostawy"), $offer->getDelivery() && $offer->getDelivery()->shippingRates ? $offer->getDelivery()->shippingRates->id : null, 'st_allegro_shippin_rates_select_tag', array('required' => true)) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[delivery][handling_time]', __("Czas wysyłki"), $offer->getDelivery() ? $offer->getDelivery()->handlingTime : null, 'st_allegro_delivery_times_select_tag', array('required' => true)) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[payments][invoice]', __("Opcje faktury"), $offer->getPayments() ? $offer->getPayments()->invoice : null, 'st_allegro_payments_invoice_select_tag', array('required' => true)) ?>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Zdjęcia') ?></h2>
|
|
<div class="content">
|
|
<div class="row">
|
|
<?php echo st_get_partial('stAllegroBackend/offer_images', array('images' => $offer->getImages() ? $offer->getImages() : array(), 'product' => $offer->getAllegroAuction()->getProduct(), 'name' => 'allegro_api_offer[images]')) ?>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Opis') ?></h2>
|
|
<div class="content">
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[description]', false, $offer->getDescription()->sections, 'partial', array(
|
|
'partial' => 'stAllegroBackend/description',
|
|
)) ?>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Cechy przedmiotu') ?></h2>
|
|
<div class="content">
|
|
<?php echo st_get_component('stAllegroBackend', 'categoryParameters', array('offer' => $offer, 'name' => 'allegro_api_offer[parameters]', 'product' => $offer->getAllegroAuction()->getProduct())) ?>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Warunki oferty') ?></h2>
|
|
<div class="content">
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[after_sales_services][return_policy][id]', __("Warunki zwrotów"), $offer->getAfterSalesServices() && $offer->getAfterSalesServices()->returnPolicy ? $offer->getAfterSalesServices()->returnPolicy->id : null, 'st_allegro_return_policy_select_tag') ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[after_sales_services][implied_warranty][id]', __("Reklamacje"), $offer->getAfterSalesServices() && $offer->getAfterSalesServices()->impliedWarranty ? $offer->getAfterSalesServices()->impliedWarranty->id : null, 'st_allegro_implied_warranty_select_tag') ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[after_sales_services][warranty][id]', __("Gwarancje"), $offer->getAfterSalesServices() && $offer->getAfterSalesServices()->warranty ? $offer->getAfterSalesServices()->warranty->id : null, 'st_allegro_warranty_select_tag') ?>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Opcje promowania') ?></h2>
|
|
<div class="content">
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[promotion][emphasized_highlight_bold_package]', __("Pakiet promowania"), "true", 'checkbox_tag', array("checked" => $offer->getPromotion() ? $offer->getPromotion()->emphasizedHighlightBoldPackage : false, 'class' => 'update-pricing-fee-preview')) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[promotion][emphasized]', __("Wyróżnienie"), "true", 'checkbox_tag', array("checked" => $offer->getPromotion() ? $offer->getPromotion()->emphasized : false, 'class' => 'update-pricing-fee-preview')) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[promotion][bold]', __("Pogrubienie"), "true", 'checkbox_tag', array("checked" => $offer->getPromotion() ? $offer->getPromotion()->bold : false, 'class' => 'update-pricing-fee-preview')) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[promotion][highlight]', __("Podświetlenie"), "true", 'checkbox_tag', array("checked" => $offer->getPromotion() ? $offer->getPromotion()->highlight : false, 'class' => 'update-pricing-fee-preview')) ?>
|
|
<?php echo st_admin_get_form_field('allegro_api_offer[promotion][department_page]', __("Oferta promowania na stronie kategorii"), "true", 'checkbox_tag', array("checked" => $offer->getPromotion() ? $offer->getPromotion()->departmentPage : false, 'class' => 'update-pricing-fee-preview')) ?>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
<h2><?php echo __('Podsumowanie') ?></h2>
|
|
<div class="content">
|
|
<div id="st-allegro-pricing-free-preview-container" class="row">
|
|
<?php echo st_get_component('stAllegroBackend', 'pricingFeePreview', array(
|
|
'category' => $offer->getCategory()->id,
|
|
'quantity' => $offer->getStock()->available,
|
|
'price' => $offer->getSellingMode()->price->amount,
|
|
"bold" => $offer->getPromotion() ? $offer->getPromotion()->bold : false,
|
|
"highlight" => $offer->getPromotion() ? $offer->getPromotion()->highlight : false,
|
|
"departmentPage" => $offer->getPromotion() ? $offer->getPromotion()->departmentPage : false,
|
|
"emphasized" => $offer->getPromotion() ? $offer->getPromotion()->emphasized : false,
|
|
"emphasizedHighlightBoldPackage" => $offer->getPromotion() ? $offer->getPromotion()->emphasizedHighlightBoldPackage : false,
|
|
"offerId" => $offer->getId() ? $offer->getId() : null,
|
|
"status" => $offer->getPublication() && isset($offer->getPublication()->status) ? $offer->getPublication()->status : null,
|
|
)) ?>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
|
|
|
|
<div id="edit_actions">
|
|
<div style="float: left">
|
|
<?php
|
|
$actions = array(
|
|
array('type' => 'list', 'label' => __('Lista'), 'action' => '@stAllegroPlugin?action=list&product_id=' . $sf_request->getParameter('product_id')),
|
|
);
|
|
|
|
if (!$sf_request->getParameter('product_id'))
|
|
{
|
|
$actions[] = array('type' => 'edit', 'label' => __('Edycja produktu'), 'action' => '@stProduct?action=edit&id=' . $offer->getAllegroAuction()->getProduct()->getId());
|
|
}
|
|
else
|
|
{
|
|
$actions[] = array('type' => 'list', 'label' => __('Lista wszystkich ofert'), 'action' => '@stAllegroPlugin?action=list');
|
|
}
|
|
|
|
echo st_get_admin_actions($actions);
|
|
?>
|
|
</div>
|
|
<div style="float: right">
|
|
<?php
|
|
$actions = array();
|
|
|
|
$actions[] = array('type' => 'save', 'label' => __('Zapisz'));
|
|
|
|
if (!$offer->getPublication() || !isset($offer->getPublication()->status) || $offer->getPublication()->status == stAllegroApi::STATUS_INACTIVE)
|
|
{
|
|
if ($offer->getId())
|
|
{
|
|
$actions = array_merge(array(array('type' => 'delete', 'label' => __('Usuń'), 'action' => '@stAllegroPlugin?action=delete&id=' . $sf_request->getParameter('id') . '&product_id=' . $sf_request->getParameter('product_id'), 'params' => array('confirm' => __('Jesteś pewien, że chcesz usunąć szkic')))), $actions);
|
|
}
|
|
|
|
$actions[] = array('type' => 'save', 'label' => __('Wystaw'), 'params' => array('name' => 'publish'));
|
|
}
|
|
else
|
|
{
|
|
if ($offer->getPublication() && ($offer->getPublication()->status == stAllegroApi::STATUS_ACTIVE || $offer->getPublication()->status == stAllegroApi::STATUS_ENDED))
|
|
{
|
|
$actions = array_merge(array(array('type' => 'duplicate', 'label' => __('Wystaw podobną'), 'action' => '@stAllegroPlugin?action=duplicate&id=' . $sf_request->getParameter('id') . '&product_id=' . $sf_request->getParameter('product_id'))), $actions);
|
|
}
|
|
|
|
if ($offer->getPublication() && $offer->getPublication()->status == stAllegroApi::STATUS_ENDED)
|
|
{
|
|
$actions[] = array('type' => 'save', 'label' => __('Wznów'), 'params' => array('name' => 'publish'));
|
|
}
|
|
|
|
if ($offer->getPublication() && $offer->getPublication()->status == stAllegroApi::STATUS_ACTIVE)
|
|
{
|
|
$actions = array_merge(array(array('type' => 'delete', 'label' => __('Zakończ'), 'action' => '@stAllegroPlugin?action=end&id=' . $sf_request->getParameter('id') . '&product_id=' . $sf_request->getParameter('product_id'), 'params' => array('confirm' => __('Jesteś pewien, że chcesz zakończyć ofertę')))), $actions);
|
|
}
|
|
}
|
|
|
|
echo st_get_admin_actions($actions);
|
|
?>
|
|
</div>
|
|
<div class="clr"></div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function($) {
|
|
$(document).ready(function() {
|
|
$('#edit_actions').stickyBox();
|
|
<?php if ($offer->getAllegroAuction()->getProduct()->isNew()): ?>
|
|
$('.st_product_options_picker').trigger('options_change');
|
|
<?php endif ?>
|
|
$('.update-pricing-fee-preview').change(function() {
|
|
var form = $(this).closest('form');
|
|
console.log(form);
|
|
$.post('<?php echo url_for('@stAllegroPlugin?action=ajaxFeePreviewUpdate&id=' . ($offer->getId() ? $offer->getId() : 0)) . '&status=' . ($offer->getPublication() && isset($offer->getPublication()->status) ? $offer->getPublication()->status : '') ?>', form.serialize(), function(response) {
|
|
$('#st-allegro-pricing-free-preview-container').html(response);
|
|
});
|
|
});
|
|
|
|
var container = $('#st-allegro-offer-form-container');
|
|
|
|
container.find('.number-type').change(function() {
|
|
var input = $(this);
|
|
var min = input.data('min');
|
|
var max = input.data('max');
|
|
var precision = input.data('precision');
|
|
var value = input.val();
|
|
|
|
value = stPrice.fixNumberFormat(value, precision);
|
|
|
|
if (value < min) {
|
|
value = min.toFixed(precision);
|
|
} else if (value > max) {
|
|
value = max.toFixed(precision);
|
|
}
|
|
|
|
input.val(value);
|
|
});
|
|
|
|
container.find('.string-type').change(function() {
|
|
var input = $(this);
|
|
input.val(input.val().trim());
|
|
});
|
|
|
|
var parameterDependency = JSON.parse($('#st_allegro_parameter_dependency').val());
|
|
|
|
function arrayIntersect(array1, array2) {
|
|
var array = array1.filter(function(n) {
|
|
return array2.indexOf(n) !== -1;
|
|
});
|
|
|
|
return array.length > 0;
|
|
}
|
|
|
|
function updateParameterDependencies(parameterId, valueIds) {
|
|
if (parameterDependency && parameterDependency[parameterId]) {
|
|
$.each(parameterDependency[parameterId], function(parameterDependencyId, dependency) {
|
|
if (dependency.required && dependency.required.length > 0) {
|
|
var parameterContainer = container.find('.st_allegro_offer_parameter_' + parameterDependencyId);
|
|
var label = parameterContainer.find('label');
|
|
|
|
if (arrayIntersect(dependency.required, valueIds)) {
|
|
label.addClass("required");
|
|
} else {
|
|
label.removeClass("required");
|
|
}
|
|
}
|
|
|
|
if (dependency.display && dependency.display.length > 0) {
|
|
|
|
var parameterContainer = container.find('.st_allegro_offer_parameter_' + parameterDependencyId);
|
|
|
|
if (arrayIntersect(dependency.display, valueIds)) {
|
|
parameterContainer.show();
|
|
} else {
|
|
parameterContainer.hide();
|
|
}
|
|
}
|
|
|
|
var parameter = container.find('[data-parameter-id='+parameterDependencyId+']');
|
|
|
|
|
|
|
|
if (parameter.is("select")) {
|
|
parameter.children().each(function() {
|
|
var child = $(this);
|
|
if (!child.data('depends-on-value-ids') || arrayIntersect(child.data('depends-on-value-ids'), valueIds)) {
|
|
child.show();
|
|
} else {
|
|
child.hide();
|
|
if (parameter.val() == child.val()) {
|
|
parameter.val(null);
|
|
}
|
|
}
|
|
});
|
|
|
|
parameter.trigger('chosen:update');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
container.find('.st_allegro_parameter').change(function() {
|
|
var formControl = $(this);
|
|
var row = formControl.closest('.row');
|
|
|
|
if (formControl.is("[type=checkbox]")) {
|
|
if (formControl.prop("checked")) {
|
|
var selectedIds = row.data("selected-ids");
|
|
selectedIds.push(formControl.val());
|
|
row.data("selected-ids", selectedIds);
|
|
} else {
|
|
var selectedIds = row.data("selected-ids");
|
|
var index = selectedIds.indexOf(formControl.val());
|
|
|
|
if (index > -1) {
|
|
selectedIds.splice(index, 1);
|
|
}
|
|
|
|
row.data("selected-ids", selectedIds);
|
|
}
|
|
}
|
|
|
|
if (formControl.is("select") || formControl.is("[type=checkbox]")) {
|
|
if (formControl.data('custom-value-enabled')) {
|
|
var custom = row.find('.st_allegro_parameter_dictionary_custom');
|
|
|
|
if (formControl.is("[type=checkbox]")) {
|
|
if (formControl.data('ambiguous-value-id') == formControl.val())
|
|
{
|
|
if (formControl.prop("checked")) {
|
|
custom.show().prop("disabled", false);
|
|
} else {
|
|
custom.hide().prop("disabled", true);
|
|
}
|
|
}
|
|
} else {
|
|
if (formControl.data('ambiguous-value-id') == formControl.val()) {
|
|
custom.show().prop("disabled", false);
|
|
} else {
|
|
custom.hide().prop("disabled", true);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (formControl.is("select")) {
|
|
updateParameterDependencies(formControl.data('parameter-id'), [ formControl.val() ]);
|
|
} else if (formControl.is("[type=checkbox]")) {
|
|
updateParameterDependencies(formControl.data('parameter-id'), row.data("selected-ids"));
|
|
}
|
|
}
|
|
});
|
|
|
|
$(document).trigger('chosen:init', '#st-allegro-offer-form-container select');
|
|
});
|
|
});
|
|
</script>
|