44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
use_helper('stPrice');
|
|
|
|
function st_depository_list_stock(Product $product, $list_mode = null)
|
|
{
|
|
if (!$product->hasStockManagmentWithOptions())
|
|
{
|
|
$stock = stPrice::round($product->getStock());
|
|
}
|
|
else
|
|
{
|
|
$c = new Criteria();
|
|
$c->addSelectColumn('SUM('.ProductOptionsValuePeer::STOCK.')');
|
|
$c->add(ProductOptionsValuePeer::PRODUCT_ID, $product->getId());
|
|
$c->add(ProductOptionsValuePeer::LFT, sprintf('%s - %s = 1', ProductOptionsValuePeer::RGT, ProductOptionsValuePeer::LFT) , Criteria::CUSTOM);
|
|
|
|
$rs = ProductOptionsValuePeer::doSelectRS($c);
|
|
|
|
$stock = stPrice::round($rs->next() ? $rs->get(1) : 0);
|
|
}
|
|
|
|
if ($list_mode == 'edit')
|
|
{
|
|
$content = input_tag('product['.$product->getId().'][stock]', $stock, array(
|
|
'onchange' => 'this.value=stPrice.fixNumberFormat(this.value, 2)',
|
|
'size' => 6,
|
|
'disabled' => false !== $product->hasStockManagmentWithOptions()
|
|
));
|
|
}
|
|
else
|
|
{
|
|
$content = $stock;
|
|
|
|
}
|
|
|
|
return $content;
|
|
}
|
|
|
|
function st_depository_product_options_link(Product $product)
|
|
{
|
|
|
|
return $product->hasStockManagmentWithOptions() ? st_get_admin_button('edit', 'Opcje produktu', '@stDepositoryPlugin?action=optionsList&product_id='.$product->getId(), array('size' => 'small')) : '';
|
|
} |