Esempio n. 1
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);
         }
     }
 }
Esempio n. 2
0
 public function __construct($path = '')
 {
     parent::__construct();
     $this->path = $path;
     if (function_exists('mb_internal_charset')) {
         mb_internal_charset('UTF-8');
     }
     define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
     $this->engine = new Smarty();
     $this->engine->setTemplateDir($path ? $path : Manager::getPublicPath() . '/templates');
     $this->engine->setCompileDir(Manager::getFrameworkPath() . '/var/templates');
     $this->engine->setCacheDir(Manager::getFrameworkPath() . '/var/cache');
     $this->engine->setConfigDir(Manager::getClassPath() . '/ui/smarty/configs');
     $this->engine->left_delimiter = '{{';
     $this->engine->right_delimiter = '}}';
     $this->context = array();
     $this->context('manager', Manager::getInstance());
 }
Esempio n. 3
0
 public function addStyleSheetCode($code)
 {
     if (Manager::isAjaxCall()) {
         $fileName = md5($code) . '.css';
         $file = Manager::getFrameworkPath('var/files/' . $fileName);
         file_put_contents($file, $code);
         $url = Manager::getDownloadURL('cache', $fileName, true);
         $this->onLoad("dojo.create(\"link\", {href:'{$url}', type:'text/css', rel:'stylesheet'}, document.getElementsByTagName('head')[0]);");
     } else {
         $this->styleSheetCode .= "\n" . $code;
     }
 }
Esempio n. 4
0
 public function loadMessages()
 {
     $file = Manager::getFrameworkPath('conf/' . $this->file);
     $msg = file_exists($file) ? require $file : array();
     $this->msg = array_merge($this->msg, $msg);
 }
Esempio n. 5
0
 public function save()
 {
     $file = \Manager::getFrameworkPath('var/files/' . $this->data->id);
     $this->renderDownload($file);
 }
Esempio n. 6
0
 public function getExtension($lang)
 {
     $valor = $this->getValue();
     if (strpos($valor, ",") > 0) {
         // retira o ponto de milhar, se tiver
         $valor = str_replace(".", "", $valor);
         // troca a virgula decimal por ponto decimal
         $valor = str_replace(",", ".", $valor);
     }
     //obtem o arquivo de configuração e linguagem
     $lang = Manager::getOptions('language');
     $file = 'messages.' . ($lang ? $lang . '.' : '') . 'php';
     $file = Manager::getFrameworkPath('conf/' . $file);
     $currencyExt = file_exists($file) ? require $file : array();
     $currencyExt = $currencyExt['currencyExtension'];
     $singular = $currencyExt['classSingular'];
     $plural = $currencyExt['classPlural'];
     $c = $currencyExt['orderHundred'];
     $d = $currencyExt['orderDozen'];
     $d10 = $currencyExt['firstDozen'];
     $u = $currencyExt['orderUnit'];
     $z = 0;
     $ot = $currencyExt['other'];
     $valor = number_format($valor, 2, ".", ".");
     $inteiro = explode(".", $valor);
     $cont = count($inteiro);
     for ($i = 0; $i < $cont; $i++) {
         for ($ii = strlen($inteiro[$i]); $ii < 3; $ii++) {
             $inteiro[$i] = "0" . $inteiro[$i];
         }
     }
     $fim = $cont - ($inteiro[$cont - 1] > 0 ? 1 : 2);
     $rt = '';
     for ($i = 0; $i < $cont; $i++) {
         $valor = $inteiro[$i];
         $rc = $valor > 100 && $valor < 200 ? $ot[1] : $c[$valor[0]];
         $rd = $valor[1] < 2 ? "" : $d[$valor[1]];
         $ru = $valor > 0 ? $valor[1] == 1 ? $d10[$valor[2]] : $u[$valor[2]] : "";
         $r = $rc . ($rc && ($rd || $ru) ? " " . $ot[2] . " " : "") . $rd . ($rd && $ru ? " " . $ot[2] . " " : "") . $ru;
         $t = $cont - 1 - $i;
         $r .= $r ? " " . ($valor > 1 ? $plural[$t] : $singular[$t]) : "";
         if ($valor == "000") {
             $z++;
         } elseif ($z > 0) {
             $z--;
         }
         if ($t == 1 && $z > 0 && $inteiro[0] > 0) {
             $r .= ($z > 1 ? " " . $ot[3] . " " : "") . $plural[$t];
         }
         if ($r) {
             $rt = $rt . ($i > 0 && $i <= $fim && $inteiro[0] > 0 && $z < 1 ? $i < $fim ? ", " : " " . $ot[2] . " " : " ") . $r;
         }
     }
     return $rt ? $rt : $ot[0];
 }