コード例 #1
0
ファイル: -ProductController.php プロジェクト: Eximagen/sochi
 public function savefileAction($idNpd)
 {
     if (!$idNpd) {
         $idNpd = new file();
         //die("sds");
     }
     $fileUploader = new FileUploader("npd");
     if ($fileUploader->isUpload()) {
         $filePath = "files/npd/" . $idNpd . "/files";
         $uploadPath = 'public/' . $filePath;
         $files = \Application\Query\FileQuery::create()->innerJoinNpdSheet()->whereAdd('NpdSheet.id_npd_sheet', $idNpd)->whereAdd('File.Type', file::$typeFile["typeFile"])->fetchAll();
         if ($files) {
             foreach ($files as $file) {
                 $dir = 'public/';
                 $filename = $file['content'];
                 $idFile = $file['id_file'];
                 unlink($dir . $filename);
                 $this->getCatalog("NpdSheetFileCatalog")->deleteById($file['id_file']);
                 $this->getCatalog("FileCatalog")->deleteById($idFile);
             }
         }
         $fileUploader->saveFile($uploadPath, false);
         $type = File::$typeFile["typeFile"];
         $sheetFile = new File();
         $sheetFile->setType($type)->setContent($filePath . $fileUploader->getFileName());
         $this->getCatalog("FileCatalog")->create($sheetFile);
         $this->getCatalog("NpdSheetCatalog")->linkToFile($idNpd, $sheetFile->getIdFile());
     }
 }
コード例 #2
0
 /**
  *
  */
 public function payAction()
 {
     $params = $this->getRequest()->getParams();
     $returnAction = $this->getRequest()->getParam("returnAction", "list");
     $payment = Zend_Json::decode(stripslashes($params["sapPayment"]));
     $this->getActualPaymentCatalog()->beginTransaction();
     try {
         $fileUploader = new FileUploader('file');
         if (!$fileUploader->isUpload()) {
             throw new Exception("El archivo es invalido");
         }
         $uploadDir = 'public/files/payments/docnum' . $docnum;
         $fileUploader->saveFile($uploadDir, false);
         $file = new File();
         $file->setContent($uploadDir . $fileUploader->getFileName());
         $file->setType(File::$typeFile['typeImage']);
         $this->getFileCatalog()->create($file);
         foreach ($params["payment"] as $programmedPaymentParam) {
             if ($programmedPaymentParam["payment"] > 0) {
                 $programmedPayment = ProgrammedPaymentQuery::create()->findByPK($programmedPaymentParam["id"]);
                 $balance = $this->getPaymentBalance($programmedPayment);
                 if ($balance + $programmedPaymentParam["payment"] > $programmedPayment->getAmmount()) {
                     throw new Exception("Balance overloaded");
                 }
                 $actualPayment = ActualPaymentFactory::createFromArray(array(ActualPayment::ID_FILE => $file->getIdFile(), ActualPayment::DOCNUM => $payment["idPayment"], ActualPayment::ID_PROGRAMMED_PAYMENT => $programmedPayment->getIdProgrammedPayment(), ActualPayment::AMMOUNT => $programmedPaymentParam["payment"], ActualPayment::PAYMENT_DATE => $payment["paymentDate"], ActualPayment::TYPE => $payment["type"]));
                 $this->getActualPaymentCatalog()->create($actualPayment);
                 if ($balance + $programmedPaymentParam["payment"] == $programmedPayment->getAmmount()) {
                     $programmedPayment->setStatus(ProgrammedPayment::$TypeStatus['Paid']);
                     $event = ProgrammedPaymentEvent::TOTAL_PAYMENT;
                 } else {
                     $programmedPayment->setStatus(ProgrammedPayment::$TypeStatus['Partial']);
                     $event = ProgrammedPaymentEvent::PARTIAL_PAYMENT;
                 }
                 $this->getProgrammedPaymentCatalog()->update($programmedPayment);
                 $this->getEventDispatcherService()->createProgrammedPaymentNotification($event, $programmedPayment, $actualPayment);
                 //TODO Despachar el evento de Pago Realizado
             }
         }
         $this->getActualPaymentCatalog()->commit();
         $this->setFlash("ok", $this->i18n->_('The payments were successfully saved'));
     } catch (Exception $e) {
         $this->getActualPaymentCatalog()->rollBack();
         $this->setFlash("error", $this->i18n->_('The payments could not be saved: ' . $e->getMessage()));
     }
     $this->getHelper('redirector')->goto($returnAction);
 }
