当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderDetail::save方法代码示例

本文整理汇总了PHP中OrderDetail::save方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderDetail::save方法的具体用法?PHP OrderDetail::save怎么用?PHP OrderDetail::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrderDetail的用法示例。


在下文中一共展示了OrderDetail::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeFormWidget

 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new OrderForm();
     if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) {
         $order = $form->save();
         $order->setUid(md5(rand(1111, 9999) . time()));
         $order->save();
         // link order details
         $this->shopping_cart = $shopping_cart = $this->getUser()->getShoppingCart();
         $this->items = $shopping_cart->getItems();
         foreach ($shopping_cart->getItems() as $i => $item) {
             $od = new OrderDetail();
             $od->fromArray(array('product_id' => $item->getId(), 'order_id' => $order->id, 'quantity' => $item->getQuantity(), 'price' => $item->getPrice()));
             $od->save();
         }
         if (sfConfig::get('app_send_order', false)) {
             dm::enableMailer();
             //send mail
             $message = $this->getMailer()->compose($_from = dmConfig::get('orderEmail'), $_to = array($order->email, dmConfig::get('orderEmail')), $_subj = '[' . dmConfig::get('siteName') . '] thanks for order');
             $message->setBody($this->getPartial('order/mailOrder', array('order' => $order, 'companyName' => dmConfig::get('companyName'), 'companyPhone' => dmConfig::get('companyPhone'), 'siteUrl' => dmConfig::get('siteUrl'), 'siteName' => dmConfig::get('siteName'))));
             $message->setContentType('text/html');
             $this->getMailer()->send($message);
         }
         // if send order
         // clear cart now
         $shopping_cart->clear();
         //redirect to order info
         $this->redirect($this->getHelper()->link('main/ordershow?uid=' . $order->uid)->getHref());
         //$this->redirectBack();
     }
     $this->forms['Order'] = $form;
 }
开发者ID:rafix,项目名称:dmshop,代码行数:32,代码来源:actions.class.php

示例2: actionCheckout

 public function actionCheckout()
 {
     if ($postData = Yii::$app->request->post()) {
         $model = new Product();
         $order = new Order();
         $order->shipping_address = $postData['address'];
         $order->city = $postData['city'];
         $order->country = $postData['country'];
         $order->postal_code = $postData['postal_code'];
         $order->status = 0;
         $order->save();
         $order_id = $order->order_id;
         $items = [];
         foreach ($postData['qty'] as $key => $val) {
             $order_detail = new OrderDetail();
             $order_detail->order_id = $order_id;
             $order_detail->prod_id = $postData['prod_id'][$key];
             $order_detail->quantity = $postData['qty'][$key];
             $order_detail->unit_price = $postData['prod_price'][$key];
             $order_detail->unit_sum = $postData['prod_price'][$key] * $order_detail->quantity;
             $order_detail->save();
             $item = new Item();
             $item->setName($postData['prod_name'][$key])->setCurrency('USD')->setQuantity($val)->setPrice($postData['prod_price'][$key]);
             $items[] = $item;
         }
         $itemList = new ItemList();
         $itemList->setItems($items);
         $payment = preparePaypal($itemList);
         print_r($items);
     }
     exit;
 }
