Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Erro ao salvar parcelas. acredito que seja store(); Olá, boa tarde! Preciso de ajuda galera por gentileza! Estou desenvolvendo um sistema para um curso de inglês, temos a parte de cobrança que geramos 6 parcelas já consigo gerar mais venho tendo problemas para salvar. Já fiz um print_r($detail); e var_dump($detail); ambos retorna as informações que preciso para salvar eu desconfio que seja o // stores the object in the databas...
JA
Erro ao salvar parcelas. acredito que seja store();  
Olá, boa tarde!


Preciso de ajuda galera por gentileza!

Estou desenvolvendo um sistema para um curso de inglês, temos a parte de cobrança que geramos 6 parcelas já consigo gerar mais venho tendo problemas para salvar.

Já fiz um print_r($detail); e var_dump($detail); ambos retorna as informações que preciso para salvar eu desconfio que seja o

// stores the object in the database
//$detail->store();

pois quando removo ele a pagina carrega sem erro quando coloco a pagina não carrega.

obs: botão gerar parcela ele gera e salva ao mesmo tempo.

log.txt :
Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (aluno_id = '1') Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (id = '919249092') Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (id = '914038784') Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (id = '916542239') Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (id = '914410275') Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (id = '917556450') Debug: 2018-04-08 12:47:19 - SELECT * FROM system_aluno_parcela WHERE (id = '915868346')


print_r($detail); :
stdClass Object ( [aluno_id] => 1 [numero_document] => 919249092 [name] => GUILHERME SANTA BARBARA SANTOS [plano_pagamento_nome] => KIDS 1 [nomeResp] => JONATHAS ALVES SANTOS [cpfResp] => 035.696.905-39 [numero_parcela] => 1/6 [vencimento] => 09/06/2005 [valor_boleto] => 266.67 [status_pagamento_id] => PENDENTE ) stdClass Object ( [aluno_id] => 1 [numero_document] => 914038784 [name] => GUILHERME SANTA BARBARA SANTOS [plano_pagamento_nome] => KIDS 1 [nomeResp] => JONATHAS ALVES SANTOS [cpfResp] => 035.696.905-39 [numero_parcela] => 2/6 [vencimento] => 09/07/2005 [valor_boleto] => 266.67 [status_pagamento_id] => PENDENTE ) stdClass Object ( [aluno_id] => 1 [numero_document] => 916542239 [name] => GUILHERME SANTA BARBARA SANTOS [plano_pagamento_nome] => KIDS 1 [nomeResp] => JONATHAS ALVES SANTOS [cpfResp] => 035.696.905-39 [numero_parcela] => 3/6 [vencimento] => 09/08/2005 [valor_boleto] => 266.67 [status_pagamento_id] => PENDENTE ) stdClass Object ( [aluno_id] => 1 [numero_document] => 914410275 [name] => GUILHERME SANTA BARBARA SANTOS [plano_pagamento_nome] => KIDS 1 [nomeResp] => JONATHAS ALVES SANTOS [cpfResp] => 035.696.905-39 [numero_parcela] => 4/6 [vencimento] => 09/09/2005 [valor_boleto] => 266.67 [status_pagamento_id] => PENDENTE ) stdClass Object ( [aluno_id] => 1 [numero_document] => 917556450 [name] => GUILHERME SANTA BARBARA SANTOS [plano_pagamento_nome] => KIDS 1 [nomeResp] => JONATHAS ALVES SANTOS [cpfResp] => 035.696.905-39 [numero_parcela] => 5/6 [vencimento] => 09/10/2005 [valor_boleto] => 266.67 [status_pagamento_id] => PENDENTE ) stdClass Object ( [aluno_id] => 1 [numero_document] => 915868346 [name] => GUILHERME SANTA BARBARA SANTOS [plano_pagamento_nome] => KIDS 1 [nomeResp] => JONATHAS ALVES SANTOS [cpfResp] => 035.696.905-39 [numero_parcela] => 6/6 [vencimento] => 09/11/2005 [valor_boleto] => 266.65 [status_pagamento_id] => PENDENTE )



control - AlunoForm.class.php - Acho que o erro está no store
  1. <?php
  2.     /*
  3.     *  Função de Gerar parcelas
  4.     *  -   Desenvolvido Jonathas Alves Santos
  5.     */
  6.     function onGerarParcelas($param)
  7.     {
  8.       try {
  9.         // abri uma transação com banco de dados 'db_guiansoft'
  10.         TTransaction::open('db_guiansoft');
  11.         // Ativar o log de depuração para operações SQL dentro da transação
  12.         TTransaction::setLogger(new TLoggerSTD); // standard output
  13.         TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  14.         // read the form data and instantiates an Active Record
  15.         $system_aluno = new SystemAluno;
  16.         $system_aluno->fromArray$param );
  17.         $system_aluno->clearParts();
  18.         // delete details
  19.         $old_parcelas SystemAlunoParcela::where('aluno_id''='$system_aluno->id)->load();
  20.         $keep_parcelas = array();
  21.         // get session items
  22.         $items TSession::getValue(__CLASS__ '_parcelas');
  23.         if ($items) {
  24.             foreach ($items as $item) {
  25.                 if (substr($item->id01) == 'X') { // new record
  26.                     $detail = new SystemAlunoParcela;
  27.                 } else {
  28.                     $detail SystemAlunoParcela::find($item->id);
  29.                 }
  30.                 $detail->aluno_id             $system_aluno->id;
  31.                 $detail->numero_document      $item->id;
  32.                 $detail->name                 $item->name;
  33.                 $detail->plano_pagamento_nome $item->plano_pagamento_nome;
  34.                 $detail->nomeResp             $item->nomeResp;
  35.                 $detail->cpfResp              $item->cpfResp;
  36.                 $detail->numero_parcela       $item->numero_parcela;
  37.                 $detail->vencimento           $item->vencimento;
  38.                 $detail->valor_boleto         $item->valor_boleto;
  39.                 $detail->status_pagamento_id  $item->status_pagamento_id;
  40.                 print_r($detail);
  41.             }
  42.         }
  43.         if ($old_parcelas) {
  44.             foreach ($old_parcelas as $old_parcela) {
  45.                 if (!in_array($old_parcela->id$keep_parcelas)) {
  46.                     $old_parcela->delete();
  47.                 }
  48.             }
  49.         }
  50.         // stores the object in the database
  51.         //$detail->store();
  52.         $this->datagrid->clear(); // limpa a grid
  53.         $this->form->validate(); // verifica os campos obrigatorios e faz a validação
  54.         // recebe dados informado pelo usuário
  55.         $nomeResp             $param['nomeResp'];
  56.         $cpfResp              $param['cpfResp'];
  57.         $logradouroResp       $param['logradouroResp'];
  58.         $numeroResp           $param['numeroResp'];
  59.         $bairroResp           $param['bairroResp'];
  60.         $cepResp              $param['cepResp'];
  61.         $cidadeResp           $param['cidadeResp'];
  62.         $ufResp               $param['ufResp'];
  63.         $name                 $param['name'];
  64.         $DataPrimeiraParcela  $param['vencimento'];
  65.         $plano_pagamento_nome $param['plano_pagamento_nome'];
  66.         $total                = ($param['valor_boleto']);
  67.         $prazo                $param['parcela'];
  68.         $status               $param['status_pagamento_id'];
  69.         // chama a função que realiza o calculo da divisão e tbm realiza o calculo dos dos vencimentos - retorna um array
  70.         $parcelas GerarParcelas::calcularParcelas($total$prazo$DataPrimeiraParcela$nomeResp$cpfResp$logradouroResp$numeroResp$bairroResp$cepResp$cidadeResp$plano_pagamento_nome$ufResp$name$statusnull);
  71.         // armazena as parcelas sem uma variavel de sessão
  72.         TSession::setValue(__CLASS__ '_parcelas'$parcelas);
  73.         // laço onde add na grid a divisão - os centavos são adicionados na ultima parcela
  74.         foreach ($parcelas as $parcela) {
  75.         // adiciona as parcelas na grid
  76.         $item = new StdClass;
  77.         $item->detail_id = empty($parcela->detail_id) ? 'X' mt_rand(1000000019999999) : $parcela->detail_id;
  78.         $item->id                          $parcela->id;
  79.         $item->numero_documento            $parcela->id;
  80.         $item->nomeResp                    $parcela->nomeResp;
  81.         $item->cpfResp                     $parcela->cpfResp;
  82.         $item->logradouroResp              $parcela->logradouroResp;
  83.         $item->numeroResp                  $parcela->numeroResp;
  84.         $item->bairroResp                  $parcela->bairroResp;
  85.         $item->cepResp                     $parcela->cepResp;
  86.         $item->cidadeResp                  $parcela->cidadeResp;
  87.         $item->ufResp                      $parcela->ufResp;
  88.         $item->name                        $parcela->name;
  89.         $item->parcela                     $parcela->numero_parcela;
  90.         $item->plano_pagamento_nome        $parcela->plano_pagamento_nome;
  91.         $item->valor_boleto                = ($parcela->valor_boleto);
  92.         $item->vencimento                  $parcela->vencimento;
  93.         $item->status_pagamento_id         $parcela->status_pagamento_id;
  94.         $this->datagrid->addItem($item);
  95.         }
  96.         // mantem os dados no form
  97.         TTransaction::close(); // close the transaction
  98.         $data = new stdClass;
  99.         $data->id $system_aluno->id;
  100.         TForm::sendData('form_aluno'$data);
  101.         $this->onEdit(array('key' => $barcode->id)); // reload form and session items
  102.         $this->form->setData($this->form->getData());
  103.         $this->datagrid->getItems;
  104.         new TMessage('info'TAdiantiCoreTranslator::translate('Record saved'));
  105.       } catch (Exception $ex) {
  106.         new TMessage('error''ma oee ' $ex->getMessage());
  107.         TTransaction::rollback();
  108.       }
  109. }
  110. ?>


