Example #1
0
 public function update_message()
 {
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     $customer_id = $app->input->get('customer_id');
     $order = new JeproshopOrderModelOrder($order_id);
     if (isset($order)) {
         if ($this->viewAccess()) {
             $customer = new JeproshopCustomerModelCustomer($customer_id);
             if (!JeproshopTools::isLoadedObject($customer, 'customer_id')) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_CUSTOMER_IS_INVALID_MESSAGE'));
             } elseif (!$inputMessage) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_THE_MESSAGE_CANNOT_BE_BLANK_MESSAGE'));
             } else {
                 /** Get Message rules anf check fields validity */
                 $rules = JeproshopMessageModelMessage::getValidationRules();
                 foreach ($rules->required as $field) {
                     $value = $app->input->get($field) == false;
                     if ($value && (string) $value != '0') {
                         if ($order_id || $field != 'passwd') {
                             JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_IS_REQUIRED_FIELD_MESSAGE'));
                         }
                     }
                 }
                 foreach ($rules->size as $field => $maxLength) {
                     if ($app->input->get($field) && strlen($field) > $maxLength) {
                         JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_FIELD_IS_TOO_LONG_LABEL') . ' ' . $maxLength . ' ' . JText::_('COM_JEPROSHOP_MAX_CHARS_LABEL'));
                     }
                 }
                 foreach ($rules->validate as $field => $function) {
                     if ($app->input->get($field)) {
                         if (!JeproshopTools::$function()) {
                             JError::raiseError(JText::_('COm_JEPROSHOP_FIELD_IS_INVALID_LABEL'));
                         }
                     }
                 }
                 if (12) {
                     $customer_thread_id = JeproshopCustomerThreadModelCustomerThread::getCustomerThreadIdByEmailAndOrderId($customer->email, $order->order_id);
                     if (!$customer_thread_id) {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread();
                         $customerThread->contact_id = 0;
                         $customerThread->customer_id = (int) $order->customer_id;
                         $customerThread->shop_id = (int) $context->shop->shop_id;
                         $customerThread->order_id = (int) $order->order_id;
                         $customerThread->lang_id = (int) $context->language->lang_id;
                         $customerThread->email = $customer->email;
                         $customerThread->status = 'open';
                         $customerThread->token = JeproshopTools::passwdGen(12);
                         $customerThread->add();
                     } else {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread((int) $customer_thread_id);
                     }
                     $customerMessage = new JeproshopCustomerMessageModelCustomerMessage();
                     $customerMessage->customer_thread_id = $customerThread->customer_thread_id;
                     $customerMessage->employee_id = (int) $context->employee->employee_id;
                     $customerMessage->message = $app->input->get('message');
                     $customerMessage->private = $app->input->get('visibility');
                     if (!$customerMessage->add()) {
                         JError::raiseError(JText::_('COM_JEPROSHOP_AN_ERROR_WHILE_'));
                     } elseif ($customerMessage->private) {
                         $app->redirect('index.php?option=com_jeproshop&view=order&task=view&order_id=' . (int) $order->order_id);
                     } else {
                     }
                 }
             }
         }
     }
 }
