Exemple #1
0
 /**
  * Saves the order to the database
  *
  * param $values
  * return unknown_type
  */
 function saveOrder($values, $user_id, $ajax = false)
 {
     $error = false;
     $guest = $user_id < Citruscart::getGuestIdStart();
     $order = $this->_order;
     // a TableOrders object (see constructor)
     $order->_adjustCredits = true;
     // this is not a POS order, so adjust the user's credits (if any used)
     $order->bind($values);
     $order->user_id = $user_id;
     $order->ip_address = $_SERVER['REMOTE_ADDR'];
     $this->setAddresses($values, false, $ajax);
     // set the shipping method
     if (isset($values['shippingrequired']) || isset($values['shipping_plugin'])) {
         $order->shipping = new JObject();
         $order->shipping->shipping_price = isset($values['shipping_price']) ? $values['shipping_price'] : "";
         $order->shipping->shipping_extra = isset($values['shipping_extra']) ? $values['shipping_extra'] : "";
         $order->shipping->shipping_name = isset($values['shipping_name']) ? $values['shipping_name'] : "";
         $order->shipping->shipping_tax = isset($values['shipping_tax']) ? $values['shipping_tax'] : "";
     }
     // Store the text verion of the currency for order integrity
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     $order->order_currency = CitruscartHelperOrder::currencyToParameters($order->currency_id);
     //get the items and add them to the order
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     //we dont need to add items in the order if onepage checkout since its already added in the shipping validation
     if (!$this->onepage_checkout) {
         $reviewitems = CitruscartHelperCarts::getProductsInfo();
         foreach ($reviewitems as $reviewitem) {
             $order->addItem($reviewitem);
         }
     }
     $this->addCoupons($values);
     $order->order_state_id = $this->initial_order_state;
     $order->calculateTotals();
     $order->getShippingTotal();
     $order->getInvoiceNumber();
     $model = JModelLegacy::getInstance('Orders', 'CitruscartModel');
     //TODO: Do Something with Payment Infomation
     if ($order->save()) {
         $model->setId($order->order_id);
         // save the order items
         if (!$this->saveOrderItems()) {
             // TODO What to do if saving order items fails?
             $error = true;
         }
         // save the order vendors
         if (!$this->saveOrderVendors()) {
             // TODO What to do if saving order vendors fails?
             $error = true;
         }
         // save the order info
         if (!$this->saveOrderInfo()) {
             // TODO What to do if saving order info fails?
             $error = true;
         }
         // save the order history
         if (!$this->saveOrderHistory()) {
             // TODO What to do if saving order history fails?
             $error = true;
         }
         // save the order taxes
         if (!$this->saveOrderTaxes()) {
             // TODO What to do if saving order taxes fails?
             $error = true;
         }
         // save the order shipping info
         if (isset($values['shipping_plugin'])) {
             if (isset($order->shipping) && !$this->saveOrderShippings($values)) {
                 // TODO What to do if saving order shippings fails?
                 $error = true;
             }
         }
         // save the order coupons
         if (!$this->saveOrderCoupons()) {
             // TODO What to do if saving order coupons fails?
             $error = true;
         }
         $model->clearCache();
     }
     if ($error) {
         return false;
     }
     return true;
 }
 public function getStatIntervalValues($stats_interval)
 {
     $this->setStatesCSV();
     $interval = new stdClass();
     switch ($stats_interval) {
         case "annually":
             $firstsale_date = CitruscartHelperOrder::getDateMarginalOrder($this->getStatesCSV(), 'ASC');
             $interval->date_from = date('Y-01-01 00:00:00', strtotime($firstsale_date));
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 year';
             $interval->step = '1';
             $interval->pointinterval = 365 * 24 * 3600 * 1000;
             // one year
             $interval->index_format = 'Y-01-01';
             $interval->current_date_format = 'Y-01-01';
             $interval->end_date_format = 'Y-12-31';
             $interval->hour_format = '0';
             break;
         case "today":
             $interval->date_from = date('Y-m-d 00:00:00', strtotime('NOW'));
             $interval->date_to = date('Y-m-d 23:59:59', strtotime('NOW'));
             $interval->next_date = '+1 hour';
             $interval->step = 1;
             $interval->pointinterval = 3600 * 1000;
             // one hour
             $interval->index_format = 'Y-m-d H:00:00';
             $interval->current_date_format = 'Y-m-d H:00:00';
             $interval->end_date_format = 'Y-m-d 23:59:59';
             $interval->hour_format = 'H';
             break;
         case "yesterday":
             $interval->date_from = date('Y-m-d 00:00:00', strtotime('yesterday'));
             $interval->date_to = date('Y-m-d 23:59:59', strtotime('yesterday'));
             $interval->next_date = '+1 hour';
             $interval->step = 1;
             $interval->pointinterval = 3600 * 1000;
             // one hour
             $interval->index_format = 'Y-m-d H:00:00';
             $interval->current_date_format = 'Y-m-d H:00:00';
             $interval->end_date_format = 'Y-m-d 23:59:59';
             $interval->hour_format = 'H';
             break;
         case "ytd":
             $interval->date_from = date('Y', strtotime('NOW')) . '-01-01';
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 month';
             $interval->step = 1;
             $interval->pointinterval = 30.25 * 24 * 3600 * 1000;
             // one month
             $interval->index_format = 'Y-m-01';
             $interval->current_date_format = 'Y-m-d';
             $interval->end_date_format = 'Y-m-d';
             $interval->hour_format = '0';
             break;
         case "last_seven":
             $interval->date_from = 'NOW -7 days';
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 day';
             $interval->step = '1';
             $interval->pointinterval = 24 * 3600 * 1000;
             // one day
             $interval->index_format = 'Y-m-d';
             $interval->current_date_format = 'Y-m-d';
             $interval->end_date_format = 'Y-m-d';
             $interval->hour_format = '0';
             break;
         case "last_thirty":
         default:
             $interval->date_from = 'NOW -30 days';
             $interval->date_to = 'NOW';
             $interval->next_date = '+1 day';
             $interval->step = '7';
             $interval->pointinterval = 24 * 3600 * 1000;
             // one day
             $interval->index_format = 'Y-m-d';
             $interval->current_date_format = 'Y-m-d';
             $interval->end_date_format = 'Y-m-d';
             $interval->hour_format = '0';
             break;
     }
     return $interval;
 }