model - SystemAlunoForm.class.php
  1. <?php
  2. /**
  3.  * SystemUser
  4.  *
  5.  * @version    1.0
  6.  * @package    model
  7.  * @subpackage admin
  8.  * @author     Pablo Dall'Oglio
  9.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10.  * @license    http://www.adianti.com.br/framework-license
  11.  */
  12. class SystemAluno extends TRecord
  13. {
  14.     const TABLENAME 'system_aluno';
  15.     const PRIMARYKEY'id';
  16.     const IDPOLICY =  'max'// {max, serial}
  17.     private $system_aluno_turmas;
  18.     private $details;
  19.     public function __construct($id NULL$callObjectLoad TRUE)
  20.     {
  21.         parent::__construct($id$callObjectLoad);
  22.         parent::addAttribute('name');
  23.         parent::addAttribute('photo_path');
  24.         parent::addAttribute('nomeResp');
  25.         parent::addAttribute('rg');
  26.         parent::addAttribute('rgResp');
  27.         parent::addAttribute('cpf');
  28.         parent::addAttribute('cpfResp');
  29.         parent::addAttribute('nomePai');
  30.         parent::addAttribute('nomeMae');
  31.         parent::addAttribute('nascimento');
  32.         parent::addAttribute('nascimentoResp');
  33.         parent::addAttribute('genero_id');
  34.         parent::addAttribute('generoRespId');
  35.         parent::addAttribute('cep');
  36.         parent::addAttribute('cepResp');
  37.         parent::addAttribute('logradouro');
  38.         parent::addAttribute('logradouroResp');
  39.         parent::addAttribute('numero');
  40.         parent::addAttribute('numeroResp');
  41.         parent::addAttribute('complemento');
  42.         parent::addAttribute('complementoResp');
  43.         parent::addAttribute('bairro');
  44.         parent::addAttribute('bairroResp');
  45.         parent::addAttribute('cidade');
  46.         parent::addAttribute('cidadeResp');
  47.         parent::addAttribute('uf');
  48.         parent::addAttribute('ufResp');
  49.         parent::addAttribute('celular');
  50.         parent::addAttribute('celPai');
  51.         parent::addAttribute('celMae');
  52.         parent::addAttribute('celularResp');
  53.         parent::addAttribute('telefone');
  54.         parent::addAttribute('telefoneResp');
  55.         parent::addAttribute('emailResp');
  56.         parent::addAttribute('tipoSanguineo');
  57.         parent::addAttribute('alergia');
  58.         parent::addAttribute('problemaSaude');
  59.         parent::addAttribute('chamarUrgencia');
  60.         parent::addAttribute('desconto');
  61.         parent::addAttribute('empresaResp');
  62.         parent::addAttribute('profissao_id');
  63.         parent::addAttribute('endProfissional');
  64.         parent::addAttribute('telProfissional');
  65.         parent::addAttribute('data_matricula');
  66.         parent::addAttribute('login');
  67.         parent::addAttribute('password');
  68.         parent::addAttribute('email');
  69.         parent::addAttribute('frontpage_id');
  70.         parent::addAttribute('system_unit_id');
  71.         parent::addAttribute('active');
  72.         parent::addAttribute('periodo_id');
  73.         parent::addAttribute('vencimento');
  74.     }
  75.     /**
  76.      * Reset aggregates
  77.      */
  78.     public function clearParts()
  79.     {
  80.         $this->system_aluno_turmas   = array();
  81.     }
  82.     /**
  83.      * Composition with Item
  84.      */
  85.     public function addSystemAlunoTurma(SystemAlunoTurma $system_aluno_turma)
  86.     {
  87.         $this->system_aluno_turmas[] = $system_aluno_turma;
  88.     }
  89.     /**
  90.      * Return Items composition
  91.      */
  92.     public function getSystemAlunoTurmas()
  93.     {
  94.         return $this->system_aluno_turmas;
  95.     }
  96.     /**
  97.      * Load the object and the aggregates
  98.      */
  99.     public function load($id)
  100.     {
  101.         $system_aluno_turma_rep = new TRepository('SystemAlunoTurma');
  102.         $criteria = new TCriteria;
  103.         $criteria->add(new TFilter('aluno_id''='$id));
  104.         // load the Item composition
  105.         $system_aluno_turmas $system_aluno_turma_rep->load($criteria);
  106.         if ($system_aluno_turmas)
  107.         {
  108.             foreach ($system_aluno_turmas as $system_aluno_turma)
  109.             {
  110.                 //$system_aluno_turma = new SystemAlunoTurma($system_aluno_turma-> id);
  111.                 $this->addSystemAlunoTurma($system_aluno_turma);
  112.             }
  113.         }
  114.         // load the object itself
  115.         return parent::load($id);
  116.     }
  117.     /**
  118.      * Stores the book and the aggregates (authors, subjects, items)
  119.      */
  120.     public function store()
  121.     {
  122.         // stores the Book
  123.         parent::store();
  124.         // delete the aggregates
  125.         $criteria = new TCriteria;
  126.         $criteria->add(new TFilter('aluno_id''='$this->id));
  127.         $repository = new TRepository('SystemAlunoParcela');
  128.         $repository->delete($criteria);
  129.         // store the system_aluno_turmas
  130.         if ($this->details)
  131.         {
  132.             foreach ($this->details as $detail)
  133.             {
  134.                 $detail-> aluno_id $this-> id;
  135.                 $detail->store();
  136.             }
  137.         }
  138.         // collect persistent item ids
  139.         if ($this->system_aluno_turmas)
  140.         {
  141.             foreach ($this->system_aluno_turmas as $system_aluno_turma)
  142.             {
  143.                 if ($system_aluno_turma->id)
  144.                 {
  145.                     $system_aluno_turma_ids[] = $system_aluno_turma->id;
  146.                 }
  147.             }
  148.         }
  149.         if (!empty($system_aluno_turma_ids))
  150.         {
  151.             // delete all items, except for those that persist
  152.             $criteria->add(new TFilter('id''NOT IN'$system_aluno_turma_ids));
  153.         }
  154.         $repository = new TRepository('SystemAlunoTurma');
  155.         $repository->delete($criteria);
  156.         // store the system_aluno_turmas
  157.         if ($this->system_aluno_turmas)
  158.         {
  159.             foreach ($this->system_aluno_turmas as $system_aluno_turma)
  160.             {
  161.                 $system_aluno_turma-> aluno_id $this-> id;
  162.                 $system_aluno_turma->store();
  163.             }
  164.         }
  165.     }
  166.     /**
  167.      * Delete the book and its aggregates
  168.      */
  169.     public function delete($id NULL)
  170.     {
  171.         $id = isset($id) ? $id $this->{'id'};
  172.         SystemAlunoTurma::where('aluno_id''='$id)->delete();
  173.         // delete the object itself
  174.         parent::delete($id);
  175.     }
  176.     /**
  177.      * Retorna periodo
  178.      */
  179.     public function get_SystemStatusPagamento()
  180.     {
  181.         return SystemStatusPagamento::find($this->status_pagamento_id);
  182.     }
  183.     /**
  184.      * Retorna periodo
  185.      */
  186.     public function get_SystemPeriodo()
  187.     {
  188.         return SystemPeriodo::find($this->periodo_id);
  189.     }
  190. }
  191. ?>