开发者ID:syedmaaz,项目名称:marxmall-,代码行数:32,代码来源:CartController.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new OrderDetail();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['OrderDetail'])) {
         $model->attributes = $_POST['OrderDetail'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:ndrahawk,项目名称:Biruni-ERP,代码行数:17,代码来源:OrderDetailController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $carts = Cart::content();
     if (Cart::count() < 1) {
         Session::flash('flash_error', 'You need add at least one product!');
     }
     $order = new Order();
     $order->user_id = Auth::user()->id;
     $order->date = date('Y-m-d h:i:s');
     $order->total = money_format('%.2n', Cart::total());
     $order->save();
     foreach ($carts as $row) {
         $product = Product::find($row->id)->firstOrFail();
         $orderDetail = new OrderDetail();
         $orderDetail->order_id = $order->id;
         $orderDetail->product_id = $product->code;
         $orderDetail->quantity = $row->qty;
         $orderDetail->sub_total = money_format('%.2n', $row->subtotal);
         $orderDetail->save();
         Cart::destroy();
     }
     Session::flash('message', 'Successfully created order!');
     return Redirect::to('orders');
 }
开发者ID:elioth010,项目名称:carretilla_online,代码行数:29,代码来源:OrderController.php

示例5: addPartialSlipDetail

 public function addPartialSlipDetail($order_detail_list)
 {
     foreach ($order_detail_list as $id_order_detail => $tab) {
         $order_detail = new OrderDetail($id_order_detail);
         $order_slip_resume = self::getProductSlipResume($id_order_detail);
         if ($tab['amount'] + $order_slip_resume['amount_tax_incl'] > $order_detail->total_price_tax_incl) {
             $tab['amount'] = $order_detail->total_price_tax_incl - $order_slip_resume['amount_tax_incl'];
         }
         if ($tab['amount'] == 0) {
             continue;
         }
         if ($tab['quantity'] + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
             $tab['quantity'] = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
         }
         $tab['amount_tax_excl'] = $tab['amount_tax_incl'] = $tab['amount'];
         $id_tax = (int) Db::getInstance()->getValue('SELECT `id_tax` FROM `' . _DB_PREFIX_ . 'order_detail_tax` WHERE `id_order_detail` = ' . (int) $id_order_detail);
         if ($id_tax > 0) {
             $rate = (double) Db::getInstance()->getValue('SELECT `rate` FROM `' . _DB_PREFIX_ . 'tax` WHERE `id_tax` = ' . (int) $id_tax);
             if ($rate > 0) {
                 $rate = 1 + $rate / 100;
                 $tab['amount_tax_excl'] = $tab['amount_tax_excl'] / $rate;
             }
         }
         if ($tab['quantity'] > 0 && $tab['quantity'] > $order_detail->product_quantity_refunded) {
             $order_detail->product_quantity_refunded = $tab['quantity'];
             $order_detail->save();
         }
         $insertOrderSlip = array('id_order_slip' => (int) $this->id, 'id_order_detail' => (int) $id_order_detail, 'product_quantity' => (int) $tab['quantity'], 'amount_tax_excl' => (double) $tab['amount_tax_excl'], 'amount_tax_incl' => (double) $tab['amount_tax_incl']);
         Db::getInstance()->insert('order_slip_detail', $insertOrderSlip);
     }
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:31,代码来源:OrderSlip.php

示例6: addPartialSlipDetail

 public function addPartialSlipDetail($order_detail_list)
 {
     // start of implementation of the module code - taxamo
     $reg_taxamo_transaction = null;
     $last_id_order_transaction = Taxamoeuvat::getLastIdByOrder($this->id_order);
     if (!is_null($last_id_order_transaction)) {
         $reg_taxamo_transaction = Taxamoeuvat::idExistsTransaction((int) $last_id_order_transaction);
     }
     // end of code implementation module - taxamo
     foreach ($order_detail_list as $id_order_detail => $tab) {
         $order_detail = new OrderDetail($id_order_detail);
         $order_slip_resume = self::getProductSlipResume($id_order_detail);
         if ($tab['amount'] + $order_slip_resume['amount_tax_incl'] > $order_detail->total_price_tax_incl) {
             $tab['amount'] = $order_detail->total_price_tax_incl - $order_slip_resume['amount_tax_incl'];
         }
         if ($tab['amount'] == 0) {
             continue;
         }
         if ($tab['quantity'] + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
             $tab['quantity'] = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
         }
         $tab['amount_tax_excl'] = $tab['amount_tax_incl'] = $tab['amount'];
         $id_tax = (int) Db::getInstance()->getValue('SELECT `id_tax` FROM `' . _DB_PREFIX_ . 'order_detail_tax` WHERE `id_order_detail` = ' . (int) $id_order_detail);
         if ($id_tax > 0) {
             $rate = (double) Db::getInstance()->getValue('SELECT `rate` FROM `' . _DB_PREFIX_ . 'tax` WHERE `id_tax` = ' . (int) $id_tax);
             if ($rate > 0) {
                 $rate = 1 + $rate / 100;
                 $tab['amount_tax_excl'] = $tab['amount_tax_excl'] / $rate;
             }
         }
         if ($tab['quantity'] > 0 && $tab['quantity'] > $order_detail->product_quantity_refunded) {
             $order_detail->product_quantity_refunded = $tab['quantity'];
             $order_detail->save();
         }
         $insert_order_slip = array('id_order_slip' => (int) $this->id, 'id_order_detail' => (int) $id_order_detail, 'product_quantity' => (int) $tab['quantity'], 'amount_tax_excl' => (double) $tab['amount_tax_excl'], 'amount_tax_incl' => (double) $tab['amount_tax_incl']);
         Db::getInstance()->insert('order_slip_detail', $insert_order_slip);
         // start of implementation of the module code - taxamo
         if (!is_null($reg_taxamo_transaction)) {
             Tools::taxamoRefunds($reg_taxamo_transaction[0]['key_transaction'], $order_detail->product_id, (double) $tab['amount_tax_incl']);
         }
         // end of code implementation module - taxamo
     }
 }
开发者ID:hjcalvo,项目名称:prestashop-taxamo-plugin,代码行数:43,代码来源:OrderSlip.php

示例7: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     //inisialisasi model Order
     $order = new Order('search');
     $order->unsetAttributes();
     // clear any default values
     if (isset($_GET['Order'])) {
         $order->attributes = $_GET['Order'];
     }
     $orderbaru = new Order('baru');
     $orderbaru->RESEP = 1;
     $orderbaru->orderdetail = new OrderDetail('baru');
     //inisialisasi model OrderDetail
     $order_detail = new OrderDetail();
     //inisialisasi model Pelanggan
     $pelanggan = new Pasien('search');
     $pelanggan->unsetAttributes();
     // clear any default values
     if (isset($_GET['Pasien'])) {
         $pelanggan->attributes = $_GET['Pasien'];
     }
     $newpl = new Pasien('baru');
     $newpl->ID_LAYANAN = 1;
     if (isset($_POST['Pasien'])) {
         $newpl->attributes = $_POST['Pasien'];
         $newpl->BIAYA_REGISTRASI = 5000;
         $newpl->TANGGAL_REGISTRASI = date('Y-m-d H:i:s');
         if ($newpl->save()) {
             Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             $this->redirect(array('/site'));
         }
     }
     if (isset($_POST['Order'])) {
         $orderbaru->attributes = $_POST['Order'];
         $orderbaru->TANGGAL_ORDER = date('Y-m-d H:i:s');
         $orderbaru->USER_PEMBUAT = Yii::app()->user->nama;
         if ($orderbaru->validate()) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if (!$orderbaru->save()) {
                     throw new Exception();
                 }
                 $subtotal = 0;
                 foreach ($_POST['OrderDetail'] as $kd => $detail) {
                     if (!empty($detail['JUMLAH'])) {
                         $od = new OrderDetail('baru');
                         $od->ID_ITEM = $kd;
                         $od->KODE_ORDER = $orderbaru->KODE_ORDER;
                         //proses harga by resep
                         $od->HARGA = Item::getHargaByResep($kd, $orderbaru->RESEP);
                         $od->JUMLAH = $detail['JUMLAH'];
                         $od->DISKON = $detail['DISKON'];
                         //$od->DISKON = Barang::getDiskonById($kd);
                         //update stok barang
                         Item::updateStokItem($kd, $detail['JUMLAH']);
                         $subtotal += $od->JUMLAH * $od->HARGA;
                         if (!$od->save()) {
                             throw new Exception();
                         }
                     }
                 }
                 $transaction->commit();
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             } catch (Exception $ex) {
                 $transaction->rollback();
                 echo $ex->getMessage();
                 exit;
             }
         }
     }
     // $dataProvider=new CActiveDataProvider('Pasien',array(
     // 	'pagination'=>false,
     // ));
     $this->render('create', array('order' => $order, 'order_detail' => $order_detail, 'pelanggan' => $pelanggan, 'pelanggan_baru' => $newpl, 'orderbaru' => $orderbaru));
 }