Exemple #3
0
 /**
  * Returns 
  * 
  * @param object
  * @param mixed Boolean
  * @param mixed Boolean
  * @return array
  */
 private function getEmailContent($data, $type = 'order')
 {
     $mainframe = JFactory::getApplication();
     $type = strtolower($type);
     $lang = JFactory::getLanguage();
     $lang->load('com_citruscart', JPATH_ADMINISTRATOR);
     $return = new stdClass();
     $return->body = '';
     $return->subject = '';
     // get config settings
     $config = CitruscartConfig::getInstance();
     $sitename = $config->get('sitename', $mainframe->getCfg('sitename'));
     $siteurl = $config->get('siteurl', JURI::root());
     // get the placeholders array here so the switch statement can add to it
     $placeholders = $this->getPlaceholderDefaults();
     switch ($type) {
         case "subscription_expiring":
             $return->subject = JText::_('COM_CITRUSCART_EMAIL_EXPIRING_SUBSCRIPTION_SUBJECT');
             $return->body = JText::_('COM_CITRUSCART_EMAIL_EXPIRING_SUBSCRIPTION_BODY');
             if ($this->use_html) {
                 $return->body = nl2br($return->body);
             }
             $placeholders['user.name'] = $data->user_name;
             $placeholders['product.name'] = $data->product_name;
             break;
         case "subscription_expired":
             $return->subject = JText::_('COM_CITRUSCART_EMAIL_EXPIRED_SUBSCRIPTION_SUBJECT');
             $return->body = JText::_('COM_CITRUSCART_EMAIL_EXPIRED_SUBSCRIPTION_BODY');
             if ($this->use_html) {
                 $return->body = nl2br($return->body);
             }
             $placeholders['user.name'] = $data->user_name;
             $placeholders['product.name'] = $data->product_name;
             break;
         case "subscription_new":
         case "new_subscription":
         case "subscription":
             $user_name = JText::_('COM_CITRUSCART_GUEST');
             if ($data->user_id > 0) {
                 $user = JUser::getInstance($data->user_id);
                 $user_name = $user->name;
             }
             if ($data->user_id < Citruscart::getGuestIdStart()) {
                 $link = JURI::root() . "index.php?option=com_citruscart&view=orders&task=view&id=" . $data->order_id . '&h=' . $data->order_hash;
             } else {
                 $link = JURI::root() . "index.php?option=com_citruscart&view=orders&task=view&id=" . $data->order_id;
             }
             $link = JRoute::_($link, false);
             $link = "<a href='{$link}'>" . $link . "</a>";
             if (count($data->history) == 1) {
                 // new order
                 $return->subject = sprintf(JText::_('COM_CITRUSCART_EMAIL_NEW_ORDER_SUBJECT'), $data->order_id);
                 // set the email body
                 $text = sprintf(JText::_('COM_CITRUSCART_EMAIL_DEAR'), $user_name) . ",\n\n";
                 $text .= JText::_('COM_CITRUSCART_EMAIL_THANKS_NEW_SUBSCRIPTION') . "\n\n";
                 $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_CHECK'), $link) . "\n\n";
                 $text .= JText::_('COM_CITRUSCART_EMAIL_RECEIPT_FOLLOWS') . "\n\n";
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
                 // get the order body
                 Citruscart::load('CitruscartHelperOrder', 'helpers.order');
                 $text .= CitruscartHelperOrder::getOrderHtmlForEmail($data->order_id);
             } else {
                 // Status Change
                 $return->subject = JText::_('COM_CITRUSCART_EMAIL_SUBSCRIPTION_STATUS_CHANGE');
                 $last_history = count($data->history) - 1;
                 $text = sprintf(JText::_('COM_CITRUSCART_EMAIL_DEAR'), $user_name) . ",\n\n";
                 $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_ORDER_UPDATED'), $data->order_id);
                 if (!empty($data->history[$last_history]->comments)) {
                     $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_ADDITIONAL_COMMENTS'), $data->history[$last_history]->comments);
                 }
                 $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_CHECK'), $link) . "\n\n";
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
             }
             $return->body = $text;
             $placeholders['user.name'] = $user_name;
             break;
         case "new_order":
         case "order":
         default:
             $user_name = JText::_('COM_CITRUSCART_GUEST');
             if ($data->user_id > 0) {
                 $user = JUser::getInstance($data->user_id);
                 $user_name = $user->name;
             }
             if ($data->user_id < Citruscart::getGuestIdStart()) {
                 $link = JURI::root() . "index.php?option=com_citruscart&view=orders&task=view&id=" . $data->order_id . '&h=' . $data->order_hash;
             } else {
                 $link = JURI::root() . "index.php?option=com_citruscart&view=orders&task=view&id=" . $data->order_id;
             }
             $link = JRoute::_($link, false);
             $link = "<a href='{$link}'>" . $link . "</a>";
             if ($type == 'new_order') {
                 // new order
                 $return->subject = sprintf(JText::_('COM_CITRUSCART_EMAIL_NEW_ORDER_SUBJECT'), $data->order_id);
                 // set the email body
                 $text = sprintf(JText::_('COM_CITRUSCART_EMAIL_DEAR'), $user_name) . ",\n\n";
                 $text .= JText::_('COM_CITRUSCART_EMAIL_THANKS_NEW_ORDER') . "\n\n";
                 $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_CHECK'), $link) . "\n\n";
                 $text .= JText::_('COM_CITRUSCART_EMAIL_RECEIPT_FOLLOWS') . "\n\n";
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
                 // get the order body
                 Citruscart::load('CitruscartHelperOrder', 'helpers.order');
                 $text .= CitruscartHelperOrder::getOrderHtmlForEmail($data->order_id);
             } else {
                 // Status Change
                 $return->subject = JText::_('COM_CITRUSCART_EMAIL_ORDER_STATUS_CHANGE');
                 $last_history = count($data->orderhistory) - 1;
                 $text = sprintf(JText::_('COM_CITRUSCART_EMAIL_DEAR'), $user_name) . ",\n\n";
                 $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_ORDER_UPDATED'), $data->order_id);
                 $text .= JText::_('COM_CITRUSCART_EMAIL_NEW_STATUS') . " " . $data->orderhistory[$last_history]->order_state_name . "\n\n";
                 if (!empty($data->orderhistory[$last_history]->comments)) {
                     $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_ADDITIONAL_COMMENTS'), $data->orderhistory[$last_history]->comments);
                 }
                 $text .= sprintf(JText::_('COM_CITRUSCART_EMAIL_CHECK'), $link) . "\n\n";
                 if ($this->use_html) {
                     $text = nl2br($text);
                 }
             }
             $return->body = $text;
             $placeholders['user.name'] = $user_name;
             break;
     }
     // replace placeholders in language strings - great idea, Oleg
     $return->subject = $this->replacePlaceholders($return->subject, $placeholders);
     $return->body = $this->replacePlaceholders($return->body, $placeholders);
     return $return;
 }