model - SystemAlunoParcelaForm.class.php
  1. <?php
  2. /**
  3.  * System_aluno_turma Active Record
  4.  * @author  <Jonathas Alves Santos>
  5.  */
  6. class SystemAlunoParcela extends TRecord
  7. {
  8.     const TABLENAME 'system_aluno_parcela';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'max'// {max, serial}
  11.     private $system_aluno;
  12.     /**
  13.      * Returns the Item from its numero_documento
  14.      */
  15.     public static function newFromNumeroDocumento($numero_documento)
  16.     {
  17.         $rep = new TRepository('SystemAlunoParcela');
  18.         $criteria = new TCriteria;
  19.         $criteria->add(new TFilter('numero_documento''='$numero_documento));
  20.         $objects $rep->load($criteria);
  21.         if ($objects)
  22.         {
  23.             $detail $objects[0];
  24.             return $detail;
  25.         }
  26.     }
  27. }
  28. ?>


Att,
Jonathas Alves

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (8)


MG

Jonathas, qual o erro ele apresenta?
JA

Boa boite Marcelo Gomes!
Salva sem apresentar erro, mais não grava nada no banco.
MG

Jonathas, talvez precise do código completo para analisar. Mas vou tentar recriar o seu cenário para ver o que poderia ser.
Este código foi gerado pelo Studio?
JA

