예제 #1
0
 public function editOrderAction()
 {
     // web page title
     $this->view->title = "Édition d'une commande";
     $quoteId = $this->_getParam('ID');
     $redirectTo = "/Order/index/list-quote-requests/";
     if (!empty($quoteId)) {
         $details = array();
         $form = new FormOrder(array('cancelUrl' => "{$this->view->baseUrl()}{$redirectTo}"));
         $this->view->assign('form', $form);
         $Order = new DemandeSoumissionObject();
         $details = $Order->populate($quoteId, $this->_defaultEditLanguage);
         $oProdReq = new ProduitDemandeObject();
         $oItemReq = new ItemDemandeObject();
         $oProduct = new ProduitObject();
         $oItem = new ItemObject();
         $oSize = new TailleObject();
         $oCategory = new CategorieTailleObject();
         $prodReq = $oProdReq->getByDemandeId($quoteId);
         foreach ($prodReq as $data) {
             $product[$data['PD_ProduitID']] = $oProduct->populate($data['PD_ProduitID'], $this->_defaultEditLanguage);
             $itemReq = $oItemReq->getByProductId($data['PD_ID']);
             foreach ($itemReq as $itemData) {
                 $key = $itemData['ID_ID'];
                 $item[$key] = $oItem->populate($itemData['ID_ItemID'], $this->_defaultEditLanguage);
                 $item[$key]['quantity'] = $itemData['ID_Quantite'];
                 if ($itemData['ID_TailleID'] != 0) {
                     $taille = $oSize->populate($itemData['ID_TailleID'], $this->_defaultEditLanguage);
                     $category = $oCategory->populate($taille['T_CategorieTailleId'], $this->_defaultEditLanguage);
                     $item[$key]['size'] = $taille;
                     $item[$key]['sCat'] = $category;
                 }
             }
             $product[$data['PD_ProduitID']]['item'] = $item;
         }
         $render = $this->_renderSummary($product);
         if (count($details) > 0) {
             $this->view->assign('quoteDetails', $details);
             $this->view->assign('render', $render);
             if ($this->_request->isPost()) {
                 $formData = $this->_request->getPost();
                 $Order->save($quoteId, $formData, $this->_currentEditLanguage);
                 $this->_redirect($redirectTo);
             }
         } else {
             $this->_redirect($redirectTo);
         }
         $form->populate($details);
     } else {
         $this->_redirect($redirectTo);
     }
 }
예제 #2
0
 /**
  * Insert data about the item for the quote request submission.
  *
  * @param array $items          Data of the items in the cart.
  * @param int   $reqProductId   Id of the requested product in the quote request
  * @param int   $quoteRequestId Id of the quote request. Usefull for export only.
  *
  * @return void
  */
 private function _insertRequestedItem($items, $reqProductId, $quoteRequestId)
 {
     $oRequestedItem = new ItemObject();
     foreach ($items as $itemId => $item) {
         $details = $item['cartDetails'][0];
         if ($details['Disabled']) {
             $reqItemData['itemId'] = $details['ItemId'];
             $reqItemData['sizeId'] = $details['SizeId'];
             $reqItemData['quantity'] = $details['Quantity'];
             $reqItemData['reqProdId'] = $reqProductId;
             $reqItemData['quotReqId'] = $quoteRequestId;
             $oRequestedItem->insert($reqItemData, 1);
         }
     }
 }