Example #2
0
 public function initOrderDetails()
 {
     $this->context->controller->init();
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     //$this->initContent();
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     if (!$order_id || !JeproshopTools::isUnsignedInt($order_id)) {
         $this->errors[] = Tools::displayError('Order ID required');
     } else {
         $order = new JeproshopOrderModelOrder($order_id);
         if (JeproshopTools::isLoadedObject($order, 'order_id') && $order->customer_id == $this->context->customer->customer_id) {
             $order_status_id = (int) $order->getCurrentState();
             $carrier = new JeproshopCarrierModelCarrier((int) $order->carrier_id, (int) $order->lang_id);
             $invoiceAddress = new JeproshopAddressModelAddress((int) $order->address_invoice_id);
             $deliveryAddress = new JeproshopAddressModelAddress((int) $order->address_delivery_id);
             $invoice_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($invoiceAddress->country_id);
             $delivery_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($deliveryAddress->country_id);
             $invoiceAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($invoiceAddress, $invoice_address_fields);
             $deliveryAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($deliveryAddress, $delivery_address_fields);
             if ($order->total_discounts > 0) {
                 $oldTotal = (double) ($order->total_paid - $order->total_discounts);
                 $this->assignRef('old_total', $oldTotal);
             }
             $products = $order->getProducts();
             /* DEPRECATED: customizedDatas @since 1.5 */
             $customizedDatas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $order->cart_id);
             JeproshopProductModelProduct::addCustomizationPrice($products, $customizedDatas);
             JeproshopOrderReturnModelOrderReturn::addReturnedQuantity($products, $order->order_id);
             $customer = new JeproshopCustomerModelCustomer($order->customer_id);
             $this->assignRef('order', $order);
             $isReturnable = (int) $order->isReturnable();
             $this->assignRef('return_allowed', $isReturnable);
             $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id));
             $order_status_id = (int) $order_status_id;
             $this->assignRef('order_status_id', $order_status_id);
             $invoiceAllowed = (int) JeproshopSettingModelSetting::getValue('invoice_allowed');
             $this->assignRef('invoice_allowed', $invoiceAllowed);
             $invoice = JeproshopOrderStatusModelOrderStatus::invoiceAvailable($order_status_id) && count($order->getInvoicesCollection());
             $this->assignRef('invoice', $invoice);
             $this->assignRef('order_history', $order->getHistory($this->context->language->lang_id, false, true));
             $this->assignRef('products', $products);
             $this->assignRef('discounts', $order->getCartRules());
             $this->assignRef('carrier', $carrier);
             $this->assignRef('invoice_address', $invoiceAddress);
             $this->assignRef('invoice_status', JeproshopTools::isLoadedObject($invoiceAddress, 'address_id') && $invoiceAddress->state_id ? new JeproshopStatusModelStatus($invoiceAddress->state_id) : false);
             $this->assignRef('delivery_address', $deliveryAddress);
             $this->assignRef('invoice_address_fields', $invoice_address_fields);
             $this->assignRef('delivery_address_fields', $delivery_address_fields);
             $this->assignRef('invoice_address_format_values', $invoiceAddressFormatValues);
             $this->assignRef('delivery_address_format_values', $deliveryAddressFormatValues);
             $this->assignRef('delivery_status', JeproshopTools::isLoadedObject($deliveryAddress, 'address_id') && $deliveryAddress->state_id ? new JeproshopStatusModelStatus($deliveryAddress->state_id) : false);
             $this->assignRef('messages', JeproshopCustomerMessageModelCustomerMessage::getMessagesByOrderId((int) $order->order_id, false));
             $files = JeproshopProductModelProduct::CUSTOMIZE_FILE;
             $this->assignRef('CUSTOMIZE_FILE', $files);
             $text_fields = JeproshopProductModelProduct::CUSTOMIZE_TEXT_FIELD;
             $this->assignRef('CUSTOMIZE_TEXT_FIELD', $text_fields);
             //$this->assignRef('isRecyclable', JeproshopSettingModelSetting::getValue('PS_RECYCLABLE_PACK'));
             $this->assignRef('use_tax', JeproshopSettingModelSetting::getValue('use_tax'));
             $group_use_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($customer->default_group_id) == COM_JEPROSHOP_TAX_INCLUDED;
             $this->assignRef('group_use_tax', $group_use_tax);
             $this->assignRef('display_price', JeproshopSettingModelSetting::getValue('display_price'));
             /* DEPRECATED: customizedDatas @since 1.5 */
             $this->assignRef('customizedDatas', $customizedDatas);
             $reordering_allowed = (int) JeproshopSettingModelSetting::getValue('enable_history_reordering');
             $this->assignRef('reordering_allowed', $reordering_allowed);
             /*
                             $this->context->smarty->assign(array(
                                 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->state_id) ? new State($addressDelivery->id_state) : false,
                                 'is_guest' => false,
                                 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false),
                                 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
                                 'CUSTOMIZE_TEXT_FIELD' => Product::CUSTOMIZE_TEXT_FIELD,
                                 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'),
                                 'use_tax' => Configuration::get('PS_TAX'),
                                 'group_use_tax' => (Group::getPriceDisplayMethod($customer->default_group_id) == PS_TAX_INC),
                                 /* DEPRECATED: customizedDatas @since 1.5 * /
                                 'customizedDatas' => $customizedDatas,
                                 /* DEPRECATED: customizedDatas @since 1.5 * /
             
                             )); */
             if ($carrier->url && $order->shipping_number) {
                 $this->assignRef('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             /*               $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
                             Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order)); */
             unset($carrier, $addressInvoice, $addressDelivery);
         } else {
             $this->errors[] = Tools::displayError('This order cannot be found.');
         }
         unset($order);
     }
     //$this->setTemplate(_PS_THEME_DIR_.'order-detail.tpl');
 }