function saveorderinfo() { JRequest::checkToken() or jexit('Invalid Token'); $mainframe =& JFactory::getApplication(); $post = JRequest::get('post'); $post['id'] = ARequest::getCid(); if (!class_exists('BookProModelOrderInfo')) { AImporter::model('orderinfo'); } $modelInfo = new BookProModelOrderInfo(); $id = $modelInfo->store($post); if (!class_exists('BookProModelPackagePrice')) { AImporter::model('packageprice'); } $modelpackprice = new BookProModelPackagePrice(); $modelpackprice->setId(JRequest::getInt('price_id')); $price = $modelpackprice->getObject(); $order_id = JRequest::getVar('order_id'); $order = array('id' => $order_id, 'total' => $total); $this->_model->store($order); if ($id !== false) { $mainframe->enqueueMessage(JText::_('Successfully saved'), 'message'); } else { $mainframe->enqueueMessage(JText::_('Save failed'), 'error'); } $this->setRedirect(JURI::base() . 'index.php?option=com_bookpro&controller=order&task=detail&cid[]=' . $order_id); }
function updateorder() { // update orderinfo $adult = JRequest::getInt('adult', 1); $child = JRequest::getInt('children', 0); $orderinfo_id = JRequest::getInt('orderinfo_id'); $order_id = JRequest::getInt('order_id'); $start = JFactory::getDate(JRequest::getVar('depart')); $notes = JRequest::getString('notes'); $location = JRequest::getInt('location'); //save order info if (!class_exists('BookProModelOrderInfo')) { AImporter::model('orderinfo'); } $modelInfo = new BookProModelOrderInfo(); $data = array('id' => $orderinfo_id, 'adult' => $adult, 'child' => $child, 'start' => $start->toSql(true), 'location' => $location); $modelInfo->store($data); if (!class_exists('BookProModelPackagePrice')) { AImporter::model('packageprice'); } $modelpackprice = new BookProModelPackagePrice(); $modelpackprice->setId(JRequest::getInt('price_id')); $price = $modelpackprice->getObject(); $total = $adult * $price->price + $child * $price->child_price; //save order $modelOrder = new BookProModelOrder(); $order = array('id' => $order_id, 'total' => $total, 'notes' => $notes); $modelOrder->store($order); $this->setRedirect(JURI::base() . 'index.php?option=com_bookpro&controller=order&task=viewdetail&order_id=' . $order_id); }