olá, boa noite! Marcelo não foi gerado pelo studio.

  1. <?php
  2. /**
  3.  * AlunoForm Registration
  4.  * @author  <your name here>
  5.  */
  6. class AlunoForm extends TPage
  7. {
  8.     private   $frame;
  9.     protected $form// form
  10.     protected $turmas_list;
  11.     protected $formgrid;
  12.     protected $formFields;
  13.     protected $datagrid;
  14.     /**
  15.      * Class constructor
  16.      * Creates the page and the registration form
  17.      */
  18.     function __construct()
  19.     {
  20.         parent::__construct();
  21.         // creates the form
  22.         $this->form = new BootstrapFormBuilder('form_Aluno');
  23.         $this->form->setFormTitle(('Aluno'));
  24.         // create the form fields aluno
  25.         $id                          = new TEntry('id');
  26.         $name                        = new TEntry('name');
  27.         $genero_id                   = new TDBCombo('genero_id','db_guiansoft','SystemGenero','id','nome');
  28.         $nascimento                  = new TDate('nascimento');
  29.         $rg                          = new TEntry('rg');
  30.         $cpf                         = new TEntry('cpf');
  31.         $logradouro                  = new TEntry('logradouro');
  32.         $cep                         = new TEntry('cep');
  33.         $numero                      = new TEntry('numero');
  34.         $bairro                      = new TEntry('bairro');
  35.         $cidade                      = new TEntry('cidade');
  36.         $uf                          = new TEntry('uf');
  37.         $complemento                 = new TEntry('complemento');
  38.         $celular                     = new TEntry('celular');
  39.         $celPai                      = new TEntry('celPai');
  40.         $celMae                      = new TEntry('celMae');
  41.         $telefone                    = new TEntry('telefone');
  42.         $email                       = new TEntry('email');
  43.         $tipoSanguineo               = new TEntry('tipoSanguineo');
  44.         $alergia                     = new TEntry('alergia');
  45.         $problemaSaude               = new TEntry('problemaSaude');
  46.         $chamarUrgencia              = new TEntry('chamarUrgencia');
  47.         $nomePai                     = new TEntry('nomePai');
  48.         $nomeMae                     = new TEntry ('nomeMae');
  49.         $photo_path                  = new TFile('photo_path');
  50.         $data_matricula              = new TDate('data_matricula');
  51.         $data_matricula->setValue(date('Y-m-d'));
  52.         $nomeResp                    = new TEntry('nomeResp');
  53.         $generoRespId                = new TDBCombo('generoRespId','db_guiansoft','SystemGenero','id','nome');
  54.         $nascimentoResp              = new TDate('nascimentoResp');
  55.         $rgResp                      = new TEntry('rgResp');
  56.         $cpfResp                     = new TEntry('cpfResp');
  57.         $logradouroResp              = new TEntry('logradouroResp');
  58.         $cepResp                     = new TEntry('cepResp');
  59.         $numeroResp                  = new TEntry('numeroResp');
  60.         $bairroResp                  = new TEntry('bairroResp');
  61.         $cidadeResp                  = new TEntry('cidadeResp');
  62.         $ufResp                      = new TEntry('ufResp');
  63.         $complementoResp             = new TEntry('complementoResp');
  64.         $celularResp                 = new TEntry('celularResp');
  65.         $telefoneResp                = new TEntry('telefoneResp');
  66.         $emailResp                   = new TEntry('emailResp');
  67.         $empresaResp                 = new TEntry('empresaResp');
  68.         $profissao_id                = new TDBCombo('profissao_id','db_guiansoft','SystemProfissao','id','nome');
  69.         $endProfissional             = new TEntry ('endProfissional');
  70.         $telProfissional             = new TEntry ('telProfissional');
  71.         $vencimento                  = new TDate('vencimento');
  72.         $desconto                    = new TEntry('desconto');
  73.         $periodoc_id                 = new TDBCombo('periodoc_id','db_guiansoft','SystemPeriodo','id','nome');
  74.         $periodos_id                 = new TDBCombo('periodos_id','db_guiansoft','SystemPeriodo','id','nome');
  75.         $plano_pagamento_id          = new  ">TDBSeekButton('plano_pagamento_id''db_guiansoft'$this->form->getName(), 'SystemPlanoPagamento''nome''plano_pagamento_id''plano_pagamento_nome');
  76.         $plano_pagamento_nome        = new TEntry('plano_pagamento_nome');
  77.         $numero_documento            = new TEntry('numero_documento');
  78.         $parcela                     = new TEntry('parcela');
  79.         $valor_boleto                = new TEntry('valor_boleto');
  80.         $status_pagamento_id         = new TDBCombo('status_pagamento_id','db_guiansoft','SystemStatusPagamento','nome','nome');
  81.         $status_pagamentos_id        = new TDBCombo('status_pagamentos_id','db_guiansoft','SystemStatusPagamento','nome','nome');
  82.         $btnCep                      = new TButton('action1');
  83.         $btnRespCep                  = new TButton('action2');
  84.         $btn $this->form->addAction_t('Save'), new TAction(array($this'onSave')), 'fa:floppy-o');
  85.         $btn->class 'btn btn-sm btn-primary';
  86.         $this->form->addAction_t('Clear'), new TAction(array($this'onEdit')), 'fa:eraser red');
  87.         $this->form->addAction( ('Gerar Parcelas'), new TAction(array($this'onGerarParcelas')), 'fa:hand-o-down');
  88.         $this->form->addAction_t('Back'), new TAction(array('AlunoList','onReload')), 'fa:arrow-circle-o-left blue');
  89.         // complete upload action
  90.         $photo_path->setCompleteAction(new TAction(array($this'onComplete')));
  91.         $photo_path->setAllowedExtensions( ['gif''png''jpg''jpeg'] );
  92.         $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  93.         $this->datagrid->datatable 'true';
  94.         $this->datagrid->style 'width: 100%';
  95.         $this->datagrid->setHeight(320);
  96.         $hbox1 = new THBox;
  97.         $hbox1->style 'margin: 4px';
  98.         $vbox1 = new TVBox;
  99.         $vbox1->style='width:100%';
  100.         $vbox1->add$hbox1 );
  101.         $vbox1->add($this->datagrid);
  102.         // creates the datagrid columns
  103.         $column_id                   = new TDataGridColumn('id''Código''center');
  104.         $column_numero_documento     = new TDataGridColumn('numero_documento''Num. Documento''center');
  105.         $column_nomeResp             = new TDataGridColumn('nomeResp''Responsável''center');
  106.         $column_parcela              = new TDataGridColumn('parcela''Parcelas''center');
  107.         $column_vencimento           = new TDataGridColumn('vencimento', ('Vencimento'), 'left');
  108.         $column_valor_boleto         = new TDataGridColumn('valor_boleto', ('Valor'), 'left');
  109.         $column_status_pagamento_id  = new TDataGridColumn('status_pagamento_id', ('Status'), 'left');
  110.         // add the columns to the DataGrid
  111.         $this->datagrid->addColumn($column_id);
  112.         $this->datagrid->addColumn($column_numero_documento);
  113.         $this->datagrid->addColumn($column_nomeResp);
  114.         $this->datagrid->addColumn($column_parcela);
  115.         $this->datagrid->addColumn($column_vencimento);
  116.         $this->datagrid->addColumn($column_valor_boleto);
  117.         $this->datagrid->addColumn($column_status_pagamento_id);
  118.         // creates two datagrid actions
  119.         $action1 = new TDataGridAction(array($this'deleteBoleto'));
  120.         $action1->setLabel('Baixa Manual');
  121.         $action1->setImage('fa:download blue');
  122.         $action1->setField('id');
  123.         $action2 = new TDataGridAction(array( 'BoletoView''onGenerate'));
  124.         $action2->setLabel('Imprimir Boleto');
  125.         $action2->setImage('fa:barcode');
  126.         $action2->setFields(['id''numero_documento''plano_pagamento_nome''nomeResp''logradouroResp''numeroResp''cpfResp''bairroResp''cepResp''cidadeResp''ufResp''name''parcela''vencimento''valor_boleto']);
  127.         $action3 = new TDataGridAction(array($this'onTeste'));
  128.         $action3->setLabel('Editar');
  129.         $action3->setImage('fa:pencil-square-o blue fa-lg');
  130.         $action3->setField('id');
  131.         $action4 = new TDataGridAction(array($this'deleteBoleto'));
  132.         $action4->setLabel('Delete');
  133.         $action4->setImage('fa:trash-o red fa-lg');
  134.         $action4->setField('id');
  135.         $action_group = new TDataGridActionGroup('Actions''bs:th');
  136.         $action_group->addHeader('Available Options');
  137.         $action_group->addAction($action1);
  138.         $action_group->addAction($action2);
  139.         $action_group->addSeparator();
  140.         $action_group->addHeader('Another Options');
  141.         $action_group->addAction($action3);
  142.         $action_group->addAction($action4);
  143.         // add the actions to the datagrid
  144.         $this->datagrid->addActionGroup($action_group);
  145.         // creates the datagrid model
  146.         $this->datagrid->createModel();
  147.         // define the button action
  148.         $btnCep->setAction(new TAction(array($this'onCep')), 'Busca');
  149.         $btnCep->setImage('fa:map-marker green');
  150.         $btnCep->class 'btn btn-sm btn-primary';
  151.         // define the button action
  152.         $btnRespCep->setAction(new TAction(array($this'onRespCep')), 'Busca');
  153.         $btnRespCep->setImage('fa:map-marker green');
  154.         $btnRespCep->class 'btn btn-sm btn-primary';
  155.         // define tamanho
  156.         $id->setSize('100%');
  157.         $name->setSize('100%');
  158.         $genero_id->setSize('100%');
  159.         $nascimento->setSize('100%');
  160.         $rg->setSize('100%');
  161.         $cpf->setSize('100%');
  162.         $logradouro->setSize('100%');
  163.         $numero->setSize('100%');
  164.         $bairro->setSize('100%');
  165.         $cep->setSize('100%');
  166.         $cidade->setSize('100%');
  167.         $uf->setSize('100%');
  168.         $complemento->setSize('100%');
  169.         $celular->setSize('100%');
  170.         $celPai->setSize('100%');
  171.         $celMae->setSize('100%');
  172.         $telefone->setSize('100%');
  173.         $photo_path->setSize('100%');
  174.         $btnCep->setSize('100%');
  175.         $tipoSanguineo->setSize('100%');
  176.         $alergia->setSize('100%');
  177.         $problemaSaude->setSize('100%');
  178.         $chamarUrgencia->setSize('100%');
  179.         $nomePai->setSize('100%');
  180.         $nomeMae->setSize('100%');
  181.         $nomeResp->setSize('100%');
  182.         $generoRespId->setSize('100%');
  183.         $nascimentoResp->setSize('100%');
  184.         $rgResp->setSize('100%');
  185.         $cpfResp->setSize('100%');
  186.         $logradouroResp->setSize('100%');
  187.         $numeroResp->setSize('100%');
  188.         $bairroResp->setSize('100%');
  189.         $cepResp->setSize('100%');
  190.         $cidadeResp->setSize('100%');
  191.         $ufResp->setSize('100%');
  192.         $complementoResp->setSize('100%');
  193.         $celularResp->setSize('100%');
  194.         $telefoneResp->setSize('100%');
  195.         $emailResp->setSize('35%');
  196.         $empresaResp->setSize('100%');
  197.         $profissao_id->setSize('100%');
  198.         $endProfissional->setSize('100%');
  199.         $telProfissional->setSize('100%');
  200.         $data_matricula->setSize('100%');
  201.         $vencimento->setSize('100%');
  202.         $desconto->setSize('100%');
  203.         $periodoc_id->setSize('100%');
  204.         $plano_pagamento_id->setSize('80');
  205.         $plano_pagamento_nome->setSize('calc(100% - 80px)');
  206.         $numero_documento->setSize('100%');
  207.         $parcela->setSize('100%');
  208.         $valor_boleto->setSize('100%');
  209.         $status_pagamento_id->setSize('100%');
  210.         $periodos_id->setSize('100%');
  211.         $status_pagamentos_id->setSize('100%');
  212.         $email->setSize('100%');
  213.         $id->setEditable(false);
  214.         $plano_pagamento_nome->setEditable(false);
  215.         // DEFINIÇÃO DE MASCARA
  216.         $cpf->setMask('000.000.000-00');
  217.         $cpfResp->setMask('000.000.000-00');
  218.         $cep->setMask('00000-000');
  219.         $cepResp->setMask('00000-000');
  220.         $celular->setMask('(00)00000-0000');
  221.         $celPai->setMask('(00)00000-0000');
  222.         $celMae->setMask('(00)00000-0000');
  223.         $celularResp->setMask('(00)00000-0000');
  224.         $telefone->setMask('(00)0000-0000');
  225.         $telefoneResp->setMask('(00)0000-0000');
  226.         //$nascimento->setMask('dd/mm/yyyy');
  227.         //$data_matricula->setMask('dd/mm/yyyy');
  228.         //$nascimentoResp->setMask('dd/mm/yyyy');
  229.         $vencimento->setMask('dd/mm/yyyy');
  230.         // campo obrigatorio
  231.         $email->addValidation('Email', new TEmailValidator);
  232.         $this->form->appendPage('Aluno');
  233.         $this->form->addFields( [new TLabel('ID:')], [$id],  [new TLabel(('Nome:'))], [$name] );
  234.         $this->form->addFields([new TLabel('Gênero:')], [$genero_id], [new TLabel('Nascimento:')], [$nascimento]);
  235.         $this->form->addFields([new TLabel('CPF:')], [$cpf], [new TLabel('RG:')], [$rg]);
  236.         $this->form->addFields([new TLabel('Tel. Aluno:')], [$telefone], [new TLabel('Cel. Aluno:')], [$celular]);
  237.         $this->form->addFields([new TLabel('Data da Matrícula:')], [$data_matricula], [new TLabel('Foto:')], [$photo_path]);
  238.         $this->frame = new TElement('div');
  239.         $this->frame->id 'photo_path';
  240.         $this->frame->style 'width:180px;height:auto;min-height:180px;border:1px solid gray;padding:4px;';
  241.         //$row = $this->form->addRow();
  242.         //$row->addCell('');
  243.         //$row->addCell($this->frame);
  244.         // SEPARAR
  245.         $this->form->addFields( [new TFormSeparator(('Filiação'))] );
  246.         $this->form->addFields([new TLabel('Pai:')], [$nomePai], [new TLabel('Mãe:')], [$nomeMae]);
  247.         $this->form->addFields([new TLabel('Cel. Pai:')], [$celPai], [new TLabel('Cel. Mãe:')], [$celMae]);
  248.         // SEPARAR
  249.         $this->form->addFields( [new TFormSeparator(('Endereço do Aluno'))] );
  250.         $this->form->addFields([new TLabel('CEP:')], [$cep], [$btnCep]);
  251.         $this->form->addFields([new TLabel('Logradouro:')], [$logradouro], [new TLabel('Número:')], [$numero]);
  252.         $this->form->addFields([new TLabel('Complemento:')], [$complemento], [new TLabel('Bairro:')], [$bairro]);
  253.         $this->form->addFields([new TLabel('Cidade:')], [$cidade], [new TLabel('Estado:')], [$uf]);
  254.         $this->form->appendPage('Responsável Financeiro');
  255.         $this->form->addFields([new TLabel('Nome:')], [$nomeResp]);
  256.         $this->form->addFields([new TLabel('Gênero:')], [$generoRespId], [new TLabel('Nascimento:')], [$nascimentoResp]);
  257.         $this->form->addFields([new TLabel('RG:')], [$rgResp], [new TLabel('CPF:')], [$cpfResp]);
  258.         $this->form->addFields([new TLabel('Cel.:')], [$celularResp], [new TLabel('Tel.:')], [$telefoneResp]);
  259.         $this->form->addFields([new TLabel('E-mail:')], [$emailResp]);
  260.         // SEPARAR
  261.         $this->form->addFields( [new TFormSeparator(('Endereço'))] );
  262.         $this->form->addFields([new TLabel('CEP:')], [$cepResp], [$btnRespCep]);
  263.         $this->form->addFields([new TLabel('Logradouro:')], [$logradouroResp], [new TLabel('Complemento:')], [$complementoResp]);
  264.         $this->form->addFields([new TLabel('Número:')], [$numeroResp], [new TLabel('Bairro:')], [$bairroResp]);
  265.         $this->form->addFields([new TLabel('Cidade:')], [$cidadeResp], [new TLabel('Estado:')], [$ufResp]);
  266.         // SEPARAR
  267.         $this->form->addFields( [new TFormSeparator(('Endereço de Trabalho'))] );
  268.         $this->form->addFields([new TLabel('Empresa:')], [$empresaResp], [new TLabel('Profissão:')], [$profissao_id]);
  269.         $this->form->addFields([new TLabel('End. Prof.:')], [$endProfissional], [new TLabel('Tel. Prof.:')], [$telProfissional]);
  270.         // SEPARAR
  271.         $this->form->addFields( [new TFormSeparator(('Dados Finánceiro'))] );
  272.         $this->form->addFields( [new TLabel('Vencimento:')], [$vencimento], [new TLabel('Desconto em %:')], [$desconto]);
  273.         $this->form->appendPage('Ficha Médica');
  274.         $this->form->addFields([new TLabel('Tipo Sanguíneo:')], [$tipoSanguineo], [new TLabel('Alergias:')], [$alergia]);
  275.         $this->form->addFields([new TLabel('Problemas de saúde?')], [$problemaSaude], [new TLabel('Quem chamar para urgência?')], [$chamarUrgencia]);
  276.         // turmas
  277.         $this->form->appendPage('Turmas');
  278.         $aluno_id         = new THidden('aluno_id[]');
  279.         $barcode          = new TEntry('barcode[]');
  280.         $periodo_id       = new TDBCombo('periodo_id[]','db_guiansoft','SystemPeriodo','id','nome');
  281.         $curso_id         = new TDBCombo('curso_id[]','db_guiansoft','SystemCurso','id','nome');
  282.         $modulo_id        = new TDBCombo('modulo_id[]','db_guiansoft','SystemModulo','id','nome');
  283.         $turma_id         = new TDBCombo('turma_id[]','db_guiansoft','SystemTurma','id','nome');
  284.         $situacao_id      = new TDBCombo('situacao_id[]','db_guiansoft','SystemSituacao','id','nome');
  285.         // set exit action for input_exit
  286.         $change_action = new TAction(array($this'onChangeActionModulo'));
  287.         $modulo_id->setChangeAction($change_action);
  288.         $barcode->setSize(120);
  289.         $periodo_id->setSize('100%');
  290.         $curso_id->setSize('100%');
  291.         $modulo_id->setSize('100%');
  292.         $turma_id->setSize('100%');
  293.         $situacao_id->setSize('100%');
  294.         $this->system_aluno_turmas_list = new TFieldList;
  295.         $this->system_aluno_turmas_list->addField'<b>'.('ID').'</b>'$aluno_id);
  296.         $this->system_aluno_turmas_list->addField'<b>'.('Barcode').'</b>'$barcode);
  297.         $this->system_aluno_turmas_list->addField'<b>'.('Período').'</b>'$periodo_id);
  298.         $this->system_aluno_turmas_list->addField'<b>'.('Curso').'</b>'$curso_id);
  299.         $this->system_aluno_turmas_list->addField'<b>'.('Módulo').'</b>'$modulo_id);
  300.         $this->system_aluno_turmas_list->addField'<b>'.('Turma').'</b>'$turma_id);
  301.         $this->system_aluno_turmas_list->addField'<b>'.('Situação').'</b>'$situacao_id);
  302.         $this->system_aluno_turmas_list->enableSorting();
  303.         $this->form->addField($aluno_id);
  304.         $this->form->addField($barcode);
  305.         $this->form->addField($periodo_id);
  306.         $this->form->addField($curso_id);
  307.         $this->form->addField($modulo_id);
  308.         $this->form->addField($turma_id);
  309.         $this->form->addField($situacao_id);
  310.         $this->form->addContent( [new TLabel('Turmas')], [$this->system_aluno_turmas_list] );
  311.         // fim turmas
  312.         $this->form->appendPage('Notas');
  313.         $NC01              = new TEntry('NC01[]');
  314.         $NC02              = new TEntry('NC02[]');
  315.         $NC01->setSize(120);
  316.         $NC02->setSize(120);
  317.         $this->system_aluno_nota_list = new TFieldList;
  318.         $this->system_aluno_nota_list->addField'<b>'.('AV1').'</b>'$NC01);
  319.         $this->system_aluno_nota_list->addField'<b>'.('AV2').'</b>'$NC02);
  320.         $this->system_aluno_nota_list->enableSorting();
  321.         $this->form->addField($NC01);
  322.         $this->form->addField($NC02);
  323.         $this->form->addContent( [new TLabel('Composition: ')], [$this->system_aluno_nota_list] );
  324.         $this->form->addContent( [new TLabel('Writhen: ')], [$this->system_aluno_nota_list] );
  325.         $this->form->addContent( [new TLabel('Oral: ')], [$this->system_aluno_nota_list] );
  326.         $this->form->addContent( [new TLabel('HomeWork: ')], [$this->system_aluno_nota_list] );
  327.         $this->form->addContent( [new TLabel('Listering: ')], [$this->system_aluno_nota_list] );
  328.         $this->form->appendPage('Cobranças');
  329.         $plano_pagamento_id->setExitAction(new TAction(array($this,'onPlanoChange')));
  330.         $this->form->addFields( [new TLabel('Periodo:')], [$periodoc_id] );
  331.         $this->form->addFields( [new TLabel('Plano de pagamento:')], [$plano_pagamento_id$plano_pagamento_nome], [new TLabel('Parcelas:')], [$parcela] );
  332.         $this->form->addFields( [new TLabel('Valor Total:')], [$valor_boleto], [new TLabel(('Status Pagamento:'))], [$status_pagamento_id] );
  333.         $this->form->addFields( [new TFormSeparator(('Parcelas'))] );
  334.         // Busca parcelas
  335.         $this->form->addFields( [ $lp=new TLabel(('Periodo'))], [$periodos_id], [$ls=new TLabel(('Status Pagamento'))], [$status_pagamentos_id] );
  336.         // Dfine a cor
  337.         $lp->setFontColor('red');
  338.         $ls->setFontColor('red');
  339.         $this->form->addFields( [$vbox1] );
  340.         $format_value = function($value) {
  341.             if (is_numeric($value)) {
  342.                 return 'R$ '.number_format($value2',''.');
  343.             }
  344.             return $value;
  345.         };
  346.         $column_valor_boleto->setTransformer$format_value );
  347.         // wrap the page content
  348.         $container = new TVBox;
  349.         $container->style 'width: 100%';
  350.         $container->add(new TXMLBreadCrumb('menu.xml''AlunoList'));
  351.         $container->add($this->form);
  352.         // add the container to the page
  353.         parent::add($container);
  354.     }
  355.     /**
  356.      * On complete upload photo_path
  357.      */
  358.     public static function onComplete($param)
  359.     {
  360.         new TMessage('info''Upload completo: ' $param['photo_path']);
  361.         copy("tmp/{$param['photo_path']}""files/fotos/alunos/{$param['photo_path']}");
  362.         // refresh photo_frame
  363.         TScript::create("$('#photo_frame').html('')");
  364.         TScript::create("$('#photo_frame').html(\"<img width='180px' height='180px' src='files/fotos/alunos/{$param['photo_path']}'>\");");
  365.     }
  366.     /*
  367.     *  Função de busca de Endereço pelo CEP
  368.     *  -   Desenvolvido Felipe Olivaes para ajaxbox.com.br
  369.     *  -   Utilizando WebService de CEP da republicavirtual.com.br
  370.     */
  371.     public static function onCep($param)
  372.     {
  373.         $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep=' urlencode($param['cep']) . '&formato=query_string');
  374.         if (!$resultado) {
  375.             $resultado "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  376.         }
  377.         parse_str($resultado$retorno);
  378.         $obj = new StdClass;
  379.         $obj->cep $param['cep'];
  380.         $obj->logradouro strtoupper($retorno['tipo_logradouro'] . ' ' $retorno['logradouro']);
  381.         $obj->bairro strtoupper($retorno['bairro']);
  382.         $obj->cidade strtoupper($retorno['cidade']);
  383.         $obj->uf strtoupper($retorno['uf']);
  384.         TForm::sendData('form_Aluno'$obj);
  385.     }
  386.     /*
  387.     *  Função de busca de Endereço pelo CEP
  388.     *  -   Desenvolvido Felipe Olivaes para ajaxbox.com.br
  389.     *  -   Utilizando WebService de CEP da republicavirtual.com.br
  390.     */
  391.     public static function onRespCep($param)
  392.     {
  393.         $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep=' urlencode($param['cepResp']) . '&formato=query_string');
  394.         if (!$resultado) {
  395.             $resultado "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  396.         }
  397.         parse_str($resultado$retorno);
  398.         $obj = new StdClass;
  399.         $obj->cepResp $param['cepResp'];
  400.         $obj->logradouroResp strtoupper($retorno['tipo_logradouro'] . ' ' $retorno['logradouro']);
  401.         $obj->bairroRespstrtoupper($retorno['bairro']);
  402.         $obj->cidadeResp strtoupper($retorno['cidade']);
  403.         $obj->ufResp strtoupper($retorno['uf']);
  404.         TForm::sendData('form_Aluno'$obj);
  405.     }
  406.     /**
  407.      * Action to be executed when the user changes the modulo_id field
  408.      */
  409.     public static function onChangeActionModulo($param)
  410.         {
  411.             TTransaction::open('db_guiansoft');
  412.             $criteria = new TCriteria;
  413.             // a variável $param tem que ser passado com o nome do campo!  $param['curso_id']
  414.             $criteria->add(new TFilter('modulo_id''='$param['modulo_id'])); //AQUI!!!
  415.             $repository = new TRepository('SystemTurma');
  416.             $turmas $repository->load($criteria);
  417.             $options = array();
  418.             foreach ($turmas as $turma){
  419.             $options[$turma->id] = $turma->nome;
  420.         }
  421.         TForm::sendData('form_Turma'$objeto);
  422.         TCombo::reload('form_Aluno''turma_id[]'$options);
  423.     }
  424.     /**
  425.      * On product change
  426.      */
  427.     static function onPlanoChange$params )
  428.     {
  429.         if( isset($params['plano_pagamento_id']) && $params['plano_pagamento_id'] )
  430.         {
  431.             try
  432.             {
  433.                 TTransaction::open('db_guiansoft');
  434.                 $systemplanopagamento = new SystemPlanoPagamento($params['plano_pagamento_id']);
  435.                 $fill_data = new StdClass;
  436.                 $fill_data->parcela $systemplanopagamento->prazo;
  437.                 $fill_data->valor_boleto $systemplanopagamento->valor_total;
  438.                 TForm::sendData('form_Aluno'$fill_data);
  439.                 TTransaction::close();
  440.             }
  441.             catch (Exception $e// in case of exception
  442.             {
  443.                 new TMessage('error'$e->getMessage());
  444.                 TTransaction::rollback();
  445.             }
  446.         }
  447.     }
  448.     /**
  449.      * method onEdit
  450.      * Edit a record data
  451.      */
  452.     function onEdit($param)
  453.     {
  454.         try
  455.         {
  456.             if (isset($param['id']))
  457.             {
  458.                 // open a transaction with database 'library'
  459.                 TTransaction::open('db_guiansoft');
  460.                 // load the Active Record according to its ID
  461.                 $system_aluno = new SystemAluno($param['id']);
  462.                 // AQUI CONVERSÃO PARA CARREGAR OS DADOS
  463.                 //$system_aluno->nascimento = DateTime::createFromFormat('Y-m-d', $system_aluno->nascimento)->format( 'd/m/Y' );
  464.                 //$system_aluno->data_matricula = DateTime::createFromFormat('Y-m-d', $system_aluno->data_matricula)->format( 'd/m/Y' );
  465.                 //$system_aluno->nascimentoResp = DateTime::createFromFormat('Y-m-d', $system_aluno->nascimentoResp)->format( 'd/m/Y' );
  466.                 //$system_aluno->vencimento = DateTime::createFromFormat('Y-m-d', $system_aluno->vencimento)->format( 'd/m/Y' );
  467.                 // load the contacts (composition)
  468.                 $system_aluno_turmas   $system_aluno->getSystemAlunoTurmas();
  469.                 //
  470.                 if ($system_aluno_turmas)
  471.                 {
  472.                     $this->system_aluno_turmas_list->addHeader();
  473.                     foreach ($system_aluno_turmas as $system_aluno_turma)
  474.                     {
  475.                         $system_aluno_turma->system_aluno_turma_id $system_aluno_turma->id;
  476.                         $this->system_aluno_turmas_list->addDetail($system_aluno_turma);
  477.                     }
  478.                     $this->system_aluno_turmas_list->addCloneAction();
  479.                 }
  480.                 else
  481.                 {
  482.                     $this->clearSystemAlunoTurmas();
  483.                 }
  484.                 // fill the form with the active record data
  485.                 $this->form->setData($system_aluno);
  486.                 // close the transaction
  487.                 TTransaction::close();
  488.             }
  489.             else
  490.             {
  491.                 $this->onClear($param);
  492.             }
  493.         }
  494.         catch (Exception $e// in case of exception
  495.         {
  496.             new TMessage('error'$e->getMessage());
  497.             TTransaction::rollback();
  498.         }
  499.     }
  500.     /**
  501.      * Clear items
  502.      */
  503.     public function clearSystemAlunoTurmas()
  504.     {
  505.         $this->system_aluno_turmas_list->addHeader();
  506.         $this->system_aluno_turmas_list->addDetail( new stdClass );
  507.         $this->system_aluno_turmas_list->addCloneAction();
  508.     }
  509.     /**
  510.      * Clear form
  511.      */
  512.     public function onClear()
  513.     {
  514.         $this->form->clear();
  515.         $this->clearSystemAlunoTurmas();
  516.     }
  517.     /**
  518.      * method onSave
  519.      * Executed whenever the user clicks at the save button
  520.      */
  521.     public static function onSave($param)
  522.     {
  523.         try
  524.         {
  525.             // open a transaction with database 'library'
  526.             TTransaction::open('db_guiansoft');
  527.             TTransaction::setLogger(new TLoggerSTD); // standard output
  528.             TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  529.             // read the form data and instantiates an Active Record
  530.             $system_aluno = new SystemAluno;
  531.             $system_aluno->fromArray$param );
  532.             $system_aluno->clearParts();
  533.             // AQUI CONVERSÃO PARA SALVAR OS DADOS
  534.             //$system_aluno->nascimento = DateTime::createFromFormat('d/m/Y', $system_aluno->nascimento)->format( 'Y-m-d' );
  535.             //$system_aluno->data_matricula = DateTime::createFromFormat('d/m/Y', $system_aluno->data_matricula)->format( 'Y-m-d' );
  536.             //$system_aluno->nascimentoResp = DateTime::createFromFormat('d/m/Y', $system_aluno->nascimentoResp)->format( 'Y-m-d' );
  537.             //$system_aluno->vencimento = DateTime::createFromFormat('d/m/Y', $system_aluno->vencimento)->format( 'Y-m-d' );
  538.             if( !empty($param['barcode']) AND is_array($param['barcode']) )
  539.             {
  540.                 foreach( $param['barcode'] as $row => $barcode)
  541.                 {
  542.                     if ($barcode)
  543.                     {
  544.                         $system_aluno_turma = new SystemAlunoTurma;
  545.                         $system_aluno_turma->barcode       $barcode;
  546.                         $system_aluno_turma->id             $param['aluno_id'][$row];
  547.                         $system_aluno_turma->periodo_id     $param['periodo_id'][$row];
  548.                         $system_aluno_turma->curso_id       $param['curso_id'][$row];
  549.                         $system_aluno_turma->modulo_id      $param['modulo_id'][$row];
  550.                         $system_aluno_turma->turma_id       $param['turma_id'][$row];
  551.                         $system_aluno_turma->situacao_id    $param['situacao_id'][$row];
  552.                         $system_aluno->addSystemAlunoTurma$system_aluno_turma );
  553.                     }
  554.                 }
  555.             }
  556.             // stores the object in the database
  557.             $system_aluno->store();
  558.             $data = new stdClass;
  559.             $data->id $system_aluno->id;
  560.             TForm::sendData('form_aluno'$data);
  561.             // shows the success message
  562.             new TMessage('info''Record saved');
  563.             TTransaction::close(); // close the transaction
  564.         }
  565.         catch (Exception $e// in case of exception
  566.         {
  567.             new TMessage('error'$e->getMessage());
  568.             TTransaction::rollback();
  569.         }
  570.     }
  571.     /*
  572.     *  Função de Gerar parcelas
  573.     *  -   Desenvolvido Jonathas Alves Santos
  574.     */
  575.     function onGerarParcelas($param)
  576.     {
  577.       try {
  578.         // abri uma transação com banco de dados 'db_guiansoft'
  579.         TTransaction::open('db_guiansoft');
  580.         // Ativar o log de depuração para operações SQL dentro da transação
  581.         TTransaction::setLogger(new TLoggerSTD); // standard output
  582.         TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  583.         // read the form data and instantiates an Active Record
  584.         $system_aluno = new SystemAluno;
  585.         $system_aluno->fromArray$param );
  586.         $system_aluno->clearParts();
  587.         $this->datagrid->clear(); // limpa a grid
  588.         $this->form->validate(); // verifica os campos obrigatorios e faz a validação
  589.         // delete details
  590.         $old_parcelas SystemAlunoParcela::where('aluno_id''='$system_aluno->id)->load();
  591.         $keep_parcelas = array();
  592.         // get session items
  593.         $items TSession::getValue(__CLASS__ '_parcelas');
  594.         if ($items) {
  595.             foreach ($items as $item) {
  596.                 if (substr($item->id01) == 'X') { // new record
  597.                     $detail = new SystemAlunoParcela;
  598.                 } else {
  599.                     $detail SystemAlunoParcela::find($item->id);
  600.                 }
  601.                 $detail->aluno_id             $system_aluno->id;
  602.                 $detail->numero_document      $item->id;
  603.                 $detail->name                 $item->name;
  604.                 $detail->plano_pagamento_nome $item->plano_pagamento_nome;
  605.                 $detail->nomeResp             $item->nomeResp;
  606.                 $detail->cpfResp              $item->cpfResp;
  607.                 $detail->numero_parcela       $item->numero_parcela;
  608.                 $detail->vencimento           $item->vencimento;
  609.                 $detail->valor_boleto         $item->valor_boleto;
  610.                 $detail->status_pagamento_id  $item->status_pagamento_id;
  611.                 var_dump($detail);
  612.             }
  613.         }
  614.         if ($old_parcelas) {
  615.             foreach ($old_parcelas as $old_parcela) {
  616.                 if (!in_array($old_parcela->id$keep_parcelas)) {
  617.                     $old_parcela->delete();
  618.                 }
  619.             }
  620.         }
  621.         // recebe dados informado pelo usuário
  622.         $nomeResp             $param['nomeResp'];
  623.         $cpfResp              $param['cpfResp'];
  624.         $logradouroResp       $param['logradouroResp'];
  625.         $numeroResp           $param['numeroResp'];
  626.         $bairroResp           $param['bairroResp'];
  627.         $cepResp              $param['cepResp'];
  628.         $cidadeResp           $param['cidadeResp'];
  629.         $ufResp               $param['ufResp'];
  630.         $name                 $param['name'];
  631.         $DataPrimeiraParcela  $param['vencimento'];
  632.         $plano_pagamento_nome $param['plano_pagamento_nome'];
  633.         $total                = ($param['valor_boleto']);
  634.         $prazo                $param['parcela'];
  635.         $status               $param['status_pagamento_id'];
  636.         // chama a função que realiza o calculo da divisão e tbm realiza o calculo dos dos vencimentos - retorna um array
  637.         $parcelas GerarParcelas::calcularParcelas($total$prazo$DataPrimeiraParcela$nomeResp$cpfResp$logradouroResp$numeroResp$bairroResp$cepResp$cidadeResp$plano_pagamento_nome$ufResp$name$statusnull);
  638.         // armazena as parcelas sem uma variavel de sessão
  639.         TSession::setValue(__CLASS__ '_parcelas'$parcelas);
  640.         // laço onde add na grid a divisão - os centavos são adicionados na ultima parcela
  641.         foreach ($parcelas as $parcela) {
  642.         // adiciona as parcelas na grid
  643.         $item = new StdClass;
  644.         $item->detail_id = empty($parcela->detail_id) ? 'X' mt_rand(1000000019999999) : $parcela->detail_id;
  645.         $item->id                          $parcela->id;
  646.         $item->numero_documento            $parcela->id;
  647.         $item->nomeResp                    $parcela->nomeResp;
  648.         $item->cpfResp                     $parcela->cpfResp;
  649.         $item->logradouroResp              $parcela->logradouroResp;
  650.         $item->numeroResp                  $parcela->numeroResp;
  651.         $item->bairroResp                  $parcela->bairroResp;
  652.         $item->cepResp                     $parcela->cepResp;
  653.         $item->cidadeResp                  $parcela->cidadeResp;
  654.         $item->ufResp                      $parcela->ufResp;
  655.         $item->name                        $parcela->name;
  656.         $item->parcela                     $parcela->numero_parcela;
  657.         $item->plano_pagamento_nome        $parcela->plano_pagamento_nome;
  658.         $item->valor_boleto                = ($parcela->valor_boleto);
  659.         $item->vencimento                  $parcela->vencimento;
  660.         $item->status_pagamento_id         $parcela->status_pagamento_id;
  661.         $this->datagrid->addItem($item);
  662.         }
  663.         // mantem os dados no form
  664.         TTransaction::close(); // close the transaction
  665.         $data = new stdClass;
  666.         //$data->id = $system_aluno->id;
  667.         TForm::sendData('form_aluno'$data);
  668.         //$this->onEdit(array('key' => $barcode->id)); // reload form and session items
  669.         $this->form->setData($this->form->getData());
  670.         $this->datagrid->getItems;
  671.         new TMessage('info'TAdiantiCoreTranslator::translate('Record saved'));
  672.       } catch (Exception $ex) {
  673.         new TMessage('error''ma oee ' $ex->getMessage());
  674.         TTransaction::rollback();
  675.       }
  676. }
  677. function onTeste($param) {
  678.     echo '<pre>';
  679.     print_r($param);
  680.     echo '<pre>';
  681. }
  682.     /**
  683.      * Remove parcela datagrid session
  684.      */
  685.     public static function deleteBoleto($param)
  686.     {
  687.         $parcelas TSession::getValue('datagrid');
  688.         unset($parcelas$param['id'] ]);
  689.         TSession::setValue('datagrid'$parcelas);
  690.     }
  691. }
  692. ?>
