Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8 対応漏れ?「受注管理>受注登録」画面でシステムエラー #829、Warning 回避 #836

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
78 changes: 56 additions & 22 deletions data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,23 +393,25 @@ public function lfInitParam(&$objFormParam)
$objFormParam->addParam('お支払い方法', 'payment_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
$objFormParam->addParam('対応状況', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
$objFormParam->addParam('お支払方法名称', 'payment_method');

// 受注詳細情報
$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('商品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');
$objFormParam->addParam('商品コード', 'product_code');
$objFormParam->addParam('商品名', 'product_name');
$objFormParam->addParam('規格名1', 'classcategory_name1');
$objFormParam->addParam('規格名2', 'classcategory_name2');
$objFormParam->addParam('税率', 'tax_rate', INT_LEN, 'n', array('NUM_CHECK'));
$objFormParam->addParam('課税規則', 'tax_rule', INT_LEN, 'n', array('NUM_CHECK'));
$objFormParam->addParam('メモ', 'note', MTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
$objFormParam->addParam('削除用項番', 'delete_no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));

// 受注詳細情報
$objFormParam->addParam('商品種別ID', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []);
$objFormParam->addParam('単価', 'price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []);
$objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []);
$objFormParam->addParam('税額', 'price_tax', '', '', [], [], false);
$objFormParam->addParam('税込単価', 'price_inctax', '', '', [], [], false);
$objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []);
$objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), []);
$objFormParam->addParam('ポイント付与率', 'point_rate', []);
$objFormParam->addParam('商品コード', 'product_code', []);
$objFormParam->addParam('商品名', 'product_name', []);
$objFormParam->addParam('規格名1', 'classcategory_name1', []);
$objFormParam->addParam('規格名2', 'classcategory_name2', []);
$objFormParam->addParam('税率', 'tax_rate', INT_LEN, 'n', array('NUM_CHECK'), []);
$objFormParam->addParam('課税規則', 'tax_rule', INT_LEN, 'n', array('NUM_CHECK'), []);

// DB読込用
$objFormParam->addParam('小計', 'subtotal');
$objFormParam->addParam('合計', 'total');
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,20 +673,27 @@ 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];
$day = $arrValues['shipping_date_day'][$key_index];
$objError = new SC_CheckError_Ex(array('shipping_date_year' => $year,
'shipping_date_month' => $month,
'shipping_date_day' => $day));
$objError->doFunc(array('お届け日', 'shipping_date_year', 'shipping_date_month', 'shipping_date_day'), array('CHECK_DATE'));
$arrErrDate['shipping_date_year'][$key_index] = $objError->arrErr['shipping_date_year'];
foreach ($objError->arrErr as $key => $error) {
$arrErrTemp[$key][$key_index] = $error;
}
}
$arrErrTemp = array_merge($arrErrTemp, $arrErrDate);

// 複数項目チェック
$year = $arrValues['order_birth_year'];
Expand All @@ -694,7 +704,9 @@ public function lfCheckError(&$objFormParam)
'order_birth_day' => $day));
$objError->doFunc(array('生年月日', 'order_birth_year', 'order_birth_month', 'order_birth_day'),
array('CHECK_BIRTHDAY'));
$arrErrTemp['order_birth_year'] = $objError->arrErr['order_birth_year'];
foreach ($objError->arrErr as $key => $error) {
$arrErrTemp[$key] = $error;
}

// 商品の種類数
$max = count($arrValues['quantity']);
Expand All @@ -703,10 +715,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['price_tax'][$i] * $arrValues['quantity'][$i];
// 加算ポイントの計算
$totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i];

Expand Down Expand Up @@ -1195,6 +1206,9 @@ public function setProductsQuantity(&$objFormParam)
$arrUpdateQuantity = array();
foreach ($arrShipmentsItems as $arritems) {
foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) {
if (!isset($arrUpdateQuantity[$shipment_product_class_id])) {
$arrUpdateQuantity[$shipment_product_class_id] = 0;
}
$arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index];
}
}
Expand Down Expand Up @@ -1308,4 +1322,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['price_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
Loading