/** * 受注データを取得して, FormParam へ設定する. * * @param FormParam $objFormParam FormParam インスタンス * @param integer $order_id 取得元の受注ID * @return void */ public function setOrderToFormParam(&$objFormParam, $order_id) { /* @var $objPurchase PurchaseHelper */ $objPurchase = Application::alias('eccube.helper.purchase'); // 受注詳細を設定 $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); $objFormParam->setParam(Utils::sfSwapArray($arrOrderDetail)); $arrShippingsTmp = $objPurchase->getShippings($order_id); $arrShippings = array(); foreach ($arrShippingsTmp as $row) { // お届け日の処理 if (!Utils::isBlank($row['shipping_date'])) { $ts = strtotime($row['shipping_date']); $row['shipping_date_year'] = date('Y', $ts); $row['shipping_date_month'] = date('n', $ts); $row['shipping_date_day'] = date('j', $ts); } $arrShippings[$row['shipping_id']] = $row; } $objFormParam->setParam(Utils::sfSwapArray($arrShippings)); /* * 配送商品を設定 * * $arrShipmentItem['shipment_(key)'][$shipping_id][$item_index] = 値 * $arrProductQuantity[$shipping_id] = 配送先ごとの配送商品数量 */ $arrProductQuantity = array(); $arrShipmentItem = array(); foreach ($arrShippings as $shipping_id => $arrShipping) { $arrProductQuantity[$shipping_id] = count($arrShipping['shipment_item']); foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) { foreach ($arrItem as $item_key => $item_val) { $arrShipmentItem['shipment_' . $item_key][$shipping_id][$item_index] = $item_val; } } } $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); $objFormParam->setParam($arrShipmentItem); /* * 受注情報を設定 * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 * が渡ってくるため, $arrOrder で上書きする. */ $arrOrder = $objPurchase->getOrder($order_id); // 生年月日の処理 if (!Utils::isBlank($arrOrder['order_birth'])) { $order_birth = substr($arrOrder['order_birth'], 0, 10); $arrOrderBirth = explode("-", $order_birth); $arrOrder['order_birth_year'] = intval($arrOrderBirth[0]); $arrOrder['order_birth_month'] = intval($arrOrderBirth[1]); $arrOrder['order_birth_day'] = intval($arrOrderBirth[2]); } $objFormParam->setParam($arrOrder); // ポイントを設定 list($db_point, $rollback_point) = Application::alias('eccube.helper.db')->getRollbackPoint($order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status']); $objFormParam->setValue('total_point', $db_point); $objFormParam->setValue('point', $rollback_point); if (!Utils::isBlank($objFormParam->getValue('customer_id'))) { $arrCustomer = Application::alias('eccube.helper.customer')->sfGetCustomerDataFromId($objFormParam->getValue('customer_id')); $objFormParam->setValue('customer_point', $arrCustomer['point']); } }
/** * フォームパラメーター取得 * - 登録モード * * @param FormParam $objFormParam FormParamインスタンス * @return array フォームパラメーター配列 */ public function lfGetFormParam_Complete(&$objFormParam) { $arrForm = $objFormParam->getHashArray(); $arrForm['category_id'] = Utils::jsonDecode($arrForm['category_id']); $objFormParam->setValue('category_id', $arrForm['category_id']); return $arrForm; }
/** * @param FormParam $objFormParam */ public function lfCheckError($post, $objFormParam, PaymentHelper $objPayment) { // DBのデータを取得 $arrPaymentData = $objPayment->get($post['payment_id']); // 手数料を設定できない場合には、手数料を0にする if ($arrPaymentData['charge_flg'] == 2) { $objFormParam->setValue('charge', '0'); } // 入力データを渡す。 $arrRet = $objFormParam->getHashArray(); /* @var $objErr CheckError */ $objErr = Application::alias('eccube.check_error', $arrRet); $objErr->arrErr = $objFormParam->checkError(); // 利用条件(下限)チェック if ($arrRet['rule_max'] < $arrPaymentData['rule_min'] and $arrPaymentData['rule_min'] != '') { $objErr->arrErr['rule'] = '利用条件(下限)は' . $arrPaymentData['rule_min'] . '円以上にしてください。<br>'; } // 利用条件(上限)チェック if ($arrRet['upper_rule'] > $arrPaymentData['upper_rule_max'] and $arrPaymentData['upper_rule_max'] != '') { $objErr->arrErr['upper_rule'] = '利用条件(上限)は' . $arrPaymentData['upper_rule_max'] . '円以下にしてください。<br>'; } // 利用条件チェック $objErr->doFunc(array('利用条件(~円以上)', '利用条件(~円以下)', 'rule_max', 'upper_rule'), array('GREATER_CHECK')); return $objErr->arrErr; }
/** * 入力済みの購入情報をフォームに設定する. * * 受注一時テーブル, セッションの配送情報から入力済みの購入情報を取得し, * フォームに設定する. * * @param FormParam $objFormParam FormParam インスタンス * @param PurchaseHelper $objPurchase PurchaseHelper インスタンス * @param integer $uniqid 購入一時情報のユニークID * @return void */ public function setFormParams(&$objFormParam, &$objPurchase, $uniqid) { $arrOrderTemp = $objPurchase->getOrderTemp($uniqid); if (Utils::isBlank($arrOrderTemp)) { $arrOrderTemp = array('order_email' => '', 'order_birth' => ''); } $arrShippingTemp = $objPurchase->getShippingTemp(); $objFormParam->setParam($arrOrderTemp); /* * count($arrShippingTemp) > 1 は複数配送であり, * $arrShippingTemp[0] は注文者が格納されている */ if (count($arrShippingTemp) > 1) { $objFormParam->setParam($arrShippingTemp[1]); } else { if ($arrOrderTemp['deliv_check'] == 1) { $objFormParam->setParam($arrShippingTemp[1]); } else { $objFormParam->setParam($arrShippingTemp[0]); } } $objFormParam->setValue('order_email02', $arrOrderTemp['order_email']); $objFormParam->setDBDate($arrOrderTemp['order_birth'], 'order_year', 'order_month', 'order_day'); }
/** * * テンプレートの文言をフォームに入れる。 * @param FormParam $objFormParam */ public function changeData(&$objFormParam) { $template_id = $objFormParam->getValue('template_id'); // 未選択時 if (strlen($template_id) === 0) { $mailTemplates = null; // 有効選択時 } elseif (Utils::sfIsInt($template_id)) { /* @var $objMailtemplate MailtemplateHelper */ $objMailtemplate = Application::alias('eccube.helper.mailtemplate'); $mailTemplates = $objMailtemplate->get($template_id); // 不正選択時 } else { trigger_error('テンプレートの指定が不正。', E_USER_ERROR); } if (empty($mailTemplates)) { foreach (array('subject', 'header', 'footer') as $key) { $objFormParam->setValue($key, ''); } } else { $objFormParam->setParam($mailTemplates); } return $objFormParam; }
/** * 会員情報をフォームに設定する. * * @param integer $customer_id 会員ID * @param FormParam $objFormParam FormParam インスタンス * @return void */ public function setCustomerTo($customer_id, &$objFormParam) { $arrCustomer = Application::alias('eccube.helper.customer')->sfGetCustomerDataFromId($customer_id); foreach ($arrCustomer as $key => $val) { $objFormParam->setValue('order_' . $key, $val); } // 誕生日の処理 if (!Utils::isBlank($objFormParam->getValue('order_birth'))) { $order_birth = substr($objFormParam->getValue('order_birth'), 0, 10); $arrOrderBirth = explode("-", $order_birth); $objFormParam->setValue('order_birth_year', intval($arrOrderBirth[0])); $objFormParam->setValue('order_birth_month', intval($arrOrderBirth[1])); $objFormParam->setValue('order_birth_day', intval($arrOrderBirth[2])); } $objFormParam->setValue('customer_id', $customer_id); $objFormParam->setValue('customer_point', $arrCustomer['point']); }
/** * 入力チェックを行う. * * @param FormParam $objFormParam FormParam インスタンス * @return array エラー情報の配列 */ public function lfCheckError(FormParam &$objFormParam, &$arrCartItem) { /* @var $objCartSess CartSession */ $objCartSess = Application::alias('eccube.cart_session'); $objFormParam->setValue('quantity', $objFormParam->getValue('quantity', 0)); $arrErr = $objFormParam->checkError(); $arrParams = $objFormParam->getSwapArray(); if (empty($arrErr)) { $arrTarget = array('product_class_id', 'quantity', 'shipping'); $arrParams = $objFormParam->getSwapArray($arrTarget); foreach ($arrParams as $index => $arrParam) { // 数量0で、お届け先を選択している場合 if ($arrParam['quantity'] == 0 && !Utils::isBlank($arrParam['shipping'])) { $arrErr['shipping'][$index] = '※ 数量が0の場合、お届け先を入力できません。<br />'; } // 数量の入力があり、お届け先を選択していない場合 if ($arrParam['quantity'] > 0 && Utils::isBlank($arrParam['shipping'])) { $arrErr['shipping'][$index] = '※ お届け先が入力されていません。<br />'; } } } // 入力エラーが無い場合、カゴの中身との数量の整合を確認 if (empty($arrErr)) { $arrQuantity = array(); // 入力内容を集計 foreach ($arrParams as $arrParam) { $product_class_id = $arrParam['product_class_id']; $arrQuantity[$product_class_id] += $arrParam['quantity']; } // カゴの中身と突き合わせ foreach ($arrCartItem as $item) { $product_class_id = $item['id']; // 差異がある場合、エラーを記録 if ($item['quantity'] != $arrQuantity[$product_class_id]) { foreach ($arrParams as $index => $arrParam) { if ($arrParam['product_class_id'] == $product_class_id) { $arrErr['line_of_num'][$product_class_id] = "※ 数量合計を「{$item['quantity']}」にしてください。<br />"; } } } } } return $arrErr; }
/** * アップロードしたファイルを削除する. * * TODO 一時ファイルの削除 * * @param FormParam $objFormParam FormParam インスタンス * @return void */ public function doFileDelete(&$objFormParam) { $objImage = new Image(DOWN_TEMP_REALDIR); $arrRealFileName = $objFormParam->getValue('down_realfilename'); $index = $objFormParam->getValue('upload_index'); $objImage->deleteImage($arrRealFileName[$index], DOWN_SAVE_REALDIR); $arrRealFileName[$index] = ''; $objFormParam->setValue('down_realfilename', $arrRealFileName); }