public function myaddressbook() { global $user; // check if the user is logged in. expQueue::flashIfNotLoggedIn('message', 'You must be logged in to manage your address book.'); expHistory::set('viewable', $this->params); $userid = empty($this->params['user_id']) ? $user->id : $this->params['user_id']; assign_to_template(array('addresses' => $this->address->find('all', 'user_id=' . $userid))); }
public function process() { global $db, $order, $user; //eDebug($order,true); if (!$user->isLoggedIn() && empty($this->params['nologin'])) { flash('message', gt("It appears that your session has expired. Please log in to continue the checkout process.")); expHistory::back(); //expHistory::redirecto_login(makeLink(array('module'=>'cart','action'=>'checkout'), 'secure')); } // if this error hits then something went horribly wrong or the user has tried to hit this // action themselves before the cart was ready or is refreshing the page after they've confirmed the // order. if (empty($order->orderitem)) { flash('error', gt('There are no items in your cart.')); } if (!expQueue::isQueueEmpty('error')) { redirect_to(array('controller' => 'store', 'action' => 'showall')); } // set the gift comments $order->update($this->params); // get the biling & shipping info $shipping = new shipping(); $billing = new billing(); // finalize the total to bill $order->calculateGrandTotal(); //eDebug($order,true); $invNum = $order->getInvoiceNumber(); // call the billing calculators process method - this will handle saving the billing options to the database. $result = $billing->calculator->process($billing->billingmethod, expSession::get('billing_options'), $this->params, $invNum); if (empty($result->errorCode)) { // if ($result->errorCode === "0" || $result->errorCode === 0) // { // save out the cart total to the database $billing->billingmethod->update(array('billing_cost' => $order->grand_total)); // set the invoice number and purchase date in the order table..this finializes the order //$invoice_num = $db->max('orders', 'invoice_id') + 1; //if ($invoice_num < ecomconfig::getConfig('starting_invoice_number')) $invoice_num += ecomconfig::getConfig('starting_invoice_number'); // get the first order status and set it for this order $order->update(array('invoice_id' => $invNum, 'purchased' => time(), 'updated' => time(), 'comment' => serialize($comment))); //$order->setDefaultStatus(); --FJD? //$order->setDefaultOrderType(); --FJD? $order->refresh(); // run each items process callback function foreach ($order->orderitem as $item) { $product = new $item->product_type($item->product_id); $product->process($item, $order->order_type->affects_inventory); } $billing->calculator->postProcess($order, $this->params); orderController::clearCartCookie(); } else { flash('error', gt('An error was encountered while processing your transaction.') . '<br /><br />' . $result->message); expHistory::back(); //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); } $billinginfo = $billing->calculator->userView(unserialize($billing->billingmethod->billing_options)); if (!DEVELOPMENT) { // send email invoices to the admins & users if needed if ($order->order_type->emails_customer) { $invoice = renderAction(array('controller' => 'order', 'action' => 'email', 'id' => $order->id)); } } else { flash('message', gt('Development on, skipping email sending.')); } //assign_to_template(array('order'=>$order, 'billing'=>$billing, 'shipping'=>$shipping, 'result'=>$result, 'billinginfo'=>$billinginfo)); flash('message', gt('Your order has been submitted.')); redirect_to(array('controller' => 'order', 'action' => 'myOrder', 'id' => $order->id, 'tc' => 1)); }
/** * Delete a help version and all assoc docs */ public function delete_version() { if (empty($this->params['id'])) { flash('error', gt('The version you are trying to delete could not be found')); } // get the version $version = new help_version($this->params['id']); if (empty($version->id)) { flash('error', gt('The version you are trying to delete could not be found')); } // if we have errors than lets get outta here! if (!expQueue::isQueueEmpty('error')) { expHistory::back(); } // delete the version $version->delete(); // get and delete the docs for this version $help = new help(); $docs = $help->find('all', 'help_version_id=' . $version->id); $num_docs = count($docs); foreach ($docs as $doc) { $doc->delete(); } expSession::un_set('help-version'); flash('message', gt('Deleted version') . ' ' . $version->version . ' ' . gt('and') . ' ' . $num_docs . ' ' . gt('documents that were in that version.')); expHistory::back(); }
function ordersbyuser() { global $user; // if the user isn't logged in flash an error msg if (!$user->isLoggedIn()) { expQueue::flashAndFlow('error', 'You must be logged in to view past orders.'); } expHistory::set('viewable', $this->params); $page = new expPaginator(array('model' => 'order', 'where' => 'purchased > 0 AND user_id=' . $user->id, 'order' => 'purchased', 'dir' => 'DESC', 'columns' => array('Date Purchased' => 'purchased', 'Invoice #' => 'invoice_id'))); assign_to_template(array('page' => $page)); }
public function confirm() { global $db; // make sure we have what we need. if (empty($this->params['key'])) { expQueue::flashAndFlow('error', 'The security key for account was not supplied.'); } if (empty($this->params['id'])) { expQueue::flashAndFlow('error', 'The subscriber id for account was not supplied.'); } // verify the id/key pair $id = $db->selectValue('subscribers', 'id', 'id=' . $this->params['id'] . ' AND hash="' . $this->params['key'] . '"'); if (empty($id)) { expQueue::flashAndFlow('error', 'We could not find any subscriptions matching the ID and Key you provided.'); } // activate this users pending subscriptions $sub->enabled = 1; $db->updateObject($sub, 'expeAlerts_subscribers', 'subscribers_id=' . $id); // find the users active subscriptions $ealerts = expeAlerts::getBySubscriber($id); assign_to_template(array('ealerts' => $ealerts)); }
function show_msg_queue($name = null) { return expQueue::show($name); }