コード例 #3
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     $params = $this->getRequest()->getParams();
     $id = $params['id_customs_broker'];
     $customsBroker = CustomsBrokerQuery::create()->findByPKOrThrow($id, $this->i18n->_('It does not exist Customs Broker with id'));
     $this->getCustomsBrokerCatalog()->beginTransaction();
     try {
         $address = AddressFactory::createFromArray($params);
         $this->getCatalog('AddressCatalog')->update($address);
     } catch (Exception $e) {
         //Address couldn't be created
         $this->getCustomsBrokerCatalog()->rollBack();
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     //updates the file and its register in the db and eliminates previous one
     $type = $_FILES['id_last_fee_file']['type'];
     if ($type) {
         try {
             $uploadPath = 'files/company/customs-broker/' . $params['id_company'];
             $fileUploader = new FileUploader("id_last_fee_file");
             if ($fileUploader->isUpload()) {
                 if ($customsBroker->getIdLastFeeFile()) {
                     $idFile = $customsBroker->getIdLastFeeFile();
                     $feeFile = \Application\Query\FileQuery::create()->findByPK($idFile);
                     //$this->getCatalog('FileCatalog')->deleteById($feeFile->getIdFile());
                     is_dir(unlink('public/' . $feeFile->getContent()));
                 }
                 if (strstr($type, "image") != false) {
                     $uploadPath .= '/images';
                     $fileUploader->saveFile('public/' . $uploadPath, true);
                 } else {
                     $uploadPath .= '/files';
                     $fileUploader->saveFile('public/' . $uploadPath, false);
                 }
                 $myFile = new File();
                 $myFile->setContent($uploadPath . $fileUploader->getFileName());
                 $myFile->setType(file::$typeFile['typeFile']);
                 $this->getCatalog('FileCatalog')->create($myFile);
                 $customsBroker->setIdLastFeeFile($myFile->getIdFile());
             }
         } catch (Exception $e) {
             //the images wasn't uploaded
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     try {
         $this->getCustomsBrokerCatalog()->unlinkAllPortCustom($id);
         $idsCustomsPort = $params['idsCustomsPort'];
         foreach ($idsCustomsPort as $idCustomsPort) {
             $this->getCustomsBrokerCatalog()->linkToPortCustom($customsBroker->getIdCustomsBroker(), $idCustomsPort);
         }
     } catch (Exception $e) {
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     //Inserts a customs broker register
     try {
         CustomsBrokerFactory::populate($customsBroker, $params);
         $this->getCustomsBrokerCatalog()->update($customsBroker);
     } catch (Exception $e) {
         $this->setFlash('error', $this->i18n->_($e->getMessage()));
     }
     $this->getCustomsBrokerCatalog()->commit();
     $this->setFlash('ok', $this->i18n->_("The Customs Brokers with id {$id} has been updated"));
     $this->_redirect("customs-broker/list");
 }
コード例 #4
0
ファイル: SupplierController.php プロジェクト: Eximagen/sochi
 public function savefileAction($inputFile, $type, $idSupplier)
 {
     $fileUploader = new FileUploader($inputFile);
     if ($fileUploader->isUpload()) {
         $filePath = "files/company/supplier/" . $idSupplier;
         $uploadPath = 'public/' . $filePath;
         $files = SupplierFileQuery::create()->innerJoinFile()->addColumns(array('File.*', 'SupplierFile.*'))->whereAdd('SupplierFile.' . SupplierFile::ID_SUPPLIER, $idSupplier)->whereAdd('SupplierFile.document_type', $type)->fetchAll();
         foreach ($files as $file) {
             $idSupplierFile = $file['id_supplier_file'];
             $dir = 'public/';
             $filename = $file['content'];
             $idFile = $file['id_file'];
             if (file_exists($dir . $filename)) {
                 unlink($dir . $filename);
             }
             $this->getSupplierFileCatalog()->deleteById($idSupplierFile);
             $this->getFileCatalog()->deleteById($file['id_file']);
         }
         $fileUploader->saveFile($uploadPath, false);
         $setupFormFile = new SupplierFile();
         $setupFormFile->setContent($filePath . $fileUploader->getFileName());
         $setupFormFile->setType(File::$typeFile['typeFile']);
         $setupFormFile->setIdSupplier($idSupplier);
         $setupFormFile->setDocumentType($type);
         $this->getSupplierFileCatalog()->create($setupFormFile);
     }
 }
コード例 #5
0
 public function savefileAction($idInspection, $idOrderEntry)
 {
     $fileUploader = new FileUploader("file");
     if ($fileUploader->isUpload()) {
         $filePath = "files/order-entry/" . $idOrderEntry . '/result';
         $uploadPath = 'public/' . $filePath;
         $files = InspectionQuery::create()->innerJoinFile()->addColumns(array('File.*'))->whereAdd('Inspection.' . Inspection::ID_INSPECTION, $idInspection)->fetchAll();
         foreach ($files as $file) {
             $dir = 'public/';
             $filename = $file['content'];
             $idFile = $file['id_file'];
             unlink($dir . $filename);
             $this->getInspectionFileCatalog()->deleteById($file['id_file']);
             $this->getFileCatalog()->deleteById($idFile);
         }
         $fileUploader->saveFile($uploadPath, false);
         $resultFile = new InspectionFile();
         $resultFile->setContent($filePath . $fileUploader->getFileName());
         $resultFile->setType(1);
         $resultFile->setIdInspection($idInspection);
         //$resultFile->setDocumentType($type);
         $this->getInspectionFileCatalog()->create($resultFile);
     }
 }