</pre></pre></your>
MG

Onde vc colocou "print", troque por $detail->store().
Pelo que entendi do seu código, o mesmo deveria ser salvo a cada iteração, não é isso?
Foi isso que você fez?
Por que no primeiro print que passou, o "store" estava fora do laço.
Outra dúvida: você sobrescreveu o "store" do TRecord?
JA

Coloquei o store veja o log de erro

[Tue Apr 10 19:37:21.096203 2018] [:error] [pid 28926] [client 127.0.0.1:50714] PHP Warning: Creating default object from empty value in /var/www/html/guiansoft_V1.4/app/control/school/AlunoForm.class.php on line 688, referer: http://localhost/guiansoft_V1.4/index.php?class=AlunoForm&method=onEdit&key=1&id=1 [Tue Apr 10 19:37:21.096436 2018] [:error] [pid 28926] [client 127.0.0.1:50714] PHP Fatal error: Uncaught Error: Call to undefined method stdClass::store() in /var/www/html/guiansoft_V1.4/app/control/school/AlunoForm.class.php:698\nStack trace:\n#0 [internal function]: AlunoForm->onGerarParcelas(Array)\n#1 /var/www/html/guiansoft_V1.4/lib/adianti/control/TPage.php(51): call_user_func(Array, Array)\n#2 /var/www/html/guiansoft_V1.4/lib/adianti/control/TPage.php(205): Adianti\\Control\\TPage->run()\n#3 /var/www/html/guiansoft_V1.4/lib/adianti/core/AdiantiCoreApplication.php(62): Adianti\\Control\\TPage->show(Array)\n#4 /var/www/html/guiansoft_V1.4/engine.php(36): Adianti\\Core\\AdiantiCoreApplication::run(true)\n#5 /var/www/html/guiansoft_V1.4/engine.php(55): TApplication::run(true)\n#6 {main}\n thrown in /var/www/html/guiansoft_V1.4/app/control/school/AlunoForm.class.php on line 698, referer: http://localhost/guiansoft_V1.4/index.php?class=AlunoForm&method=onEdit&key=1&id=1


