Skip to content

Commit

Permalink
PHP8 対応漏れ?「受注管理>受注登録」画面でシステムエラー EC-CUBE#829
Browse files Browse the repository at this point in the history
  • Loading branch information
seasoftjapan committed Feb 4, 2024
1 parent 21c0025 commit b8addb8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
6 changes: 2 additions & 4 deletions data/Smarty/templates/admin/order/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,15 @@
</td>
<!--{assign var=price value="`$arrForm.price.value[$product_index]`"}-->
<!--{assign var=quantity value="`$arrForm.quantity.value[$product_index]`"}-->
<!--{assign var=tax_rate value="`$arrForm.tax_rate.value[$product_index]`"}-->
<!--{assign var=tax_rule value="`$arrForm.tax_rule.value[$product_index]`"}-->
<input type="hidden" name="tax_rule[<!--{$product_index}-->]" value="<!--{$arrForm.tax_rule.value[$product_index]|h}-->" id="tax_rule_<!--{$product_index}-->" />
<td class="right">
<!--{$price|sfCalcIncTax:$tax_rate:$tax_rule|n2s}--><br />
<!--{$arrForm.price_inctax.value[$product_index]|n2s}--><br />
<!--{assign var=key value="tax_rate"}-->
<span class="attention"><!--{$arrErr[$key][$product_index]}--></span>
税率<input type="text" name="<!--{$key}-->[<!--{$product_index}-->]" value="<!--{$arrForm[$key].value[$product_index]|h}-->" size="3" class="box3" maxlength="<!--{$arrForm[$key].length}-->" style="<!--{$arrErr[$key][$product_index]|sfGetErrorColor}-->" id="<!--{$key}-->_<!--{$product_index}-->" />%
</td>
<td class="right"><!--{$price|sfCalcIncTax:$tax_rate:$tax_rule|sfMultiply:$quantity|n2s}--></td>
<td class="right"><!--{$arrForm.price_inctax.value[$product_index]|sfMultiply:$quantity|n2s}--></td>
</tr>
<!--{/section}-->
<tr>
Expand Down
37 changes: 33 additions & 4 deletions data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ public function lfInitParam(&$objFormParam)
$objFormParam->addParam('商品種別ID', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0');
$objFormParam->addParam('単価', 'price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0');
$objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0');
$objFormParam->addParam('税額', 'tax', '', '', [], [], false);
$objFormParam->addParam('税込単価', 'price_inctax', '', '', [], [], false);
$objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0');
$objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0');
$objFormParam->addParam('ポイント付与率', 'point_rate');
Expand Down Expand Up @@ -579,6 +581,7 @@ public function setOrderToFormParam(&$objFormParam, $order_id)
// 受注詳細を設定
$arrOrderDetail = $objPurchase->getOrderDetail($order_id, false);
$objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail));
$this->calcPriceInctax($objFormParam);

$arrShippingsTmp = $objPurchase->getShippings($order_id);
$arrShippings = array();
Expand Down Expand Up @@ -670,9 +673,16 @@ public function setOrderToFormParam(&$objFormParam, $order_id)
public function lfCheckError(&$objFormParam)
{
$objProduct = new SC_Product_Ex();
$arrErrTemp = $objFormParam->checkError();

if (!SC_Utils_Ex::isBlank($arrErrTemp)) {
return $arrErrTemp;
}

$this->calcPriceInctax($objFormParam);

$arrValues = $objFormParam->getHashArray();
$arrErr = array();
$arrErrTemp = $objFormParam->checkError();
$arrErrDate = array();
foreach ($arrValues['shipping_date_year'] as $key_index => $year) {
$month = $arrValues['shipping_date_month'][$key_index];
Expand Down Expand Up @@ -703,10 +713,9 @@ public function lfCheckError(&$objFormParam)
$totaltax = 0;
for ($i = 0; $i < $max; $i++) {
// 小計の計算
$tax = SC_Helper_TaxRule_Ex::calcTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]);
$subtotal += ($tax + $arrValues['price'][$i]) * $arrValues['quantity'][$i];
$subtotal += $arrValues['price_inctax'][$i] * $arrValues['quantity'][$i];
// 税額の計算
$totaltax += $tax * $arrValues['quantity'][$i];
$totaltax += $arrValues['tax'][$i] * $arrValues['quantity'][$i];
// 加算ポイントの計算
$totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];

Expand Down Expand Up @@ -1308,4 +1317,24 @@ public function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $i
return null;
}
}

/**
* 税込単価を計算する。
*
* @param SC_FormParam $objFormParam
* @return void
*/
public function calcPriceInctax(&$objFormParam)
{
$arrValues = $objFormParam->getHashArray();
foreach ($arrValues['price'] as $index => $dummy) {
// 税額
$arrValues['tax'][$index] =
$tax = SC_Helper_TaxRule_Ex::calcTax($arrValues['price'][$index], $arrValues['tax_rate'][$index], $arrValues['tax_rule'][$index]);

// 税込単価
$arrValues['price_inctax'][$index] = $tax + $arrValues['price'][$index];
}
$objFormParam->setParam($arrValues);
}
}
7 changes: 7 additions & 0 deletions data/class/util/SC_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,13 @@ public static function getHash2Array($hash, $requires = array())
/* かけ算をする(Smarty用) */
public static function sfMultiply($num1, $num2)
{
if (strlen($num1) == 0) {
return '';
}
if (strlen($num2) == 0) {
return '';
}

return $num1 * $num2;
}

Expand Down

0 comments on commit b8addb8

Please sign in to comment.