开发者ID:bangphe,项目名称:klinik,代码行数:80,代码来源:OrderController.php

示例8: create

    public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
    {
        $currency = new Currency((int) $order->id_currency);
        $order_slip = new OrderSlip();
        $order_slip->id_customer = (int) $order->id_customer;
        $order_slip->id_order = (int) $order->id;
        $order_slip->conversion_rate = $currency->conversion_rate;
        if ($add_tax) {
            $add_or_remove = 'add';
            $inc_or_ex_1 = 'excl';
            $inc_or_ex_2 = 'incl';
        } else {
            $add_or_remove = 'remove';
            $inc_or_ex_1 = 'incl';
            $inc_or_ex_2 = 'excl';
        }
        $order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = 0;
        $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = 0;
        $order_slip->partial = 0;
        if ($shipping_cost !== false) {
            $order_slip->shipping_cost = true;
            $carrier = new Carrier((int) $order->id_carrier);
            $address = Address::initialize($order->id_address_delivery, false);
            $tax_calculator = $carrier->getTaxCalculator($address);
            $order_slip->{'total_shipping_tax_' . $inc_or_ex_1} = $shipping_cost === null ? $order->{'total_shipping_tax_' . $inc_or_ex_1} : (double) $shipping_cost;
            if ($tax_calculator instanceof TaxCalculator) {
                $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($order_slip->{'total_shipping_tax_' . $inc_or_ex_1}), _PS_PRICE_COMPUTE_PRECISION_);
            } else {
                $order_slip->{'total_shipping_tax_' . $inc_or_ex_2} = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
            }
        } else {
            $order_slip->shipping_cost = false;
        }
        $order_slip->amount = 0;
        $order_slip->{'total_products_tax_' . $inc_or_ex_1} = 0;
        $order_slip->{'total_products_tax_' . $inc_or_ex_2} = 0;
        foreach ($product_list as &$product) {
            $order_detail = new OrderDetail((int) $product['id_order_detail']);
            $price = (double) $product['unit_price'];
            $quantity = (int) $product['quantity'];
            $order_slip_resume = OrderSlip::getProductSlipResume((int) $order_detail->id);
            if ($quantity + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
                $quantity = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
            }
            if ($quantity == 0) {
                continue;
            }
            $order_detail->product_quantity_refunded += $quantity;
            $order_detail->save();
            $address = Address::initialize($order->id_address_invoice, false);
            $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $order_detail->product_id);
            $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
            $order_slip->{'total_products_tax_' . $inc_or_ex_1} += $price * $quantity;
            if (in_array(Configuration::get('PS_ROUND_TYPE'), array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
                if (!isset($total_products[$id_tax_rules_group])) {
                    $total_products[$id_tax_rules_group] = 0;
                } else {
                    if (!isset($total_products[$id_tax_rules_group . '_' . $id_address])) {
                        $total_products[$id_tax_rules_group . '_' . $id_address] = 0;
                    }
                }
            }
            $product_tax_incl_line = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price) * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
            switch (Configuration::get('PS_ROUND_TYPE')) {
                case Order::ROUND_ITEM:
                    $product_tax_incl = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_) * $quantity;
                    $total_products[$id_tax_rules_group] += $product_tax_incl;
                    break;
                case Order::ROUND_LINE:
                    $product_tax_incl = $product_tax_incl_line;
                    $total_products[$id_tax_rules_group] += $product_tax_incl;
                    break;
                case Order::ROUND_TOTAL:
                    $product_tax_incl = $product_tax_incl_line;
                    $total_products[$id_tax_rules_group . '_' . $id_address] += $price * $quantity;
                    break;
            }
            $product['unit_price_tax_' . $inc_or_ex_1] = $price;
            $product['unit_price_tax_' . $inc_or_ex_2] = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
            $product['total_price_tax_' . $inc_or_ex_1] = Tools::ps_round($price * $quantity, _PS_PRICE_COMPUTE_PRECISION_);
            $product['total_price_tax_' . $inc_or_ex_2] = Tools::ps_round($product_tax_incl, _PS_PRICE_COMPUTE_PRECISION_);
            $product['product_id'] = $order_detail->product_id;
        }
        unset($product);
        foreach ($total_products as $key => $price) {
            if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
                $tmp = explode('_', $key);
                $address = Address::initialize((int) $tmp[1], true);
                $tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
                $order_slip->{'total_products_tax_' . $inc_or_ex_2} += Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), _PS_PRICE_COMPUTE_PRECISION_);
            } else {
                $order_slip->{'total_products_tax_' . $inc_or_ex_2} += $price;
            }
        }
        $order_slip->{'total_products_tax_' . $inc_or_ex_2} -= (double) $amount && !$amount_choosen ? (double) $amount : 0;
        $order_slip->amount = $amount_choosen ? (double) $amount : $order_slip->{'total_products_tax_' . $inc_or_ex_1};
        $order_slip->shipping_cost_amount = $order_slip->{'total_shipping_tax_' . $inc_or_ex_1};
        if ((double) $amount && !$amount_choosen) {
            $order_slip->order_slip_type = 1;
        }
