Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Apagando registro anterior Olá, boa noite estou com um problema, quando acrescento um novo registro ou edito ele acaba apagando o registro anterior. A ideia é registrar cada ano que o aluno estudou na instituição como periodo, curso, modulo, turma e situação do aluno na turma. ...
JA
Apagando registro anterior  
Olá, boa noite estou com um problema, quando acrescento um novo registro ou edito ele acaba apagando o registro anterior. A ideia é registrar cada ano que o aluno estudou na instituição como periodo, curso, modulo, turma e situação do aluno na turma.

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


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 $system_aluno_parcelas;
  19.     public function __construct($id NULL$callObjectLoad TRUE)
  20.     {
  21.         parent::__construct($id$callObjectLoad);
  22.         parent::addAttribute('matricula');
  23.         parent::addAttribute('name');
  24.         parent::addAttribute('photo_path');
  25.         parent::addAttribute('nomeResp');
  26.         parent::addAttribute('rg');
  27.         parent::addAttribute('rgResp');
  28.         parent::addAttribute('cpf');
  29.         parent::addAttribute('cpfResp');
  30.         parent::addAttribute('nomePai');
  31.         parent::addAttribute('nomeMae');
  32.         parent::addAttribute('nascimento');
  33.         parent::addAttribute('nascimentoResp');
  34.         parent::addAttribute('genero_id');
  35.         parent::addAttribute('generoRespId');
  36.         parent::addAttribute('cep');
  37.         parent::addAttribute('cepResp');
  38.         parent::addAttribute('logradouro');
  39.         parent::addAttribute('logradouroResp');
  40.         parent::addAttribute('numero');
  41.         parent::addAttribute('numeroResp');
  42.         parent::addAttribute('complemento');
  43.         parent::addAttribute('complementoResp');
  44.         parent::addAttribute('bairro');
  45.         parent::addAttribute('bairroResp');
  46.         parent::addAttribute('cidade');
  47.         parent::addAttribute('cidadeResp');
  48.         parent::addAttribute('uf');
  49.         parent::addAttribute('ufResp');
  50.         parent::addAttribute('celular');
  51.         parent::addAttribute('celPai');
  52.         parent::addAttribute('celMae');
  53.         parent::addAttribute('celularResp');
  54.         parent::addAttribute('telefone');
  55.         parent::addAttribute('telefoneResp');
  56.         parent::addAttribute('emailResp');
  57.         parent::addAttribute('tipoSanguineo');
  58.         parent::addAttribute('alergia');
  59.         parent::addAttribute('problemaSaude');
  60.         parent::addAttribute('chamarUrgencia');
  61.         parent::addAttribute('desconto');
  62.         parent::addAttribute('empresaResp');
  63.         parent::addAttribute('profissao_id');
  64.         parent::addAttribute('endProfissional');
  65.         parent::addAttribute('telProfissional');
  66.         parent::addAttribute('data_matricula');
  67.         parent::addAttribute('login');
  68.         parent::addAttribute('password');
  69.         parent::addAttribute('email');
  70.         parent::addAttribute('frontpage_id');
  71.         parent::addAttribute('system_unit_id');
  72.         parent::addAttribute('active');
  73.         parent::addAttribute('periodo_id');
  74.         parent::addAttribute('vencimento');
  75.     }
  76.     /**
  77.      * Reset aggregates
  78.      */
  79.     public function clearParts()
  80.     {
  81.         $this->system_aluno_turmas   = array();
  82.         $this->system_aluno_parcelas   = array();
  83.     }
  84.     /**
  85.      * Composition with Item
  86.      */
  87.     public function addSystemAlunoTurma(SystemAlunoTurma $system_aluno_turma)
  88.     {
  89.         $this->system_aluno_turmas[] = $system_aluno_turma;
  90.     }
  91.     /**
  92.      * Composition with Item
  93.      */
  94.     public function addSystemAlunoParcela(SystemAlunoParcela $system_aluno_parcela)
  95.     {
  96.         $this->system_aluno_parcelas[] = $system_aluno_parcela;
  97.     }
  98.     /**
  99.      * Return Items composition
  100.      */
  101.     public function getSystemAlunoTurmas()
  102.     {
  103.         return $this->system_aluno_turmas;
  104.     }
  105.     /**
  106.      * Return Items composition
  107.      */
  108.     public function getSystemAlunoParcelas()
  109.     {
  110.         return $this->system_aluno_parcelas;
  111.     }
  112.     /**
  113.      * Load the object and the aggregates
  114.      */
  115.     public function load($id)
  116.     {
  117.         $this->system_aluno_turmas =  parent::loadComposite('SystemAlunoTurma''aluno_id'$id);
  118.         $this->system_aluno_parcelas =  parent::loadComposite('SystemAlunoParcela''aluno_id'$id);
  119.         // load the object itself
  120.         return parent::load($id);
  121.     }
  122.     /**
  123.      * Stores the book and the aggregates (authors, subjects, items)
  124.      */
  125.     public function store()
  126.     {
  127.         // stores the Book
  128.         parent::store();
  129.         parent::saveComposite('SystemAlunoTurma''aluno_id'$this->id$this->system_aluno_turmas);
  130.         parent::saveComposite('SystemAlunoParcela''aluno_id'$this->id$this->system_aluno_parcelas);
  131.     }
  132.     /**
  133.      * Delete the book and its aggregates
  134.      */
  135.     public function delete($id NULL)
  136.     {
  137.         $id = isset($id) ? $id $this->{'id'};
  138.         parent::deleteComposite('SystemAlunoTurma''aluno_id'$id);
  139.         parent::deleteComposite('SystemAlunoParcela''aluno_id'$id);
  140.         // delete the object itself
  141.         parent::delete($id);
  142.     }
  143.     public function get_system_status_pagamento()
  144.         {
  145.             // loads the associated object
  146.             if (empty($this->system_status_pagamentos))
  147.                 $this->system_status_pagamentos = new SystemStatusPagamento($this->status_pagamento_id);
  148.             // returns the associated object
  149.             return $this->system_status_pagamentos->nome;
  150.         }
  151.     /**
  152.      * Retorna periodo
  153.      */
  154.     public function get_SystemAluno()
  155.     {
  156.         return SystemAluno::find($this->aluno_id);
  157.     }
  158.     /**
  159.      * Retorna periodo
  160.      */
  161.     public function get_SystemStatusPagamento()
  162.     {
  163.         return SystemStatusPagamento::find($this->status_pagamento_id);
  164.     }
  165.     /**
  166.      * Retorna periodo
  167.      */
  168.     public function get_SystemPeriodo()
  169.     {
  170.         return SystemPeriodo::find($this->periodo_id);
  171.     }
  172.     /**
  173.      * Retorna periodo
  174.      */
  175.     public function get_SystemAlunoNota()
  176.     {
  177.         return SystemAlunoNota::find($this->aluno_id);
  178.     }
  179. }
  180. ?>

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 (4)


