first commit
This commit is contained in:
6
plugins/smArmetAdditionalFieldPlugin/config/config.php
Normal file
6
plugins/smArmetAdditionalFieldPlugin/config/config.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
if (SF_APP == 'backend')
|
||||
{
|
||||
$dispatcher->connect('stAdminGenerator.generateStProduct', array('smArmetAdditionalFieldListener', 'generateStProduct'));
|
||||
$dispatcher->connect('autoStProductActions.updateListItem', array('smArmetAdditionalFieldListener', 'updateListItem'));
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class smArmetAdditionalFieldListener
|
||||
{
|
||||
public static function generateStProduct(sfEvent $event)
|
||||
{
|
||||
$generator = $event->getSubject();
|
||||
|
||||
$generator->insertParameterAfter('list.display[producer_id]', array('_weight', '_availability_id', '_stock'));
|
||||
|
||||
$generator->setValueForParameter('list.fields.weight', array(
|
||||
'name' => "Waga [kg]",
|
||||
'module' => "smArmetAdditionalFieldBackend",
|
||||
));
|
||||
|
||||
$generator->setValueForParameter('list.fields.availability_id', array(
|
||||
'name' => "Dostępność",
|
||||
'module' => "smArmetAdditionalFieldBackend",
|
||||
));
|
||||
|
||||
$generator->setValueForParameter('list.fields.stock', array(
|
||||
'name' => "Magazyn",
|
||||
'module' => "smArmetAdditionalFieldBackend",
|
||||
));
|
||||
}
|
||||
|
||||
public static function updateListItem(sfEvent $event)
|
||||
{
|
||||
$product = $event['modelInstance'];
|
||||
$action = $event->getSubject();
|
||||
|
||||
$request = $action->getRequestParameter('product');
|
||||
|
||||
$data = $request[$product->getId()];
|
||||
|
||||
if (isset($data['weight']))
|
||||
{
|
||||
$product->setWeight($data['weight']);
|
||||
}
|
||||
|
||||
if (isset($data['stock']))
|
||||
{
|
||||
$product->setStock($data['stock']);
|
||||
}
|
||||
|
||||
if (isset($data['availability_id']))
|
||||
{
|
||||
$product->setAvailabilityId($data['availability_id'] ? $data['availability_id'] : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php if ($sf_user->getParameter('mode', null, 'soteshop/stAdminGenerator/stProduct/list/config') == 'edit'): ?>
|
||||
<?php echo object_product_availability($product, null, array('control_name' => 'product['.$product->getId().'][availability_id]')); ?>
|
||||
<?php else:
|
||||
$availabilities = AvailabilityPeer::doSelectOrderByStockCached();
|
||||
$availability = isset($availabilities[$product->getAvailabilityId()]) ? $availabilities[$product->getAvailabilityId()] : __('Ustaw według magazynu', null, 'stProduct');
|
||||
?>
|
||||
<?php echo $availability ?>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php if ($sf_user->getParameter('mode', null, 'soteshop/stAdminGenerator/stProduct/list/config') == 'edit'): ?>
|
||||
<?php if ($product->getOptHasOptions() > 1 && $product->hasStockManagmentWithOptions()): ?>
|
||||
<?php echo st_link_to(__('Edytuj', null, 'stProduct'), 'stProduct/optionsStockList?id='.$product->getId()) ?>
|
||||
<?php else: ?>
|
||||
<?php echo input_tag('product['.$product->getId().'][stock]', stPrice::round($product->getStock()), array('style' => 'width: 60px')); ?>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
var field = $('#product_<?php echo $product->getId() ?>_stock');
|
||||
field.change(function() {
|
||||
this.value = stPrice.fixNumberFormat(this.value);
|
||||
});
|
||||
|
||||
field.keypress(function(event) {
|
||||
if (event.keyCode == Event.KEY_RETURN)
|
||||
{
|
||||
this.value = stPrice.fixNumberFormat(this.value);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endif ?>
|
||||
<?php else: ?>
|
||||
<?php echo stPrice::round($product->getStock()) ?>
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
#st_record_list th:nth-of-type(10), #st_record_list th:nth-of-type(11), #st_record_list td:nth-of-type(12), #st_record_list td:nth-of-type(13){
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php if ($sf_user->getParameter('mode', null, 'soteshop/stAdminGenerator/stProduct/list/config') == 'edit'): ?>
|
||||
<?php echo input_tag('product['.$product->getId().'][weight]', stPrice::round($product->getWeight()), array('style' => 'width: 60px')); ?>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
var field = $('#product_<?php echo $product->getId() ?>_weight');
|
||||
field.change(function() {
|
||||
this.value = stPrice.fixNumberFormat(this.value);
|
||||
});
|
||||
|
||||
field.keypress(function(event) {
|
||||
if (event.keyCode == Event.KEY_RETURN)
|
||||
{
|
||||
this.value = stPrice.fixNumberFormat(this.value);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php else: ?>
|
||||
<?php echo stPrice::round($product->getWeight()) ?>
|
||||
<?php endif ?>
|
||||
Reference in New Issue
Block a user