Exemple #4
0
 /**
  * _lifetime function.
  *
  * @access private
  * @return void
  */
 function _lifetime()
 {
     $database = JFactory::getDBO();
     $today = CitruscartHelperBase::getToday();
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     $firstsale_date = CitruscartHelperOrder::getDateMarginalOrder($this->getStatesCSV(), 'ASC');
     $lastsale_date = CitruscartHelperOrder::getDateMarginalOrder($this->getStatesCSV(), 'DESC');
     $return = $this->_getDateDb($firstsale_date, $lastsale_date);
     $days = $return->days_in_business > 0 ? $return->days_in_business : 1;
     $return->average_daily = $return->num / $days;
     return $return;
 }
Exemple #5
0
 public function prepare($values, $options = array(), &$order = null)
 {
     if (empty($order)) {
         $order = $this->getTable();
     }
     $this->_order = $order;
     $this->_values = $values;
     $this->_options = $options;
     if (empty($options['skip_adjust_credits'])) {
         $order->_adjustCredits = true;
         // this is not a POS order, so adjust the user's credits (if any used)
     }
     $order->bind($values);
     $order->user_id = $values['user_id'];
     $order->ip_address = $values['ip_address'];
     //$_SERVER['REMOTE_ADDR'];
     // set the currency
     if (empty($values['currency_id'])) {
         Citruscart::load('CitruscartHelperCurrency', 'helpers.currency');
         $order->currency_id = CitruscartHelperCurrency::getCurrentCurrency();
     }
     // Store the text verion of the currency for order integrity
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     $order->order_currency = CitruscartHelperOrder::currencyToParameters($order->currency_id);
     $saveAddressesToDB = empty($options["save_addresses"]) ? false : true;
     $this->setAddresses($values, $saveAddressesToDB);
     // set the shipping method
     if (isset($values['shippingrequired']) || !empty($values['shipping_plugin'])) {
         $order->shipping = new JObject();
         $order->shipping->shipping_price = $values['shipping_price'];
         $order->shipping->shipping_extra = $values['shipping_extra'];
         $order->shipping->shipping_name = $values['shipping_name'];
         $order->shipping->shipping_tax = $values['shipping_tax'];
     }
     if (empty($options['skip_add_items'])) {
         //get the items from the current user's cart and add them to the order
         Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
         $reviewitems = CitruscartHelperCarts::getProductsInfo();
         foreach ($reviewitems as $reviewitem) {
             $order->addItem($reviewitem);
         }
     }
     if (empty($options['skip_add_coupons'])) {
         $this->addCoupons($values);
     }
     if (empty($options['skip_add_credit']) && !empty($values['order_credit'])) {
         $order->addCredit($values['order_credit']);
     }
     $order->order_state_id = empty($values['orderstate_id']) ? $this->initial_order_state : $values['orderstate_id'];
     $order->calculateTotals();
     $order->getShippingTotal();
     $order->getInvoiceNumber();
     return $order;
 }
