Exemplo n.º 1
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     extract($_POST);
     //     	echo '<pre>';
     //     	print_r($_POST);
     //     	die;
     $booking = new Booking();
     $booking->setIdBooking($id_booking);
     $booking->setEta($eta);
     $booking->setEtaWarehouse($warehouse_eta);
     $booking->setEtd($etd);
     $booking->setTrackingNumber($tracking_number);
     $booking->setNameVessel($vessel_name);
     $booking->setCarrier($carrier);
     $booking->setContainerNumber($container_number);
     $booking->setSize($size);
     $booking->setCartons($cartons);
     $booking->setCubicMeters($bookingCbm);
     $booking->setWeight($bookingWeight);
     $this->getCatalog('BookingCatalog')->beginTransaction();
     try {
         $this->getCatalog('BookingCatalog')->update($booking);
     } catch (Exception $e) {
         echo $e;
         print_r($booking->toArray());
         $this->getCatalog('FolioImportCatalog')->rollBack();
         $this->setFlash('error', $e->getMessage());
         $this->_redirect('folio-import/list');
     }
     try {
         $folioImport = FolioImportQuery::create()->findByPK($id_folio_import);
         $folioImport->setStatus(FolioImport::$Status['Assigned']);
         $this->getCatalog('FolioImportCatalog')->update($folioImport);
     } catch (Exception $e) {
         $this->getCatalog('FolioImportCatalog')->rollBack();
         $this->setFlash('error', $e->getMessage());
         $this->_redirect('folio-import/list');
     }
     $idBooking = $booking->getIdBooking();
     $itineraries = $this->getRequest()->getParam('itineraries');
     foreach ($itineraries as $itinerary) {
         extract($itinerary);
         $myItinerary = new Itinerary();
         $myItinerary->setIdBooking($idBooking);
         $myItinerary->setOrigin($origin);
         $myItinerary->setDestination($destination);
         $myItinerary->setType($type);
         $myItinerary->setDays($days);
         $myItinerary->setEtd($etd);
         $myItinerary->setEta($eta);
         try {
             if (isset($itinerary['idItinerary'])) {
                 if ($itinerary['status'] == 1) {
                     $myItinerary->setIdItinerary($itinerary['idItinerary']);
                     $this->getCatalog('ItineraryCatalog')->update($myItinerary);
                 } else {
                     if ($itinerary['status'] == 0) {
                         $this->getCatalog('ItineraryCatalog')->deleteById($itinerary['idItinerary']);
                     }
                 }
             } else {
                 $this->getCatalog('ItineraryCatalog')->create($myItinerary);
             }
         } catch (Exception $e) {
             $this->setFlash('error', $e);
             $this->_redirect('booking/list');
         }
     }
     $this->setFlash('ok', $this->i18n->_($this->UPDATE_OK));
     $this->getCatalog('BookingCatalog')->commit();
     $this->_redirect('folio-import/list');
 }
Exemplo n.º 2
0
 /**
  * @author Jose Luis Suarez Nieto
  * @return array
  */
 public function createAction()
 {
     $params = $this->getRequest()->getParams();
     $myFolioImport = new FolioImport();
     $myFolioImport->setIdForwarder($params['merchandiseForwarder']);
     $myFolioImport->setIdPortCustom($params['merchandiseDeparturePort']);
     $myFolioImport->setIdPortDestination($params['destination']);
     $myFolioImport->setIdWarehouse($params['warehouse']);
     if (isset($params['preInspected'])) {
         $myFolioImport->setPreInspected(1);
     } else {
         $myFolioImport->setPreInspected(0);
     }
     if (isset($params['customsBroker']) && $params['customsBroker'] != '') {
         $myFolioImport->setIdCustomsBroker($params['customsBroker']);
     }
     if (isset($params['typeIncome'])) {
         $myFolioImport->setTypeIncome($params['typeIncome']);
     }
     try {
         $this->getFolioImportCatalog()->beginTransaction();
         $this->getFolioImportCatalog()->create($myFolioImport);
         $this->newLogForCreate($myFolioImport);
         $folio = $this->createFolio($myFolioImport->getIdFolioImport());
         $myFolioImport->setFolio($folio);
         $this->getFolioImportCatalog()->update($myFolioImport);
         $this->newLogForCreate($myFolioImport);
         /**
          * To create the notification
          */
         $this->getEventDispatcherService()->createFolioImportNotification($myFolioImport, FolioImportEvent::FOLIO_IMPORT_CREATED);
     } catch (Exception $e) {
         echo $e;
         $this->getFolioImportCatalog()->rollBack();
         die;
     }
     try {
         $booking = new Booking();
         $booking->setIdFolioImport($myFolioImport->getIdFolioImport());
         $booking->setWeight($params['bookingWeight']);
         $booking->setCubicMeters($params['bookingCbm']);
         $this->getCatalog('BookingCatalog')->create($booking);
         $this->getFolioImportCatalog()->update($myFolioImport);
     } catch (Exception $e) {
         $this->setFlash('error', $e->getMessage());
         $this->getFolioImportCatalog()->rollBack();
         $this->_redirect('folio-import/list');
     }
     try {
         foreach ($params['idFreightFare'] as $id => $value) {
             $myFolioImportFreightFare = new FolioImportFreightFare();
             $myFolioImportFreightFare->setIdFolioImport($myFolioImport->getIdFolioImport());
             $myFolioImportFreightFare->setIdFreightFare($id);
             $myFolioImportFreightFare->setQuantity($value);
             $this->getCatalog('FolioImportFreightFareCatalog')->create($myFolioImportFreightFare);
         }
     } catch (Exception $e) {
         echo $e;
         $this->getFolioImportCatalog()->rollBack();
         die;
     }
     try {
         $purchaseOrders = new PurchaseOrderCollection();
         $allPurchaseOrderEntries = new PurchaseOrderEntryCollection();
         foreach ($params['purchaseOrders'] as $purchaseOrder) {
             if (isset($purchaseOrder['value'])) {
                 $SapConnector = new SAPConnectorClient();
                 $myPurchaseOrder = PurchaseOrderQuery::create()->findByPK($purchaseOrder['id']);
                 $myPurchaseOrder->setStatus(PurchaseOrder::$Status['Assigned']);
                 $myPurchaseOrder->setIdFolioImport($myFolioImport->getIdFolioImport());
                 $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrder['id'])->find();
                 $result = $SapConnector->purchaseOrder($myPurchaseOrder, $purchaseOrderEntries);
                 $purchaseOrders->append($myPurchaseOrder);
                 $allPurchaseOrderEntries = $allPurchaseOrderEntries->merge($purchaseOrderEntries);
                 if ($result->purchaseOrderResult->code != 200) {
                     $this->setFlash('error', $this->i18n->_($result->purchaseOrderResult->message));
                     $this->getFolioImportCatalog()->rollBack();
                     $this->_redirect('folio-import/list');
                 }
             }
         }
     } catch (Exception $e) {
         echo $e;
         $this->getFolioImportCatalog()->rollBack();
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
         $this->_redirect('folio-import/list');
     }
     $this->getFolioImportCatalog()->commit();
     $this->setFlash('ok', $this->i18n->_("The Folio Import " . $myFolioImport->getFolio() . " has been created."));
     while ($purchaseOrder = $purchaseOrders->read()) {
         $purchaseOrderEntries = $allPurchaseOrderEntries->filterByPurchaseOrderPk($purchaseOrder->getIdPurchaseOrder());
         $this->getEventDispatcherService()->dispatchPurchaseOrderEvent($purchaseOrder, PurchaseOrderEvent::PURCHASEORDER_SHIPPED, $purchaseOrderEntries);
     }
     $this->_redirect('folio-import/list');
 }