NR

Habilite os logs de sql para facilitar e isolar o problema.
JA

Olá, Nataniel Rabaioli!

São esses logs:

Debug: 2018-04-30 17:17:48 - UPDATE system_aluno SET matricula = NULL, name = 'PEDRO SANTA BÁRBARA SANTOS', genero_id = NULL, nascimento = '2015-07-02', cpf = NULL, rg = NULL, telefone = NULL, celular = NULL, data_matricula = '2018-04-29', photo_path = NULL, nomePai = NULL, nomeMae = NULL, celPai = NULL, celMae = NULL, cep = '49040-200', logradouro = 'RUA DOS FLAMBOYANTS', numero = '494', complemento = NULL, bairro = 'INáCIO BARBOSA', cidade = 'ARACAJU', uf = 'SE', nomeResp = 'JONATHAS ALVES SANTOS', generoRespId = NULL, nascimentoResp = '2018-04-29', rgResp = NULL, cpfResp = NULL, celularResp = NULL, telefoneResp = NULL, emailResp = NULL, cepResp = '49040-200', logradouroResp = 'RUA DOS FLAMBOYANTS', complementoResp = NULL, numeroResp = '494', bairroResp = 'INáCIO BARBOSA', cidadeResp = 'ARACAJU', ufResp = 'SE', empresaResp = NULL, profissao_id = NULL, endProfissional = NULL, telProfissional = NULL, vencimento = '2018-05-10', desconto = NULL, tipoSanguineo = NULL, alergia = NULL, problemaSaude = NULL, chamarUrgencia = NULL WHERE (id = '1') Debug: 2018-04-30 17:17:48 - DELETE FROM system_aluno_turma WHERE (aluno_id = '1') Debug: 2018-04-30 17:17:48 - INSERT INTO system_aluno_turma (id, periodo_id, curso_id, modulo_id, turma_id, situacao_id, aluno_id) values ('1', '1', '2', '1', '1', '1', '1') Debug: 2018-04-30 17:17:48 - UPDATE system_aluno_turma SET periodo_id = '2', curso_id = '2', modulo_id = '2', turma_id = '1', situacao_id = '1', aluno_id = '1' WHERE (id = '1') Debug: 2018-04-30 17:17:48 - UPDATE system_aluno_turma SET periodo_id = '2', curso_id = '2', modulo_id = '3', turma_id = '1', situacao_id = '1', aluno_id = '1' WHERE (id = '1') Debug: 2018-04-30 17:17:48 - SELECT max(id) as id FROM system_aluno_turma Debug: 2018-04-30 17:17:48 - INSERT INTO system_aluno_turma (id, periodo_id, curso_id, modulo_id, turma_id, situacao_id, aluno_id) values (2, '2', '2', '4', '1', '5', '1') Debug: 2018-04-30 17:17:48 - DELETE FROM system_aluno_parcela WHERE (aluno_id = '1')

NR

Veja que pelos logs é possível perceber que são feitos vários updates na system_aluno_turma após o insert. Era esse o comportamento desejado?

Achei estranho o trecho abaixo:
  1. <?php
  2. $system_aluno_turma->id             $param['aluno_id'][$row];
  3. ?>

aluno_id não seria a coluna de vínculo, ao invés da chave primária na tabela aluno_turma?
JA

Obrigado Nataniel! Deu certo.