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);
             }
         }
     }
 }
Beispiel #2
0
 public function __construct($connection = '')
 {
     if ($connection) {
         $this->ftpCon = Ftp::connection($connection);
     } else {
         $this->ftpCon = Ftp::connection();
     }
 }