//.........这里部分代码省略.........
开发者ID:ankkal,项目名称:SPN_project,代码行数:101,代码来源:OrderSlip.php

示例9: completeOrder

 public function completeOrder($tid)
 {
     $transaction = Transaction::getTransactionBasedOnTID($tid);
     $user = new User($transaction->getUser());
     $order = new Order();
     $order->setTid($transaction->getTid());
     $order->setUser($transaction->getUser());
     $order->setCustomerName($user->getName());
     $order->setUserEmail($user->getEmail());
     $order->setPhone($transaction->getPhone());
     $order->setShippingStreet($transaction->getShippingStreet());
     $order->setShippingCity($transaction->getShippingCity());
     $order->setShippingPostal($transaction->getShippingPostal());
     $order->setShippingProvince($transaction->getShippingProvince());
     $order->setShippingCountry($transaction->getShippingCountry());
     $order->setBillingStreet($transaction->getBillingStreet());
     $order->setBillingCity($transaction->getBillingCity());
     $order->setBillingPostal($transaction->getBillingPostal());
     $order->setBillingProvince($transaction->getBillingProvince());
     $order->setBillingCountry($transaction->getBillingCountry());
     $order->setCostSubtotal($transaction->getCostSubtotal());
     $order->setCostTax($transaction->getCostTax());
     $order->setCostShipping($transaction->getCostShipping());
     $order->setCostTotal($transaction->getCostTotal());
     $order->setIp($transaction->getIp());
     $order->setShippingClass($transaction->getShippingClass());
     $order->setPaymentClass($transaction->getPaymentClass());
     $order->setDeliveryInstructions($transaction->getDeliveryInstructions());
     $order->setStatus('Pending');
     $order->save();
     $cartItems = CartItem::getAll($transaction->getSession());
     foreach ($cartItems as $cartItem) {
         $product = new Product($cartItem->getProduct());
         $orderDetail = new OrderDetail();
         $orderDetail->setOrderNb($order->getId());
         $orderDetail->setProduct($product->getId());
         $orderDetail->setProductName($product->getName());
         $orderDetail->setQuantity($cartItem->getQuantity());
         $orderDetail->save();
         $cartItem->delete();
     }
     $transaction->delete();
     //Send an email to the user
     $this->sendEmailOrderComplete($order->getId());
     return true;
 }
