コード例 #1
0
ファイル: SrpReport.class.php プロジェクト: andermall/tcc
 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         //TTransaction::setLogger(new TLoggerTXT("c:\\array\\LOG" . date("Ymd-His") . ".txt"));
         // get the form data into an active record
         $formdata = $this->form->getData();
         $validadeI = $formdata->validadeI;
         $validadeF = TDate::date2us($formdata->validadeF);
         if (!$validadeI === 0) {
             $validadeI = '0';
         } else {
             $validadeI = TDate::date2us($validadeI);
         }
         $this->form->validate();
         $repository = new TRepository('Srp');
         $criteria = new TCriteria();
         $param['order'] = 'id';
         $param['direction'] = 'desc';
         $criteria->setProperties($param);
         if ($formdata->numeroProcessoI != '' && $formdata->numeroProcessoF != '') {
             $criteria->add(new TFilter('numeroProcesso', 'BETWEEN', "{$formdata->numeroProcessoI}", "{$formdata->numeroProcessoF}"));
         }
         if ($formdata->validadeI != '' && $formdata->validadeF != '') {
             $criteria->add(new TFilter('validade', 'between', "{$validadeI}", "{$validadeF}"));
         }
         if ($formdata->numeroSRPI != '' && $formdata->numeroSRPF != '') {
             $criteria->add(new TFilter('numeroSRP', 'between', "{$formdata->numeroSRPI}", "{$formdata->numeroSRPF}"));
         }
         if ($formdata->numeroIRPI != '' && $formdata->numeroIRPF != '') {
             $criteria->add(new TFilter('numeroIRP', 'between', "{$formdata->numeroIRPI}", "{$formdata->numeroIRPF}"));
         }
         $imprimeZero = true;
         if (isset($formdata->itensZero)) {
             if ($formdata->itensZero === '0') {
                 $imprimeZero = false;
             }
         }
         $srps = $repository->load($criteria, true);
         if ($srps) {
             $this->pdf = new FPDF();
             $this->pdf->AliasNbPages();
             $this->pdf->SetMargins(10, 10, 10);
             $this->pdf->setHeaderCallback(array($this, 'header'));
             $this->pdf->setFooterCallback(array($this, 'footer'));
             $this->pdf->AddPage();
             foreach ($srps as $srp) {
                 $this->data = $srp;
                 $this->srpHeader($imprimeZero);
                 $this->srpItens($imprimeZero);
             }
             if (!file_exists("app/output/RelatorioSrp.pdf") or is_writable("app/output/RelatorioSrp.pdf")) {
                 $this->pdf->Output("app/output/RelatorioSrp.pdf");
             } else {
                 throw new Exception('Permissão negada' . ': ' . "app/output/RelatorioSrp.pdf");
             }
             parent::openFile("app/output/RelatorioSrp.pdf");
             //new TMessage('info', 'Relatório gerado. Por favor, habilite o pop-up do seu browser.');
         } else {
             new TMessage('error', 'Nenhum registro encontrado');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         // in case of exception
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
コード例 #2
0
 public function onSave($param)
 {
     try {
         $this->form_requisicao->validate();
         // validate form data
         $form_requisicao_data = $this->form_requisicao->getData();
         $form_requisicao = TSession::getValue('form_requisicao');
         $form_requisicao->numeroProcesso = $form_requisicao_data->numeroProcesso;
         $form_requisicao->emissao = $form_requisicao_data->emissao;
         $requisicao_itens = TSession::getValue('requisicao_itens');
         if (!isset($requisicao_itens) || count($requisicao_itens) == 0) {
             new TMessage('error', 'Insira ao menos 1 item');
             return;
         }
         TTransaction::open('saciq');
         //TTransaction::setLogger(new \Adianti\Log\TLoggerTXT("c:\\array\\LOG".date("Ymd-His").".txt"));
         if ($requisicao_itens) {
             $id = isset($form_requisicao->id) ? $form_requisicao->id : NULL;
             $requisicao = new Requisicao($id);
             // create a new Sale
             $requisicao->clearParts();
             $requisicao->numeroProcesso = $form_requisicao->numeroProcesso;
             $requisicao->emissao = TDate::date2us($form_requisicao->emissao);
             //if (!$requisicao->emissao){
             //    $requisicao->emissao = date("Y-m-d");
             //}
             $requisicao->aprovado = 0;
             $requisicao->srp = new Srp(TSession::getValue("SRP_id"));
             foreach ($requisicao_itens as $item) {
                 $item_requisicao = new Item($item->item_id);
                 $item_requisicao->justificativa = $item->justificativa;
                 $item_requisicao->quantidade = $item->quantidade;
                 $item_requisicao->prazoEntrega = $item->prazoEntrega;
                 $item_requisicao->quantidade = str_replace('.', '', $item->quantidade);
                 $item_requisicao->quantidade = str_replace(',', '.', $item->quantidade);
                 $requisicao->addItem($item_requisicao);
                 // add the item to the Sale
             }
             $requisicao->store();
             // store the Sale
             TSession::delValue('requisicao_itens');
             TSession::delValue('form_requisicao');
             TSession::delValue('SRP_id');
             new TMessage('info', 'Requisição salva');
         }
         TTransaction::close();
         $this->onReload();
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
     }
 }
コード例 #3
0
ファイル: CessaoForm.class.php プロジェクト: andermall/tcc
 public function onSave($param)
 {
     try {
         $this->form_cessao->validate();
         // validate form data
         $form_cessao_data = $this->form_cessao->getData();
         $form_cessao = TSession::getValue('form_cessao');
         $form_cessao->numeroCessao = $form_cessao_data->numeroCessao;
         $form_cessao->campusID = $form_cessao_data->campusID;
         $form_cessao->campusNome = $form_cessao_data->campusNome;
         $form_cessao->emissao = $form_cessao_data->emissao;
         $cessao_itens = TSession::getValue('cessao_itens');
         if (!isset($cessao_itens) || count($cessao_itens) == 0) {
             new TMessage('error', 'Insira ao menos 1 item');
             return;
         }
         TTransaction::open('saciq');
         if ($cessao_itens) {
             $id = isset($form_cessao->id) ? $form_cessao->id : NULL;
             $cessao = new Cessao($id);
             // create a new Sale
             $cessao->clearParts();
             $cessao->numeroCessao = $form_cessao->numeroCessao;
             $cessao->campus = new Campus($form_cessao->campusID);
             $cessao->emissao = TDate::date2us($form_cessao->emissao);
             //if (!$cessao->emissao){
             //    $cessao->emissao = date("Y-m-d");
             //}
             $cessao->aprovado = 0;
             $cessao->srp = new Srp(TSession::getValue('SRP_id'));
             foreach ($cessao_itens as $item) {
                 $item_cessao = new Item($item->item_id);
                 $item_cessao->quantidade = $item->quantidade;
                 $item_cessao->quantidade = str_replace('.', '', $item->quantidade);
                 $item_cessao->quantidade = str_replace(',', '.', $item->quantidade);
                 $cessao->addItem($item_cessao);
                 // add the item to the Sale
             }
             $cessao->store();
             // store the Sale
             TSession::delValue('cessao_itens');
             TSession::delValue('form_cessao');
             TSession::delValue('SRP_id');
             new TMessage('info', 'Cessão salva');
         }
         TTransaction::close();
         $this->onReload();
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
     }
 }
コード例 #4
0
ファイル: DocCessaoForm.class.php プロジェクト: andermall/tcc
 public function onGenerate($param)
 {
     //var_dump($param);
     $this->B = 0;
     $this->I = 0;
     $this->U = 0;
     $this->HREF = '';
     $data = $this->form->getData();
     $id = $data->cessao_id;
     $this->pdf = new FPDF();
     $this->pdf->AliasNbPages();
     setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
     try {
         TTransaction::open('saciq');
         $this->form->validate();
         $cessao = new Cessao($id);
         $itens_list = $cessao->getItems();
         if (count($itens_list) == 0) {
             new TMessage('error', 'Nenhum item encontrado na cessão');
             $this->form->sendData('doc_cessao_form', $data);
             return;
         }
         $memorando = utf8_decode($data->memorando);
         $emissao = TDate::date2us($data->emissao);
         $repository = new TRepository('Campus');
         $criteria = new TCriteria();
         $criteria->add(new TFilter('sigla', '=', CAMPUS));
         $campus_list = $repository->load($criteria);
         $campus = $campus_list[0];
         $this->cidade = $campus->nome;
         $destino = strtoupper($data->campusNome);
         $this->gerente = $data->gerente;
         $this->diretor = $data->diretor;
         $emissao = strtotime($emissao);
         $mes = ucfirst(strftime('%B', $emissao));
         $emissao = $this->cidade . ', ' . strftime(" %d de {$mes} de %Y.", $emissao);
         $srp = $cessao->srp->numeroSRP;
         $natureza = $cessao->srp->natureza->descricao;
         $nomeSrp = $cessao->srp->nome;
         //$this->pdf->Open();
         $this->pdf->SetMargins(25, 20, 25);
         $this->pdf->setHeaderCallback(array($this, 'Header'));
         //$this->pdf->setFooterCallback(array($this, 'Footer'));
         $this->pdf->AddPage();
         $this->pdf->SetFont('Times', '', 12);
         //$this->pdf->Cell(15);
         $this->pdf->Cell(0, 5, "{$memorando}", 0, 1);
         $this->pdf->Ln(10);
         $this->pdf->Cell(0, 5, $emissao, 0, 0, 'R');
         $this->pdf->Ln(10);
         $this->pdf->Cell(0, 5, utf8_decode('À'), 0, 1);
         $this->pdf->Cell(0, 5, utf8_decode("GERÊNCIA ADMINISTRATIVA DO CAMPUS {$destino}"));
         $this->pdf->Ln(10);
         $this->pdf->SetFont('Times', 'B', 12);
         $this->pdf->MultiCell(0, 5, utf8_decode("ASSUNTO: CESSÃO DE QUANTITATIVO - SRP {$srp} - {$natureza} - {$nomeSrp}"));
         $this->pdf->SetFont('Times', '', 12);
         $this->pdf->Ln(15);
         $this->pdf->SetX(21);
         $this->WriteHTML(utf8_decode("1.Conforme solicitação, autorizamos a utilização do quantitativo abaixo referido," . "referente a estimativa do Câmpus Capivari para a <B>SRP {$srp} - {$natureza} - {$nomeSrp}</B>"));
         $this->pdf->Ln(10);
         //cabecalho da tabela
         $y = $this->pdf->GetY();
         $x = $this->pdf->GetX();
         $this->pdf->SetFont('Times', 'B', 12);
         $width = array(18, 107, 38);
         $this->pdf->MultiCell($width[0], 10, utf8_decode('ITEM'), 1, 'C');
         $this->pdf->SetXY($x += $width[0], $y);
         $this->pdf->MultiCell($width[1], 10, utf8_decode("DESCRIÇÃO"), 1, 'C');
         $this->pdf->SetXY($x += $width[1], $y);
         $this->pdf->MultiCell($width[2], 10, utf8_decode('QUANT.'), 1, 'C');
         $this->pdf->SetFont('Times', '', 12);
         $this->pdf->ln(0);
         $y = $this->pdf->GetY();
         $x = $this->pdf->GetX();
         usort($itens_list, array("DocCessaoForm", "cmp"));
         //preencher a tabela
         foreach ($itens_list as $item) {
             $numeroItem = $item->numeroItem;
             $descricaoSumaria = substr($item->descricaoSumaria, 0, 80);
             $quantidade = $item->quantidade;
             $t1 = $this->pdf->GetStringWidth($descricaoSumaria);
             $tamanhoTexto = $t1;
             $tamanhoDesc = $width[1];
             $qtdLinha = 1;
             $offset = 0;
             $atualSize = 0;
             while (true) {
                 $pos = strpos($descricaoSumaria, ' ', $offset);
                 if ($pos === FALSE) {
                     while ($tamanhoTexto > $tamanhoDesc) {
                         $qtdLinha++;
                         $tamanhoTexto -= $tamanhoDesc;
                     }
                     break;
                 }
                 $textCompare = substr($descricaoSumaria, $offset, $pos - $offset);
                 $textSize = $this->pdf->GetStringWidth($textCompare . ' ');
                 if ($textSize + $atualSize > $tamanhoDesc) {
                     $qtdLinha++;
                     $tamanhoTexto -= $atualSize;
                     $atualSize = 0;
                 } else {
                     $atualSize += $textSize;
                     $offset = $pos + 1;
                 }
             }
             if ($qtdLinha == 1) {
                 $qtdLinha = 2;
             }
             $alturaLinha = 5 * $qtdLinha;
             if ($this->pdf->GetY() + $alturaLinha > 280) {
                 $this->pdf->Cell(array_sum($width), 0, '', 'T');
                 $this->pdf->AddPage();
                 $y = $this->pdf->GetY();
                 $x = $this->pdf->GetX();
             }
             $this->pdf->MultiCell($width[0], $alturaLinha, utf8_decode($numeroItem), 'LRT', 'C');
             $this->pdf->SetXY($x += $width[0], $y);
             $this->pdf->MultiCell($width[1], 5, utf8_decode($descricaoSumaria), 'LRT', 'J');
             $this->pdf->SetXY($x += $width[1], $y);
             $this->pdf->MultiCell($width[2], $alturaLinha, utf8_decode($quantidade), 'LRT', 'C');
             $this->pdf->Ln(0);
             $y = $this->pdf->GetY();
             $x = $this->pdf->GetX();
         }
         $this->pdf->Cell(array_sum($width), 0, '', 'T');
         if ($this->pdf->GetY() + $alturaLinha > 210) {
             $this->pdf->AddPage();
             $this->ImprimiNoRodape = false;
         } else {
             $this->ImprimiNoRodape = true;
         }
         $this->Footer();
         if (!file_exists("app/output/doc.pdf") or is_writable("app/output/doc.pdf")) {
             $this->pdf->Output("app/output/doc.pdf");
         } else {
             throw new Exception('Permissão negada' . ': ' . "app/output/doc.pdf");
         }
         parent::openFile('app/output/doc.pdf');
         $this->form->sendData('doc_cessao_form', $data);
         TTransaction::close();
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
コード例 #5
0
ファイル: SrpList.class.php プロジェクト: andermall/tcc
 public function rowFormat($date, $object, $row)
 {
     if ($object->estaVencida(TDate::date2us($date))) {
         $row->style = "background: #FFDADE";
     }
     return $date;
 }