コード例 #1
0
 public function saveorderdetail()
 {
     $this->layout = 'index';
     $this->autoRender = false;
     $this->loadModel('OpenOrder');
     $this->loadModel('AssignService');
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = Configure::read('linnwork_api_username');
     $password = Configure::read('linnwork_api_password');
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $openorder = OrdersMethods::GetOpenOrders('100', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
     foreach ($openorder->Data as $orderids) {
         $orders[] = $orderids->OrderId;
     }
     $results = OrdersMethods::GetOrders($orders, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     foreach ($results as $result) {
         $data['order_id'] = $result->OrderId;
         $data['num_order_id'] = $result->NumOrderId;
         $data['general_info'] = serialize($result->GeneralInfo);
         $data['shipping_info'] = serialize($result->ShippingInfo);
         $data['customer_info'] = serialize($result->CustomerInfo);
         $data['totals_info'] = serialize($result->TotalsInfo);
         $data['folder_name'] = serialize($result->FolderName);
         $data['items'] = serialize($result->Items);
         //Extra information will save my according to manage sorting station section
         $data['destination'] = $result->CustomerInfo->Address->Country;
         $this->OpenOrder->create();
         $checkorder = $this->OpenOrder->find('all', array('conditions' => array('OpenOrder.order_id' => $result->OrderId)));
         if (count($checkorder) > 0) {
         } else {
             $this->OpenOrder->save($data);
         }
     }
     /* call the function for assign the postal servises */
     $this->assign_services();
     $this->getBarcode();
     $this->setAgainAssignedServiceToAllOrder();
     // Euraco Group
 }
コード例 #2
0
 public function saveorderdetail()
 {
     $this->layout = 'index';
     $this->autoRender = false;
     $this->loadModel('OpenOrder');
     $this->loadModel('AssignService');
     $this->loadModel('Customer');
     $this->loadModel('OrderItem');
     $this->loadModel('Product');
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = Configure::read('linnwork_api_username');
     $password = Configure::read('linnwork_api_password');
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $openorder = OrdersMethods::GetOpenOrders('100', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
     foreach ($openorder->Data as $orderids) {
         $orders[] = $orderids->OrderId;
     }
     $results = OrdersMethods::GetOrders($orders, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     $countryArray = array('Austria' => 'Austria', 'Belgium' => 'Belgium', 'Bulgaria' => 'Bulgaria', 'Croatia' => 'Croatia', 'Cyprus' => 'Cyprus', 'Czech Republic' => 'Czech Republic', 'Denmark' => 'Denmark', 'Estonia' => 'Estonia', 'Finland' => 'Finland', 'France' => 'France', 'Germany' => 'Germany', 'Greece' => 'Greece', 'Hungary' => 'Hungary', 'Ireland' => 'Ireland', 'Italy' => 'Italy', 'Latvia' => 'Latvia', 'Lithuania' => 'Lithuania', 'Luxembourg' => 'Luxembourg', 'Malta' => 'Malta', 'Netherlands' => 'Netherlands', 'Poland' => 'Poland', 'Portugal' => 'Portugal', 'Romania' => 'Romania', 'Slovakia' => 'Slovakia', 'Slovenia' => 'Slovenia', 'Spain' => 'Spain', 'Sweden' => 'Sweden', 'United Kingdom' => 'United Kingdom');
     foreach ($results as $result) {
         if (($result->GeneralInfo->Status == 1 || $result->GeneralInfo->Status == 4) && $result->GeneralInfo->HoldOrCancel == '') {
             $data['order_id'] = $result->OrderId;
             $data['num_order_id'] = $result->NumOrderId;
             $data['general_info'] = serialize($result->GeneralInfo);
             $data['shipping_info'] = serialize($result->ShippingInfo);
             $data['customer_info'] = serialize($result->CustomerInfo);
             $data['totals_info'] = serialize($result->TotalsInfo);
             $data['folder_name'] = serialize($result->FolderName);
             $data['items'] = serialize($result->Items);
             //Extra information will save my according to manage sorting station section
             $country = $data['destination'] = $result->CustomerInfo->Address->Country;
             $orderitems = unserialize($data['items']);
             $this->OpenOrder->create();
             $checkorder = $this->OpenOrder->find('all', array('conditions' => array('OpenOrder.order_id' => $result->OrderId)));
             if (count($checkorder) > 0) {
             } else {
                 $this->OpenOrder->save($data);
                 //pr($result); exit;
                 $getCurrencyText = $result->TotalsInfo->Currency;
                 if ($getCurrencyText == "EUR") {
                     $baseRate = '1';
                 } else {
                     $baseRate = '1.38';
                 }
                 //pr($orderitems);
                 /***************** split the order item ******************/
                 $bundleIdentity = 0;
                 foreach ($orderitems as $orderitem) {
                     echo $orderitem->SKU . '==' . $orderitem->PricePerUnit;
                     echo "<br>";
                     $splitskus = explode('-', $orderitem->SKU);
                     $count = count($splitskus);
                     if (count($orderitems) > 1) {
                         $orderGroup = "Group B";
                     } else {
                         $orderGroup = "Group A";
                     }
                     //Find Country
                     if (in_array($country, $countryArray)) {
                         //It means, Inside EU country shipping for bundle with sameSKU
                         if ($splitskus['0'] == 'B') {
                             for ($i = 1; $i <= count($splitskus) - 2; $i++) {
                                 if ($count == 3) {
                                     echo $value = $orderitem->Quantity * $orderitem->PricePerUnit * $baseRate;
                                     //echo $value = $orderitem->CostIncTax * $baseRate;
                                     echo "<br>";
                                     //For Euro
                                     if ($value <= 35 || $value > 150) {
                                         $numId = '';
                                         if ($bundleIdentity > 0) {
                                             $bundleIdentity = $bundleIdentity + 1;
                                             $numId = $result->NumOrderId . '-' . $bundleIdentity;
                                             $splititem['product_order_id_identify'] = $numId;
                                             $splititem['order_split'] = $orderGroup;
                                             //$splititem['order_split']		=	"split";
                                         } else {
                                             if (count($orderitems) == 1) {
                                                 $numId = $result->NumOrderId;
                                             } else {
                                                 $bundleIdentity = $bundleIdentity + 1;
                                                 $numId = $result->NumOrderId . '-' . $bundleIdentity;
                                                 $splititem['product_order_id_identify'] = $numId;
                                                 $splititem['order_split'] = $orderGroup;
                                                 //$splititem['order_split']		=	"split";
                                             }
                                         }
                                         $splititem['order_split'] = $orderGroup;
                                         $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                         $splititem['product_sku_identifier'] = "single";
                                         $splititem['price'] = $orderitem->PricePerUnit;
                                         $splititem['quantity'] = $orderitem->Quantity;
                                         $splititem['product_type'] = "bundle";
                                         $splititem['order_id'] = $result->NumOrderId;
                                         $splititem['sku'] = 'S-' . $splitskus[$i];
                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                         $this->OrderItem->create();
                                         $this->OrderItem->save($splititem);
                                     } else {
                                         if ($value <= 150 && $value > 35) {
                                             $total = 0;
                                             $perUnitPrice = $orderitem->Quantity * $orderitem->PricePerUnit;
                                             $orderQuantity = $orderitem->Quantity * $splitskus[$count - 1];
                                             $itemPrice = $perUnitPrice / $orderQuantity;
                                             $inc = 0;
                                             $checkOuter = 0;
                                             $isLeader = false;
                                             if ($orderQuantity > 1) {
                                                 //It will be the same as Linnworks custom script term , So now will split the orders with SEQUENCING
                                                 $e = 0;
                                                 while ($e <= $orderQuantity - 1) {
                                                     //$total = $total + ( $baseRate * $itemPrice );
                                                     if ($total + $baseRate * $itemPrice <= 35) {
                                                         $total = $total + $baseRate * $itemPrice;
                                                         echo $total;
                                                         echo "<br>";
                                                         $inc++;
                                                         $checkOuter++;
                                                         $isLeader = true;
                                                         if ($e == $orderQuantity - 1) {
                                                             echo "Now Split" . $total;
                                                             echo "<br>*********<br>";
                                                             //Splitting the order accordign the rule
                                                             //Store previous then initialized
                                                             $bundleIdentity++;
                                                             //Store and split the same SKU bundle order
                                                             $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                             $splititem['product_sku_identifier'] = "single";
                                                             $splititem['price'] = $total / $baseRate;
                                                             $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                             $splititem['order_split'] = $orderGroup;
                                                             $splititem['quantity'] = $inc;
                                                             $splititem['product_type'] = "bundle";
                                                             $splititem['order_id'] = $result->NumOrderId;
                                                             $splititem['sku'] = 'S-' . $splitskus[$i];
                                                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                             $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                             pr($splititem);
                                                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                             $this->OrderItem->create();
                                                             $this->OrderItem->save($splititem);
                                                             $total = 0;
                                                             $inc = 1;
                                                             $total = $total + $baseRate * $itemPrice;
                                                             echo $total;
                                                             echo "<br>";
                                                         }
                                                     } else {
                                                         if ($isLeader == false) {
                                                             //Increase Counter
                                                             $checkOuter++;
                                                             $total = $total + $baseRate * $itemPrice;
                                                             if ($e == $orderQuantity - 1) {
                                                                 $inc = 1;
                                                                 echo "Now Split " . $total;
                                                                 echo "<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "single";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 $splititem['order_split'] = $orderGroup;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['quantity'] = $checkOuter;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 0;
                                                             }
                                                         } else {
                                                             if ($e == $orderQuantity - 1) {
                                                                 //For Previous calculate and store it split order into database
                                                                 echo "Now Split------" . $total;
                                                                 echo "<br>*********<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "single";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['order_split'] = $orderGroup;
                                                                 $splititem['quantity'] = $inc;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 1;
                                                                 $total = $total + $baseRate * $itemPrice;
                                                                 echo $total;
                                                                 echo "<br>";
                                                                 //Now store last index calculation if reaches at end point then
                                                                 //need to be remind , there is last one we have to also store into database
                                                                 echo "Now Split" . $total;
                                                                 echo "<br>*********<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "single";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['order_split'] = $orderGroup;
                                                                 $splititem['quantity'] = $inc;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 1;
                                                                 $total = $total + $baseRate * $itemPrice;
                                                                 echo $total;
                                                                 echo "<br>";
                                                             } else {
                                                                 echo "Now Split " . $total;
                                                                 echo "<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "single";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['order_split'] = $orderGroup;
                                                                 $splititem['quantity'] = $inc;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 1;
                                                                 $total = $total + $baseRate * $itemPrice;
                                                                 echo $total;
                                                                 echo "<br>";
                                                             }
                                                         }
                                                     }
                                                     $e++;
                                                 }
                                             }
                                         } else {
                                             //echo "Exceed Limit to split."; exit;
                                         }
                                     }
                                 } else {
                                     //Get Count Sku for bundle with multiple
                                     $getLastIndex = $splitskus[count($splitskus) - 1];
                                     //Handle Multiple Sku with type bundle
                                     echo $value = $orderitem->Quantity * ($orderitem->PricePerUnit / $getLastIndex) * $baseRate;
                                     //echo $value = $orderitem->CostIncTax * $baseRate;
                                     echo "<br>";
                                     $anotherValue = $orderitem->Quantity * $orderitem->PricePerUnit * $baseRate;
                                     //For Euro
                                     if ($anotherValue <= 35 || $anotherValue > 150) {
                                         //Check bundle with single Sku if comes under 35 from single SKU
                                         /*$numId = '';
                                         		if( $bundleIdentity > 0 )
                                         		{
                                         			$bundleIdentity = $bundleIdentity + 1;												
                                         			$numId = $result->NumOrderId .'-'. $bundleIdentity;
                                         			$splititem['product_order_id_identify']		=	$numId;
                                         			$splititem['order_split']		=	$orderGroup;
                                         		}
                                         		else
                                         		{
                                         			$bundleIdentity = $bundleIdentity + 1;	
                                         			$numId = $result->NumOrderId .'-'. $bundleIdentity;	
                                         			$splititem['product_order_id_identify']		=	$numId;
                                         			$splititem['order_split']		=	$orderGroup;														
                                         		}
                                         		
                                         		$splititem['order_split']		=	$orderGroup;
                                         		$splititem['pack_order_quantity']		=	$splitskus[$count-1];
                                         		$splititem['product_sku_identifier']		= "multiple";			
                                         		$splititem['price']		=	$value; //$orderitem->PricePerUnit;
                                         		
                                         		$splititem['quantity']			=	$orderitem->Quantity;
                                         		$splititem['product_type']		=	"bundle";
                                         		$splititem['order_id']		=	$result->NumOrderId;
                                         		$splititem['sku']			=	'S-'.$splitskus[$i];
                                         		$productDetail				=	$this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'] )));
                                         		$splititem['barcode']		=	$productDetail['ProductDesc']['barcode'];
                                         		
                                         		$productDetail['Product']['current_stock_level']	= $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                         		$productDetail['Product']['lock_qty']				= $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                         		
                                         		$this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']),
                                         									array('Product.product_sku' => $splititem['sku']));
                                         		$this->OrderItem->create();
                                         		$this->OrderItem->save( $splititem );*/
                                         if (count($splitskus) - 2 == $i) {
                                             echo $totalQuantity = $orderitem->Quantity * $getLastIndex;
                                             echo "<br>";
                                             $combinedSkuForMulti .= ',' . $orderitem->Quantity . 'X' . 'S-' . $splitskus[$i];
                                             if ($bundleIdentity > 0) {
                                                 if (count($orderitems) > 1) {
                                                     $bundleIdentity = $bundleIdentity + 1;
                                                     $numId = $result->NumOrderId . '-' . $bundleIdentity;
                                                 } else {
                                                     $numId = $result->NumOrderId;
                                                 }
                                             } else {
                                                 if (count($orderitems) > 1) {
                                                     $bundleIdentity = $bundleIdentity + 1;
                                                     $numId = $result->NumOrderId . '-' . $bundleIdentity;
                                                 } else {
                                                     $numId = $result->NumOrderId;
                                                 }
                                             }
                                             $splititem['product_order_id_identify'] = $numId;
                                             $splititem['order_split'] = "Group B";
                                             $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                             $splititem['product_sku_identifier'] = "multiple";
                                             $splititem['price'] = $orderitem->PricePerUnit;
                                             $splititem['quantity'] = $totalQuantity;
                                             $splititem['product_type'] = "bundle";
                                             $splititem['order_id'] = $result->NumOrderId;
                                             $splititem['sku'] = $combinedSkuForMulti;
                                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                             $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                             $this->OrderItem->create();
                                             $this->OrderItem->save($splititem);
                                         } else {
                                             echo $totalQuantity = $orderitem->Quantity * $getLastIndex;
                                             echo "<br>";
                                             if ($i == 1) {
                                                 $combinedSkuForMulti = $orderitem->Quantity . 'X' . 'S-' . $splitskus[$i];
                                             } else {
                                                 $combinedSkuForMulti .= ',' . $orderitem->Quantity . 'X' . 'S-' . $splitskus[$i];
                                             }
                                         }
                                     } else {
                                         if ($anotherValue <= 150 && $anotherValue > 35) {
                                             $total = 0;
                                             $perUnitPrice = $orderitem->Quantity * ($orderitem->PricePerUnit / $getLastIndex);
                                             $orderQuantity = $orderitem->Quantity;
                                             $itemPrice = $perUnitPrice / $orderQuantity;
                                             $inc = 0;
                                             $checkOuter = 0;
                                             $isLeader = false;
                                             if ($orderQuantity > 0) {
                                                 //It will be the same as Linnworks custom script term , So now will split the orders with SEQUENCING
                                                 $e = 0;
                                                 while ($e <= $orderQuantity - 1) {
                                                     //$total = $total + ( $baseRate * $itemPrice );
                                                     if ($total + $baseRate * $itemPrice <= 35) {
                                                         $total = $total + $baseRate * $itemPrice;
                                                         echo $total;
                                                         echo "<br>";
                                                         $inc++;
                                                         $checkOuter++;
                                                         $isLeader = true;
                                                         if ($e == $orderQuantity - 1) {
                                                             echo "Now Split" . $total;
                                                             echo "<br>*********<br>";
                                                             //Splitting the order accordign the rule
                                                             //Store previous then initialized
                                                             $bundleIdentity++;
                                                             //Store and split the same SKU bundle order
                                                             $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                             $splititem['product_sku_identifier'] = "multiple";
                                                             $splititem['price'] = $total / $baseRate;
                                                             $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                             $splititem['order_split'] = "Group B";
                                                             //$orderGroup;
                                                             $splititem['quantity'] = $inc;
                                                             $splititem['product_type'] = "bundle";
                                                             $splititem['order_id'] = $result->NumOrderId;
                                                             $splititem['sku'] = 'S-' . $splitskus[$i];
                                                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                             $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                             pr($splititem);
                                                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                             $this->OrderItem->create();
                                                             $this->OrderItem->save($splititem);
                                                             $total = 0;
                                                             $inc = 1;
                                                             $total = $total + $baseRate * $itemPrice;
                                                             echo $total;
                                                             echo "<br>";
                                                         }
                                                     } else {
                                                         if ($isLeader == false) {
                                                             //Increase Counter
                                                             $checkOuter++;
                                                             $total = $total + $baseRate * $itemPrice;
                                                             if ($e == $orderQuantity - 1) {
                                                                 $inc = 1;
                                                                 echo "Now Split " . $total;
                                                                 echo "<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "multiple";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 $splititem['order_split'] = "Group B";
                                                                 //$orderGroup;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['quantity'] = $checkOuter;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 0;
                                                             }
                                                         } else {
                                                             if ($e == $orderQuantity - 1) {
                                                                 //For Previous calculate and store it split order into database
                                                                 echo "Now Split------" . $total;
                                                                 echo "<br>*********<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "multiple";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['order_split'] = "Group B";
                                                                 //$orderGroup;
                                                                 $splititem['quantity'] = $inc;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 1;
                                                                 $total = $total + $baseRate * $itemPrice;
                                                                 echo $total;
                                                                 echo "<br>";
                                                                 //Now store last index calculation if reaches at end point then
                                                                 //need to be remind , there is last one we have to also store into database
                                                                 echo "Now Split" . $total;
                                                                 echo "<br>*********<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "multiple";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['order_split'] = "Group B";
                                                                 //$orderGroup;
                                                                 $splititem['quantity'] = $inc;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 1;
                                                                 $total = $total + $baseRate * $itemPrice;
                                                                 echo $total;
                                                                 echo "<br>";
                                                             } else {
                                                                 echo "Now Split " . $total;
                                                                 echo "<br>";
                                                                 //Splitting the order accordign the rule
                                                                 //Store previous then initialized
                                                                 $bundleIdentity++;
                                                                 //Store and split the same SKU bundle order
                                                                 $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                                 $splititem['product_sku_identifier'] = "multiple";
                                                                 $splititem['price'] = $total / $baseRate;
                                                                 $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                                 //$splititem['order_split']		=	"split";
                                                                 $splititem['order_split'] = "Group B";
                                                                 //$orderGroup;
                                                                 $splititem['quantity'] = $inc;
                                                                 $splititem['product_type'] = "bundle";
                                                                 $splititem['order_id'] = $result->NumOrderId;
                                                                 $splititem['sku'] = 'S-' . $splitskus[$i];
                                                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                                 pr($splititem);
                                                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                                 $this->OrderItem->create();
                                                                 $this->OrderItem->save($splititem);
                                                                 $total = 0;
                                                                 $inc = 1;
                                                                 $total = $total + $baseRate * $itemPrice;
                                                                 echo $total;
                                                                 echo "<br>";
                                                             }
                                                         }
                                                     }
                                                     $e++;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             // Single SKU order splitting
                             echo $value = $orderitem->Quantity * $orderitem->PricePerUnit * $baseRate;
                             //echo $value = $orderitem->CostIncTax * $baseRate;
                             echo "<br>";
                             //For Euro
                             if ($value <= 35 || $value > 150) {
                                 $numId = '';
                                 if ($bundleIdentity > 0) {
                                     $bundleIdentity = $bundleIdentity + 1;
                                     $numId = $result->NumOrderId . '-' . $bundleIdentity;
                                     $splititem['product_order_id_identify'] = $numId;
                                     //$splititem['order_split']		=	"split";
                                 } else {
                                     if (count($orderitems) == 1) {
                                         $numId = $result->NumOrderId;
                                     } else {
                                         $bundleIdentity = $bundleIdentity + 1;
                                         $numId = $result->NumOrderId . '-' . $bundleIdentity;
                                         $splititem['product_order_id_identify'] = $numId;
                                         //$splititem['order_split']		=	"split";
                                     }
                                 }
                                 $splititem['order_split'] = $orderGroup;
                                 $splititem['pack_order_quantity'] = 0;
                                 $splititem['product_sku_identifier'] = "single";
                                 $splititem['price'] = $orderitem->PricePerUnit;
                                 $splititem['quantity'] = $orderitem->Quantity;
                                 $splititem['product_type'] = "single";
                                 $splititem['order_id'] = $result->NumOrderId;
                                 $splititem['sku'] = $orderitem->SKU;
                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                 $this->OrderItem->create();
                                 $this->OrderItem->save($splititem);
                             } else {
                                 if ($value <= 150 && $value > 35) {
                                     $total = 0;
                                     $perUnitPrice = $orderitem->Quantity * $orderitem->PricePerUnit;
                                     $orderQuantity = $orderitem->Quantity;
                                     $itemPrice = $perUnitPrice / $orderQuantity;
                                     $inc = 0;
                                     $checkOuter = 0;
                                     $isLeader = false;
                                     if ($orderQuantity > 1) {
                                         //It will be the same as Linnworks custom script term , So now will split the orders with SEQUENCING
                                         $e = 0;
                                         while ($e <= $orderQuantity - 1) {
                                             //$total = $total + ( $baseRate * $itemPrice );
                                             if ($total + $baseRate * $itemPrice <= 35) {
                                                 $total = $total + $baseRate * $itemPrice;
                                                 echo $total;
                                                 echo "<br>";
                                                 $inc++;
                                                 $checkOuter++;
                                                 $isLeader = true;
                                                 if ($e == $orderQuantity - 1) {
                                                     echo "Now Split" . $total;
                                                     echo "<br>*********<br>";
                                                     //Splitting the order accordign the rule
                                                     //Store previous then initialized
                                                     $bundleIdentity++;
                                                     //Store and split the same SKU bundle order
                                                     $splititem['pack_order_quantity'] = 0;
                                                     $splititem['product_sku_identifier'] = "single";
                                                     $splititem['price'] = $total / $baseRate;
                                                     $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                     //$splititem['order_split']		=	"split";
                                                     $splititem['order_split'] = $orderGroup;
                                                     $splititem['quantity'] = $inc;
                                                     $splititem['product_type'] = "single";
                                                     $splititem['order_id'] = $result->NumOrderId;
                                                     $splititem['sku'] = $orderitem->SKU;
                                                     $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                     $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                     pr($splititem);
                                                     $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                     $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                     $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                     $this->OrderItem->create();
                                                     $this->OrderItem->save($splititem);
                                                     $total = 0;
                                                     $inc = 1;
                                                     $total = $total + $baseRate * $itemPrice;
                                                     echo $total;
                                                     echo "<br>";
                                                 }
                                             } else {
                                                 if ($isLeader == false) {
                                                     //Increase Counter
                                                     $checkOuter++;
                                                     $total = $total + $baseRate * $itemPrice;
                                                     if ($e == $orderQuantity - 1) {
                                                         $inc = 1;
                                                         echo "Now Split " . $total;
                                                         echo "<br>";
                                                         //Splitting the order accordign the rule
                                                         //Store previous then initialized
                                                         $bundleIdentity++;
                                                         //Store and split the same SKU bundle order
                                                         $splititem['pack_order_quantity'] = 0;
                                                         $splititem['product_sku_identifier'] = "single";
                                                         $splititem['price'] = $total / $baseRate;
                                                         $splititem['product_order_id_identify'] = $result->NumOrderId;
                                                         $splititem['order_split'] = $orderGroup;
                                                         $splititem['quantity'] = $checkOuter;
                                                         $splititem['product_type'] = "single";
                                                         $splititem['order_id'] = $result->NumOrderId;
                                                         $splititem['sku'] = $orderitem->SKU;
                                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                         pr($splititem);
                                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                         $this->OrderItem->create();
                                                         $this->OrderItem->save($splititem);
                                                         $total = 0;
                                                         $inc = 0;
                                                     }
                                                 } else {
                                                     if ($e == $orderQuantity - 1) {
                                                         //For Previous calculate and store it split order into database
                                                         echo "Now Split------" . $total;
                                                         echo "<br>*********<br>";
                                                         //Splitting the order accordign the rule
                                                         //Store previous then initialized
                                                         $bundleIdentity++;
                                                         //Store and split the same SKU bundle order
                                                         $splititem['pack_order_quantity'] = 0;
                                                         $splititem['product_sku_identifier'] = "single";
                                                         $splititem['price'] = $total / $baseRate;
                                                         $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                         //$splititem['order_split']		=	"split";
                                                         $splititem['order_split'] = $orderGroup;
                                                         $splititem['quantity'] = $inc;
                                                         $splititem['product_type'] = "single";
                                                         $splititem['order_id'] = $result->NumOrderId;
                                                         $splititem['sku'] = $orderitem->SKU;
                                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                         pr($splititem);
                                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                         $this->OrderItem->create();
                                                         $this->OrderItem->save($splititem);
                                                         $total = 0;
                                                         $inc = 1;
                                                         $total = $total + $baseRate * $itemPrice;
                                                         echo $total;
                                                         echo "<br>";
                                                         //Now store last index calculation if reaches at end point then
                                                         //need to be remind , there is last one we have to also store into database
                                                         echo "Now Split" . $total;
                                                         echo "<br>*********<br>";
                                                         //Splitting the order accordign the rule
                                                         //Store previous then initialized
                                                         $bundleIdentity++;
                                                         //Store and split the same SKU bundle order
                                                         $splititem['pack_order_quantity'] = 0;
                                                         $splititem['product_sku_identifier'] = "single";
                                                         $splititem['price'] = $total / $baseRate;
                                                         $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                         $splititem['order_split'] = $orderGroup;
                                                         $splititem['quantity'] = $inc;
                                                         $splititem['product_type'] = "single";
                                                         $splititem['order_id'] = $result->NumOrderId;
                                                         $splititem['sku'] = $orderitem->SKU;
                                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                         pr($splititem);
                                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                         $this->OrderItem->create();
                                                         $this->OrderItem->save($splititem);
                                                         $total = 0;
                                                         $inc = 1;
                                                         $total = $total + $baseRate * $itemPrice;
                                                         echo $total;
                                                         echo "<br>";
                                                     } else {
                                                         echo "Now Split " . $total;
                                                         echo "<br>";
                                                         //Splitting the order accordign the rule
                                                         //Store previous then initialized
                                                         $bundleIdentity++;
                                                         //Store and split the same SKU bundle order
                                                         $splititem['pack_order_quantity'] = 0;
                                                         $splititem['product_sku_identifier'] = "single";
                                                         $splititem['price'] = $total / $baseRate;
                                                         $splititem['product_order_id_identify'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                         $splititem['order_split'] = $orderGroup;
                                                         $splititem['quantity'] = $inc;
                                                         $splititem['product_type'] = "single";
                                                         $splititem['order_id'] = $result->NumOrderId;
                                                         $splititem['sku'] = $orderitem->SKU;
                                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                         pr($splititem);
                                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                         $this->OrderItem->create();
                                                         $this->OrderItem->save($splititem);
                                                         $total = 0;
                                                         $inc = 1;
                                                         $total = $total + $baseRate * $itemPrice;
                                                         echo $total;
                                                         echo "<br>";
                                                     }
                                                 }
                                             }
                                             $e++;
                                         }
                                     } else {
                                         //If order item count is 1 then would be store directly
                                         $splititem['pack_order_quantity'] = 0;
                                         $splititem['product_sku_identifier'] = "single";
                                         $splititem['price'] = $orderitem->PricePerUnit;
                                         $splititem['order_split'] = $orderGroup;
                                         $splititem['quantity'] = $orderitem->Quantity;
                                         $splititem['product_type'] = "single";
                                         $splititem['order_id'] = $result->NumOrderId;
                                         $splititem['sku'] = $orderitem->SKU;
                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                         $this->OrderItem->create();
                                         $this->OrderItem->save($splititem);
                                     }
                                 } else {
                                     //echo "Exceed Limit to split."; exit;
                                 }
                             }
                         }
                     } else {
                         //It means, Outside EU country shipping
                         //pr($orderitem);
                         if (count(explode('-', $orderitem->SKU)) == 2) {
                             // For Single Type Sku
                             //If order item count is 1 then would be store directly
                             $splititem['pack_order_quantity'] = 0;
                             $splititem['product_sku_identifier'] = "single";
                             $splititem['price'] = $orderitem->PricePerUnit;
                             $splititem['order_split'] = $orderGroup;
                             $splititem['quantity'] = $orderitem->Quantity;
                             $splititem['product_type'] = "single";
                             $splititem['order_id'] = $result->NumOrderId;
                             $splititem['sku'] = $orderitem->SKU;
                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                             $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                             $this->OrderItem->create();
                             $this->OrderItem->save($splititem);
                         } else {
                             if (count(explode('-', $orderitem->SKU)) == 3) {
                                 $splitskus = explode('-', $orderitem->SKU);
                                 // For Bundle with same type Sku
                                 //Store and split the same SKU bundle order
                                 $splititem['pack_order_quantity'] = $splitskus[2];
                                 $splititem['product_sku_identifier'] = "single";
                                 $splititem['price'] = $orderitem->Quantity * $orderitem->PricePerUnit;
                                 $splititem['product_order_id_identify'] = $result->NumOrderId;
                                 $splititem['order_split'] = $orderGroup;
                                 $splititem['quantity'] = $orderitem->Quantity;
                                 $splititem['product_type'] = "bundle";
                                 $splititem['order_id'] = $result->NumOrderId;
                                 $splititem['sku'] = 'S-' . $splitskus[1];
                                 $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                 $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                 pr($splititem);
                                 $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                 $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                 $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                 $this->OrderItem->create();
                                 $this->OrderItem->save($splititem);
                             }
                         }
                         if (count(explode('-', $orderitem->SKU)) > 3) {
                             // For Bundle with muti type Sku
                         } else {
                         }
                     }
                 }
                 //************** Merge Order after splitting with different scenarios **************
                 $this->mergeSplitOrdersByOrderId_AccordingRules($result->NumOrderId);
                 //$this->loadModel( 'MergeOrder' );
                 //pr( $this->MergeOrder->find('all') ); exit;
                 // code for save customer detail
                 $customerInfo['Customer']['email'] = $result->CustomerInfo->Address->EmailAddress;
                 $customerInfo['Customer']['address1'] = $result->CustomerInfo->Address->Address1;
                 $customerInfo['Customer']['address2'] = $result->CustomerInfo->Address->Address2;
                 $customerInfo['Customer']['address3'] = $result->CustomerInfo->Address->Address3;
                 $customerInfo['Customer']['town'] = $result->CustomerInfo->Address->Town;
                 $customerInfo['Customer']['region'] = $result->CustomerInfo->Address->Region;
                 $customerInfo['Customer']['postcode'] = $result->CustomerInfo->Address->PostCode;
                 $customerInfo['Customer']['country'] = $result->CustomerInfo->Address->Country;
                 $customerInfo['Customer']['name'] = $result->CustomerInfo->Address->FullName;
                 $customerInfo['Customer']['company'] = $result->CustomerInfo->Address->Company;
                 $customerInfo['Customer']['phone'] = $result->CustomerInfo->Address->PhoneNumber;
                 $customerInfo['Customer']['source'] = $result->GeneralInfo->Source;
                 $customerInfo['Customer']['subsource'] = $result->GeneralInfo->SubSource;
                 $customerdetails = $this->Customer->find('first', array('conditions' => array('Customer.email' => $customerInfo['Customer']['email'])));
                 if (count($customerdetails) > 0) {
                     //$customerdetails['Customer']['count'] = $customerdetails['Customer']['count'] + '1';
                     $this->Customer->updateAll(array('Customer.order_id' => $result->NumOrderId), array('Customer.email' => $customerdetails['Customer']['email']));
                 } else {
                     $customerInfo['Customer']['order_id'] = $result->NumOrderId;
                     $this->Customer->create();
                     $this->Customer->saveAll($customerInfo);
                 }
             }
         } else {
             //Do something you required
         }
     }
     /* call the function for assign the postal servises */
     $this->assign_services();
     $this->getBarcode();
     $this->setAgainAssignedServiceToAllOrder();
     // Euraco Group
     App::import('Controller', 'Products');
     $productModel = new ProductsController();
     $productModel->prepareVirtualStock();
 }
コード例 #3
0
 public function getPdfOfOpenOrders()
 {
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = "******";
     $password = "******";
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $order[] = 'b9f2eab0-f952-4fdb-91ac-f3af793eb075';
     $results = OrdersMethods::GetOrders($order, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     pr($results);
     exit;
 }
コード例 #4
0
 public function saveopenorder()
 {
     $this->layout = '';
     $this->autoRender = false;
     $this->loadModel('Order');
     $this->loadModel('Item');
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = Configure::read('linnwork_api_username');
     $password = Configure::read('linnwork_api_password');
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $openorder = OrdersMethods::GetOpenOrders('100', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
     foreach ($openorder->Data as $orderids) {
         $orders[] = $orderids->OrderId;
     }
     $results = OrdersMethods::GetOrders($orders, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     $count = 0;
     foreach ($results as $result) {
         $finddata = $this->Order->find('first', array('conditions' => array('Order.num_order_id' => $result->NumOrderId)));
         if (empty($finddata)) {
             $data['Order']['num_order_id'] = $result->NumOrderId;
             $data['Order']['pk_order_id'] = $result->OrderId;
             $data['Order']['total'] = $result->TotalsInfo->TotalCharge;
             $data['Order']['postal_service'] = $result->ShippingInfo->PostalServiceName;
             $data['Order']['customer_name'] = $result->CustomerInfo->Address->FullName;
             $data['Order']['source'] = $result->GeneralInfo->Source;
             $dateTime = explode('T', $result->GeneralInfo->ReceivedDate);
             $data['Order']['received_date'] = $dateTime[0];
             $this->Order->saveAll($data);
             $order_id = $this->Order->getLastInsertID();
             foreach ($result->Items as $Item) {
                 $dataNew['Item']['order_id'] = $order_id;
                 $dataNew['Item']['sku'] = $Item->SKU;
                 $dataNew['Item']['barcode'] = $Item->BarcodeNumber;
                 $dataNew['Item']['quantity'] = $Item->Quantity;
                 $dataNew['Item']['title'] = $Item->Title;
                 $dataNew['Item']['priceperunit'] = $Item->PricePerUnit;
                 $dataNew['Item']['discount'] = $Item->Discount;
                 $dataNew['Item']['tax'] = $Item->Tax;
                 $dataNew['Item']['costinctax'] = $Item->CostIncTax;
                 $this->Item->saveAll($dataNew);
             }
             $count++;
         }
     }
     echo $count;
 }
コード例 #5
0
ファイル: CronjobsController.php プロジェクト: agashish/wms
 public function saveorderdetail()
 {
     $this->layout = 'index';
     $this->autoRender = false;
     $this->loadModel('OpenOrder');
     $this->loadModel('AssignService');
     $this->loadModel('Customer');
     $this->loadModel('OrderItem');
     $this->loadModel('Product');
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = Configure::read('linnwork_api_username');
     $password = Configure::read('linnwork_api_password');
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $openorder = OrdersMethods::GetOpenOrders('100', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
     foreach ($openorder->Data as $orderids) {
         $orders[] = $orderids->OrderId;
     }
     $results = OrdersMethods::GetOrders($orders, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     $countryArray = array('Austria' => 'Austria', 'Belgium' => 'Belgium', 'Bulgaria' => 'Bulgaria', 'Croatia' => 'Croatia', 'Cyprus' => 'Cyprus', 'Czech Republic' => 'Czech Republic', 'Denmark' => 'Denmark', 'Estonia' => 'Estonia', 'Finland' => 'Finland', 'France' => 'France', 'Germany' => 'Germany', 'Greece' => 'Greece', 'Hungary' => 'Hungary', 'Ireland' => 'Ireland', 'Italy' => 'Italy', 'Latvia' => 'Latvia', 'Lithuania' => 'Lithuania', 'Luxembourg' => 'Luxembourg', 'Malta' => 'Malta', 'Netherlands' => 'Netherlands', 'Poland' => 'Poland', 'Portugal' => 'Portugal', 'Romania' => 'Romania', 'Slovakia' => 'Slovakia', 'Slovenia' => 'Slovenia', 'Spain' => 'Spain', 'Sweden' => 'Sweden', 'United Kingdom' => 'United Kingdom');
     foreach ($results as $result) {
         if (($result->GeneralInfo->Status == 1 || $result->GeneralInfo->Status == 4) && $result->GeneralInfo->HoldOrCancel == '') {
             $data['order_id'] = $result->OrderId;
             $data['num_order_id'] = $result->NumOrderId;
             $data['general_info'] = serialize($result->GeneralInfo);
             $data['shipping_info'] = serialize($result->ShippingInfo);
             $data['customer_info'] = serialize($result->CustomerInfo);
             $data['totals_info'] = serialize($result->TotalsInfo);
             $data['folder_name'] = serialize($result->FolderName);
             $data['items'] = serialize($result->Items);
             //Extra information will save my according to manage sorting station section
             $country = $data['destination'] = $result->CustomerInfo->Address->Country;
             $orderitems = unserialize($data['items']);
             $this->OpenOrder->create();
             $checkorder = $this->OpenOrder->find('all', array('conditions' => array('OpenOrder.order_id' => $result->OrderId)));
             if (count($checkorder) > 0) {
             } else {
                 $this->OpenOrder->save($data);
                 //pr($orderitems);
                 /***************** split the order item ******************/
                 foreach ($orderitems as $orderitem) {
                     echo $orderitem->SKU . '==' . $orderitem->PricePerUnit;
                     echo "<br>";
                     $splitskus = explode('-', $orderitem->SKU);
                     $count = count($splitskus);
                     //Find Country
                     if (in_array($country, $countryArray)) {
                         //It means, Inside EU country shipping for bundle with sameSKU
                         if ($splitskus['0'] == 'B') {
                             for ($i = 1; $i <= count($splitskus) - 2; $i++) {
                                 if ($count == 3) {
                                     echo $value = $orderitem->Quantity * $orderitem->PricePerUnit * 1.38;
                                     echo "<br>";
                                     //For Euro
                                     if ($value < 35) {
                                         $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                         $splititem['product_sku_identifier'] = "single";
                                         $splititem['price'] = $orderitem->PricePerUnit;
                                         $splititem['quantity'] = $orderitem->Quantity;
                                         $splititem['product_type'] = "bundle";
                                         $splititem['order_id'] = $result->NumOrderId;
                                         $splititem['sku'] = 'S-' . $splitskus[$i];
                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                         $this->OrderItem->create();
                                         $this->OrderItem->save($splititem);
                                     } else {
                                         if ($value <= 150 && $value >= 35) {
                                             $total = 0;
                                             $perUnitPrice = $orderitem->PricePerUnit;
                                             $orderQuantity = $orderitem->Quantity;
                                             $inc = 0;
                                             $bundleIdentity = 0;
                                             if ($splitskus[$count - 1] > 1) {
                                                 //It will be the same as Linnworks custom script term , So now will split the orders with SEQUENCING
                                                 $e = 0;
                                                 while ($e <= $orderQuantity - 1) {
                                                     $total = $total + 1.38 * $perUnitPrice;
                                                     if ($total <= 35) {
                                                         echo "Indes is :: " . $e . " <> Start ::" . $total;
                                                         echo "<br>";
                                                         $inc++;
                                                     } else {
                                                         echo "Indes is :: " . $e . " <> Bigger ::" . $total;
                                                         echo "<br>";
                                                         //Store previous then initialized
                                                         $bundleIdentity++;
                                                         //Store and split the same SKU bundle order
                                                         $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                         $splititem['product_sku_identifier'] = "single";
                                                         $splititem['price'] = $orderitem->PricePerUnit;
                                                         $splititem['product_order_id_identify'] = $result->NumOrderId;
                                                         $splititem['quantity'] = $inc;
                                                         $splititem['product_type'] = "bundle";
                                                         $splititem['order_id'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                         $splititem['sku'] = 'S-' . $splitskus[$i];
                                                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                         $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                         $total = 0;
                                                         $total = $total + 1.38 * $perUnitPrice;
                                                         $inc = 1;
                                                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                         $this->OrderItem->create();
                                                         $this->OrderItem->save($splititem);
                                                         if ($e == $orderQuantity - 1) {
                                                             //Store previous then initialized
                                                             $bundleIdentity++;
                                                             $inc = 1;
                                                             //Store and split the same SKU bundle order
                                                             $splititem['pack_order_quantity'] = $splitskus[$count - 1];
                                                             $splititem['product_sku_identifier'] = "single";
                                                             $splititem['price'] = $orderitem->PricePerUnit;
                                                             $splititem['product_order_id_identify'] = $result->NumOrderId;
                                                             $splititem['quantity'] = $inc;
                                                             $splititem['product_type'] = "bundle";
                                                             $splititem['order_id'] = $result->NumOrderId . '-' . $bundleIdentity;
                                                             $splititem['sku'] = 'S-' . $splitskus[$i];
                                                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                                                             $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                                                             $total = 0;
                                                             $total = $total + 1.38 * $perUnitPrice;
                                                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                                                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                                                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                                                             $this->OrderItem->create();
                                                             $this->OrderItem->save($splititem);
                                                         }
                                                     }
                                                     $e++;
                                                 }
                                             }
                                         } else {
                                             //echo "Exceed Limit to split."; exit;
                                         }
                                     }
                                 } else {
                                     //Handle Multiple Sku with type bundle
                                 }
                             }
                         } else {
                             $itemdata['price'] = $orderitem->PricePerUnit;
                             $itemdata['product_type'] = "single";
                             $itemdata['order_id'] = $result->NumOrderId;
                             $itemdata['sku'] = $orderitem->SKU;
                             $itemdata['quantity'] = $orderitem->Quantity;
                             $itemdata['barcode'] = $orderitem->BarcodeNumber;
                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $itemdata['sku'])));
                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $itemdata['quantity'];
                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $itemdata['quantity'];
                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $itemdata['sku']));
                             $this->OrderItem->create();
                             $this->OrderItem->save($itemdata);
                         }
                     } else {
                         //It means, Outside EU country shipping
                     }
                     /*************************************************************************/
                     /*if($splitskus['0'] == 'B')
                     		{
                     			for( $i = 1; $i <= count($splitskus)-2 ; $i++ )
                     			{
                     				if( $count == 3 )
                     				{
                     					$splititem['pack_order_quantity']		=	$splitskus[$count-1];
                     					$splititem['product_sku_identifier']		= "single";			
                     					$splititem['price']		=	$orderitem->PricePerUnit;
                     					
                     					$splititem['quantity']			=	$orderitem->Quantity;
                     					$splititem['product_type']		=	"bundle";
                     					$splititem['order_id']		=	$result->NumOrderId;
                     					$splititem['sku']			=	'S-'.$splitskus[$i];
                     					$productDetail				=	$this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'] )));
                     					$splititem['barcode']		=	$productDetail['ProductDesc']['barcode'];
                     					
                     					$productDetail['Product']['current_stock_level']	= $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                     					$productDetail['Product']['lock_qty']				= $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                     					
                     					$this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']),
                     												array('Product.product_sku' => $splititem['sku']));
                     					$this->OrderItem->create();
                     					$this->OrderItem->save( $splititem );								
                     					
                     				}
                     				else
                     				{
                     					$splititem['pack_order_quantity']			=	$splitskus[$count];	
                     					$splititem['product_sku_identifier']		= "multiple";
                     					$splititem['price']		=	$orderitem->PricePerUnit;																													
                     					
                     					$splititem['quantity']			=	$orderitem->Quantity;
                     					$splititem['product_type']		=	"bundle";
                     					$splititem['order_id']		=	$result->NumOrderId;
                     					$splititem['sku']			=	'S-'.$splitskus[$i];
                     					$productDetail				=	$this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'] )));
                     					$splititem['barcode']		=	$productDetail['ProductDesc']['barcode'];
                     					
                     					$productDetail['Product']['current_stock_level']	= $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                     					$productDetail['Product']['lock_qty']				= $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                     					
                     					$this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']),
                     												array('Product.product_sku' => $splititem['sku']));
                     					$this->OrderItem->create();
                     					$this->OrderItem->save( $splititem );
                     				}										
                     			}
                     		}
                     		else
                     		{
                     			$itemdata	['price']			=	$orderitem->PricePerUnit;								
                     			$itemdata['product_type']		=	"single";
                     			$itemdata['order_id']			=	$result->NumOrderId;
                     			$itemdata['sku']				=	$orderitem->SKU;
                     			$itemdata['quantity']			=	$orderitem->Quantity;
                     			$itemdata['barcode']			=	$orderitem->BarcodeNumber;
                     			
                     			$productDetail				=	$this->Product->find('first', array('conditions' => array('Product.product_sku' => $itemdata['sku'] )));
                     			$productDetail['Product']['current_stock_level']	= $productDetail['Product']['current_stock_level'] - $itemdata['quantity'];
                     			$productDetail['Product']['lock_qty']				= $productDetail['Product']['lock_qty'] + $itemdata['quantity'];
                     			$this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']),
                     											array('Product.product_sku' => $itemdata['sku']));
                     			$this->OrderItem->create();
                     			$this->OrderItem->save( $itemdata );
                     		}*/
                 }
                 /***********************************/
                 /*foreach( $orderitems as $orderitem )
                 		{
                 			$itemdata['order_id']			=	$result->NumOrderId;
                 			$itemdata['sku']				=	$orderitem->SKU;
                 			$itemdata['quantity']			=	$orderitem->Quantity;
                 			$itemdata['barcode']			=	$orderitem->BarcodeNumber;
                 			$this->OrderItem->create();
                 			$this->OrderItem->save( $itemdata );
                 		}*/
                 // code for save customer detail
                 $customerInfo['Customer']['email'] = $result->CustomerInfo->Address->EmailAddress;
                 $customerInfo['Customer']['address1'] = $result->CustomerInfo->Address->Address1;
                 $customerInfo['Customer']['address2'] = $result->CustomerInfo->Address->Address2;
                 $customerInfo['Customer']['address3'] = $result->CustomerInfo->Address->Address3;
                 $customerInfo['Customer']['town'] = $result->CustomerInfo->Address->Town;
                 $customerInfo['Customer']['region'] = $result->CustomerInfo->Address->Region;
                 $customerInfo['Customer']['postcode'] = $result->CustomerInfo->Address->PostCode;
                 $customerInfo['Customer']['country'] = $result->CustomerInfo->Address->Country;
                 $customerInfo['Customer']['name'] = $result->CustomerInfo->Address->FullName;
                 $customerInfo['Customer']['company'] = $result->CustomerInfo->Address->Company;
                 $customerInfo['Customer']['phone'] = $result->CustomerInfo->Address->PhoneNumber;
                 $customerInfo['Customer']['source'] = $result->GeneralInfo->Source;
                 $customerInfo['Customer']['subsource'] = $result->GeneralInfo->SubSource;
                 $customerdetails = $this->Customer->find('first', array('conditions' => array('Customer.email' => $customerInfo['Customer']['email'])));
                 if (count($customerdetails) > 0) {
                     //$customerdetails['Customer']['count'] = $customerdetails['Customer']['count'] + '1';
                     $this->Customer->updateAll(array('Customer.order_id' => $result->NumOrderId), array('Customer.email' => $customerdetails['Customer']['email']));
                 } else {
                     $customerInfo['Customer']['order_id'] = $result->NumOrderId;
                     $this->Customer->create();
                     $this->Customer->saveAll($customerInfo);
                 }
             }
         } else {
             //Do something you required
         }
     }
     /* call the function for assign the postal servises */
     $this->assign_services();
     $this->getBarcode();
     $this->setAgainAssignedServiceToAllOrder();
     // Euraco Group
     App::import('Controller', 'Products');
     $productModel = new ProductsController();
     $productModel->prepareVirtualStock();
 }
コード例 #6
0
 public function saveorderdetail()
 {
     $this->layout = 'index';
     $this->autoRender = false;
     $this->loadModel('OpenOrder');
     $this->loadModel('AssignService');
     $this->loadModel('Customer');
     $this->loadModel('OrderItem');
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = Configure::read('linnwork_api_username');
     $password = Configure::read('linnwork_api_password');
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $openorder = OrdersMethods::GetOpenOrders('100', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
     foreach ($openorder->Data as $orderids) {
         $orders[] = $orderids->OrderId;
     }
     $results = OrdersMethods::GetOrders($orders, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     foreach ($results as $result) {
         $data['order_id'] = $result->OrderId;
         $data['num_order_id'] = $result->NumOrderId;
         $data['general_info'] = serialize($result->GeneralInfo);
         $data['shipping_info'] = serialize($result->ShippingInfo);
         $data['customer_info'] = serialize($result->CustomerInfo);
         $data['totals_info'] = serialize($result->TotalsInfo);
         $data['folder_name'] = serialize($result->FolderName);
         $data['items'] = serialize($result->Items);
         //Extra information will save my according to manage sorting station section
         $data['destination'] = $result->CustomerInfo->Address->Country;
         $orderitems = unserialize($data['items']);
         $this->OpenOrder->create();
         $checkorder = $this->OpenOrder->find('all', array('conditions' => array('OpenOrder.order_id' => $result->OrderId)));
         if (count($checkorder) > 0) {
         } else {
             $this->OpenOrder->save($data);
             foreach ($orderitems as $orderitem) {
                 $itemdata['order_id'] = $result->NumOrderId;
                 $itemdata['sku'] = $orderitem->SKU;
                 $itemdata['quantity'] = $orderitem->Quantity;
                 $itemdata['barcode'] = $orderitem->BarcodeNumber;
                 $this->OrderItem->create();
                 $this->OrderItem->save($itemdata);
             }
             // code for save customer detail
             $customerInfo['Customer']['email'] = $result->CustomerInfo->Address->EmailAddress;
             $customerInfo['Customer']['address1'] = $result->CustomerInfo->Address->Address1;
             $customerInfo['Customer']['address2'] = $result->CustomerInfo->Address->Address2;
             $customerInfo['Customer']['address3'] = $result->CustomerInfo->Address->Address3;
             $customerInfo['Customer']['town'] = $result->CustomerInfo->Address->Town;
             $customerInfo['Customer']['region'] = $result->CustomerInfo->Address->Region;
             $customerInfo['Customer']['postcode'] = $result->CustomerInfo->Address->PostCode;
             $customerInfo['Customer']['country'] = $result->CustomerInfo->Address->Country;
             $customerInfo['Customer']['name'] = $result->CustomerInfo->Address->FullName;
             $customerInfo['Customer']['company'] = $result->CustomerInfo->Address->Company;
             $customerInfo['Customer']['phone'] = $result->CustomerInfo->Address->PhoneNumber;
             $customerInfo['Customer']['source'] = $result->GeneralInfo->Source;
             $customerInfo['Customer']['subsource'] = $result->GeneralInfo->SubSource;
             $customerdetails = $this->Customer->find('first', array('conditions' => array('Customer.email' => $customerInfo['Customer']['email'])));
             if (count($customerdetails) > 0) {
                 //$customerdetails['Customer']['count'] = $customerdetails['Customer']['count'] + '1';
                 $this->Customer->updateAll(array('Customer.order_id' => $result->NumOrderId), array('Customer.email' => $customerdetails['Customer']['email']));
             } else {
                 $customerInfo['Customer']['order_id'] = $result->NumOrderId;
                 $this->Customer->create();
                 $this->Customer->saveAll($customerInfo);
             }
         }
     }
     /* call the function for assign the postal servises */
     $this->assign_services();
     $this->getBarcode();
     $this->setAgainAssignedServiceToAllOrder();
     // Euraco Group
 }
コード例 #7
0
ファイル: index.php プロジェクト: agashish/test_new
include "api/Auth.php";
//include("api/ImportExport.php");
include "api/Orders.php";
include "api/ProcessedOrders.php";
include "api/PrintService.php";
$username = "******";
$password = "******";
/*$username = "******";
	$password = "******";*/
$multi = AuthMethods::Multilogin($username, $password);
$auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
$token = $auth->Token;
$server = $auth->Server;
//filters={"TextFields":[{"Type":0,"Text":"sample string 1","FieldCode":0}
//GetOpenOrders('','1',$filters,'','00000000-0000-0000-0000-000000000000','',$token, $server)
$result = OrdersMethods::GetOpenOrders('5', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
echo "<pre>";
print_r($result);
exit;
$orderId = '696e9699-62f0-4584-a5c1-744745dbf16d';
$scanPerformed = true;
$fulfilmentCenter = '00000000-0000-0000-0000-000000000000';
//$result = OrdersMethods::ProcessOrder($orderId,$scanPerformed,$token, $server); //done
//$result = OrdersMethods::CancelOrder($orderId,$fulfilmentCenter,86.2,'it is test order',$token, $server); //done
$pkOrderId = 'e35b1f81-1f98-44ef-a9a9-1c7a0d3263f7';
$despatchLocation = '00000000-0000-0000-0000-000000000000';
$category = 'Health & Beauty';
$reason = 'In Transit';
$additionalCost = 15.04;
//$result = ProcessedOrdersMethods::CreateFullResend($pkOrderId,$despatchLocation,$category,$reason,$additionalCost,$token, $server); //done
//$result = PrintServiceMethods::GetTemplateList('Invoice Template',$token, $server); //done
コード例 #8
0
 public function saveorderdetail()
 {
     $this->layout = 'index';
     $this->autoRender = false;
     $this->loadModel('OpenOrder');
     $this->loadModel('AssignService');
     $this->loadModel('Customer');
     $this->loadModel('OrderItem');
     $this->loadModel('Product');
     App::import('Vendor', 'linnwork/api/Auth');
     App::import('Vendor', 'linnwork/api/Factory');
     App::import('Vendor', 'linnwork/api/Orders');
     $username = Configure::read('linnwork_api_username');
     $password = Configure::read('linnwork_api_password');
     $multi = AuthMethods::Multilogin($username, $password);
     $auth = AuthMethods::Authorize($username, $password, $multi[0]->Id);
     $token = $auth->Token;
     $server = $auth->Server;
     $openorder = OrdersMethods::GetOpenOrders('100', '1', '', '', '00000000-0000-0000-0000-000000000000', '', $token, $server);
     foreach ($openorder->Data as $orderids) {
         $orders[] = $orderids->OrderId;
     }
     $results = OrdersMethods::GetOrders($orders, '00000000-0000-0000-0000-000000000000', true, true, $token, $server);
     foreach ($results as $result) {
         if ($result->GeneralInfo->status = 1 && $result->GeneralInfo->HoldOrCancel == '') {
             $data['order_id'] = $result->OrderId;
             $data['num_order_id'] = $result->NumOrderId;
             $data['general_info'] = serialize($result->GeneralInfo);
             $data['shipping_info'] = serialize($result->ShippingInfo);
             $data['customer_info'] = serialize($result->CustomerInfo);
             $data['totals_info'] = serialize($result->TotalsInfo);
             $data['folder_name'] = serialize($result->FolderName);
             $data['items'] = serialize($result->Items);
             //Extra information will save my according to manage sorting station section
             $data['destination'] = $result->CustomerInfo->Address->Country;
             $orderitems = unserialize($data['items']);
             $this->OpenOrder->create();
             $checkorder = $this->OpenOrder->find('all', array('conditions' => array('OpenOrder.order_id' => $result->OrderId)));
             if (count($checkorder) > 0) {
             } else {
                 $this->OpenOrder->save($data);
                 /***************** split the order item ******************/
                 foreach ($orderitems as $orderitem) {
                     $splitskus = explode('-', $orderitem->SKU);
                     $count = count($splitskus);
                     if ($splitskus['0'] == 'B') {
                         for ($i = 1; $i <= count($splitskus) - 2; $i++) {
                             if ($count == 3) {
                                 $splititem['quantity'] = $splitskus[$count - 1];
                             } else {
                                 $splititem['quantity'] = $orderitem->Quantity;
                             }
                             $splititem['order_id'] = $result->NumOrderId;
                             $splititem['sku'] = 'S-' . $splitskus[$i];
                             $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $splititem['sku'])));
                             $splititem['barcode'] = $productDetail['ProductDesc']['barcode'];
                             $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $splititem['quantity'];
                             $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $splititem['quantity'];
                             $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $splititem['sku']));
                             $this->OrderItem->create();
                             $this->OrderItem->save($splititem);
                         }
                     } else {
                         $itemdata['order_id'] = $result->NumOrderId;
                         $itemdata['sku'] = $orderitem->SKU;
                         $itemdata['quantity'] = $orderitem->Quantity;
                         $itemdata['barcode'] = $orderitem->BarcodeNumber;
                         $productDetail = $this->Product->find('first', array('conditions' => array('Product.product_sku' => $itemdata['sku'])));
                         $productDetail['Product']['current_stock_level'] = $productDetail['Product']['current_stock_level'] - $itemdata['quantity'];
                         $productDetail['Product']['lock_qty'] = $productDetail['Product']['lock_qty'] + $itemdata['quantity'];
                         $this->Product->updateAll(array('Product.current_stock_level' => $productDetail['Product']['current_stock_level'], 'Product.lock_qty' => $productDetail['Product']['lock_qty']), array('Product.product_sku' => $itemdata['sku']));
                         $this->OrderItem->create();
                         $this->OrderItem->save($itemdata);
                     }
                 }
                 /***********************************/
                 /*foreach( $orderitems as $orderitem )
                 		{
                 			$itemdata['order_id']			=	$result->NumOrderId;
                 			$itemdata['sku']				=	$orderitem->SKU;
                 			$itemdata['quantity']			=	$orderitem->Quantity;
                 			$itemdata['barcode']			=	$orderitem->BarcodeNumber;
                 			$this->OrderItem->create();
                 			$this->OrderItem->save( $itemdata );
                 		}*/
                 // code for save customer detail
                 $customerInfo['Customer']['email'] = $result->CustomerInfo->Address->EmailAddress;
                 $customerInfo['Customer']['address1'] = $result->CustomerInfo->Address->Address1;
                 $customerInfo['Customer']['address2'] = $result->CustomerInfo->Address->Address2;
                 $customerInfo['Customer']['address3'] = $result->CustomerInfo->Address->Address3;
                 $customerInfo['Customer']['town'] = $result->CustomerInfo->Address->Town;
                 $customerInfo['Customer']['region'] = $result->CustomerInfo->Address->Region;
                 $customerInfo['Customer']['postcode'] = $result->CustomerInfo->Address->PostCode;
                 $customerInfo['Customer']['country'] = $result->CustomerInfo->Address->Country;
                 $customerInfo['Customer']['name'] = $result->CustomerInfo->Address->FullName;
                 $customerInfo['Customer']['company'] = $result->CustomerInfo->Address->Company;
                 $customerInfo['Customer']['phone'] = $result->CustomerInfo->Address->PhoneNumber;
                 $customerInfo['Customer']['source'] = $result->GeneralInfo->Source;
                 $customerInfo['Customer']['subsource'] = $result->GeneralInfo->SubSource;
                 $customerdetails = $this->Customer->find('first', array('conditions' => array('Customer.email' => $customerInfo['Customer']['email'])));
                 if (count($customerdetails) > 0) {
                     //$customerdetails['Customer']['count'] = $customerdetails['Customer']['count'] + '1';
                     $this->Customer->updateAll(array('Customer.order_id' => $result->NumOrderId), array('Customer.email' => $customerdetails['Customer']['email']));
                 } else {
                     $customerInfo['Customer']['order_id'] = $result->NumOrderId;
                     $this->Customer->create();
                     $this->Customer->saveAll($customerInfo);
                 }
             }
         }
     }
     /* call the function for assign the postal servises */
     $this->assign_services();
     $this->getBarcode();
     $this->setAgainAssignedServiceToAllOrder();
     // Euraco Group
     App::import('Controller', 'Products');
     $productModel = new ProductsController();
     $productModel->prepareVirtualStock();
 }