public function process(array $data)
 {
     //todo log the data to get the order increment id
     $shipment = Mage::getModel('sales/order_shipment')->load($data['order_id'], 'order_id');
     $customerId = null;
     $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore($data['store_id'])->getWebsiteId())->loadByEmail($data['partner_email']);
     if ($customer->getId()) {
         $customerId = ' (' . $customer->getId() . ')';
     }
     $helperTools = Mage::helper('swisspost_yellowcube/tools');
     $partner = new Partner();
     $partner->setPartnerType($data['partner_type'])->setPartnerNo($this->cutString($data['partner_number']), 10)->setPartnerReference($this->cutString($this->getHelper()->getPartnerReference($data['partner_name'], $data['partner_zip_code'])), 50)->setName1($this->cutString($data['partner_name']))->setName2($this->cutString($data['partner_name2']))->setStreet($this->cutString($data['partner_street']))->setName3($this->cutString($data['partner_name3']))->setCountryCode($data['partner_country_code'])->setZIPCode($this->cutString($data['partner_zip_code']), 10)->setCity($this->cutString($data['partner_city']))->setEmail($this->cutString($data['partner_email']), 241)->setPhoneNo($this->cutString($data['partner_phone']), 16)->setLanguageCode($this->cutString($data['partner_language']), 2);
     $ycOrder = new Order();
     $ycOrder->setOrderHeader(new OrderHeader($this->cutString($data['deposit_number'], 10), $this->cutString($shipment->getIncrementId()), $data['order_date']))->setPartnerAddress($partner)->addValueAddedService(new BasicShippingServices($this->cutString($data['service_basic_shipping']), 40))->addValueAddedService(new AdditionalShippingServices($this->cutString($data['service_additional_shipping']), 40))->setOrderDocumentsFlag(false);
     // Mime-Type: X(3) pdf oder pcl (kleine Buchstaben)
     // DocTyp: X(2) IV=Invoice/Rechnung, LS=Lieferschein, ZS=ZahlSchein
     $doc = null;
     $pdfa = $this->getPdfA($shipment);
     if ($pdfa) {
         $doc = Doc::fromFile(Doc::DOC_TYPE_LS, Doc::MIME_TYPE_PDF, $pdfa);
         $ycOrder->addOrderDocument($doc)->setOrderDocumentsFlag(true);
     }
     foreach ($data['items'] as $key => $item) {
         $position = new Position();
         $position->setPosNo($key + 1)->setArticleNo($this->cutString($item['article_number']))->setEAN($this->cutString($item['article_ean']))->setPlant($this->cutString($data['plant_id']), 4)->setQuantity($item['article_qty'])->setQuantityISO(\YellowCube\ART\UnitsOfMeasure\ISO::PCE)->setShortDescription($this->cutString($item['article_title']), 40);
         $ycOrder->addOrderPosition($position);
     }
     $response = $this->getYellowCubeService()->createYCCustomerOrder($ycOrder);
     try {
         if (!is_object($response) || !$response->isSuccess()) {
             $message = $this->getHelper()->__('Shipment #%s for Order #%s could not be transmitted to YellowCube: "%s".', $shipment->getIncrementId(), $data['order_increment_id'], $response->getStatusText());
             $shipment->addComment($message, false, false)->save();
             Mage::log($message . "\n" . print_r($response, true), Zend_Log::ERR, Swisspost_YellowCube_Helper_Data::YC_LOG_FILE, true);
             $helperTools->sendAdminNotification($message);
             // @todo allow the user to send again to yellow cube the request from backend
         } else {
             if ($this->getHelper()->getDebug()) {
                 Mage::log(print_r($ycOrder, true), Zend_Log::DEBUG, Swisspost_YellowCube_Helper_Data::YC_LOG_FILE);
                 Mage::log(print_r($response, true), Zend_Log::DEBUG, Swisspost_YellowCube_Helper_Data::YC_LOG_FILE);
             }
             /**
              * Define yc_shipped to 0 to be used later in BAR process that the shipping has not been done
              */
             reset($data['items']);
             foreach ($shipment->getItemsCollection() as $item) {
                 /* @var $item Mage_Sales_Model_Order_Shipment_Item */
                 $item->setAdditionalData(Zend_Json::encode(array('yc_shipped' => 0)))->save();
             }
             $shipment->addComment($this->getHelper()->__('Shipment #%s for Order #%s was successfully transmitted to YellowCube. Received reference number %s and status message "%s".', $shipment->getIncrementId(), $data['order_increment_id'], $response->getReference(), $response->getStatusText()), false, false)->save();
             // WAR Message
             $this->getQueue()->send(Zend_Json::encode(array('action' => Swisspost_YellowCube_Model_Synchronizer::SYNC_ORDER_UPDATE, 'order_id' => $data['order_id'], 'shipment_increment_id' => $shipment->getIncrementId(), 'yc_reference' => $response->getReference())));
         }
     } catch (Exception $e) {
         // Let's keep going further processes
         Mage::logException($e);
     }
     return $this;
 }
