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. $this->form->appendPage('Aluno');
  240. // SEPARAR
  241. $this->form->addFields( [new TFormSeparator(('Dados do Aluno'))] );
  242. $this->form->addFields([new TLabel('Código:')], [$id], [new TLabel(('Matricula:'))], [$matricula]);
  243. $this->form->addFields([new TLabel(('Nome:'))], [$name]);
  244. $this->form->addFields([new TLabel('Gênero:')], [$genero_id], [new TLabel('Nascimento:')], [$nascimento]);
  245. $this->form->addFields([new TLabel('CPF:')], [$cpf], [new TLabel('RG:')], [$rg]);
  246. $this->form->addFields([new TLabel('Tel. Aluno:')], [$telefone], [new TLabel('Cel. Aluno:')], [$celular]);
  247. $this->form->addFields([new TLabel('Data da Matrícula:')], [$data_matricula], [new TLabel('Foto:')], [$photo_path]);
  248. $this->frame = new TElement('div');
  249. $this->frame->id = 'photo_path';
  250. $this->frame->style = 'width:180px;height:auto;min-height:180px;border:1px solid gray;padding:4px;';
  251. // SEPARAR
  252. $this->form->addFields( [new TFormSeparator(('Filiação'))] );
  253. $this->form->addFields([new TLabel('Pai:')], [$nomePai], [new TLabel('Mãe:')], [$nomeMae]);
  254. $this->form->addFields([new TLabel('Cel. Pai:')], [$celPai], [new TLabel('Cel. Mãe:')], [$celMae]);
  255. // SEPARAR
  256. $this->form->addFields( [new TFormSeparator(('Endereço do Aluno'))] );
  257. $this->form->addFields([new TLabel('CEP:')], [$cep], [$btnCep]);
  258. $this->form->addFields([new TLabel('Logradouro:')], [$logradouro], [new TLabel('Número:')], [$numero]);
  259. $this->form->addFields([new TLabel('Complemento:')], [$complemento], [new TLabel('Bairro:')], [$bairro]);
  260. $this->form->addFields([new TLabel('Cidade:')], [$cidade], [new TLabel('Estado:')], [$uf]);
  261. $this->form->appendPage('Responsável Financeiro');
  262. $this->form->addFields([new TLabel('Nome:')], [$nomeResp]);
  263. $this->form->addFields([new TLabel('Gênero:')], [$generoRespId], [new TLabel('Nascimento:')], [$nascimentoResp]);
  264. $this->form->addFields([new TLabel('RG:')], [$rgResp], [new TLabel('CPF:')], [$cpfResp]);
  265. $this->form->addFields([new TLabel('Cel.:')], [$celularResp], [new TLabel('Tel.:')], [$telefoneResp]);
  266. $this->form->addFields([new TLabel('E-mail:')], [$emailResp]);
  267. // SEPARAR
  268. $this->form->addFields( [new TFormSeparator(('Endereço'))] );
  269. $this->form->addFields([new TLabel('CEP:')], [$cepResp], [$btnRespCep]);
  270. $this->form->addFields([new TLabel('Logradouro:')], [$logradouroResp], [new TLabel('Complemento:')], [$complementoResp]);
  271. $this->form->addFields([new TLabel('Número:')], [$numeroResp], [new TLabel('Bairro:')], [$bairroResp]);
  272. $this->form->addFields([new TLabel('Cidade:')], [$cidadeResp], [new TLabel('Estado:')], [$ufResp]);
  273. // SEPARAR
  274. $this->form->addFields( [new TFormSeparator(('Endereço de Trabalho'))] );
  275. $this->form->addFields([new TLabel('Empresa:')], [$empresaResp], [new TLabel('Profissão:')], [$profissao_id]);
  276. $this->form->addFields([new TLabel('End. Prof.:')], [$endProfissional], [new TLabel('Tel. Prof.:')], [$telProfissional]);
  277. // SEPARAR
  278. $this->form->addFields( [new TFormSeparator(('Dados Finánceiro'))] );
  279. $this->form->addFields( [new TLabel('Vencimento:')], [$vencimento], [new TLabel('Desconto em %:')], [$desconto]);
  280. $this->form->appendPage('Ficha Médica');
  281. $this->form->addFields([new TLabel('Tipo Sanguíneo:')], [$tipoSanguineo], [new TLabel('Alergias:')], [$alergia]);
  282. $this->form->addFields([new TLabel('Problemas de saúde?')], [$problemaSaude], [new TLabel('Quem chamar para urgência?')], [$chamarUrgencia]);
  283. // TURMA
  284. $this->form->appendPage('Turmas');
  285. $aluno_id = new THidden('aluno_id[]');
  286. $barcode = new TEntry('barcode[]');
  287. $periodo_id = new TDBCombo('periodo_id[]','db_guiansoft','SystemPeriodo','id','nome');
  288. $curso_id = new TDBCombo('curso_id[]','db_guiansoft','SystemCurso','id','nome');
  289. $modulo_id = new TDBCombo('modulo_id[]','db_guiansoft','SystemModulo','id','nome');
  290. $turma_id = new TDBCombo('turma_id[]','db_guiansoft','SystemTurma','id','nome');
  291. $situacao_id = new TDBCombo('situacao_id[]','db_guiansoft','SystemSituacaoAlunoTurma','id','nome');
  292. // set exit action for input_exit
  293. $change_action = new TAction(array($this, 'onChangeActionModulo'));
  294. $modulo_id->setChangeAction($change_action);
  295. // DEFINE TAMANHO
  296. $aluno_id->setSize('100%');
  297. $barcode->setSize(120);
  298. $periodo_id->setSize('100%');
  299. $curso_id->setSize('100%');
  300. $modulo_id->setSize('100%');
  301. $turma_id->setSize('100%');
  302. $situacao_id->setSize('100%');
  303. $this->system_aluno_turmas_list = new TFieldList;
  304. $this->system_aluno_turmas_list->addField( '<b>'.('ID').'</b>', $aluno_id);
  305. $this->system_aluno_turmas_list->addField( '<b>'.('Barcode').'</b>', $barcode);
  306. $this->system_aluno_turmas_list->addField( '<b>'.('Período').'</b>', $periodo_id);
  307. $this->system_aluno_turmas_list->addField( '<b>'.('Curso').'</b>', $curso_id);
  308. $this->system_aluno_turmas_list->addField( '<b>'.('Módulo').'</b>', $modulo_id);
  309. $this->system_aluno_turmas_list->addField( '<b>'.('Turma').'</b>', $turma_id);
  310. $this->system_aluno_turmas_list->addField( '<b>'.('Situação').'</b>', $situacao_id);
  311. $this->system_aluno_turmas_list->enableSorting();
  312. $this->form->addField($aluno_id);
  313. $this->form->addField($barcode);
  314. $this->form->addField($periodo_id);
  315. $this->form->addField($curso_id);
  316. $this->form->addField($modulo_id);
  317. $this->form->addField($turma_id);
  318. $this->form->addField($situacao_id);
  319. $this->form->addContent( [new TLabel('Turmas')], [$this->system_aluno_turmas_list] );
  320. // FIM TURMAS
  321. // COBRANÇA
  322. $this->form->appendPage('Cobranças');
  323. $plano_pagamento_id->setExitAction(new TAction(array($this,'onPlanoChange')));
  324. $this->form->addFields( [new TLabel('Periodo:')], [$periodoc_id] );
  325. $this->form->addFields( [new TLabel('Plano de pagamento:')], [$plano_pagamento_id, $plano_pagamento_nome], [new TLabel('Parcelas:')], [$parcela] );
  326. $this->form->addFields( [new TLabel('Valor Total:')], [$valor_boleto], [new TLabel(('Status Pagamento:'))], [$status_pagamento_id] );
  327. $this->form->addFields( [new TFormSeparator(('Parcelas'))] );
  328. // BUSCA PARCELA POR PERIODO E STATUS
  329. $this->form->addFields( [ $lp=new TLabel(('Periodo'))], [$periodos_id], [$ls=new TLabel(('Status Pagamento'))], [$status_pagamentos_id] );
  330. // DEFINE A COR
  331. $lp->setFontColor('red');
  332. $ls->setFontColor('red');
  333. $this->form->addFields( [$vbox1] );
  334. // FORMATA O VALOR DA PARCELA NO DATAGRID, NO PADÃO -> R$ 1.000,99
  335. $format_value = function($value) {
  336. if (is_numeric($value)) {
  337. return 'R$ '.number_format($value, 2, ',', '.');
  338. }
  339. return $value;
  340. };
  341. $column_valor_boleto->setTransformer( $format_value );
  342. // FIM COBRANÇA
  343. // wrap the page content
  344. $container = new TVBox;
  345. $container->style = 'width: 100%';
  346. $container->add(new TXMLBreadCrumb('menu.xml', 'AlunoList'));
  347. $container->add($this->form);
  348. // add the container to the page
  349. parent::add($container);
  350. }
  351. /**
  352. * On complete upload photo_path
  353. */
  354. public static function onComplete($param)
  355. {
  356. new TMessage('info', 'Upload completo: ' . $param['photo_path']);
  357. copy("tmp/{$param['photo_path']}", "files/fotos/alunos/{$param['photo_path']}");
  358. // refresh photo_frame
  359. TScript::create("$('#photo_frame').html('')");
  360. TScript::create("$('#photo_frame').html(\"<img width='180px' height='180px' src='files/fotos/alunos/{$param['photo_path']}'>\");");
  361. }
  362. /*
  363. * Função de busca de Endereço pelo CEP
  364. * - Desenvolvido Felipe Olivaes para ajaxbox.com.br
  365. * - Utilizando WebService de CEP da republicavirtual.com.br
  366. */
  367. public static function onCep($param)
  368. {
  369. $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep=' . urlencode($param['cep']) . '&formato=query_string');
  370. if (!$resultado) {
  371. $resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  372. }
  373. parse_str($resultado, $retorno);
  374. $obj = new StdClass;
  375. $obj->cep = $param['cep'];
  376. $obj->logradouro = strtoupper($retorno['tipo_logradouro'] . ' ' . $retorno['logradouro']);
  377. $obj->bairro = strtoupper($retorno['bairro']);
  378. $obj->cidade = strtoupper($retorno['cidade']);
  379. $obj->uf = strtoupper($retorno['uf']);
  380. TForm::sendData('form_Aluno', $obj);
  381. }
  382. /*
  383. * Função de busca de Endereço pelo CEP
  384. * - Desenvolvido Felipe Olivaes para ajaxbox.com.br
  385. * - Utilizando WebService de CEP da republicavirtual.com.br
  386. */
  387. public static function onRespCep($param)
  388. {
  389. $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep=' . urlencode($param['cepResp']) . '&formato=query_string');
  390. if (!$resultado) {
  391. $resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  392. }
  393. parse_str($resultado, $retorno);
  394. $obj = new StdClass;
  395. $obj->cepResp = $param['cepResp'];
  396. $obj->logradouroResp = strtoupper($retorno['tipo_logradouro'] . ' ' . $retorno['logradouro']);
  397. $obj->bairroResp= strtoupper($retorno['bairro']);
  398. $obj->cidadeResp = strtoupper($retorno['cidade']);
  399. $obj->ufResp = strtoupper($retorno['uf']);
  400. TForm::sendData('form_Aluno', $obj);
  401. }
  402. /**
  403. * Action to be executed when the user changes the modulo_id field
  404. */
  405. public static function onChangeActionModulo($param)
  406. {
  407. TTransaction::open('db_guiansoft');
  408. $criteria = new TCriteria;
  409. $criteria->add(new TFilter('modulo_id', '=', $param['modulo_id']));
  410. $repository = new TRepository('SystemTurma');
  411. $turmas = $repository->load($criteria);
  412. $options = array();
  413. foreach ($turmas as $turma){
  414. $options[$turma->id] = $turma->nome;
  415. }
  416. //TForm::sendData('form_Aluno', $objeto);
  417. TCombo::reload('form_Aluno', 'turma_id[]', $options);
  418. }
  419. /**
  420. * On product change
  421. */
  422. static function onPlanoChange( $params )
  423. {
  424. if( isset($params['plano_pagamento_id']) && $params['plano_pagamento_id'] )
  425. {
  426. try
  427. {
  428. TTransaction::open('db_guiansoft');
  429. $systemplanopagamento = new SystemPlanoPagamento($params['plano_pagamento_id']);
  430. $fill_data = new StdClass;
  431. $fill_data->parcela = $systemplanopagamento->prazo;
  432. $fill_data->valor_boleto = $systemplanopagamento->valor_total;
  433. TForm::sendData('form_Aluno', $fill_data);
  434. TTransaction::close();
  435. }
  436. catch (Exception $e) // in case of exception
  437. {
  438. new TMessage('error', $e->getMessage());
  439. TTransaction::rollback();
  440. }
  441. }
  442. }
  443. /**
  444. * Reload the item list
  445. * @param $param URL parameters
  446. */
  447. public function onReload($param)
  448. {
  449. // read session items
  450. $parcelas = TSession::getValue(__CLASS__ . '_parcelas');
  451. $this->datagrid->clear(); // clear detail list
  452. $data = $this->form->getData();
  453. if ($system_aluno_parcelas)
  454. {
  455. $cont = 1;
  456. foreach ($system_aluno_parcelas as $parcelas_id => $parcelas)
  457. {
  458. $system_aluno_parcela->id = $parcelas['id'];
  459. $system_aluno_parcela->numero_documento = $parcelas['numero_documento'];
  460. $system_aluno_parcela->nomeResp = $parcelas['nomeResp'];
  461. $system_aluno_parcela->parcela = $parcelas['parcela'];
  462. $system_aluno_parcela->vencimento = $parcelas['vencimento'];
  463. $system_aluno_parcela->valor_boleto = $parcelas['valor_boleto'];
  464. $system_aluno_parcela->status_pagamento_id = $parcelas['status_pagamento_id'];
  465. $row = $this->datagrid->addSystemAlunoParcela( $system_aluno_parcela );
  466. $row->onmouseover = '';
  467. $row->onmouseout = '';
  468. }
  469. $this->form->setFields( $this->formFields );
  470. }
  471. $this->loaded = TRUE;
  472. }
  473. /**
  474. * method onEdit
  475. * Edit a record data
  476. */
  477. function onEdit($param)
  478. {
  479. try
  480. {
  481. if (isset($param['id'])){
  482. $id = $param['id']; // OBTÉM O PARÂMETRO $key
  483. TTransaction::open('db_guiansoft'); // ABRE A TRANSAÇÃO
  484. $system_aluno = new SystemAluno($param['id']); // INSTANCIA O ACTIVE RECORD
  485. // load the contacts (composition)
  486. $system_aluno_turmas = $system_aluno->getSystemAlunoTurmas();
  487. $system_aluno_parcelas = $system_aluno->getSystemAlunoParcelas();
  488. if ($system_aluno_parcelas) {
  489. foreach ($system_aluno_parcelas as $system_aluno_parcela) {
  490. $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
  491. $this->datagrid->addItem($system_aluno_parcela); // add the detail inside the datagrid
  492. }
  493. }
  494. // TURMAS
  495. if ($system_aluno_turmas) {
  496. $this->system_aluno_turmas_list->addHeader();
  497. foreach ($system_aluno_turmas as $system_aluno_turma)
  498. {
  499. $system_aluno_turma->system_aluno_turma_id = $system_aluno_turma->id;
  500. $this->system_aluno_turmas_list->addDetail($system_aluno_turma);
  501. }
  502. $this->system_aluno_turmas_list->addCloneAction();
  503. }
  504. else
  505. {
  506. $this->clearSystemAlunoTurmas();
  507. }
  508. $this->form->setData($system_aluno); // PREENCHE O FORM
  509. TTransaction::close(); // FECHA A TRANSAÇÃO
  510. }
  511. else {
  512. $this->onClear($param);
  513. $this->form->clear();
  514. TSession::setValue('$system_aluno_parcelas', null);
  515. $this->onReload( $param );
  516. }
  517. }
  518. catch (Exception $e) // in case of exception
  519. {
  520. new TMessage('error', $e->getMessage());
  521. TTransaction::rollback();
  522. }
  523. }
  524. /**
  525. * Clear Turmas
  526. */
  527. public function clearSystemAlunoTurmas()
  528. {
  529. $this->system_aluno_turmas_list->addHeader();
  530. $this->system_aluno_turmas_list->addDetail( new stdClass );
  531. $this->system_aluno_turmas_list->addCloneAction();
  532. }
  533. /**
  534. * Clear form
  535. */
  536. public function onClear()
  537. {
  538. $this->form->clear();
  539. $this->clearSystemAlunoTurmas();
  540. $this->clearSystemAlunoParcelas();
  541. TSession::setValue(__CLASS__ . '_parcelas', array());
  542. $this->onReload($param);
  543. }
  544. /**
  545. * method onSave
  546. * Executed whenever the user clicks at the save button
  547. */
  548. public static function onSave($param)
  549. {
  550. try
  551. {
  552. // ABRE UMA TRANSAÇÃO COM O BANCO DE DADOS
  553. TTransaction::open('db_guiansoft');
  554. // read the form data and instantiates an Active Record
  555. $system_aluno = new SystemAluno;
  556. $system_aluno->fromArray( $param );
  557. $system_aluno->clearParts();
  558. if( !empty($param['barcode']) AND is_array($param['barcode']) )
  559. {
  560. foreach( $param['barcode'] as $row => $barcode)
  561. {
  562. if ($barcode)
  563. {
  564. $system_aluno_turma = new SystemAlunoTurma;
  565. $system_aluno_turma->barcode = $barcode;
  566. $system_aluno_turma->id = $param['aluno_id'][$row];
  567. $system_aluno_turma->periodo_id = $param['periodo_id'][$row];
  568. $system_aluno_turma->curso_id = $param['curso_id'][$row];
  569. $system_aluno_turma->modulo_id = $param['modulo_id'][$row];
  570. $system_aluno_turma->turma_id = $param['turma_id'][$row];
  571. $system_aluno_turma->situacao_id = $param['situacao_id'][$row];
  572. $system_aluno->addSystemAlunoTurma( $system_aluno_turma );
  573. }
  574. }
  575. }
  576. $system_aluno->store(); // SALAVA O OBJETO
  577. $data = new stdClass;
  578. $data->id = $system_aluno->id;
  579. TForm::sendData('form_aluno', $data);
  580. // shows the success message
  581. new TMessage('info', 'Record saved');
  582. TTransaction::close(); // close the transaction
  583. }
  584. catch (Exception $e) // in case of exception
  585. {
  586. new TMessage('error', $e->getMessage());
  587. // undo all pending operations
  588. TTransaction::rollback();
  589. }
  590. }
  591. /*
  592. * - Função de Gerar parcelas
  593. * - Indev (ajuda ate ajudar) kkkk
  594. */
  595. function onGerarParcelas($param)
  596. {
  597. try {
  598. // ABRE UMA TRANSAÇÃO COM O BANCO DE DADOS
  599. TTransaction::open('db_guiansoft');
  600. // read the form data and instantiates an Active Record
  601. $system_aluno = new SystemAluno($param['id']);
  602. $this->datagrid->clear(); // LIMPA A GRID
  603. $this->form->validate(); // VERIFICA OS CAMPOS OBRIGATORIOS E FAZ A VALIDAÇÃO
  604. $old_parcelas = SystemAlunoParcela::where('aluno_id', '=', $system_aluno->id)->load();
  605. $keep_parcelas = array();
  606. // get session items
  607. $items = TSession::getValue(__CLASS__ . '_parcelas');
  608. if (!is_null($items) && ! empty($items)) {
  609. foreach ($items as $item) {
  610. if (substr($item->id, 0, 1) == 'X') { // new record
  611. $system_aluno_parcela = new SystemAlunoParcela;
  612. // recebe dados informado pelo usuário
  613. $system_aluno_parcela->fromArray($item) ;
  614. $system_aluno_parcela->aluno_id = $system_aluno->id;
  615. $system_aluno_parcela->store(); // salva o objeto
  616. } else {
  617. $system_aluno_parcela = new SystemAlunoParcela($item->id);
  618. echo "ja existe parcelas";
  619. }
  620. $keep_parcelas[] = $system_aluno_parcela->id;
  621. $this->addParcelasAluno($system_aluno,$system_aluno_parcela);;
  622. }
  623. TSession::setValue(__CLASS__ . '_parcelas', null);
  624. }else{
  625. // chama a função que realiza o calculo da divisão e tbm realiza o calculo dos dos vencimentos - retorna um array
  626. $parcelas = GerarParcelas::calcularParcelas($param['valor_boleto'],
  627. $param['parcela'], $param['vencimento'],
  628. $param['nomeResp'], $param['cpfResp'], $param['logradouroResp'],
  629. $param['numeroResp'], $param['bairroResp'], $param['cepResp'],
  630. $param['cidadeResp'], $param['plano_pagamento_nome'], $param['ufResp'],
  631. $param['name'], $param['status_pagamento_id'], null);
  632. foreach ($parcelas as $parcela) {
  633. $this->addParcelasAluno($system_aluno,$parcela); // adciona as parcelas
  634. }
  635. // armazena as parcelas sem uma variavel de sessão
  636. TSession::setValue(__CLASS__ . '_parcelas', $parcelas);
  637. }
  638. if ($old_parcelas) {
  639. foreach ($old_parcelas as $old_item) {
  640. if (!in_array($old_item->id, $keep_parcelas)) {
  641. $old_item->delete();
  642. }
  643. }
  644. }
  645. $parcelas = TSession::getValue(__CLASS__ . '_parcelas');
  646. // laço onde add na grid a divisão - os centavos são adicionados na ultima parcela
  647. foreach ($parcelas as $parcela) {
  648. // adiciona as parcelas na grid
  649. $item = new StdClass;
  650. $item->detail_id = empty($parcela->detail_id) ? 'X' . mt_rand(10000000, 19999999) : $parcela->detail_id;
  651. $item->id = $parcela->id;
  652. $item->nosso_numero = $parcela->nosso_numero;
  653. $item->numero_documento = $parcela->numero_documento;
  654. $item->name = $parcela->name;
  655. $item->nomeResp = $parcela->nomeResp;
  656. $item->cpfResp = $parcela->cpfResp;
  657. $item->cepResp = $parcela->cepResp;
  658. $item->logradouroResp = $parcela->logradouroResp;
  659. $item->numeroResp = $parcela->numeroResp;
  660. $item->bairroResp = $parcela->bairroResp;
  661. $item->cidadeResp = $parcela->cidadeResp;
  662. $item->ufResp = $parcela->ufResp;
  663. $item->parcela = $parcela->parcela;
  664. $item->vencimento = DateTime::createFromFormat('d/m/Y', $parcela->vencimento)->format( 'Y-m-d' );
  665. $item->plano_pagamento_nome = $parcela->plano_pagamento_nome;
  666. $item->valor_boleto = ($parcela->valor_boleto);
  667. $item->status_pagamento_id = $parcela->status_pagamento_id;
  668. $this->datagrid->addItem($item);
  669. }
  670. $data = new stdClass;
  671. TForm::sendData('form_aluno', $data);
  672. $this->form->setData($this->form->getData());
  673. TTransaction::close(); // close the transaction
  674. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  675. } catch (Exception $ex) {
  676. new TMessage('error', 'ma oee ' . $ex->getMessage().' file: '.$ex->getFile().' line: '.$ex->getLine());
  677. TTransaction::rollback();
  678. }
  679. }
  680. private function addParcelasAluno($system_aluno, $parcela){
  681. try {
  682. // abri uma transação com banco de dados 'db_guiansoft'
  683. TTransaction::open('db_guiansoft');
  684. $system_aluno_parcela = new SystemAlunoParcela;
  685. $system_aluno_parcela->nosso_numero = $parcela->nosso_numero;
  686. $system_aluno_parcela->numero_documento = $parcela->numero_documento;
  687. $system_aluno_parcela->aluno_id = $system_aluno->id;
  688. $system_aluno_parcela->name = $parcela->name;
  689. $system_aluno_parcela->nomeResp = $parcela->nomeResp;
  690. $system_aluno_parcela->cpfResp = $parcela->cpfResp;
  691. $system_aluno_parcela->cepResp = $parcela->cepResp;
  692. $system_aluno_parcela->logradouroResp = $parcela->logradouroResp;
  693. $system_aluno_parcela->numeroResp = $parcela->numeroResp;
  694. $system_aluno_parcela->bairroResp = $parcela->bairroResp;
  695. $system_aluno_parcela->cidadeResp = $parcela->cidadeResp;
  696. $system_aluno_parcela->ufResp = $parcela->ufResp;
  697. $system_aluno_parcela->valor_boleto = ($parcela->valor_boleto);
  698. $system_aluno_parcela->parcela = $parcela->parcela;
  699. $system_aluno_parcela->plano_pagamento_nome = $parcela->plano_pagamento_nome;
  700. $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
  701. $system_aluno_parcela->status_pagamento_id = $parcela->status_pagamento_id;
  702. $system_aluno_parcela->store(); // salva o objeto
  703. $system_aluno->addSystemAlunoParcela($system_aluno_parcela); // aqui salva a parecela
  704. $system_aluno->store(); // salva o objeto
  705. TTransaction::close(); // close the transaction
  706. } catch (Exception $ex) {
  707. new TMessage('error', 'ma oee ' . $ex->getMessage().' file: '.$ex->getFile().' line: '.$ex->getLine());
  708. }
  709. }
  710. /**
  711. * Show the page
  712. */
  713. public function show() {
  714. parent::show();
  715. }
  716. function onTeste($param) {
  717. echo '<pre>';
  718. print_r($param);
  719. echo '<pre>';
  720. }
  721. /**
  722. * Remove parcela datagrid session
  723. */
  724. public static function deleteBoleto($param)
  725. {
  726. $parcelas = TSession::getValue('datagrid');
  727. unset($parcelas[ $param['id'] ]);
  728. TSession::setValue('datagrid', $parcelas);
  729. }
  730. }
  731. ?>


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 Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework 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.