Example #1
0
 public function setData($data)
 {
     // exemplo de um tratamento específico: acrescentar prefixo
     $data->nome = 'Sr(a). ' . str_replace('Sr(a). ', '', $data->nome);
     // files não são convertidos automaticamente
     $data->foto = \Mutil::parsefiles('foto', 0);
     // campos NULL devem ser forçados
     $data->opcional = $data->opcional ?: NULL;
     // testa CPF vazio
     // executa setData (faz as conversoes de tipo se necessário)
     parent::setData($data);
 }
 public function saveFoto()
 {
     try {
         $pessoa = new Pessoa($this->data->id);
         $pessoa->setFoto(Mutil::parseFiles('foto', 0));
         $pessoa->save();
         $go = '>exemplos/pessoa/formObject/' . $this->data->id;
         $this->renderPrompt('information', 'OK', $go);
     } catch (Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
Example #3
0
 function fill($fileInput, $fileOutput, $fileType, $parameters, $classPath, $save)
 {
     if ($this->executionType == 'local') {
         // execute java program at localhost
         $params = array();
         // build a params array as base to json encoding
         if (is_array($parameters)) {
             foreach ($parameters as $pn => $pv) {
                 $params[$pn] = utf8_encode($pv);
             }
         }
         $db = Manager::$conf['db'][$this->dataSource];
         $params['dbUser'] = $db['user'];
         $params['jdbcDriver'] = $db['jdbc']['driver'];
         $params['jdbcDb'] = $db['jdbc']['db'];
         $prefix = substr(uniqid(md5(uniqid(""))), 0, 10);
         $params['pass'] = base64_encode($prefix . $db['password']);
         $params['relatorio'] = $fileInput;
         $params['fileOutput'] = $fileOutput;
         $params['fileType'] = $this->fileType;
         $javaPath = $this->manager->getOptions("javaPath");
         //            $logPath = $this->manager->getConf('home.logs');
         $fileLog = $this->manager->getLog()->getLogFileName(str_replace("\\", "", "Jasper_" . str_replace('/', '', $this->name)) . "_" . substr(uniqid(md5(uniqid(""))), 0, 6) . '.log');
         $json = addslashes(json_encode($params));
         $MJasperPath = Manager::getFrameworkPath('classes/extensions/jasper');
         $debug = $this->manager->getOptions("debug");
         $cmd = $javaPath . "/bin/java -classpath {$classPath} MJasper \"{$json}\"" . ($debug ? " 2> {$fileLog}" : "");
         ////mdump($cmd);
         exec($cmd, $output);
         //var_dump($output);
         if (trim($output[0]) == "end") {
             //no errors!
             if ($this->fileType == "TXT") {
                 // adjust for CR+LF difference between Windows and Linux
                 Mutil::unix2dos($fileOutput);
             }
             if ($save) {
                 // download
                 $this->manager->response->sendDownload($fileOutput);
             } else {
                 // new window
                 $output = Manager::getAbsoluteURL('var/reports/' . $this->fileOutput);
                 $this->manager->getPage()->window($output);
             }
         } else {
             // errors!
             $link = new MLink('', 'aqui', Manager::getActionURL('manager', "logs:{$fileLog}"), 'aqui', '_errors');
             $detalhes = "<br>Para mais detalhes clique " . $link->generate();
             throw new EControlException(implode("<br>", $output) . $detalhes);
         }
     } else {
         if ($this->executionType == 'remote') {
             //Generate report throught another host, via TomCat
             $this->fileOutput = $this->manager->getConf("home.url_jasper") . "?bd={$this->db}&relatorio={$filein}" . $parameters;
             $this->manager->getPage()->window($this->fileOutput);
         }
     }
 }