Exemple #6
0
 function store($updateNulls = false)
 {
     // add hash to orders which are placed by guests
     if (!$this->order_id && !strlen($this->order_hash) && $this->user_id < Citruscart::getGuestIdStart()) {
         Citruscart::load('CitruscartHelperOrder', 'helpers.order');
         $this->order_hash = CitruscartHelperOrder::getHashInvoice($this);
     }
     return parent::store($updateNulls);
 }
 /**
  * Processes the sale payment
  *
  * @param  array   $data IPN data
  * @return boolean Did the IPN Validate?
  * @access protected
  */
 public function _processSale($data, $ipnValidationFailed = '')
 {
     /*
      * validate the payment data
      */
     $errors = array();
     if (!empty($ipnValidationFailed)) {
         $errors[] = $ipnValidationFailed;
     }
     // is the recipient correct?
     if (empty($data['receiver_email']) || $data['receiver_email'] != $this->_getParam('merchant_email')) {
         $errors[] = JText::_('PAYPAL MESSAGE RECEIVER INVALID');
     }
     if (empty($data['custom'])) {
         $errors[] = JText::_('PAYPAL MESSAGE INVALID ORDERPAYMENTID');
         return count($errors) ? implode("\n", $errors) : '';
     }
     // load the orderpayment record and set some values
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $orderpayment = JTable::getInstance('OrderPayments', 'CitruscartTable');
     $orderpayment->load($data['custom']);
     if (empty($data['custom']) || empty($orderpayment->orderpayment_id)) {
         $errors[] = JText::_('PAYPAL MESSAGE INVALID ORDERPAYMENTID');
         return count($errors) ? implode("\n", $errors) : '';
     }
     $orderpayment->transaction_details = $data['transaction_details'];
     $orderpayment->transaction_id = $data['txn_id'];
     $orderpayment->transaction_status = $data['payment_status'];
     // check the stored amount against the payment amount
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $stored_amount = CitruscartHelperBase::number($orderpayment->get('orderpayment_amount'), array('thousands' => ''));
     $respond_amount = CitruscartHelperBase::number($data['mc_gross'], array('thousands' => ''));
     if ($stored_amount != $respond_amount) {
         $errors[] = JText::_('PAYPAL MESSAGE AMOUNT INVALID');
         $errors[] = $stored_amount . " != " . $respond_amount;
     }
     // check the payment status
     if (empty($data['payment_status']) || $data['payment_status'] != 'Completed' && $data['payment_status'] != 'Pending') {
         $errors[] = JText::sprintf('PAYPAL MESSAGE STATUS INVALID', $data['payment_status']);
     }
     // set the order's new status and update quantities if necessary
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     $order = JTable::getInstance('Orders', 'CitruscartTable');
     $order->load($orderpayment->order_id);
     if (count($errors)) {
         // if an error occurred
         $order->order_state_id = $this->params->get('failed_order_state', '10');
         // FAILED
     } elseif ($data['payment_status'] == 'Pending') {
         // if the transaction has the "pending" status,
         $order->order_state_id = Citruscart::getInstance('pending_order_state', '1');
         // PENDING
         // Update quantities for echeck payments
         CitruscartHelperOrder::updateProductQuantities($orderpayment->order_id, '-');
         // remove items from cart
         CitruscartHelperCarts::removeOrderItems($orderpayment->order_id);
         // send email
         $send_email = true;
     } else {
         $order->order_state_id = $this->params->get('payment_received_order_state', '17');
         // PAYMENT RECEIVED
         // do post payment actions
         $setOrderPaymentReceived = true;
         // send email
         $send_email = true;
     }
     // save the order
     if (!$order->save()) {
         $errors[] = $order->getError();
     }
     // save the orderpayment
     if (!$orderpayment->save()) {
         $errors[] = $orderpayment->getError();
     }
     if (!empty($setOrderPaymentReceived)) {
         $this->setOrderPaymentReceived($orderpayment->order_id);
     }
     if ($send_email) {
         // send notice of new order
         Citruscart::load("CitruscartHelperBase", 'helpers._base');
         $helper = CitruscartHelperBase::getInstance('Email');
         $model = Citruscart::getClass("CitruscartModelOrders", "models.orders");
         $model->setId($orderpayment->order_id);
         $order = $model->getItem();
         $helper->sendEmailNotices($order, 'new_order');
     }
     return count($errors) ? implode("\n", $errors) : '';
 }