veja tbm minha model

  1. <?php
  2. /**
  3.  * SystemUser
  4.  *
  5.  * @version    1.0
  6.  * @package    model
  7.  * @subpackage admin
  8.  * @author     Pablo Dall'Oglio
  9.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10.  * @license    http://www.adianti.com.br/framework-license
  11.  */
  12. class SystemAluno extends TRecord
  13. {
  14.     const TABLENAME 'system_aluno';
  15.     const PRIMARYKEY'id';
  16.     const IDPOLICY =  'max'// {max, serial}
  17.     private $system_aluno_turmas;
  18.     private $details;
  19.     public function __construct($id NULL$callObjectLoad TRUE)
  20.     {
  21.         parent::__construct($id$callObjectLoad);
  22.         parent::addAttribute('name');
  23.         parent::addAttribute('photo_path');
  24.         parent::addAttribute('nomeResp');
  25.         parent::addAttribute('rg');
  26.         parent::addAttribute('rgResp');
  27.         parent::addAttribute('cpf');
  28.         parent::addAttribute('cpfResp');
  29.         parent::addAttribute('nomePai');
  30.         parent::addAttribute('nomeMae');
  31.         parent::addAttribute('nascimento');
  32.         parent::addAttribute('nascimentoResp');
  33.         parent::addAttribute('genero_id');
  34.         parent::addAttribute('generoRespId');
  35.         parent::addAttribute('cep');
  36.         parent::addAttribute('cepResp');
  37.         parent::addAttribute('logradouro');
  38.         parent::addAttribute('logradouroResp');
  39.         parent::addAttribute('numero');
  40.         parent::addAttribute('numeroResp');
  41.         parent::addAttribute('complemento');
  42.         parent::addAttribute('complementoResp');
  43.         parent::addAttribute('bairro');
  44.         parent::addAttribute('bairroResp');
  45.         parent::addAttribute('cidade');
  46.         parent::addAttribute('cidadeResp');
  47.         parent::addAttribute('uf');
  48.         parent::addAttribute('ufResp');
  49.         parent::addAttribute('celular');
  50.         parent::addAttribute('celPai');
  51.         parent::addAttribute('celMae');
  52.         parent::addAttribute('celularResp');
  53.         parent::addAttribute('telefone');
  54.         parent::addAttribute('telefoneResp');
  55.         parent::addAttribute('emailResp');
  56.         parent::addAttribute('tipoSanguineo');
  57.         parent::addAttribute('alergia');
  58.         parent::addAttribute('problemaSaude');
  59.         parent::addAttribute('chamarUrgencia');
  60.         parent::addAttribute('desconto');
  61.         parent::addAttribute('empresaResp');
  62.         parent::addAttribute('profissao_id');
  63.         parent::addAttribute('endProfissional');
  64.         parent::addAttribute('telProfissional');
  65.         parent::addAttribute('data_matricula');
  66.         parent::addAttribute('login');
  67.         parent::addAttribute('password');
  68.         parent::addAttribute('email');
  69.         parent::addAttribute('frontpage_id');
  70.         parent::addAttribute('system_unit_id');
  71.         parent::addAttribute('active');
  72.         parent::addAttribute('periodo_id');
  73.         parent::addAttribute('vencimento');
  74.     }
  75.     /**
  76.      * Reset aggregates
  77.      */
  78.     public function clearParts()
  79.     {
  80.         $this->system_aluno_turmas   = array();
  81.         $this->details   = array();
  82.     }
  83.     /**
  84.      * Composition with Item
  85.      */
  86.     public function addSystemAlunoTurma(SystemAlunoTurma $system_aluno_turma)
  87.     {
  88.         $this->system_aluno_turmas[] = $system_aluno_turma;
  89.     }
  90.     /**
  91.      * Composition with Item
  92.      */
  93.     public function addSystemAlunoParcela(SystemAlunoParcela $detail)
  94.     {
  95.         $this->details[] = $detail;
  96.     }
  97.     /**
  98.      * Return Items composition
  99.      */
  100.     public function getSystemAlunoTurmas()
  101.     {
  102.         return $this->system_aluno_turmas;
  103.     }
  104.     /**
  105.      * Return Items composition
  106.      */
  107.     public function getSystemParcelas()
  108.     {
  109.         return $this->details;
  110.     }
  111.     /**
  112.      * Load the object and the aggregates
  113.      */
  114.     public function load($id)
  115.     {
  116.         $system_aluno_turma_rep = new TRepository('SystemAlunoTurma');
  117.         $detail_rep = new TRepository('SystemAlunoParcela');
  118.         $criteria = new TCriteria;
  119.         $criteria->add(new TFilter('aluno_id''='$id));
  120.         // load the Item composition
  121.         $details $detail_rep->load($criteria);
  122.         if ($details)
  123.         {
  124.             foreach ($details as $detail)
  125.             {
  126.                 //$system_aluno_turma = new SystemAlunoTurma($system_aluno_turma-> id);
  127.                 $this->addSystemAlunoParcela($detail);
  128.             }
  129.         }
  130.         // load the Item composition
  131.         $system_aluno_turmas $system_aluno_turma_rep->load($criteria);
  132.         if ($system_aluno_turmas)
  133.         {
  134.             foreach ($system_aluno_turmas as $system_aluno_turma)
  135.             {
  136.                 $system_aluno_turma = new SystemAlunoTurma($system_aluno_turma-> id);
  137.                 $this->addSystemAlunoTurma($system_aluno_turma);
  138.             }
  139.         }
  140.         // load the object itself
  141.         return parent::load($id);
  142.     }
  143.     /**
  144.      * Stores the book and the aggregates (authors, subjects, items)
  145.      */
  146.     public function store()
  147.     {
  148.         // stores the Book
  149.         parent::store();
  150.         // delete the aggregates
  151.         $criteria = new TCriteria;
  152.         $criteria->add(new TFilter('aluno_id''='$this->id));
  153.         // collect persistent item ids
  154.         if ($this->system_aluno_turmas)
  155.         {
  156.             foreach ($this->system_aluno_turmas as $system_aluno_turma)
  157.             {
  158.                 if ($system_aluno_turma->id)
  159.                 {
  160.                     $system_aluno_turma_ids[] = $system_aluno_turma->id;
  161.                 }
  162.             }
  163.         }
  164.         if (!empty($system_aluno_turma_ids))
  165.         {
  166.             // delete all items, except for those that persist
  167.             $criteria->add(new TFilter('id''NOT IN'$system_aluno_turma_ids));
  168.         }
  169.         $repository = new TRepository('SystemAlunoTurma');
  170.         $repository->delete($criteria);
  171.         // store the system_aluno_turmas
  172.         if ($this->system_aluno_turmas)
  173.         {
  174.             foreach ($this->system_aluno_turmas as $system_aluno_turma)
  175.             {
  176.                 $system_aluno_turma-> aluno_id $this-> id;
  177.                 $system_aluno_turma->store();
  178.             }
  179.         }
  180.         // collect persistent item ids
  181.         if ($this->details)
  182.         {
  183.             foreach ($this->details as $detail)
  184.             {
  185.                 if ($detail->id)
  186.                 {
  187.                     $detail_ids[] = $detail->id;
  188.                 }
  189.             }
  190.         }
  191.         if (!empty($detail_ids))
  192.         {
  193.             // delete all items, except for those that persist
  194.             $criteria->add(new TFilter('id''NOT IN'$detail_ids));
  195.         }
  196.         $repository = new TRepository('SystemAlunoParcela');
  197.         $repository->delete($criteria);
  198.         // store the details
  199.         if ($this->details)
  200.         {
  201.             foreach ($this->details as $detail)
  202.             {
  203.                 $detail-> aluno_id $this-> id;
  204.                 $detail->store();
  205.             }
  206.         }
  207.     }
  208.     /**
  209.      * Delete the book and its aggregates
  210.      */
  211.     public function delete($id NULL)
  212.     {
  213.         $id = isset($id) ? $id $this->{'id'};
  214.         SystemAlunoTurma::where('aluno_id''='$id)->delete();
  215.         SystemAlunoParcela::where('aluno_id''='$id)->delete();
  216.         // delete the object itself
  217.         parent::delete($id);
  218.     }
  219.     /**
  220.      * Retorna periodo
  221.      */
  222.     public function get_SystemStatusPagamento()
  223.     {
  224.         return SystemStatusPagamento::find($this->status_pagamento_id);
  225.     }
  226.     /**
  227.      * Retorna periodo
  228.      */
  229.     public function get_SystemPeriodo()
  230.     {
  231.         return SystemPeriodo::find($this->periodo_id);
  232.     }
  233. }
  234. ?>