Exemplo n.º 3
0
 private function createFrontpageTable()
 {
     $border = 'T';
     $fill = false;
     $this->SetLineWidth(0.1);
     $this->SetFillColor(225, 225, 225);
     $cellHeight = $this->regularSize / 1.8;
     $x0 = $this->GetX();
     $y0 = $this->GetY();
     foreach ($this->frontpage as $entry) {
         $rowHeight = 0;
         $x = $x0;
         foreach ($entry as $name => $entryCell) {
             $y = $this->GetY();
             $content = $entryCell['number'] == true ? number_format($entryCell['content'], 4) : $entryCell['content'];
             $this->MultiCell($entryCell['cellWeight'], $cellHeight, $content, $border, 'R', $fill, 0);
             $x += $entryCell['cellWeight'];
             $y2 = $this->GetY();
             $this->SetXY($x, $y);
             $currentCellHeight = $y2 - $y;
             if ($rowHeight < $currentCellHeight) {
                 $rowHeight = $currentCellHeight;
             }
         }
         $this->Ln($rowHeight);
     }
     $rowHeight = 0;
     $x = $x0;
     foreach (self::$FrontPageTableHeaders as $name => $tableHeader) {
         $y = $this->GetY();
         switch ($name) {
             case 'amount_usd':
                 $content = number_format($this->loadCost, 4);
                 break;
             case 'amount_mxp':
                 $content = number_format($this->loadCost * $this->folioImport->getExchangeDollarToPeso(), 4);
                 break;
             case 'entry_weight':
                 $content = number_format($this->totalWeight, 4);
                 break;
             case 'increasable_freight_mxp':
                 $content = number_format($this->booking->getIncreasableFreight() * $this->folioImport->getExchangeDollarToPeso(), 4);
                 break;
             case 'increasable_insurance_mxp':
                 $content = number_format($this->booking->getIncreasableFreight() * $this->folioImport->getExchangeDollarToPeso(), 4);
                 break;
             case 'customs_value_mxp':
                 $content = number_format($this->totalCustomsValue, 4);
                 break;
             case 'tariff_mxp':
                 $content = number_format($this->totalTariffMxp, 4);
                 break;
             case 'cc_value':
                 $content = $this->getAntidumpingDutyValues()->getTotalValue() == 0 ? '-' : $this->getAntidumpingDutyValues()->getTotalValue() . 'MXP';
                 break;
             case 'not_increasable_freight_mxp':
                 $content = number_format($this->totalNotIncreasableFreightMxp, 4);
                 break;
             case 'cif_value':
                 $content = number_format($this->totalCifValue, 4);
                 break;
             default:
                 $content = ' ';
         }
         $this->MultiCell($tableHeader['cellWeight'], $cellHeight, $content, $border, 'R', $fill, 0);
         $x += $tableHeader['cellWeight'];
         $y2 = $this->GetY();
         $this->SetXY($x, $y);
         $currentCellHeight = $y2 - $y;
         if ($rowHeight < $currentCellHeight) {
             $rowHeight = $currentCellHeight;
         }
     }
     $this->Ln($rowHeight);
     $this->Ln($rowHeight);
 }