Exemple #8
0
 /**
  * (non-PHPdoc)
  * @see Citruscart/site/CitruscartController#view()
  */
 function printOrder()
 {
     $input = JFactory::getApplication()->input;
     // if the user cannot view order, fail
     $model = $this->getModel($this->get('suffix'));
     $model->getId();
     $order = $model->getTable('orders');
     $order->load($model->getId());
     $row = $model->getItem();
     $row->order_ships = $order->order_ships;
     $orderitems = $order->getItems();
     $user_id = JFactory::getUser()->id;
     if ($row->user_id > 0) {
         if (empty($user_id) || $user_id != $row->user_id) {
             $this->messagetype = 'notice';
             $this->message = JText::_('COM_CITRUSCART_INVALID_ORDER');
             $redirect = "index.php?option=com_citruscart&view=" . $this->get('suffix');
             $redirect = JRoute::_($redirect, false);
             $this->setRedirect($redirect, $this->message, $this->messagetype);
             return;
         }
     } else {
         $hash = $input->getString('h', '');
         if ($row->order_hash != $hash) {
             $this->messagetype = 'notice';
             $this->message = JText::_('COM_CITRUSCART_INVALID_ORDER');
             $redirect = "index.php?option=com_citruscart&view=" . $this->get('suffix');
             $redirect = JRoute::_($redirect, false);
             $this->setRedirect($redirect, $this->message, $this->messagetype);
             return;
         }
     }
     Citruscart::load('CitruscartUrl', 'library.url');
     $view = $this->getView('orders', 'html');
     $view->set('_controller', 'orders');
     $view->set('_view', 'orders');
     $view->set('_doTask', true);
     $view->set('hidemenu', true);
     $view->setModel($model, true);
     $config = Citruscart::getInstance();
     $show_tax = $config->get('display_prices_with_tax');
     if ($show_tax) {
         $order->order_subtotal += $order->order_tax;
     }
     //START onDisplayOrderItem: trigger plugins for extra orderitem information
     if (!empty($orderitems)) {
         Citruscart::load('CitruscartHelperOrder', 'helpers.order');
         $onDisplayOrderItem = CitruscartHelperOrder::onDisplayOrderItems($orderitems);
         $view->assign('onDisplayOrderItem', $onDisplayOrderItem);
     }
     foreach ($orderitems as $item) {
         if ($show_tax) {
             $item->orderitem_price += $item->orderitem_tax / $item->orderitem_quantity;
         }
     }
     //END onDisplayOrderItem
     $view->assign('show_tax', $show_tax);
     $view->assign('using_default_geozone', false);
     $view->assign('order', $order);
     $view->setLayout('print');
     $view->display();
 }