use YellowCube\WAB\AdditionalService\DeliveryTimeJIT;
use YellowCube\WAB\AdditionalService\DeliveryTimeTo;
use YellowCube\WAB\AdditionalService\FloorNo;
use YellowCube\WAB\AdditionalService\FrightShippingFlag;
use YellowCube\WAB\AdditionalService\NotificationServiceCode;
use YellowCube\WAB\AdditionalService\NotificationType;
use YellowCube\WAB\Order;
use YellowCube\WAB\OrderHeader;
use YellowCube\WAB\Partner;
use YellowCube\WAB\Position;
### "order-header"
$order = new Order();
$order->setOrderHeader(new OrderHeader('0000040730', \uniqid('yc'), date('Ymd')));
### "partner-address"
$partner = new Partner();
$partner->setPartnerType('WE')->setPartnerNo('0000300020')->setPartnerReference('LiiP AG')->setTitle('Madame')->setName1('We Name')->setName2('c/o Cailler')->setStreet('Strasse')->setCountryCode('CH')->setZIPCode('8057')->setCity('Zurich')->setPOBox('po box')->setPhoneNo('0041793020467')->setSMSAvisMobNo('0041793020467')->setFaxNo('0041793020467')->setEmail('*****@*****.**')->setLanguageCode('en');
$order->setPartnerAddress($partner);
### "order-position"
$position = new Position();
$position->setPosNo(10)->setArticleNo('200522004')->setEAN('714718003580')->setPlant('Y010')->setQuantity(1.0)->setQuantityISO('PCE')->setShortDescription('loral Pasty Daisie');
$order->addOrderPosition($position);
### "order-document"
$exampleDocument = YellowCube\WAB\Doc::fromFile('LS', 'pdf', '../../../../../order/example-file.pdf');
$order->addOrderDocument($exampleDocument);
### "additional-services"
$order->addValueAddedService(new AdditionalShippingServices())->addValueAddedService(new BasicShippingServices(BasicShippingServices::ECO))->addValueAddedService(new DeliveryInstructions('ZAW3219;ZAW3222'))->addValueAddedService(new DeliveryLocation('Last house in the street.'))->addValueAddedService(new DeliveryPeriodeCode(DeliveryPeriodeCode::MORNING))->addValueAddedService(new DeliveryTimeFrom('13:00'))->addValueAddedService(new DeliveryTimeTo('15:00'))->addValueAddedService(new DeliveryTimeJIT('14:00'))->addValueAddedService(new DeliveryDate(date('Ymd', strtotime('+4 days'))))->addValueAddedService(new CODAmount('150.00'))->addValueAddedService(new CODAccountNo('010683242'))->addValueAddedService(new CODRefNo('897201301070000097673'))->addValueAddedService(new FrightShippingFlag('1'))->addValueAddedService(new FloorNo('3'))->addValueAddedService(new NotificationType(NotificationType::EMAIL))->addValueAddedService(new NotificationServiceCode('2'));
### "create-order"
$service = new YellowCube\Service(Config::testConfig());
$response = $service->createYCCustomerOrder($order);
echo "Successfully created order with reference {$response->getReference()}" . PHP_EOL . PHP_EOL;
print_r($response);