开发者ID:anas,项目名称:feedstore,代码行数:46,代码来源:EComm.php

示例10: actionIndex

 public function actionIndex()
 {
     if (!WebUser::isGuest() && WebUser::isAdmin()) {
         $this->render('index');
     } elseif (!WebUser::isGuest() && WebUser::isKasir()) {
         //inisialisasi model Order
         $order = new Order('search');
         $order->unsetAttributes();
         // clear any default values
         if (isset($_GET['Order'])) {
             $order->attributes = $_GET['Order'];
         }
         $orderbaru = new Order('baru');
         $orderbaru->RESEP = 1;
         $orderbaru->orderdetail = new OrderDetail('baru');
         //inisialisasi model OrderDetail
         $order_detail = new OrderDetail();
         //inisialisasi model Pelanggan
         $pelanggan = new Pasien('search');
         $pelanggan->unsetAttributes();
         // clear any default values
         if (isset($_GET['Pasien'])) {
             $pelanggan->attributes = $_GET['Pasien'];
         }
         $newpl = new Pasien('baru');
         // $newpl->ID_LAYANAN = 1;
         if (isset($_POST['Pasien'])) {
             $newpl->attributes = $_POST['Pasien'];
             //$newpl->BIAYA_REGISTRASI = 5000;
             $newpl->TANGGAL_REGISTRASI = date('Y-m-d H:i:s');
             if ($newpl->save()) {
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/site'));
             }
         }
         if (isset($_POST['Order'])) {
             //var_dump($_POST['Order']);
             //die();
             $orderbaru->attributes = $_POST['Order'];
             $orderbaru->TANGGAL_ORDER = date('Y-m-d H:i:s');
             $orderbaru->USER_PEMBUAT = Yii::app()->user->nama;
             if ($orderbaru->save()) {
                 $subtotal = 0;
                 foreach ($_POST['OrderDetail'] as $detail) {
                     //var_dump($_POST['OrderDetail']);
                     //die();
                     $od = new OrderDetail('baru');
                     $od->ID_ITEM = $detail['ID_ITEM'];
                     $od->KODE_ORDER = $orderbaru->KODE_ORDER;
                     //proses harga by resep
                     $od->HARGA = Item::getHargaByResep($detail['ID_ITEM'], $orderbaru->RESEP);
                     $od->JUMLAH = $detail['JUMLAH'];
                     $od->DISKON = $detail['DISKON'];
                     $od->save();
                     Item::updateStokItem($detail['ID_ITEM'], $detail['JUMLAH']);
                     $subtotal += $od->JUMLAH * $od->HARGA;
                 }
                 Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                 $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             }
             // if ($orderbaru->validate()) {
             //     $transaction = Yii::app()->db->beginTransaction();
             //     try {
             //         if (!$orderbaru->save())
             //             throw new Exception;
             //         $subtotal = 0;
             //         foreach ($_POST['OrderDetail'] as $kd => $detail) {
             //             if (!empty($detail['JUMLAH'])) {
             //                 $od = new OrderDetail('baru');
             //              $od->ID_ITEM = $kd;
             //              $od->KODE_ORDER = $orderbaru->KODE_ORDER;
             //              //proses harga by resep
             //              $od->HARGA = Item::getHargaByResep($kd, $orderbaru->RESEP);
             //              $od->JUMLAH = $detail['JUMLAH'];
             //              //$od->DISKON = $detail['DISKON'];
             //              //$od->DISKON = Barang::getDiskonById($kd);
             //              //var_dump($_POST['OrderDetail']);
             // 	//die();
             //              //update stok barang
             //              Item::updateStokItem($kd, $detail['JUMLAH']);
             //              $subtotal += $od->JUMLAH * $od->HARGA;
             //                 if (!$od->save())
             //                     throw new Exception;
             //             }
             //         }
             //         $transaction->commit();
             //         Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
             //         $this->redirect(array('/order/view', 'id' => $orderbaru->KODE_ORDER));
             //     } catch (Exception $ex) {
             //         $transaction->rollback();
             //         echo $ex->getMessage(); exit();
             //     }
             // }
         }
         $criteria = new CDbCriteria();
         $criteria->order = 'TANGGAL_REGISTRASI DESC';
         $dataProvider = new CActiveDataProvider('Pasien', array('criteria' => $criteria, 'pagination' => false));
         $pasien_today = Pasien::listRegisterToday();
         $this->render('index3', array('dataProvider' => $dataProvider, 'order' => $order, 'order_detail' => $order_detail, 'pelanggan' => $pelanggan, 'pelanggan_baru' => $newpl, 'orderbaru' => $orderbaru, 'pasien_today' => $pasien_today));
     } else {
//.........这里部分代码省略.........
开发者ID:bangphe,项目名称:klinik,代码行数:101,代码来源:SiteController.php


注:本文中的OrderDetail::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。