function sendForBilling() { $response = new Response(); try { $projectId = $this->input->post("project-id"); $amount = $this->input->post("project-bill-amount"); $billDoc = $this->input->post("bill-doc"); $project = $this->findById("Project", $projectId); if ($project == null) { throw new RuntimeException("Invalid Project..!"); } $project->setStatus(Project::PROJECT_BILL); $project->getWorkOrder()->setStatus(Workorder::STATUS_COMPLETED); $project->getWorkOrder()->setApprovedBy($this->getLoggedInUser()); $bill = new Bill(); $bill->setAmount($amount); $bill->setProject($project); $bill->setCreated(new DateTime()); $bill->setStatus(Bill::STATUS_PENDING); if ($billDoc != null && $billDoc != "") { foreach ($billDoc as $file) { $doc = new Document(); $doc->setName($file); $doc->setCreated(new DateTime()); $bill->getBillDoc()->add($doc); } } $this->save($bill); $response->setData(Project::PROJECT_BILL); } catch (Exception $e) { $response->setStatus(false); $response->setErrorMessage($e->getMessage()); } $this->output->set_content_type('application/json')->set_output(json_encode($response)); }
/** * @param string $suffix * @return Document */ protected function getDocument($suffix = '') { $document = new Document(); $document->setName('Test name ' . $suffix); $document->setDescription('Test description ' . $suffix); $document->setRank(11); $document->setRating(93.31); return $document; }
/** * @param string $username * @param string $password * @param array $roles * @throws InvalidArgumentException */ public function createUser($username, $password, $roles = array()) { if (strlen($username) < 1 || strlen($password) < 1) { throw new InvalidArgumentException("Details can't be empty"); } $document = new Document(); $document->setName($username)->setType('user')->setRoles($roles)->setPassword((string) $password); $url = $this->getServerUrl() . "/_users/org.couchdb.user:{$username}"; $this->client->put($url, 201, $this->getOptions(), $document); }
/** * This method parses the given document and extract its fingerprints * encapsulating the result in a Document object. * * @private * @param $documentName the name given by the user to the file * @param $documentPath the temporary path that the document is being stored * @return {Document} */ private function parseDocument($documentName, $documentPath) { $pdfParser = new \Smalot\PdfParser\Parser(); $parsedPDF = $pdfParser->parseFile($documentPath); $text = $parsedPDF->getText(); $fingerprints = $this->documentService->extractFingerprint($text); $doc = new Document(); $doc->setName($documentName); //preg_replace('/[^a-zA-Z0-9]/', '', $text) $doc->setContent($text); $doc->setFingerprints($fingerprints); return $doc; }
/** * Создает новый Документ. При создании нового Документа добавляется запись в БД. * @param string $file Путь к файлу * @param boolean $copy Если значение параметра Истина, то файл будет скопирован в папку модуля trustednetsiger * @param string $name Пользовательское имя файла * @param string $type Тип файла. По умолчанию DOCUMENT_TYPE_DOCUMENT * @return \Document */ public static function createDocument($file, $copy, $name = null, $type = DOCUMENT_TYPE_FILE) { $sysName = CDirectory::getFileName($file); echo $sysName . PHP_EOL; if ($copy && CDirectory::exists($file) && !is_dir($file)) { print_r("Copy file" . PHP_EOL); print_r(TRUSDET_SIGN_DOCS_ROOT . PHP_EOL); if (!CDirectory::exists(TRUSDET_SIGN_DOCS_ROOT)) { print_r("Create folder" . PHP_EOL); CDirectory::create(TRUSDET_SIGN_DOCS_ROOT); } $new_path = TRUSDET_SIGN_DOCS_ROOT . '/' . $sysName; copy($file, $new_path); //unlink($file); $file = $new_path; } $name = $name ? $name : $sysName; $doc = new Document(); $doc->setPath(str_replace($sysName, urlencode($sysName), $file)); $doc->setName($name); $doc->setSysName($sysName); $doc->setType($type); // $doc->getProperties()->add(new Property($doc->getId(), "STATUS", "NONE")); // $props = $doc->getProperties(); // $props->add(new Property(null, "ORDER", $orderId)); print_r($doc); $doc->save(); return $doc; }
/** * * @return \Document */ public function copy() { $new = new Document(); $new->setName($this->getName()); $new->setPath($this->getPath()); $new->setSigners($this->getSigners()); $new->setSysName($this->getSysName()); $new->setType($this->getType()); $list = $this->getProperties()->getList(); foreach ($list as &$prop) { $newProp = new Property(null, $prop->getType(), $prop->getValue()); $new->getProperties()->add($newProp); } return $new; }
public function addDocument($name, $file) { $document = new Document($this->addSubElement("document")); $document->setId($this->getId() . "_document_" . $this->getNewDocumentId()); $document->setName($name); $document->setFile($file); $this->saveDOM(); return $document; }
function approveTechnicalSanction() { $response = new Response(); try { $projectId = $this->input->post("approve-project-id"); $approvedAmt = $this->input->post("project-sanction-amount"); $attachment = $this->input->post("approve-doc"); $project = $this->findById("Project", $projectId); if ($project == null) { throw new RuntimeException("Invalid Project..!"); } $project->setStatus(Project::PROJECT_TENDER); $techSanction = new TechnicalSanction(); $techSanction->setProject($project); $techSanction->setCreated(new DateTime()); $techSanction->setSanctionedAmount($approvedAmt); $techSanction->setApprovedBy($this->getLoggedInUser()); if ($attachment != null && $attachment != "") { foreach ($attachment as $file) { $doc = new Document(); $doc->setName($file); $doc->setCreated(new DateTime()); $techSanction->getSanctionDoc()->add($doc); } } $this->save($techSanction); } catch (Exception $e) { $response->setStatus(false); $response->setErrorMessage($e->getMessage()); } $this->output->set_content_type('application/json')->set_output(json_encode($response)); }