Exemple #9
0
$k = 0;
?>
        <?php 
foreach ($items as $item) {
    ?>
            <tr class='row<?php 
    echo $k;
    ?>
'>
                <td style="text-align: center;">
                    <a href="<?php 
    echo JRoute::_($item->link_view);
    ?>
">
                        <?php 
    echo CitruscartHelperOrder::displayOrderNumber($item);
    ?>
                    </a>
                </td>
                <td style="text-align: center;">
                    <a href="<?php 
    echo JRoute::_($item->link_view);
    ?>
">
                        <?php 
    echo JHTML::_('date', $item->created_date, Citruscart::getInstance()->get('date_format'));
    ?>
                    </a>
                </td>
                <td style="text-align: center;">
                    <a href="<?php 
Exemple #10
0
 /**
  * This method for after an orderpayment has been received when the admin click on the
  * that performs acts such as:
  * enabling file downloads
  *
  * @param $order_id
  * @return unknown_type
  */
 public static function doCompletedOrderTasks($order_id)
 {
     $errors = array();
     $error = false;
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $order = JTable::getInstance('Orders', 'CitruscartTable');
     $order->load($order_id);
     if (empty($order->order_id)) {
         // TODO we must make sure this class is always instantiated
         $this->setError(JText::_('COM_CITRUSCART_INVALID_ORDER_ID'));
         return false;
     }
     // Fire an doCompletedOrderTasks event
     JFactory::getApplication()->triggerEvent('doCompletedOrderTasks', array($order_id));
     // 0. Enable One-Time Purchase Subscriptions
     CitruscartHelperOrder::enableNonRecurringSubscriptions($order_id);
     // 1. Update quantities
     CitruscartHelperOrder::updateProductQuantities($order_id, '-');
     // 2. remove items from cart
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     CitruscartHelperCarts::removeOrderItems($order_id);
     // 3. add productfiles to product downloads
     CitruscartHelperOrder::enableProductDownloads($order_id);
     // 4. do SQL queries
     $helper = CitruscartHelperBase::getInstance('Sql');
     $helper->processOrder($order_id);
     // register commission if amigos is installed
     $helper = CitruscartHelperBase::getInstance('Amigos');
     $helper->createCommission($order_id);
     // change ticket limits if billets is installed
     $helper = CitruscartHelperBase::getInstance('Billets');
     $helper->processOrder($order_id);
     // add to JUGA Groups if JUGA installed
     $helper = CitruscartHelperBase::getInstance('Juga');
     $helper->processOrder($order_id);
     // change core ACL if set
     $helper = CitruscartHelperBase::getInstance('User');
     $helper->processOrder($order_id);
     // do Ambra Subscriptions Integration processes
     $helper = CitruscartHelperBase::getInstance('Ambrasubs');
     $helper->processOrder($order_id);
     // increase the hit counts for coupons in the order
     $helper = CitruscartHelperBase::getInstance('Coupon');
     $helper->processOrder($order_id);
     if ($error) {
         $this->setError(implode('<br/>', $errors));
         return false;
     } else {
         $order->completed_tasks = '1';
         $order->store();
         return true;
     }
 }
Exemple #11
0
// fire plugin event here to enable extending the form
JDispatcher::getInstance()->trigger('onBeforeDisplayOrderView', array($row));
?>

<div id="order_info">
	<h3>
	<?php 
echo JText::_('COM_CITRUSCART_ORDER_INFORMATION');
?>
	</h3>
	<strong><?php 
echo JText::_('COM_CITRUSCART_ORDER_ID');
?>
 </strong>:
		<?php 
echo CitruscartHelperOrder::displayOrderNumber($row);
?>
	<br /> <strong><?php 
echo JText::_('COM_CITRUSCART_DATE');
?>
 </strong>:
		<?php 
echo JHTML::_('date', $row->created_date, Citruscart::getInstance()->get('date_format'));
?>
	<br /> <strong><?php 
echo JText::_('COM_CITRUSCART_STATUS');
?>
 </strong>:
		<?php 
echo $row->order_state_name;
?>
Exemple #12
0
 /**
  * This method can be executed by a payment plugin after a succesful payment
  * to perform acts such as enabling file downloads, removing items from cart,
  * updating product quantities, etc
  *
  * @param unknown_type $order_id
  * @return unknown_type
  */
 function setOrderPaymentReceived($order_id)
 {
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     CitruscartHelperOrder::setOrderPaymentReceived($order_id);
 }
Exemple #13
0
 function saveOrder($values)
 {
     $session = JFactory::getSession();
     $user_id = $session->get('user_id', '', 'citruscart_pos');
     $error = false;
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables');
     $order = JTable::getInstance('Orders', 'CitruscartTable');
     $order->bind($values);
     $order->user_id = $user_id;
     $order->ip_address = $_SERVER['REMOTE_ADDR'];
     $this->setAddresses($order, $values);
     $session = JFactory::getSession();
     // set the shipping method
     if ($values['shippingrequired']) {
         $order->shipping = new JObject();
         $order->shipping->shipping_price = $session->get('shipping_price', '', 'citruscart_pos');
         $order->shipping->shipping_extra = $session->get('shipping_extra', '', 'citruscart_pos');
         $order->shipping->shipping_name = $session->get('shipping_name', '', 'citruscart_pos');
         $order->shipping->shipping_tax = $session->get('shipping_tax', '', 'citruscart_pos');
     }
     // Store the text verion of the currency for order integrity
     Citruscart::load('CitruscartHelperOrder', 'helpers.order');
     $order->order_currency = CitruscartHelperOrder::currencyToParameters($order->currency_id);
     $reviewitems = $this->getProductsInfo();
     foreach ($reviewitems as $reviewitem) {
         $order->addItem($reviewitem);
     }
     // get all coupons and add them to the order
     $coupons_enabled = Citruscart::getInstance()->get('coupons_enabled');
     $mult_enabled = Citruscart::getInstance()->get('multiple_usercoupons_enabled');
     if (!empty($values['coupons']) && $coupons_enabled) {
         foreach ($values['coupons'] as $coupon_id) {
             $coupon = JTable::getInstance('Coupons', 'CitruscartTable');
             $coupon->load(array('coupon_id' => $coupon_id));
             $order->addCoupon($coupon);
             if (empty($mult_enabled)) {
                 // this prevents Firebug users from adding multiple coupons to orders
                 break;
             }
         }
     }
     $order->order_state_id = 15;
     $order->calculateTotals();
     $order->getShippingTotal();
     $order->getInvoiceNumber();
     $model = DSCModel::getInstance('Orders', 'CitruscartModel');
     if ($order->save()) {
         $model->setId($order->order_id);
         // save the order items
         if (!$this->saveOrderItems($order)) {
             // TODO What to do if saving order items fails?
             $error = true;
         }
         // save the order vendors
         if (!$this->saveOrderVendors($order)) {
             // TODO What to do if saving order vendors fails?
             $error = true;
         }
         // save the order info
         if (!$this->saveOrderInfo($order)) {
             // TODO What to do if saving order info fails?
             $error = true;
         }
         // save the order history
         if (!$this->saveOrderHistory($order)) {
             // TODO What to do if saving order history fails?
             $error = true;
         }
         // save the order taxes
         if (!$this->saveOrderTaxes($order)) {
             // TODO What to do if saving order taxes fails?
             $error = true;
         }
         // save the order shipping info
         if (!$this->saveOrderShippings($order)) {
             // TODO What to do if saving order shippings fails?
             $error = true;
         }
         // save the order coupons
         if (!$this->saveOrderCoupons($order)) {
             // TODO What to do if saving order coupons fails?
             $error = true;
         }
         $model->clearCache();
     }
     return $order;
 }
Exemple #14
0
 /**
  * This method is updating the all orders on the basis of the action
  * @return void
  */
 function updatebatch()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     // Get the list of selected items and their selected params
     $cids = $app->input->get('cid', array(0), 'array');
     $sendMails = $app->input->get('new_orderstate_notify', array(0), 'array');
     $completeTasks = $app->input->get('completed_tasks', array(0), 'array');
     $states = $app->input->get('new_orderstate_id', array(0), 'array');
     $comments = $app->input->get('new_orderstate_comments', array(0), 'array');
     // for the updation
     $counter = 0;
     foreach ($cids as $orderId) {
         $row = $model->getTable();
         $row->load($orderId);
         $row->order_state_id = $states[$counter];
         $completed_tasks = $completeTasks[$orderId];
         $is_notify = 0;
         if ($completed_tasks == "on" && empty($row->completed_tasks)) {
             Citruscart::load('CitruscartHelperOrder', 'helpers.order');
             CitruscartHelperOrder::doCompletedOrderTasks($row->order_id);
             $row->completed_tasks = 1;
         }
         // saving the row
         if ($row->save()) {
             $model->setId($row->order_id);
             $this->messagetype = 'message';
             $this->message = JText::_('COM_CITRUSCART_ORDER_SAVED');
             $history = JTable::getInstance('OrderHistory', 'CitruscartTable');
             $history->order_id = $row->order_id;
             $history->order_state_id = $row->order_state_id;
             if ($sendMails[$orderId] == "on") {
                 $is_notify = 1;
             }
             $history->notify_customer = $is_notify;
             $history->comments = $comments[$counter];
             if (!$history->save()) {
                 $this->setError($history->getError());
                 $this->messagetype = 'notice';
                 $this->message .= " :: " . JText::_('COM_CITRUSCART_ORDERHISTORY_SAVE_FAILED');
             }
             JFactory::getApplication()->triggerEvent('onAfterUpdateStatus' . $this->get('suffix'), array($row));
         } else {
             $this->messagetype = 'notice';
             $this->message = JText::_('COM_CITRUSCART_SAVE_FAILED') . " - " . $row->getError();
         }
         $counter++;
     }
     $model->clearCache();
     $redirect = "index.php?option=com_citruscart";
     $redirect .= '&view=' . $this->get('suffix');
     $redirect = JRoute::_($redirect, false);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }