Exemple #1
0
 /**
  * 
  */
 public function run()
 {
     $_job = new Tools_DataView_Job_MapperView();
     $_job->setId($this->jobId)->retrieve();
     try {
         $start = ZendT_Type_Date::nowDateTime();
         $config = array('useragent' => 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/44.0', 'encodecookies' => false, 'timeout' => 60 * 60);
         $params = Tools_Interface_Job::prepareParams($_job->getParametro()->toPhp());
         $_client = new Zend_Http_Client($_job->getProcedimento()->toPhp(), $config);
         if (count($params) > 0) {
             foreach ($params as $name => $value) {
                 $_client->setParameterGet($name, $value);
             }
         }
         $response = $_client->request();
         $message = $response->getBody();
         if ($message == '' || $message == 'OK') {
         } else {
             Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message);
         }
         $finish = ZendT_Type_Date::nowDateTime();
         $diff = $start->diff($finish);
         $_job->setTempoUlExec($diff->i);
     } catch (Exception $ex) {
         $message = 'Mensagem: ' . $ex->getMessage() . "\n";
         $message .= 'Erro: ' . $ex->getTraceAsString() . "\n";
         Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message);
         $_job->setTempoUlExec(0);
     }
     $_job->setDhUltExec(ZendT_Type_Date::nowDateTime());
     $_job->setStatus('A');
     $_job->update();
     return true;
 }
Exemple #2
0
 /**
  * Atualiza o término de exeução do relatório
  *
  * @param int $numRows Quantidade de Registro Processado
  * @return \Log_Context_Relatorio 
  */
 public function finish($numRows = '')
 {
     if ($this->_session) {
         $this->setQtdReg($numRows)->setDhFimRelat(ZendT_Type_Date::nowDateTime())->update();
     }
     return $this;
 }
Exemple #3
0
 public function _beforeSave()
 {
     parent::_beforeSave();
     if ($this->_action != 'delete') {
         if ($this->getIdEmpresa(true)->toPhp() == '') {
             $this->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa());
         }
         if ($this->getIdCliente(true)->toPhp() == '') {
             $_pessoa = new Ca_DataView_Pessoa_MapperView();
             $_pessoa->setNome(_i18n('CONSUMIDOR'));
             $_pessoa->retrieve();
             $this->setIdCliente($_pessoa->getId());
         }
         if ($this->getIdClienteCon(true)->toPhp() == '') {
             $this->setIdClienteCon($this->getIdCliente());
         }
         if ($this->getIdUsuInc(true)->toPhp() == '') {
             $this->setIdUsuInc(Auth_Session_User::getInstance()->getId());
         }
         if ($this->getTipo(true)->toPhp() == '') {
             $this->setTipo('V');
         }
         if ($this->getStatus(true)->toPhp() == '') {
             $this->setStatus('A');
         }
         if ($this->getStatusEdi(true)->toPhp() == '') {
             $this->setStatusEdi('N');
         }
         if ($this->getDtEmis(true)->toPhp() == '') {
             $this->setDtEmis(ZendT_Type_Date::nowDate());
         }
         if ($this->getDhInc(true)->toPhp() == '') {
             $this->setDhInc(ZendT_Type_Date::nowDateTime());
         }
         $this->setIdUsuAlt(Auth_Session_User::getInstance()->getId());
         if ($this->getIdFuncionario(true)->toPhp() == '') {
             $_pessoa = new Ca_DataView_Pessoa_MapperView();
             $_pessoa->setEmail(Auth_Session_User::getInstance()->getLogin());
             $_pessoa->retrieve();
             $this->setIdFuncionario($_pessoa->getId());
         }
         if ($this->_action == 'update') {
             /*if ($this->getStatus()->toPhp() == 'A') {
                   $this->_pagamento = new Vendas_DataView_Pagamento_MapperView();
                   $this->_saldoPagto = $this->_pagamento->getSaldoPagar($this->getId());
                   if ($this->_saldoPagto == 0) {
                       $this->setStatus('P'); // pago
                   }
               }*/
         }
     }
     if ($this->_action == 'insert' && !$this->getNumero(true)->toPhp()) {
         $_numeracao = new Ca_Model_Numeracao_Mapper();
         $numero = $_numeracao->proximo(self::$table . '.numero', $this->getIdEmpresa()->toPhp());
         $this->setNumero($numero);
     }
 }
Exemple #4
0
 public static function log($id, $message)
 {
     if (self::$_instance == null) {
         self::$_instance = new Vendas_Model_LogPedido_Mapper();
     }
     self::$_instance->newRow();
     self::$_instance->setIdPedido($id)->setDhLog(ZendT_Type_Date::nowDateTime())->setMensagem(substr($message, 0, 999))->insert();
     return true;
 }
Exemple #5
0
 public static function log($proc, $message)
 {
     if (self::$_instance == null) {
         self::$_instance = new Tools_Model_LogErro_Mapper();
     }
     self::$_instance->newRow();
     self::$_instance->setProcedimento($proc)->setDhLog(ZendT_Type_Date::nowDateTime())->setMensagem(substr($message, 0, 999))->insert();
     return true;
 }
Exemple #6
0
 public function run()
 {
     $_job = new Tools_DataView_Job_MapperView();
     $_where = new ZendT_Db_Where();
     $_where->addFilter('job.dh_pro_exec', ZendT_Type_Date::nowDateTime(), '<=');
     $_where->addFilter('job.dh_fim_exec', ZendT_Type_Date::nowDateTime(), '>=');
     $_where->addFilter('job.status', 'A');
     $_job->findAll($_where, '*');
     while ($_job->fetch()) {
         $_now = ZendT_Type_Date::nowDateTime();
         while ($_job->getDhProExec()->toPhp() <= $_now->toPhp()) {
             if ($_job->getTpFrequencia()->toPhp() == 'H') {
                 $_job->getDhProExec()->addHour($_job->getNumFrequencia()->toPhp());
             } else {
                 if ($_job->getTpFrequencia()->toPhp() == 'D') {
                     $_job->getDhProExec()->addDay($_job->getNumFrequencia()->toPhp());
                 } else {
                     if ($_job->getTpFrequencia()->toPhp() == 'M') {
                         $_job->getDhProExec()->addMonth($_job->getNumFrequencia()->toPhp());
                     }
                 }
             }
         }
         $_job->setStatus('E');
         $_job->update();
         try {
             if ($_job->getFormaExec()->toPhp() == 'C') {
                 $_adapter = new Tools_Interface_Job_Php();
             } else {
                 $_adapter = new Tools_Interface_Job_Http();
             }
             $_adapter->jobId = $_job->getId()->toPhp();
             $_th = new ZendT_Thread();
             $_th->start($_adapter, 'run');
         } catch (Exception $ex) {
             $message = 'Mensagem: ' . $ex->getMessage() . "\n";
             $message .= 'Erro: ' . $ex->getTraceAsString() . "\n";
             Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message);
         }
     }
 }
Exemple #7
0
 /**
  * 
  */
 public function run()
 {
     $_job = new Tools_DataView_Job_MapperView();
     $_job->setId($this->jobId)->retrieve();
     try {
         $start = ZendT_Type_Date::nowDateTime();
         $params = Tools_Interface_Job::prepareParams($_job->getParametro()->toPhp());
         $procedimento = explode("::", $_job->getProcedimento()->toPhp());
         $_obj = new $procedimento[0]();
         $_obj->{$procedimento[1]}($params);
         $finish = ZendT_Type_Date::nowDateTime();
         $diff = $start->diff($finish);
         $_job->setTempoUlExec($diff->i);
     } catch (Exception $ex) {
         $message = 'Mensagem: ' . $ex->getMessage() . "\n";
         $message .= 'Erro: ' . $ex->getTraceAsString() . "\n";
         Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message);
         $_job->setTempoUlExec(0);
     }
     $_job->setDhUltExec(ZendT_Type_Date::nowDateTime());
     $_job->setStatus('A');
     $_job->update();
     return true;
 }
Exemple #8
0
 /**
  * 
  * @param string|int $categoria
  * @param string $orderBy
  * @return array
  */
 protected function _list($categoria, $idConteudoPai = '', $orderBy = '')
 {
     $this->_removeLob = false;
     $_fileSystem = new Ged_Model_Arquivo_FileSystem();
     $idUsuario = Auth_Session_User::getInstance()->getId();
     $_auth = new Auth_Model_Usuario_Mapper();
     $_auth->setLogin('GUEST')->retrieve();
     $avatarGuest = $_auth->getAvatar(true)->toPhp();
     /**
      * caso seja uma string retorna o id
      */
     $idCategoria = $this->_getIdCategoria($categoria);
     if (!$orderBy) {
         $orderBy = 'cms_conteudo.dh_ini_pub';
     }
     $_whereGroup = new ZendT_Db_Where_Group('AND');
     $_where = new ZendT_Db_Where();
     $_where->addFilter("cms_conteudo.id_categoria", $idCategoria);
     if ($idConteudoPai) {
         $_where->addFilter("cms_conteudo.id_conteudo_pai", $idConteudoPai);
     }
     $_where->addFilter("cms_conteudo.dh_ini_pub", ZendT_Type_Date::nowDateTime(), "<=");
     $_where->addFilter("status.acao", "A");
     $_whereGroup->addWhere($_where);
     $_where = new ZendT_Db_Where('OR');
     $_where->addFilter("cms_conteudo.dh_fim_pub", ZendT_Type_Date::nowDateTime(), ">=");
     $_where->addFilter("cms_conteudo.dh_fim_pub", "", "NULL");
     $_whereGroup->addWhere($_where);
     //($where, $retrieve = false, $found = false, $orderBy='1')
     $_recordset = $this->recordset($_whereGroup, false, false, $orderBy);
     $data = array();
     $result = array();
     while ($data = $_recordset->getRow()) {
         $data['url'] = ZendT_Url::getBaseUrl() . '/cms/conteudo/view/id/' . $data['id']->toPhp();
         $thumbnail = $data['thumbnail']->toPhp();
         if (!$thumbnail) {
             $_conteudo = new Cms_Model_Conteudo_Mapper();
             $_conteudo->setChave('generic')->retrieve();
             $thumbnail = $_conteudo->getThumbnail(true)->toPhp();
         }
         $data['thumbnail'] = $_fileSystem->getDirectoryAdress($thumbnail);
         $data['banner'] = $_fileSystem->getDirectoryAdress($data['banner']->toPhp());
         $avatar = $data['avatar_usuario_inc']->toPhp();
         if (!$avatar) {
             $avatar = $avatarGuest;
             //avatar genérico
         }
         $data['avatar_usuario_inc'] = $_fileSystem->getDirectoryAdress($avatar);
         $data['html_like'] = Cms_Helper_Likes::button($data['id']);
         $data['html_comment'] = Cms_Helper_Feeds::button($data['id']);
         if ($data['id_usuario_inc']->toPhp() == $idUsuario) {
             $data['nome_usuario_inc'] = 'Você';
         }
         $result[] = $data;
     }
     return $result;
 }
Exemple #9
0
 public function isValidLastTime($hours = 0, $minutes = 0, $seconds = 0)
 {
     $_conteudo = new Cms_DataView_Conteudo_MapperView();
     $_conteudo->setIdCategoria($this->getIdCategoria())->setIdConteudoPai($this->getIdConteudoPai())->setIdUsuarioInc($this->getIdUsuarioInc())->findAll(null, '*', 'dh_ini_pub desc');
     if (!$_conteudo->exists()) {
         return true;
     }
     $_conteudo->fetch();
     $hours *= 60 * 60;
     $minutes *= 60;
     $total = $hours + $minutes + $seconds;
     $now = ZendT_Type_Date::nowDateTime()->toPhp();
     $last = $_conteudo->getDhIniPub()->toPhp();
     $last += $total;
     if ($now > $last) {
         return true;
     }
     return false;
 }
Exemple #10
0
 protected function _dateLine()
 {
     $_cell = new ZendT_Report_Cell();
     $_cell->setTextAlign('center');
     $_cell->setFontSize(7);
     $_cell->setTaStyle($this->_checkStyle($_cell));
     $styleId = $_cell->getTaStyle();
     if (!$styleId) {
         $styleId = 'String';
     }
     $date = ZendT_Type_Date::nowDateTime()->get();
     $this->_memObject->value .= "<Row>\n";
     $this->_memObject->value .= '<Cell ss:StyleID="' . $styleId . '"><Data ss:Type="String">' . $this->_escapeString($date) . '</Data></Cell>' . "\n";
     $this->_memObject->value .= "</Row>\n\n";
     $this->_rows++;
 }