/**
  *
  * @static
  * @param ProductPrintingAreaFile productPrintingAreaFile
  * @param array $fields
  */
 public static function populate($productPrintingAreaFile, $fields)
 {
     parent::populate($productPrintingAreaFile, $fields);
     if (!$productPrintingAreaFile instanceof ProductPrintingAreaFile) {
         static::throwException("El objecto no es un ProductPrintingAreaFile");
     }
     if (isset($fields['id_product_printing_area_file'])) {
         $productPrintingAreaFile->setIdProductPrintingAreaFile($fields['id_product_printing_area_file']);
     }
     if (isset($fields['id_product_printing_area'])) {
         $productPrintingAreaFile->setIdProductPrintingArea($fields['id_product_printing_area']);
     }
     if (isset($fields['id_file'])) {
         $productPrintingAreaFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['document_type'])) {
         $productPrintingAreaFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 2
0
 /**
  *
  * @static
  * @param ClaimReportFile claimReportFile
  * @param array $fields
  */
 public static function populate($claimReportFile, $fields)
 {
     parent::populate($claimReportFile, $fields);
     if (!$claimReportFile instanceof ClaimReportFile) {
         static::throwException("El objecto no es un ClaimReportFile");
     }
     if (isset($fields['id_warehouse_entrance_file'])) {
         $claimReportFile->setIdWarehouseEntranceFile($fields['id_warehouse_entrance_file']);
     }
     if (isset($fields['id_warehouse_entrance_claim_report'])) {
         $claimReportFile->setIdWarehouseEntranceClaimReport($fields['id_warehouse_entrance_claim_report']);
     }
     if (isset($fields['id_file'])) {
         $claimReportFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['document_type'])) {
         $claimReportFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 3
0
 /**
  *
  * @static
  * @param BookingFile bookingFile
  * @param array $fields
  */
 public static function populate($bookingFile, $fields)
 {
     parent::populate($bookingFile, $fields);
     if (!$bookingFile instanceof BookingFile) {
         static::throwException("El objecto no es un BookingFile");
     }
     if (isset($fields['id_booking_file'])) {
         $bookingFile->setIdBookingFile($fields['id_booking_file']);
     }
     if (isset($fields['id_booking'])) {
         $bookingFile->setIdBooking($fields['id_booking']);
     }
     if (isset($fields['id_file'])) {
         $bookingFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['document_type'])) {
         $bookingFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 4
0
 /**
  *
  * @static
  * @param InspectionFile inspectionFile
  * @param array $fields
  */
 public static function populate($inspectionFile, $fields)
 {
     parent::populate($inspectionFile, $fields);
     if (!$inspectionFile instanceof InspectionFile) {
         static::throwException("El objecto no es un InspectionFile");
     }
     if (isset($fields['id_inspection_file'])) {
         $inspectionFile->setIdInspectionFile($fields['id_inspection_file']);
     }
     if (isset($fields['id_inspection'])) {
         $inspectionFile->setIdInspection($fields['id_inspection']);
     }
     if (isset($fields['id_file'])) {
         $inspectionFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['document_type'])) {
         $inspectionFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 5
0
 /**
  *
  * @static
  * @param PurchaseOrderFile purchaseOrderFile
  * @param array $fields
  */
 public static function populate($purchaseOrderFile, $fields)
 {
     parent::populate($purchaseOrderFile, $fields);
     if (!$purchaseOrderFile instanceof PurchaseOrderFile) {
         static::throwException("El objecto no es un PurchaseOrderFile");
     }
     if (isset($fields['id_purchase_order_file'])) {
         $purchaseOrderFile->setIdPurchaseOrderFile($fields['id_purchase_order_file']);
     }
     if (isset($fields['id_purchase_order'])) {
         $purchaseOrderFile->setIdPurchaseOrder($fields['id_purchase_order']);
     }
     if (isset($fields['id_file'])) {
         $purchaseOrderFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['document_type'])) {
         $purchaseOrderFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 6
0
 /**
  *
  * @static
  * @param FolioImportFile folioImportFile
  * @param array $fields
  */
 public static function populate($folioImportFile, $fields)
 {
     parent::populate($folioImportFile, $fields);
     if (!$folioImportFile instanceof FolioImportFile) {
         static::throwException("El objecto no es un FolioImportFile");
     }
     if (isset($fields['id_folio_import_file'])) {
         $folioImportFile->setIdFolioImportFile($fields['id_folio_import_file']);
     }
     if (isset($fields['id_file'])) {
         $folioImportFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['id_folio_import'])) {
         $folioImportFile->setIdFolioImport($fields['id_folio_import']);
     }
     if (isset($fields['document_type'])) {
         $folioImportFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 7
0
 /**
  *
  * @static
  * @param SupplierFile supplierFile
  * @param array $fields
  */
 public static function populate($supplierFile, $fields)
 {
     parent::populate($supplierFile, $fields);
     if (!$supplierFile instanceof SupplierFile) {
         static::throwException("El objecto no es un SupplierFile");
     }
     if (isset($fields['id_supplier_file'])) {
         $supplierFile->setIdSupplierFile($fields['id_supplier_file']);
     }
     if (isset($fields['id_file'])) {
         $supplierFile->setIdFile($fields['id_file']);
     }
     if (isset($fields['id_supplier'])) {
         $supplierFile->setIdSupplier($fields['id_supplier']);
     }
     if (isset($fields['document_type'])) {
         $supplierFile->setDocumentType($fields['document_type']);
     }
 }
Exemplo n.º 8
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     $params = $this->getRequest()->getParams();
     if ($this->getRequest()->isPost()) {
         $idProformaInvoice = $this->getRequest()->getParam('id_proforma_invoice');
         $proformaInvoiceParams['date'] = $this->getRequest()->getParam('date', null);
         $proformaInvoiceParams['folio'] = $this->getRequest()->getParam('folio', null);
         $proformaInvoiceParams['id_courtyard'] = $this->getRequest()->getParam('id_courtyard', null);
         $proformaInvoiceParams['id_currency'] = $this->getRequest()->getParam('id_currency');
         $proformaInvoiceParams['comments'] = $this->getRequest()->getParam('comments', null);
         $proformaInvoiceEntriesParams['warehouseStore'] = $this->getRequest()->getParam('warehouse_store', '');
         $proformaInvoiceEntriesParams['entries'] = $this->getRequest()->getParam('entries', array());
         $proformaInvoicePaymentTermIds = ProformaInvoiceProgrammedPaymentQuery::create()->addColumn(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM)->whereAdd(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE, $idProformaInvoice)->fetchCol();
         $proformaInvoiceNotErasableEvents = ProformaInvoicePaymentTermQuery::create()->addColumn(ProformaInvoicePaymentTerm::ID_EVENT)->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE_PAYMENT, $proformaInvoicePaymentTermIds, ProformaInvoicePaymentTermQuery::IN)->distinct()->fetchCol();
         $erasableEvents = EventQuery::create()->addColumn(Event::ID_EVENT)->whereAdd(Event::ID_EVENT, $proformaInvoiceNotErasableEvents, EventQuery::NOT_IN)->distinct()->fetchCol();
         $proformaInvoicePaymentTermsParams["events"] = $this->getRequest()->getParam('events', array());
         $totalAmmount = $this->getRequest()->getParam('quantityMatch');
         $totalProformaInvoiceEntries = count($proformaInvoiceEntriesParams['entries']);
         try {
             $proformaInvoice = ProformaInvoiceQuery::create()->findByPKOrThrow($idProformaInvoice, $this->i18n->_("Proforma Invoice with id {$idProformaInvoice} not found"));
             $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
             foreach ($proformaInvoiceEntriesParams['entries'] as $index => $values) {
                 $proformaInvoiceEntry = $proformaInvoiceEntries->getByPK($index);
                 $values["id_warehouse_store"] = $proformaInvoiceEntriesParams['warehouseStore'];
                 ProformaInvoiceEntryFactory::populate($proformaInvoiceEntry, $values);
             }
             ProformaInvoiceFactory::populate($proformaInvoice, $proformaInvoiceParams);
             $sapConnectionClient = new SAPConnectorClient();
             $result = $sapConnectionClient->purchaseQuotation($proformaInvoice, $proformaInvoiceEntries);
             if ($result->purchaseQuotationResult->code == 200) {
                 $proformaInvoiceFiles = ProformaInvoiceFileQuery::create()->whereAdd(ProformaInvoiceFile::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
                 $uploadPath = 'public/' . ($filePath = "files/proformas/" . $result->purchaseQuotationResult->id);
                 if ($_FILES["proforma_invoice_file"]["name"] != "") {
                     $fileUploader = new FileUploader("proforma_invoice_file");
                     $fileUploader->saveFile($uploadPath, false);
                     $newFile = FileFactory::createFromArray(array(File::CONTENT => $filePath . $fileUploader->getFileName(), File::TYPE => file::$typeFile["typeFile"]));
                     $this->getFileCatalog()->create($newFile);
                     $newProformaInvoiceFile = ProformaInvoiceFileFactory::createFromArray(array(ProformaInvoiceFile::ID_PROFORMA_INVOICE => $proformaInvoice->getIdProformaInvoice(), ProformaInvoiceFile::ID_FILE => $newFile->getIdFile(), ProformaInvoiceFile::TYPE => ProformaInvoiceFile::$Types["PINew"]));
                     $this->getProformaInvoiceFileCatalog()->create($newProformaInvoiceFile);
                     $proformaInvoiceFile = $proformaInvoiceFiles->getByType(ProformaInvoiceFile::$Types["PINew"]);
                     if ($proformaInvoiceFile->getIdProformaInvoiceFile() > 0) {
                         $this->getProformaInvoiceFileCatalog()->deleteById($proformaInvoiceFile->getIdProformaInvoiceFile());
                         $this->getFileCatalog()->deleteById($proformaInvoiceFile->getIdFile());
                     }
                 }
                 if ($_FILES["proforma_invoice_file_authorized"]["name"] != "") {
                     $fileUploader = new FileUploader("proforma_invoice_file_authorized");
                     $fileUploader->saveFile($uploadPath, false);
                     $newFile = FileFactory::createFromArray(array(File::CONTENT => $filePath . $fileUploader->getFileName(), File::TYPE => file::$typeFile["typeFile"]));
                     $this->getFileCatalog()->create($newFile);
                     $newProformaInvoiceFile = ProformaInvoiceFileFactory::createFromArray(array(ProformaInvoiceFile::ID_PROFORMA_INVOICE => $proformaInvoice->getIdProformaInvoice(), ProformaInvoiceFile::ID_FILE => $newFile->getIdFile(), ProformaInvoiceFile::TYPE => ProformaInvoiceFile::$Types["PIAuthorized"]));
                     $this->getProformaInvoiceFileCatalog()->create($newProformaInvoiceFile);
                     $proformaInvoiceFile = $proformaInvoiceFiles->getByType(ProformaInvoiceFile::$Types["PIAuthorized"]);
                     if ($proformaInvoiceFile->getIdProformaInvoiceFile() > 0) {
                         $this->getProformaInvoiceFileCatalog()->deleteById($proformaInvoiceFile->getIdProformaInvoiceFile());
                         $this->getFileCatalog()->deleteById($proformaInvoiceFile->getIdFile());
                     }
                 }
                 $allPaymentTerms = ProformaInvoicePaymentTermQuery::create()->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
                 try {
                     $this->getProformaInvoicePaymentTermCatalog()->beginTransaction();
                     $paymentTerms = $allPaymentTerms->filterByEventId($erasableEvents);
                     while ($paymentTerms->valid()) {
                         $paymentTerm = $paymentTerms->read();
                         $this->getProformaInvoicePaymentTermCatalog()->deleteById($paymentTerm->getIdProformaInvoicePayment());
                     }
                     $notErasabledPaymentTerms = $allPaymentTerms->filterByEventId($proformaInvoiceNotErasableEvents, $line);
                     $programmedPayments = ProformaInvoiceProgrammedPaymentQuery::create()->whereAdd(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM, $notErasabledPaymentTerms->getPrimaryKeys())->find();
                     while ($proformaInvoiceEntries->valid()) {
                         $proformaInvoiceEntry = $proformaInvoiceEntries->read();
                         $totalPayment = 0;
                         foreach ($proformaInvoicePaymentTermsParams["events"] as $key => $payment) {
                             $amount = str_replace(",", "", $payment['payment']);
                             $proformaInvoicePaymentTermsParams["events"][$key]['percentage'] = $amount / $totalAmmount * 100;
                         }
                         foreach ($proformaInvoicePaymentTermsParams["events"] as $event) {
                             $newPaymentTerm = ProformaInvoicePaymentTermFactory::createFromArray(array(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE => $proformaInvoice->getIdProformaInvoice(), ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE_ENTRY => $proformaInvoiceEntry->getIdProformaInvoiceEntry(), ProformaInvoicePaymentTerm::LINE => $proformaInvoiceEntry->getVisOrder(), ProformaInvoicePaymentTerm::ID_EVENT => $event["id"], ProformaInvoicePaymentTerm::PIECES => $proformaInvoiceEntry->getQuantity(), ProformaInvoicePaymentTerm::PAYMENT => $proformaInvoiceEntry->getTotalImport() * $event["percentage"] / 100, ProformaInvoicePaymentTerm::CURRENCY => $proformaInvoice->getIdCurrency()));
                             $this->getProformaInvoicePaymentTermCatalog()->create($newPaymentTerm);
                         }
                         $entryPaymentTerms = $notErasabledPaymentTerms->filterByProformaInvoiceEntry($proformaInvoiceEntry);
                         while ($entryPaymentTerms->valid()) {
                             $paymentTerm = $entryPaymentTerms->read();
                             $entryProgrammedPayments = $programmedPayments->filterByPaymentTerm($paymentTerm);
                             while ($entryProgrammedPayments->valid()) {
                                 $payment = $entryProgrammedPayments->read();
                                 $payment->setIdCurrency($proformaInvoice->getIdCurrency());
                                 $payment->setLine($proformaInvoiceEntry->getVisOrder());
                                 $this->getProformaInvoiceProgrammedPaymentCatalog()->update($payment);
                             }
                             $paymentTerm->setCurrency($proformaInvoice->getIdCurrency());
                             $paymentTerm->setIdProformaInvoiceEntry($proformaInvoiceEntry->getIdProformaInvoiceEntry());
                             $paymentTerm->setLine($proformaInvoiceEntry->getVisOrder());
                             $this->getProformaInvoicePaymentTermCatalog()->update($paymentTerm);
                         }
                     }
                     $this->newLogForUpdate($proformaInvoice);
                     $this->getProformaInvoicePaymentTermCatalog()->commit();
                     $this->setFlash('ok', $this->i18n->_("Proforma Invoice with id {$result->purchaseQuotationResult->id} was updated."));
                 } catch (Exception $e) {
                     $this->getProformaInvoicePaymentTermCatalog()->rollBack();
                     $this->setFlash('error', $this->i18n->_($e->getMessage()));
                 }
             } else {
                 $this->setFlash('error', $result->purchaseQuotationResult->code . " - " . $result->purchaseQuotationResult->message);
             }
         } catch (Exception $e) {
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->_redirect('proforma-invoice/list');
 }
Exemplo n.º 9
0
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\File
  */
 protected function makeBean($resultset)
 {
     return FileFactory::createFromArray($resultset);
 }
Exemplo n.º 10
0
 /**
  * 
  * @param NotificationType $notificationType
  * @return \Application\Model\Collection\FileCollection
  */
 private function getFiles(Notification $notification)
 {
     $notificationType = NotificationTypeQuery::create()->findByPK($notification->getIdNotificationType());
     $array = array();
     $files = new FileCollection($array);
     switch ($notificationType->getIdNotificationType()) {
         case NotificationType::$id['CLAIM_REPORT_NOTIFICATION']:
             $vars = json_decode($notification->getVariables(), true);
             $filename = sys_get_temp_dir() . '/claim_report.pdf';
             $claimReport = new ClaimReport();
             $claimReport->setDocumentName($filename);
             $claimReport->setFolio($vars['folio']);
             $claimReport->setPurchaseOrder($vars['purchaseOrder']);
             $claimReport->setPercentageOfAceptance($vars['percentageOfAcceptance']);
             $claimReport->setPercentageOfDefects($vars['percentageOfDefects']);
             $claimReport->setDescription($vars['description']);
             $claimReport->setIncreasableFreight($vars['increasableFreight']);
             $claimReport->setGood($vars['claimReport']['good']);
             $claimReport->setRejected($vars['claimReport']['rejected']);
             $claimReport->setMissing($vars['claimReport']['missing']);
             $claimReport->setEstimatedRecuperationCost($vars['ERCost']);
             $claimReport->setRefuseTotal($vars['refuseTotal']);
             $claimReport->setComments($vars['comments']);
             $claimReport->setOutputDestination(ClaimReport::$OutputDestination['SAVE_LOCAL_DESTINATION']);
             $claimReport->generateClaimReport();
             $files->append(FileFactory::createFromArray(array('content' => $filename)));
             break;
     }
     return $files;
 }