public function export() { if (null !== ($response = $this->checkAuth([AdminResources::MODULE, AdminResources::ORDER], ['Predict'], AccessManager::VIEW))) { return $response; } $orders = PredictQuery::getOrders(); $export = new PredictExport(); $export_data = ""; /** * Validate the form and checks which order(s) must be exported */ try { $form = new ExportForm($this->getRequest()); $vform = $this->validateForm($form, "post"); $entries = array(); /** @var \Thelia\Model\Order $order */ foreach ($orders as $order) { if ($vform->get("order_" . $order->getId())->getData()) { $entries[] = $entry = new ExportEntry($order, $vform->get("guaranty_" . $order->getId())->getData()); $export->addEntry($entry); } } /** * Be sure that the export is done before updating the order status */ $export_data = $export->doExport(); $status = null; switch ($vform->get("new_status")->getData()) { case "processing": $status = OrderStatus::CODE_PROCESSING; break; case "sent": $status = OrderStatus::CODE_SENT; break; } if ($status !== null) { /** * If the current user doesn't have the right to edit orders, return an error */ if (null !== ($response = $this->checkAuth([AdminResources::ORDER], [], AccessManager::UPDATE))) { return $response; } /** * Get status ID */ $status_id = OrderStatusQuery::create()->findOneByCode($status)->getId(); /** @var ExportEntry $entry */ foreach ($entries as $entry) { $event = new OrderEvent($entry->getOrder()); $event->setStatus($status_id); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } } } catch (\Exception $e) { return $this->render("module-configure", ["module_code" => "Predict", "tab" => "export", "error_message" => $e->getMessage()]); } return $this->createResponse($export_data); }
/** * @depends testCreate * * @param OrderModel $order */ public function testUpdateStatus(OrderModel $order) { $newStatus = $order->getStatusId() == 5 ? 1 : 5; $this->orderEvent->setStatus($newStatus); $this->orderEvent->setOrder($order); $this->orderAction->updateStatus($this->orderEvent); $this->assertEquals($newStatus, $this->orderEvent->getOrder()->getStatusId()); $this->assertEquals($newStatus, OrderQuery::create()->findPk($order->getId())->getStatusId()); }
/** * @throws \Exception */ public function receiveResponse() { $request = $this->getRequest(); $order_id = $request->get('reference'); if (is_numeric($order_id)) { $order_id = (int) $order_id; } /* * Configure log output */ $log = Tlog::getInstance(); $log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile"); $log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, THELIA_ROOT . "log" . DS . "log-cmcic.txt"); $log->info("accessed"); $order = OrderQuery::create()->findPk($order_id); /* * Retrieve HMac for CGI2 */ $config = Config::read(CmCIC::JSON_CONFIG_PATH); $hashable = sprintf(CmCIC::CMCIC_CGI2_FIELDS, $config['CMCIC_TPE'], $request->get('date'), $request->get('montant'), $request->get('reference'), $request->get('texte-libre'), $config['CMCIC_VERSION'], $request->get('code-retour'), $request->get('cvx'), $request->get('vld'), $request->get('brand'), $request->get('status3ds'), $request->get('numauto'), $request->get('motifrefus'), $request->get('originecb'), $request->get('bincb'), $request->get('hpancb'), $request->get('ipclient'), $request->get('originetr'), $request->get('veres'), $request->get('pares')); $mac = CmCIC::computeHmac($hashable, CmCIC::getUsableKey($config["CMCIC_KEY"])); $response = CmCIC::CMCIC_CGI2_MACNOTOK . $hashable; if ($mac === strtolower($request->get('MAC'))) { $code = $request->get("code-retour"); $msg = null; $status = OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_PAID); $event = new OrderEvent($order); $event->setStatus($status->getId()); switch ($code) { case "payetest": $msg = "The test payment of the order " . $order->getRef() . " has been successfully released. "; $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); break; case "paiement": $msg = "The payment of the order " . $order->getRef() . " has been successfully released. "; $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); break; case "Annulation": $msg = "Error during the paiement: " . $this->getRequest()->get("motifrefus"); break; default: $log->error("Error while receiving response from CMCIC: code-retour not valid"); throw new \Exception(Translator::getInstance()->trans("An error occured, no valid code-retour")); } if (!empty($msg)) { $log->info($msg); } $response = CmCIC::CMCIC_CGI2_MACOK; } /* * Get log back to previous state */ $log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationRotatingFile"); return Response::create(sprintf(CmCIC::CMCIC_CGI2_RECEIPT, $response), 200, array("Content-type" => "text/plain", "Pragma" => "nocache")); }
public function updateStatus($order_id = null) { if (null !== ($response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::UPDATE))) { return $response; } $message = null; try { if ($order_id === null) { $order_id = $this->getRequest()->get("order_id"); } $order = OrderQuery::create()->findPk($order_id); $statusId = $this->getRequest()->request->get("status_id"); $status = OrderStatusQuery::create()->findPk($statusId); if (null === $order) { throw new \InvalidArgumentException("The order you want to update status does not exist"); } if (null === $status) { throw new \InvalidArgumentException("The status you want to set to the order does not exist"); } $event = new OrderEvent($order); $event->setStatus($statusId); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } catch (\Exception $e) { $message = $e->getMessage(); } $params = array(); if ($message) { $params["update_status_error_message"] = $message; } $browsedPage = $this->getRequest()->get("order_page"); $currentStatus = $this->getRequest()->get("status"); if ($browsedPage) { $params["order_page"] = $browsedPage; if (null !== $currentStatus) { $params["status"] = $currentStatus; } $response = $this->generateRedirectFromRoute("admin.order.list", $params); } else { $params["tab"] = $this->getRequest()->get("tab", 'cart'); $response = $this->generateRedirectFromRoute("admin.order.update.view", $params, ['order_id' => $order_id]); } return $response; }
public function exportAction() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('Colissimo'), AccessManager::UPDATE))) { return $response; } $form = new FormExport($this->getRequest()); try { $exportForm = $this->validateForm($form); // Get new status $status_id = $exportForm->get('status_id')->getData(); $status = OrderStatusQuery::create()->filterByCode($status_id)->findOne(); // Get Colissimo orders $orders = ColissimoQuery::getOrders()->find(); $export = ""; $store_name = ConfigQuery::getStoreName(); /** @var $order \Thelia\Model\Order */ foreach ($orders as $order) { $value = $exportForm->get('order_' . $order->getId())->getData(); if ($value) { // Get order information $customer = $order->getCustomer(); $locale = $order->getLang()->getLocale(); $address = $order->getOrderAddressRelatedByDeliveryOrderAddressId(); $country = CountryQuery::create()->findPk($address->getCountryId()); $country->setLocale($locale); $customerTitle = CustomerTitleQuery::create()->findPk($address->getCustomerTitleId()); $customerTitle->setLocale($locale); $weight = $exportForm->get('order_weight_' . $order->getId())->getData(); if ($weight == 0) { /** @var \Thelia\Model\OrderProduct $product */ foreach ($order->getOrderProducts() as $product) { $weight += (double) $product->getWeight(); } } /** * Get user's phone & cellphone * First get invoice address phone, * If empty, try to get default address' phone. * If still empty, set default value */ $phone = $address->getPhone(); if (empty($phone)) { $phone = $customer->getDefaultAddress()->getPhone(); if (empty($phone)) { $phone = self::DEFAULT_PHONE; } } // Cellphone $cellphone = $customer->getDefaultAddress()->getCellphone(); if (empty($cellphone)) { $cellphone = $customer->getDefaultAddress()->getCellphone(); if (empty($cellphone)) { $cellphone = self::DEFAULT_CELLPHONE; } } $export .= "\"" . $order->getRef() . "\";\"" . $address->getLastname() . "\";\"" . $address->getFirstname() . "\";\"" . $address->getAddress1() . "\";\"" . $address->getAddress2() . "\";\"" . $address->getAddress3() . "\";\"" . $address->getZipcode() . "\";\"" . $address->getCity() . "\";\"" . $country->getIsoalpha2() . "\";\"" . $phone . "\";\"" . $cellphone . "\";\"" . $weight . "\";\"" . $customer->getEmail() . "\";\"\";\"" . $store_name . "\";\"DOM\";\r\n"; if ($status) { $event = new OrderEvent($order); $event->setStatus($status->getId()); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } } } return Response::create(utf8_decode($export), 200, array("Content-Encoding" => "ISO-8889-1", "Content-Type" => "application/csv-tab-delimited-table", "Content-disposition" => "filename=export.csv")); } catch (FormValidationException $e) { $this->setupFormErrorContext(Translator::getInstance()->trans("colissimo expeditor export", [], Colissimo::DOMAIN_NAME), $e->getMessage(), $form, $e); return $this->render("module-configure", array("module_code" => "Colissimo")); } }
public function pay(Order $order) { $event = new OrderEvent($order); $event->setStatus(OrderStatusQuery::getPaidStatus()->getId()); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); }
/** * Set paid status to the order * @param OrderEvent $orderEvent * @throws \Propel\Runtime\Exception\PropelException */ public function changeOrderStatus(OrderEvent $orderEvent) { $paidStatusId = OrderStatusQuery::create()->filterByCode('paid')->select('ID')->findOne(); $event = new OrderEvent($orderEvent->getPlacedOrder()); $event->setStatus($paidStatusId); $orderEvent->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); }
/** * Process the cancelation of a payment on the payment gateway. The order will go back to the * "not paid" status. * * @param int $order_id the order ID */ public function cancelPayment($order_id) { $order_id = intval($order_id); if (null !== ($order = $this->getOrder($order_id))) { $this->getLog()->addInfo($this->getTranslator()->trans("Processing cancelation of payment for order ref. %ref", array('%ref' => $order->getRef()))); $event = new OrderEvent($order); $event->setStatus(OrderStatus::CODE_NOT_PAID); $this->getLog()->addInfo($this->getTranslator()->trans("Order ref. %ref is now unpaid.", array('%ref' => $order->getRef()))); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } }
protected function changeStatus() { $orderIdList = $this->getRequest()->request->get("order-selection"); if (!is_array($orderIdList)) { $orderIdList = [$orderIdList]; } $statusId = $this->getRequest()->request->get("status-status", null); $message = null; try { $status = OrderStatusQuery::create()->findPk($statusId); if (null === $status) { throw new \InvalidArgumentException("The status you want to set to the order does not exist"); } foreach ($orderIdList as $orderId) { $order = OrderQuery::create()->findPk($orderId); if (null === $order) { throw new \InvalidArgumentException("The order you want to update status does not exist"); } $event = new OrderEvent($order); $event->setStatus($statusId); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } } catch (\Exception $e) { $message = $e->getMessage(); } if (null !== $message) { $this->getRequest()->getSession()->getFlashBag()->add('tntfrance-error', $message); } return $this->generateRedirectFromRoute('tntfrance.orders.list'); }
public function cancel($order_id) { /* * Check if token&order are valid */ $token = null; $order = $this->checkorder($order_id, $token); /* * $logger PaypalApiLogManager used to log transctions with paypal */ $logger = new PaypalApiLogManager('canceled_orders'); $logger->logText("Order canceled: " . $order->getRef()); $event = new OrderEvent($order); $event->setStatus(OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_CANCELED)->getId()); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); return $this->render("order-failed", ["failed_order_id" => $order_id]); }
public function exportfile() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('DpdPickup'), AccessManager::UPDATE))) { return $response; } if (is_readable(ExportExaprint::getJSONpath())) { $admici = json_decode(file_get_contents(ExportExaprint::getJSONpath()), true); $keys = array("name", "addr", "zipcode", "city", "tel", "mobile", "mail", "expcode"); $valid = true; foreach ($keys as $key) { $valid &= isset($admici[$key]) && ($key === "assur" ? true : !empty($admici[$key])); } if (!$valid) { return Response::create(Translator::getInstance()->trans("The file DpdPickup/Config/exportdat.json is not valid. Please correct it.", [], DpdPickup::DOMAIN), 500); } } else { return Response::create(Translator::getInstance()->trans("Can't read DpdPickup/Config/exportdat.json. Did you save the export information ?", [], DpdPickup::DOMAIN), 500); } $exp_name = $admici['name']; $exp_address1 = $admici['addr']; $exp_address2 = isset($admici['addr2']) ? $admici['addr2'] : ""; $exp_zipcode = $admici['zipcode']; $exp_city = $admici['city']; $exp_phone = $admici['tel']; $exp_cellphone = $admici['mobile']; $exp_email = $admici['mail']; $exp_code = $admici['expcode']; $res = self::harmonise('$' . "VERSION=110", 'alphanumeric', 12) . "\r\n"; $orders = OrderQuery::create()->filterByDeliveryModuleId(DpdPickup::getModuleId())->find(); // FORM VALIDATION $form = new ExportExaprintSelection($this->getRequest()); $status_id = null; try { $vform = $this->validateForm($form); $status_id = $vform->get("new_status_id")->getData(); if (!preg_match("#^nochange|processing|sent\$#", $status_id)) { throw new \Exception("Invalid status ID. Expecting nochange or processing or sent"); } } catch (\Exception $e) { Tlog::getInstance()->error("Form dpdpickup.selection sent with bad infos. "); return Response::create(Translator::getInstance()->trans("Got invalid data : %err", ['%err' => $e->getMessage()], DpdPickup::DOMAIN), 500); } // For each selected order /** @var Order $order */ foreach ($orders as $order) { $orderRef = str_replace(".", "-", $order->getRef()); $collectionKey = array_search($orderRef, $vform->getData()['order_ref']); if (false !== $collectionKey && array_key_exists($collectionKey, $vform->getData()['order_ref_check']) && $vform->getData()['order_ref_check'][$collectionKey]) { // Get if the package is assured, how many packages there are & their weight $assur_package = array_key_exists($collectionKey, $vform->getData()['assur']) ? $vform->getData()['assur'][$collectionKey] : false; $pkgNumber = array_key_exists($collectionKey, $vform->getData()['pkgNumber']) ? $vform->getData()['pkgNumber'][$collectionKey] : null; $pkgWeight = array_key_exists($collectionKey, $vform->getData()['pkgWeight']) ? $vform->getData()['pkgWeight'][$collectionKey] : null; // Check if status has to be changed if ($status_id == "processing") { $event = new OrderEvent($order); $status = OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_PROCESSING); $event->setStatus($status->getId()); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } elseif ($status_id == "sent") { $event = new OrderEvent($order); $status = OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_SENT); $event->setStatus($status->getId()); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } //Get invoice address $address = OrderAddressQuery::create()->findPK($order->getInvoiceOrderAddressId()); //Get Customer object $customer = CustomerQuery::create()->findPK($order->getCustomerId()); //Get OrderAddressDpdPickup object $icirelais_code = OrderAddressIcirelaisQuery::create()->findPK($order->getDeliveryOrderAddressId()); if ($icirelais_code !== null) { // Get Customer's cellphone if (null == ($cellphone = $address->getCellphone())) { $address->getPhone(); } //Weight & price calc $price = 0; $price = $order->getTotalAmount($price, false); // tax = 0 && include postage = flase $pkgWeight = floor($pkgWeight * 100); $assur_price = $assur_package == 'true' ? $price : 0; $date_format = date("d/m/y", $order->getUpdatedAt()->getTimestamp()); $res .= self::harmonise($order->getRef(), 'alphanumeric', 35); // Order ref $res .= self::harmonise("", 'alphanumeric', 2); $res .= self::harmonise($pkgWeight, 'numeric', 8); // Package weight $res .= self::harmonise("", 'alphanumeric', 15); $res .= self::harmonise($address->getLastname(), 'alphanumeric', 35); // Charged customer $res .= self::harmonise($address->getFirstname(), 'alphanumeric', 35); $res .= self::harmonise($address->getAddress2(), 'alphanumeric', 35); // Invoice address info $res .= self::harmonise($address->getAddress3(), 'alphanumeric', 35); $res .= self::harmonise("", 'alphanumeric', 35); $res .= self::harmonise("", 'alphanumeric', 35); $res .= self::harmonise($address->getZipcode(), 'alphanumeric', 10); // Invoice address $res .= self::harmonise($address->getCity(), 'alphanumeric', 35); $res .= self::harmonise("", 'alphanumeric', 10); $res .= self::harmonise($address->getAddress1(), 'alphanumeric', 35); $res .= self::harmonise("", 'alphanumeric', 10); $res .= self::harmonise("F", 'alphanumeric', 3); // Default invoice country code $res .= self::harmonise($address->getPhone(), 'alphanumeric', 30); // Invoice phone $res .= self::harmonise("", 'alphanumeric', 15); $res .= self::harmonise($exp_name, 'alphanumeric', 35); // Expeditor name $res .= self::harmonise($exp_address2, 'alphanumeric', 35); // Expeditor address $res .= self::harmonise("", 'alphanumeric', 140); $res .= self::harmonise($exp_zipcode, 'alphanumeric', 10); $res .= self::harmonise($exp_city, 'alphanumeric', 35); $res .= self::harmonise("", 'alphanumeric', 10); $res .= self::harmonise($exp_address1, 'alphanumeric', 35); $res .= self::harmonise("", 'alphanumeric', 10); $res .= self::harmonise("F", 'alphanumeric', 3); // Default expeditor country code $res .= self::harmonise($exp_phone, 'alphanumeric', 30); // Expeditor phone $res .= self::harmonise("", 'alphanumeric', 35); // Order comment 1 $res .= self::harmonise("", 'alphanumeric', 35); // Order comment 2 $res .= self::harmonise("", 'alphanumeric', 35); // Order comment 3 $res .= self::harmonise("", 'alphanumeric', 35); // Order comment 4 $res .= self::harmonise($date_format . ' ', 'alphanumeric', 10); // Date $res .= self::harmonise($exp_code, 'numeric', 8); // Expeditor DPD code $res .= self::harmonise("", 'alphanumeric', 35); // Bar code $res .= self::harmonise($customer->getRef(), 'alphanumeric', 35); // Customer ref $res .= self::harmonise("", 'alphanumeric', 29); $res .= self::harmonise($assur_price, 'float', 9); // Insured value $res .= self::harmonise("", 'alphanumeric', 8); $res .= self::harmonise($customer->getId(), 'alphanumeric', 35); // Customer ID $res .= self::harmonise("", 'alphanumeric', 46); $res .= self::harmonise($exp_email, 'alphanumeric', 80); // Expeditor email $res .= self::harmonise($exp_cellphone, 'alphanumeric', 35); // Expeditor cellphone $res .= self::harmonise($customer->getEmail(), 'alphanumeric', 80); // Customer email $res .= self::harmonise($cellphone, 'alphanumeric', 35); // Invoice cellphone $res .= self::harmonise("", 'alphanumeric', 96); $res .= self::harmonise($icirelais_code->getCode(), 'alphanumeric', 8); // DPD relay ID $res .= "\r\n"; } } } $response = new Response(utf8_decode(mb_strtoupper($res)), 200, array('Content-Type' => 'application/csv-tab-delimited-table;charset=iso-8859-1', 'Content-disposition' => 'filename=export.dat')); return $response; }
/** * Process the cancellation of a payment on the payment gateway. The order will go back to the * "not paid" status. * * @param int $orderId the order ID */ public function cancelPayment($orderId) { try { $orderId = intval($orderId); if (null !== ($order = $this->getOrder($orderId))) { $this->getLog()->addInfo($this->getTranslator()->trans("Processing cancelation of payment for order ref. %ref", array('%ref' => $order->getRef()))); $event = new OrderEvent($order); $event->setStatus(OrderStatusQuery::getNotPaidStatus()->getId()); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); $this->getLog()->addInfo($this->getTranslator()->trans("Order ref. %ref is now unpaid.", array('%ref' => $order->getRef()))); } } catch (\Exception $ex) { $this->getLog()->addError($this->getTranslator()->trans("Error occurred while cancelling order ref. %ref, ID %id: %err", array('%err' => $ex->getMessage(), '%ref' => !isset($order) ? "?" : $order->getRef(), '%id' => !isset($order) ? "?" : $order->getId()))); throw $ex; } }
public function export() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('FreeShipping'), AccessManager::UPDATE))) { return $response; } $csv = new CSV(self::CSV_SEPARATOR); try { $form = new ExportOrder($this->getRequest()); $vform = $this->validateForm($form); // Check status_id $status_id = $vform->get("new_status_id")->getData(); if (!preg_match("#^nochange|processing|sent\$#", $status_id)) { throw new Exception("Bad value for new_status_id field"); } $status = OrderStatusQuery::create()->filterByCode(array(OrderStatus::CODE_PAID, OrderStatus::CODE_PROCESSING, OrderStatus::CODE_SENT), Criteria::IN)->find()->toArray("code"); $query = OrderQuery::create()->filterByDeliveryModuleId(FreeShipping::getModuleId())->filterByStatusId(array($status[OrderStatus::CODE_PAID]['Id'], $status[OrderStatus::CODE_PROCESSING]['Id']), Criteria::IN)->find(); // check form && exec csv /** @var \Thelia\Model\Order $order */ foreach ($query as $order) { $value = $vform->get('order_' . $order->getId())->getData(); // If checkbox is checked if ($value) { /** * Retrieve user with the order */ $customer = $order->getCustomer(); /** * Retrieve address with the order */ $address = OrderAddressQuery::create()->findPk($order->getDeliveryOrderAddressId()); if ($address === null) { throw new Exception("Could not find the order's invoice address"); } /** * Retrieve country with the address */ $country = CountryQuery::create()->findPk($address->getCountryId()); if ($country === null) { throw new Exception("Could not find the order's country"); } /** * Retrieve Title */ $title = CustomerTitleI18nQuery::create()->filterById($customer->getTitleId())->findOneByLocale($this->getSession()->getAdminEditionLang()->getLocale()); /** * Get user's phone & cellphone * First get invoice address phone, * If empty, try to get default address' phone. * If still empty, set default value */ $phone = $address->getPhone(); if (empty($phone)) { $phone = $customer->getDefaultAddress()->getPhone(); if (empty($phone)) { $phone = self::DEFAULT_PHONE; } } /** * Cellp */ $cellphone = $customer->getDefaultAddress()->getCellphone(); if (empty($cellphone)) { $cellphone = self::DEFAULT_CELLPHONE; } /** * Compute package weight */ $weight = 0; /** @var \Thelia\Model\OrderProduct $product */ foreach ($order->getOrderProducts() as $product) { $weight += (double) $product->getWeight(); } /** * Get store's name */ $store_name = ConfigQuery::read("store_name"); /** * Write CSV line */ $csv->addLine(CSVLine::create(array($address->getFirstname(), $address->getLastname(), $address->getCompany(), $address->getAddress1(), $address->getAddress2(), $address->getAddress3(), $address->getZipcode(), $address->getCity(), $country->getIsoalpha2(), $phone, $cellphone, $order->getRef(), $title->getShort(), $customer->getEmail(), $weight, $store_name))); /** * Then update order's status if necessary */ if ($status_id == "processing") { $event = new OrderEvent($order); $event->setStatus($status[OrderStatus::CODE_PROCESSING]['Id']); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } elseif ($status_id == "sent") { $event = new OrderEvent($order); $event->setStatus($status[OrderStatus::CODE_SENT]['Id']); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } } } } catch (\Exception $e) { return Response::create($e->getMessage(), 500); } return Response::create(utf8_decode($csv->parse()), 200, array("Content-Encoding" => "ISO-8889-1", "Content-Type" => "application/csv-tab-delimited-table", "Content-disposition" => "filename=export.csv")); }