first commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<?php use_helper('stAdminGenerator') ?>
|
||||
<?php echo st_get_admin_actions_head() ?>
|
||||
<?php echo st_get_admin_action('more', __('Stan magazynowy opcji'), '@stProductOptionsBackend?action=stockList&product_id='.$product->getId()) ?>
|
||||
<?php echo st_get_admin_actions_foot() ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php st_include_component('stProduct', '_editMenu', array("related_object" => $related_object)) ?>
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
<?php
|
||||
use_helper('stProductImage');
|
||||
/**
|
||||
* @var sfAsset[] $images
|
||||
* @var ProductOptionsValue $product_options_value
|
||||
*/
|
||||
?>
|
||||
|
||||
<div id="st_product_options_images">
|
||||
<label class="image" title="">
|
||||
<span class="none"><?php echo __('Brak') ?></span>
|
||||
<?php echo st_admin_radio_tag('product_options_value[sf_asset_id]', null, null === $product_options_value->getSfAssetId()) ?>
|
||||
</label>
|
||||
<?php foreach($images as $image): $preview = '<img src="'.st_product_image_path($image, 'small').'" style="max-width: 100%">' ?>
|
||||
<label class="image" title="<?php echo htmlspecialchars($preview) ?>">
|
||||
<span style="background-image: url(<?php echo st_product_image_path($image, 'small') ?>)"></span>
|
||||
<?php echo st_admin_radio_tag('product_options_value[sf_asset_id]', $image->getId(), $product_options_value->getSfAssetId() == $image->getId()) ?>
|
||||
</label>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<?php init_tooltip('#st_product_options_images .image') ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php st_include_partial('stProductOptionsBackend/value_edit_color', array('value' => $product_options_value, 'form_name' => 'product_options_value')) ?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @var ProductOptionsField $product_options_field
|
||||
*/
|
||||
|
||||
if ($product_options_field->isNew())
|
||||
{
|
||||
$parent = ProductOptionsValuePeer::retrieveByPK($sf_request->getParameter('parent_id'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$values = $product_options_field->getProductOptionsValues();
|
||||
$parent = $values[0]->getParent();
|
||||
}
|
||||
|
||||
echo st_admin_checkbox_tag($name, true, $product_options_field->getIsActive() && $parent->getIsActive(), [
|
||||
'disabled' => !$parent->getIsActive(),
|
||||
]);
|
||||
|
||||
if (!$parent->getIsActive())
|
||||
{
|
||||
echo input_hidden_tag($name, 0);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @var ProductOptionsValue $product_options_value
|
||||
*/
|
||||
|
||||
|
||||
$disabled = !$product_options_value->getParent()->getIsActive() || !$product_options_value->getProductOptionsField()->getIsActive();
|
||||
|
||||
echo st_admin_checkbox_tag($name, true, $product_options_value->getIsActive() && !$disabled, [
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
|
||||
if ($disabled)
|
||||
{
|
||||
echo input_hidden_tag($name, 0);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php echo input_tag('product_options_value[stock]', stPrice::round($product_options_value->getStock()), array ('size' => 10, 'disabled' => null === $product_options_value->getStock())) ?>
|
||||
|
||||
<?php echo st_product_uom($related_object) ?>
|
||||
<label style="float: none; margin-left: 5px">
|
||||
<?php echo st_admin_checkbox_tag('product_options_value[validate_stock]', 1, null !== $product_options_value->getStock() || $product_options_value->isNew()) ?>
|
||||
<?php echo __('Włączony') ?>
|
||||
</label>
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
<?php
|
||||
/**
|
||||
* @var ProductOptionsFilter $product_options_filter
|
||||
*/
|
||||
|
||||
if ($type == 'list')
|
||||
{
|
||||
echo $product_options_filter->getFilterTypeLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo select_tag('product_options_filter[filter_type]', options_for_select(ProductOptionsFilterPeer::getFilterTypes($i18n), $product_options_filter->getFilterType()));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php st_include_partial('stProduct/header', array(
|
||||
'related_object' => isset($related_object) ? $related_object : null,
|
||||
'title' => $title,
|
||||
'culture' => isset($culture) ? $culture : null,
|
||||
'route' => $route,
|
||||
)) ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php st_include_component('stProduct', 'listMenu', array("related_object" => null)) ?>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php use_helper('stUrl', 'stProductOptionsBackend') ?>
|
||||
|
||||
<?php if(!$ajax): ?>
|
||||
<?php use_stylesheet('backend/stProductOptionsPicker.css?v1') ?>
|
||||
<div class="st_product_options_picker" data-namespace="<?php echo $namespace ?>">
|
||||
<?php endif ?>
|
||||
<ul>
|
||||
<?php st_product_options_picker_show($namespace, $options, $selected) ?>
|
||||
</ul>
|
||||
<?php echo input_hidden_tag($namespace, implode(',', array_values($selected)), array('class' => 'st_product_options_selected')) ?>
|
||||
<?php if(!$ajax): ?>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function() {
|
||||
$('.st_product_options_picker').each(function() {
|
||||
var current = $(this);
|
||||
if (!current.data('initialized')) {
|
||||
current.data('initialized', true);
|
||||
|
||||
current.on('change', 'select', function() {
|
||||
var select = $(this);
|
||||
var selects = current.find('select');
|
||||
var post = selects.serialize()+'&namespace='+current.data('namespace')+'&changed='+select.data('field');
|
||||
selects.attr('disabled', true);
|
||||
|
||||
current.trigger('before_options_change');
|
||||
|
||||
$.post("<?php echo st_url_for('stProductOptionsBackend/ajaxOptionChangeUpdate?product_id='.$product->getId()) ?>", post, function(response) {
|
||||
current.html(response.content);
|
||||
current.trigger('options_change', [ response.price, response.stock, response.man_code, response.options ]);
|
||||
|
||||
$(document).trigger("chosen:init", current.find('select'));
|
||||
});
|
||||
});
|
||||
|
||||
$(document).trigger("chosen:init", current.find('select'));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php echo st_get_admin_actions_head('style="margin-top: 10px; float: right"') ?>
|
||||
<?php echo st_get_admin_action('list', __('Pokaż listę', null, 'stAdminGeneratorPlugin'), 'stProduct/depositoryList', array("link_to" => "stProduct/depositoryList","name" => "list",)) ?>
|
||||
<?php echo st_get_admin_action('save', __('Zapisz', null, 'stAdminGeneratorPlugin'), null, array('class' => 'update-list-form', 'id' => 'update-list-form')) ?>
|
||||
<?php echo st_get_admin_actions_foot() ?>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @var ProductOptionsValue $product_options_value
|
||||
*/
|
||||
|
||||
echo select_tag('product_options_value[price_type]', options_for_select(array(
|
||||
'netto' => __('Netto'),
|
||||
'brutto' => __('Brutto'),
|
||||
), $product_options_value->getPriceType()));
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use_helper('stPrice');
|
||||
echo input_tag('product_options_value['.$product_options_value->getId().'][stock]', $product_options_value->getStock(), array(
|
||||
'tabindex' => $product_options_value->getId(),
|
||||
'type' => 'number',
|
||||
'step' => 1,
|
||||
'min' => 0,
|
||||
'class' => 'stock_value',
|
||||
'style' => 'text-align: center; vertical-align: middle; margin-right: 5px; width: 70px', 'disabled' => null === $product_options_value->getStock()));
|
||||
echo checkbox_tag('product_options_value['.$product_options_value->getId().'][stock_enabled]', 1, null !== $product_options_value->getStock(), array('class' => 'stock_enabled'));
|
||||
?>
|
||||
<input type="hidden" name="product_options_value[<?php echo $product_options_value->getId() ?>][disabled]" value="<?php echo intval(null === $product_options_value->getStock()) ?>" />
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php $path_objects = $product_options_value->getPath() ?>
|
||||
|
||||
<?php //use_stylesheet('backend/stProductOptionsPlugin.css')?>
|
||||
|
||||
<?php $path = '<ul style="text-align: left">' ?>
|
||||
<?php foreach($path_objects as $path_object): ?>
|
||||
<?php $path .= $path_object->isRoot() ? '' : '<li><strong>'.$path_object->getProductOptionsField()->getName().':</strong> '.$path_object->getValue().'</li>' ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if($product_options_value->getProductOptionsField()): ?>
|
||||
<?php $path .= '<li><strong>'.$product_options_value->getProductOptionsField()->getName().':</strong> ' ?>
|
||||
<?php endif; ?>
|
||||
<?php echo $path.$product_options_value->getValue().'</li></ul>' ?>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php st_include_partial('stProductOptionsBackend/tree', array(
|
||||
'root' => $root,
|
||||
'fetch_route' => '@stProductOptionsBackend?action=ajaxJstreeTemplateJson&template_id='.$product_options_template->getId(),
|
||||
'delete_route' => '@stProductOptionsBackend?action=ajaxJstreeTemplateDelete&template_id='.$product_options_template->getId(),
|
||||
'add_route' => '@stProductOptionsBackend?action=ajaxJstreeTemplateAdd&template_id='.$product_options_template->getId(),
|
||||
'move_route' => '@stProductOptionsBackend?action=ajaxJstreeTemplateMove&template_id='.$product_options_template->getId(),
|
||||
'edit_field_route' => '@stProductOptionsBackend?action=templateFieldEdit&template_id='.$product_options_template->getId(),
|
||||
'edit_value_route' => '@stProductOptionsBackend?action=templateValueEdit&template_id='.$product_options_template->getId(),
|
||||
));
|
||||
@@ -0,0 +1 @@
|
||||
<?php st_include_partial('stProductOptionsBackend/value_edit_color', array('value' => $product_options_default_value, 'form_name' => 'product_options_default_value')) ?>
|
||||
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
use_helper("stJQueryTools");
|
||||
use_stylesheet("backend/stProductOptions.css?v6");
|
||||
use_javascript("/jQueryTools/jstree/js/jstree.min.js?v1");
|
||||
plupload_init();
|
||||
st_colorpicker_init();
|
||||
if (!isset($tree_id))
|
||||
{
|
||||
$tree_id = "st_product_options_tree";
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="<?php echo $tree_id ?>" style="width: 100%">
|
||||
<div class="st_product_options_tree_container">
|
||||
<div class="jstree"></div>
|
||||
</div>
|
||||
<div class="st_product_options_window_container"></div>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
|
||||
<?php echo init_tooltip('.jstree', array('trigger' => 'mouseenter')) ?>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
var windowContainer = $("#<?php echo $tree_id ?> > .st_product_options_window_container");
|
||||
|
||||
var tree = null;
|
||||
var selectedNode = null;
|
||||
var culture = "<?php echo $sf_request->getParameter("culture", stLanguage::getHydrateCulture()) ?>";
|
||||
|
||||
windowContainer.on("submit", "form", function(e) {
|
||||
var form = $(this);
|
||||
var parameters = form.serialize();
|
||||
showPreloader();
|
||||
$.post(form.prop("action"), parameters, function(response) {
|
||||
windowContainer.html(response.content);
|
||||
windowContainer.find('select').selectBox();
|
||||
var type = tree._get_type(selectedNode);
|
||||
if (type != "root") {
|
||||
tree.set_text(selectedNode, type == "field" ? response.data.name : response.data.value);
|
||||
}
|
||||
selectedNode.data("entity-data", response.data);
|
||||
hidePreloader();
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
windowContainer.on("click", "input[name=delete]", function(e) {
|
||||
var button = $(this);
|
||||
if (window.confirm(button.data("admin-confirm"))) {
|
||||
showPreloader();
|
||||
$.post(button.data("admin-action-url"), function() {
|
||||
tree.delete_node(selectedNode);
|
||||
hidePreloader();
|
||||
});
|
||||
}
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
|
||||
function showPreloader() {
|
||||
$(document).trigger("preloader", "show");
|
||||
}
|
||||
|
||||
function hidePreloader() {
|
||||
$(document).trigger("preloader", "close");
|
||||
}
|
||||
|
||||
function prepareEntityData(data) {
|
||||
var result = {};
|
||||
|
||||
if (data) {
|
||||
$.each(data, function(name, value) {
|
||||
if (value != null) {
|
||||
result[name] = typeof value === 'boolean' ? Number(value) : value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getFieldsOrder(tree, parent) {
|
||||
var fields_order = {};
|
||||
|
||||
tree._get_children(parent).each(function() {
|
||||
var field = $(this);
|
||||
if (field.data("id")) {
|
||||
fields_order[field.data("id")] = field.index();
|
||||
}
|
||||
});
|
||||
|
||||
return fields_order;
|
||||
}
|
||||
|
||||
function editOption(tree, node) {
|
||||
var type = tree._get_type(node);
|
||||
let parent = null;
|
||||
|
||||
switch (type) {
|
||||
case "root":
|
||||
var url = "<?php echo isset($edit_root_route) ? st_url_for($edit_root_route) : '' ?>";
|
||||
|
||||
break;
|
||||
|
||||
case "value":
|
||||
var url = "<?php echo st_url_for($edit_value_route) ?>";
|
||||
const parentField = tree._get_parent(node);
|
||||
parent = tree._get_parent(parentField);
|
||||
break;
|
||||
|
||||
default:
|
||||
var url = "<?php echo st_url_for($edit_field_route) ?>";
|
||||
parent = tree._get_parent(node);
|
||||
break;
|
||||
}
|
||||
|
||||
if (url) {
|
||||
showPreloader();
|
||||
|
||||
var parameters = { id: node.data("id"), culture: culture, parent_id: parent ? parent.data("id") : '' };
|
||||
|
||||
if (!node.data("id") && type == "field") {
|
||||
parameters.entity_data = prepareEntityData(node.data("entity-data"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
$.get(url, parameters, function(response) {
|
||||
windowContainer.html(response.content);
|
||||
windowContainer.find('select').selectBox();
|
||||
node.data("entity-data", response.data);
|
||||
hidePreloader();
|
||||
});
|
||||
} else {
|
||||
windowContainer.html("");
|
||||
}
|
||||
}
|
||||
|
||||
var tree_container = $("#<?php echo $tree_id ?> .jstree").jstree({
|
||||
core: {
|
||||
animation: 100
|
||||
},
|
||||
plugins: ["themes", "json_data", "dnd", "ui", "crrm", "contextmenu", "types"],
|
||||
themes: {
|
||||
url: "/jQueryTools/jstree/themes/default/style.css",
|
||||
theme: "default"
|
||||
},
|
||||
types: {
|
||||
valid_children: ["root"],
|
||||
root: {
|
||||
valid_children: ["field"]
|
||||
},
|
||||
field: {
|
||||
valid_children: ["value"]
|
||||
},
|
||||
value: {
|
||||
valid_children: ["field"]
|
||||
}
|
||||
},
|
||||
crrm: {
|
||||
move: {
|
||||
check_move: function(m) {
|
||||
console.log(m);
|
||||
var parent = m.np;
|
||||
var nodeType = this._get_type(m.o);
|
||||
|
||||
if (("after" == m.p || "before" == m.p) && parent < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parentType = this._get_type(parent);
|
||||
|
||||
if (nodeType == "field" && parentType == "field" || nodeType == 'value' && parentType == 'value' || nodeType == "value" && parent.data("id") != m.op.data("id")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
json_data: {
|
||||
progressive_render: true,
|
||||
progressive_unload: true,
|
||||
data: function(node, cb) {
|
||||
if (node == -1) {
|
||||
cb([<?php echo json_encode($root) ?>]);
|
||||
} else {
|
||||
$.get("<?php echo st_url_for($fetch_route) ?>", { id: node.data("id"), type: this._get_type(node), culture: culture } , function(response) {
|
||||
cb(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
ui: {
|
||||
select_limit: 1,
|
||||
},
|
||||
contextmenu: {
|
||||
select_node: true,
|
||||
items: function(node) {
|
||||
var type = this._get_type(node);
|
||||
var items = {
|
||||
create: {
|
||||
label: "<?php echo __("Dodaj", null, "stCategoryTree") ?>",
|
||||
action: function(node) {
|
||||
var type = this._get_type(node);
|
||||
this.create(node, "last", {
|
||||
data: type == "field" ? "<?php echo __("Nowa wartość") ?>" : "<?php echo __("Nowa opcja") ?>"
|
||||
});
|
||||
},
|
||||
separator_after: true,
|
||||
},
|
||||
remove: {
|
||||
label: "<?php echo __("Usuń", null, "stCategoryTree") ?>",
|
||||
action: function(node) {
|
||||
var tree = this;
|
||||
var type = tree._get_type(node);
|
||||
|
||||
if (node.data("id")) {
|
||||
var parent = tree._get_parent(node);
|
||||
|
||||
var is_valid = type != "value" || tree._get_children(parent).length > 1;
|
||||
|
||||
if (!is_valid) {
|
||||
window.alert("<?php echo __("Opcja musi posiadać przynajmniej jedną wartość") ?>");
|
||||
} else if (window.confirm("<?php echo __("Zamierzasz usunąć opcję. Jesteś pewien, że chcesz kontynuować?") ?>")) {
|
||||
showPreloader();
|
||||
$.post("<?php echo st_url_for($delete_route) ?>", { id: node.data("id"), type: type }, function(response) {
|
||||
tree.delete_node(node);
|
||||
hidePreloader();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
tree.delete_node(node);
|
||||
}
|
||||
},
|
||||
_disabled: type == "root",
|
||||
separator_after: true,
|
||||
},
|
||||
}
|
||||
|
||||
var result = tree_container.triggerHandler("init.contextmenu", [items, node, tree]);
|
||||
|
||||
if (result) {
|
||||
items = result;
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
.on("create_node.jstree", function(e, data) {
|
||||
var node = data.rslt.obj;
|
||||
var tree = data.inst;
|
||||
|
||||
var parent = tree._get_parent(node);
|
||||
var type = tree._get_type(parent);
|
||||
|
||||
if (type == "root" || type == "value") {
|
||||
node.attr("rel", "field");
|
||||
} else {
|
||||
node.attr("rel", "value");
|
||||
}
|
||||
})
|
||||
.on("rename_node.jstree", function(e, data) {
|
||||
var node = data.rslt.obj;
|
||||
var name = data.rslt.name;
|
||||
var tree = data.inst;
|
||||
var type = tree._get_type(node);
|
||||
|
||||
if (!node.data("id")) {
|
||||
if (type == "value") {
|
||||
var field = tree._get_parent(node);
|
||||
var parent = tree._get_parent(field);
|
||||
|
||||
if (!field.data("id")) {
|
||||
var fieldData = field.data("entity-data");
|
||||
fieldData.field_order = field.index();
|
||||
fieldData.fields_order = getFieldsOrder(tree, parent);
|
||||
|
||||
var parameters = {
|
||||
entity_field_data: prepareEntityData(fieldData),
|
||||
parent_id: parent.data("id"),
|
||||
value: data.rslt.name,
|
||||
}
|
||||
|
||||
$.post("<?php echo st_url_for($add_route) ?>", parameters, function(response) {
|
||||
node.data("id", response.data.id);
|
||||
field.data("id", response.data.product_options_field_id);
|
||||
if (node.data("select_node")) {
|
||||
editOption(tree, node);
|
||||
node.data("select_node", false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var parameters = {
|
||||
field_id: field.data("id"),
|
||||
parent_id: parent.data("id"),
|
||||
value: data.rslt.name,
|
||||
}
|
||||
|
||||
$.post("<?php echo st_url_for($add_route) ?>", parameters, function(response) {
|
||||
node.data("id", response.data.id);
|
||||
if (node.data("select_node")) {
|
||||
editOption(tree, node);
|
||||
node.data("select_node", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
node.data("entity-data", {
|
||||
name: name,
|
||||
});
|
||||
|
||||
if (node.data("select_node")) {
|
||||
editOption(tree, node);
|
||||
node.data("select_node", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.on("select_node.jstree", function(e, data) {
|
||||
tree = data.inst;
|
||||
var treeContainer = tree.get_container();
|
||||
var type = tree._get_type(data.rslt.obj);
|
||||
var node = data.rslt.obj;
|
||||
|
||||
if (node.find('.jstree-rename-input').length) {
|
||||
node.data("select_node", true);
|
||||
node.find('.jstree-rename-input').blur();
|
||||
}
|
||||
else {
|
||||
editOption(tree, node);
|
||||
}
|
||||
|
||||
selectedNode = data.rslt.obj;
|
||||
}).on("move_node.jstree", function(e, data) {
|
||||
var tree = data.inst;
|
||||
var node = data.rslt.o;
|
||||
|
||||
if (node.data("id")) {
|
||||
var target = data.rslt.r;
|
||||
var type = data.rslt.p;
|
||||
var nodeType = tree._get_type(node);
|
||||
var parent = data.rslt.np;
|
||||
var parent_id = nodeType == 'value' ? tree._get_parent(parent).data("id") : parent.data("id");
|
||||
var parameters = { id: node.data("id"), type: nodeType, parent_id: parent_id, culture: culture };
|
||||
|
||||
switch (type) {
|
||||
case "after":
|
||||
var next = tree._get_next(node, true);
|
||||
|
||||
if (next) {
|
||||
parameters.prev_sibling_id = next.data("id");
|
||||
}
|
||||
break;
|
||||
|
||||
case "before":
|
||||
parameters.prev_sibling_id = target.data("id");
|
||||
break;
|
||||
}
|
||||
|
||||
if (nodeType == "field") {
|
||||
parameters.fields_order = getFieldsOrder(tree, parent);
|
||||
}
|
||||
|
||||
showPreloader();
|
||||
$.post("<?php echo st_url_for($move_route) ?>", parameters, function(response) {
|
||||
hidePreloader();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
<div id="color_type">
|
||||
<?php echo select_tag($form_name.'[color_type]', options_for_select(array(__("Wybierz kolor"), __("Wybierz zdjęcie")), $value->getUseImageAsColor())) ?>
|
||||
</div>
|
||||
<div id="color_image"<?php if (!$value->getUseImageAsColor()): ?> style="display: none"<?php endif ?>>
|
||||
<?php echo plupload_images_tag($form_name.'[color_image]', $value->getUseImageAsColor() && $value->getColorImagePath() ? array($value->getColorImagePath()) : array(), array('limit' => 1)) ?>
|
||||
</div>
|
||||
<div id="color_picker"<?php if ($value->getUseImageAsColor()): ?> style="display: none"<?php endif ?>>
|
||||
<?php echo st_colorpicker_input_tag($form_name.'[color]', !$value->getUseImageAsColor() && $value->getColor() ? $value->getColor() : 'ffffff') ?>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$.cssHooks.backgroundColor = {
|
||||
get: function(elem) {
|
||||
if (elem.currentStyle)
|
||||
var bg = elem.currentStyle["backgroundColor"];
|
||||
else if (window.getComputedStyle)
|
||||
var bg = document.defaultView.getComputedStyle(elem,
|
||||
null).getPropertyValue("background-color");
|
||||
if (bg.search("rgb") == -1)
|
||||
return bg;
|
||||
else {
|
||||
bg = bg.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
function hex(x) {
|
||||
return ("0" + parseInt(x).toString(16)).slice(-2);
|
||||
}
|
||||
return "#" + hex(bg[1]) + hex(bg[2]) + hex(bg[3]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$('#<?php echo $form_name ?>_color').change(function() {
|
||||
$(this).val($('#<?php echo $form_name ?>_color-trigger').css('backgroundColor').slice(1));
|
||||
});
|
||||
|
||||
$('#<?php echo $form_name ?>_color_type').change(function() {
|
||||
|
||||
if (this.selectedIndex > 0) {
|
||||
$('#color_picker').hide();
|
||||
$('#color_image').show();
|
||||
} else {
|
||||
$('#color_picker').show();
|
||||
$('#color_image').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php require sfConfig::get('sf_module_cache_dir') . '/auto' . ucfirst($sf_context->getModuleName()) . '/templates/' . basename(__FILE__); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
function fixModificator() {
|
||||
var input = $(this);
|
||||
var val = $.trim(input.val()).replace(/[^-+,%0-9\.]/ig, '');
|
||||
|
||||
var prefix = val[0] == '+' || val[0] == '-' ? val[0] : '';
|
||||
|
||||
var suffix = val.substr(-1) == '%' ? '%' : '';
|
||||
|
||||
var value = val.replace(',', '.').replace(/[^0-9\.]/ig, '');
|
||||
|
||||
input.val(prefix + value + suffix);
|
||||
}
|
||||
|
||||
$('#product_options_value_price').change(fixModificator);
|
||||
$('#product_options_value_weight').change(fixModificator);
|
||||
$('#product_options_value_validate_stock').change(function() {
|
||||
$('#product_options_value_stock').attr('disabled', !this.checked);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php use_helper('stProgressBar'); ?>
|
||||
<?php echo progress_bar('stProductOptions_fix', 'stFixProductOptions', 'fix', stFixProductOptions::count());?>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php use_helper('stProgressBar'); ?>
|
||||
<?php echo progress_bar('stProductOptions_fix', 'stProductOptionsStockFix', 'execute', stProductOptionsStockFix::count());?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
use_helper('stAdminGenerator', 'stProductOptionsBackend');
|
||||
/**
|
||||
* @var ProductOptionsValue $root
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php st_include_partial('stProduct/header', array(
|
||||
'related_object' => $product,
|
||||
'title' => __('Opcje produktu'),
|
||||
'route' => '@stProductOptionsBackend?action=manager&product_id=' . $product->getId(),
|
||||
'culture' => $product->getCulture()
|
||||
)) ?>
|
||||
<?php st_include_partial('stProduct/edit_menu', array(
|
||||
'related_object' => $product,
|
||||
'forward_parameters' => array('product_id' => $product->getId(), 'category_id' => $sf_request->getParameter('category_id'))
|
||||
)) ?>
|
||||
<?php st_include_partial('stAdminGenerator/message') ?>
|
||||
|
||||
<?php st_include_partial('stProductOptionsBackend/tree', array(
|
||||
'tree_id' => 'st_product_options_tree',
|
||||
'root' => ProductOptionsValuePeer::doSelectRootAsJsTreeFormat($product),
|
||||
'fetch_route' => '@stProductOptionsBackend?action=ajaxJstreeJson&product_id=' . $product->getId(),
|
||||
'delete_route' => '@stProductOptionsBackend?action=ajaxJstreeDelete&product_id=' . $product->getId(),
|
||||
'add_route' => '@stProductOptionsBackend?action=ajaxJstreeAdd&product_id=' . $product->getId(),
|
||||
'edit_field_route' => '@stProductOptionsBackend?action=fieldEdit&product_id=' . $product->getId(),
|
||||
'edit_value_route' => '@stProductOptionsBackend?action=edit&product_id=' . $product->getId(),
|
||||
'edit_root_route' => '@stProductOptionsBackend?action=rootEdit&product_id=' . $product->getId(),
|
||||
'move_route' => '@stProductOptionsBackend?action=ajaxJstreeMove&product_id=' . $product->getId(),
|
||||
)) ?>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
let tippyInstance = null;
|
||||
|
||||
$('#st_product_options_tree').on("click", function() {
|
||||
if (tippyInstance) {
|
||||
tippyInstance.hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#st_product_options_tree .jstree').on("init.contextmenu", function(e, items, node, tree) {
|
||||
var type = tree._get_type(node);
|
||||
items.use_template = {
|
||||
label: "<?php echo __("Dodaj szablon") ?>",
|
||||
_disabled: type == 'field',
|
||||
action: function(node) {
|
||||
tippyInstance = tippy(node.find(' > a').get(0), {
|
||||
allowHTML: true,
|
||||
interactive: true,
|
||||
animation: 'scale',
|
||||
trigger: 'manual',
|
||||
zIndex: 10000,
|
||||
placement: 'top-start',
|
||||
offset: [5, 10],
|
||||
appendTo: function() {
|
||||
return document.body;
|
||||
},
|
||||
onShow(instance) {
|
||||
$.get('<?php echo st_url_for('@stProductOptionsBackend?action=selectTemplate') ?>', function(response) {
|
||||
instance.setContent(response);
|
||||
$('#st_product_options_template_picker select').change(function() {
|
||||
var select = $(this);
|
||||
|
||||
if (select.val()) {
|
||||
$(document).trigger("preloader", "show");
|
||||
$.post(select.closest('form').prop('action'), { parent_id: node.data("id"), template_id: select.val() }, function() {
|
||||
instance.hide();
|
||||
$(document).trigger("preloader", "close");
|
||||
if (!tree.is_open(node)) {
|
||||
tree.load_node(node, function() {
|
||||
tree.open_node(node);
|
||||
});
|
||||
} else {
|
||||
tree.refresh(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onHidden(instance) {
|
||||
instance.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
tippyInstance.show();
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php st_include_partial('stProduct/footer') ?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use_helper('stProductOptionsBackend');
|
||||
|
||||
$select_template = st_product_options_template_select_tag('product_options_template', null, array(
|
||||
"include_custom" => __("Wybierz szablon")
|
||||
));
|
||||
?>
|
||||
|
||||
<form action="<?php echo st_url_for('@stProductOptionsBackend?action=ajaxJstreeAddTemplate') ?>" id="st_product_options_template_picker">
|
||||
<?php if ($select_template): ?>
|
||||
<p><?php echo $select_template ?></p>
|
||||
<?php else: ?>
|
||||
<p><?php echo __('Nie dodałeś jeszcze żadnych szablonów') ?></p>
|
||||
<?php endif ?>
|
||||
<a href="<?php echo st_url_for('@stProductOptionsBackend?action=templateList') ?>" target="_blank"><?php echo __('Dodaj nowy szablon') ?></a>
|
||||
</form>
|
||||
Reference in New Issue
Block a user