e a model da parcelas

  1. <?php
  2. /**
  3.  * System_aluno_turma Active Record
  4.  * @author  <Jonathas Alves Santos>
  5.  */
  6. class SystemAlunoParcela extends TRecord
  7. {
  8.     const TABLENAME 'system_aluno_parcela';
  9.     const PRIMARYKEY'id';
  10.     const IDPOLICY =  'max'// {max, serial}
  11.     private $system_aluno;
  12.     /**
  13.      * Returns the Item from its numero_documento
  14.      */
  15.     public static function newFromNumeroDocumento($numero_documento)
  16.     {
  17.         $rep = new TRepository('SystemAlunoParcela');
  18.         $criteria = new TCriteria;
  19.         $criteria->add(new TFilter('numero_documento''='$numero_documento));
  20.         $objects $rep->load($criteria);
  21.         if ($objects)
  22.         {
  23.             $detail $objects[0];
  24.             return $detail;
  25.         }
  26.     }
  27. }
  28. ?>


</Jonathas>
MG

Jonathas
O erro é claro, o método "store" não existe para o objeto "$detail" no método "onGerar...".
Tem muito conteúdo na tela fica difícil navegar. Revise este objeto. veja se ele está sendo instanciado corretamente.
O método "store" é herdado de um Model estendido de um TRecord.
No momento que chama "store", $detail não é um objeto da Classe: SystemAlunoParcela.
JA

Olá, consegui resolver o problema !

Obrigado!