public function importhillerstorp() { $ftp = Ftp::connection('hillerstorp'); $files = $ftp->getDirListing('From Hillerstorp'); foreach ($files as $file) { $localFilename = substr($file, strrpos($file, '/') + 1); $localPath = base_path("resources/files/xml/hillerstorp/imports/{$localFilename}"); $ftp->downloadFile($file, $localPath); $xml = simplexml_load_string(utf8_encode(file_get_contents($localPath))); //Order confirmations got this element, we only parse these files if ($xml->ConfirmationHeader) { $orderId = $xml->ConfirmationHeader->OrderId; $order = $this->navisionService->getByOrderNumber($orderId); if ($order) { //Loop all our items and check for date diff (delays) foreach ($xml->PurchOrderConfirmationItem as $row) { $vendorItemId = (string) $row->PurchOrderItem->ItemId; $hillerstorpDate = (string) $row->ConfirmedDeliveryDate; $navisionProduct = $order->products->where('vendorItemNumber', $vendorItemId)->first(); $updatedData = []; // If the dates are missmatching, upate webbservice if ($navisionProduct->expectedReceiptDate != $hillerstorpDate) { $updatedData[] = ['Key' => $navisionProduct->key, 'Promised_Receipt_Date' => $hillerstorpDate]; } } $this->navisionService->updateDatesAndConfirm($order->key, $updatedData); } } } }
/** * Search by order number * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function search(Request $request) { $order = $this->navisionService->getByOrderNumber($request->input('search')); if ($order) { return $this->success(); } return $this->error(); }
public function denyOrderProduct($orderNumber, Request $request) { $productData = $request->input('product'); $reason = $request->input('reason'); DB::table('denied_products')->insert(['order_number' => $orderNumber, 'product_number' => $productData['number'], 'product_key' => $productData['key'], 'reason' => $reason, 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]); event(with(new OrderChangedEvent($orderNumber))); $order = $this->navisionService->getByOrderNumber($orderNumber)->first(); return $this->success($order); }