Jump to content

gmc1103

Members
  • Posts

    258
  • Joined

  • Last visited

Everything posted by gmc1103

  1. Let me tell you that you have a fantastic way of helping...Congratulations What have you done so far is telling me 0. Why i have this problem? No one clue. If it is the way you are here for helping those who want to learn.....let me tell you, nobody will By the way...i have fixed with $_SESSION.... Thank you for.....nothing.
  2. Ok.. Let me start again and trying to explain me better This is my class class ESMAIOR { private $email; public $db; public $turma; public $professor; function __construct($DB_con) { $this->db = $DB_con; } public function getEmail() { return $this->email; } public function setEmail($email) { $this->email = $email; } public function getTurma() { return $this->turma; } public function setTurma($turma) { $this->turma = $turma; } public function getProfessor() { return $this->professor; } public function setProfessor($professor) { $this->professor = $professor; } The user fill a form, the values of that form are registered into database with this function inside the class public function novaAula($atividade, $turmas, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $id_professor){ try{ $stmt = $this->db->prepare("INSERT INTO `aulas_exterior` (`atividade`,`id_turma`,`local`,`data_aula`,`inicio`,`fim`,`fundamentacao`,`observacoes`) VALUES (:atividade,:id_turma,:local,:data_aula,:inicio,:fim,:fundamentacao,:observacoes);"); $stmt->bindparam(":atividade", $atividade); $stmt->bindparam(":local", $local); $stmt->bindparam(":data_aula", $dataAula); $stmt->bindparam(":inicio", $inicio); $stmt->bindparam(":fim", $fim); $stmt->bindparam(":fundamentacao", $fundamentacao); $stmt->bindparam(":observacoes", $observacoes); $turma = explode(',', $turmas); foreach ($turma as $id_turma) { $stmt->bindParam(':id_turma', $id_turma, PDO::PARAM_INT); $result = $stmt->execute(); $idAula = $this->db->lastInsertId(); $this->insertPedidoByLastId($idAula,$id_professor, $id_turma); $nome_turma = $this->getTurmaById($id_turma); $nome_professor = $this->getNomeById($id_professor); $this->setTurma($nome_turma); $this->setProfessor(($nome_professor)); $this->getTurmaeProfessor(); } if (!$result) { print_r($stmt->errorInfo()); return array('status' => 'error', 'message' => 'Problema ao gravar esta nova atividade...'); } else{ return array('status' => 'success', 'message' => 'O pedido foi criado com sucesso...'); } } catch (Exception $ex) { echo $ex->getMessage(); } } In this function i use the following lines $nome_turma = $this->getTurmaById($id_turma); // call this fucntion to get the name by id $nome_professor = $this->getNomeById($id_professor);// call this fucntion to get the name by id $this->setTurma($nome_turma); //setting the name in variable defined outside the function $this->setProfessor(($nome_professor));//setting the name in variable defined outside the function $this->getTurmaeProfessor(); //Call the method i want to use the return without arguments since i have set the variables i need Inside this funtion getTurmaeProfessor() public function getTurmaeProfessor(){ $myArr[] = $this->getProfessor(); //Getting the teacher name $myArr[] = $this->getTurma(); // Getting the class name print_r($myArr); } //With this print i see i'm receiving the variables - Array ( [0] => Tony Morias [1] => 5ºA ) Until now everything is ok. Now i need to print a pdf (another file) with the name of teacher and the name of class <?php error_reporting(E_ALL); ini_set('display_errors', 1); include_once '../db/dbconfig.php'; $esmaior = new ESMAIOR($DB_con); require_once __DIR__ . '/../vendor/autoload.php'; set_include_path('../src/' . PATH_SEPARATOR . get_include_path()); $dados = $esmaior->getTurmaeProfessor(); if(!$dados){ echo "sem dados"; } print_r($dados); //print_r($dados) gives me - Array ( [0] => [1] => ) So i don't see why i'm not receiving the values, it seems the variables setted disapears... Thanks
  3. I know you not attack me, maybe i do have to learn more PHP, with Java and never had this issue. Have you an logic explanation for not receiving the values outside the function?? I'm lost Regards
  4. Hi Jacques I know methods.....the problem is not getting the values i'm expecting For example i have this method public function getTurmaeProfessor(){ global $myArr; $myArr[] = $this->getProfessor(); $myArr[] = $this->getTurma(); print_r($myArr); return $myArr; } The print_r gives me this Array ( [0] => Name of someone [1] => 5ºA ) When i call this method from outside function i have empty array.....normal?? I don't think so. The variables seems to disapear...and as you can see they are there, so what's hapening? If i put a local variable...the method works, with the getters only works inside that function
  5. Hi Jacques Thanks for your apport. First you don't see all the method. The following receives variables from an "insert method" public function newPdfPedido($atividade, $id_turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $id_professor){} And after receiving those variables i must keep them in array and then call that method from the other page. The problem is this method expects variables, so the best way to do will be using getter and setters.
  6. Hi i understand this.....but i don't want to pass parameters here list($atividade, $id_turma, $turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $professor)= $esmaior->newPdfPedido(); i want to receive those parameters.... So...my function receives the parameters public function newPdfPedido($atividade, $id_turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $id_professor){ return array($atividade, $id_turma, $turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $professor); } And in the final of this function...i want to send parameters with return to the new file So how can i get the return array values to that new file?
  7. Hi I nedd some help regarding this function public function newPdfPedido($atividade, $id_turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $id_professor){ try{ $stmt = $this->db->prepare("SELECT `turma` FROM `turmas` WHERE `id_turma`=:id_turma;"); $stmt->execute(array(":id_turma" => $id_turma)); $userRow = $stmt->fetch(PDO::FETCH_ASSOC); $turma = $userRow['turma']; if($turma == ""){ print_r($stmt->errorInfo()); } else{ $stmt = $this->db->prepare("SELECT `nome` FROM `professor` WHERE `id_prof` = :id_prof;"); $stmt->execute(array(":id_prof" => $id_professor)); $prof = $stmt->fetch(PDO::FETCH_ASSOC); $professor = $prof['nome']; if($professor == ""){ print_r($stmt->errorInfo()); } else{ return array($atividade, $id_turma, $turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $professor); } } } catch (Exception $ex) { echo $ex->getMessage(); } } and then i want to get the values here in another file list($atividade, $id_turma, $turma, $local, $dataAula, $inicio, $fim, $fundamentacao, $observacoes, $professor)= $esmaior->newPdfPedido(); echo $atividade; and i'm getting those errors Warning: Missing argument 1 for ESMAIOR::newPdfPedido() Warning: Missing argument 2 for ESMAIOR::newPdfPedido() Warning: Missing argument 3 for ESMAIOR::newPdfPedido() Warning: Missing argument 4 for ESMAIOR::newPdfPedido() Warning: Missing argument 5 for ESMAIOR::newPdfPedido() Warning: Missing argument 6 for ESMAIOR::newPdfPedido() Warning: Missing argument 7 for ESMAIOR::newPdfPedido() Warning: Missing argument 8 for ESMAIOR::newPdfPedido() Warning: Missing argument 9 for ESMAIOR::newPdfPedido() But i want the values from the array...
  8. Hi Jacques1 I have fixed that....i can't believe, it was really stupid...look at those two I've posted this one $myArray = explode(',', $id_escola); foreach ($myArray as $id) { $stmt->bindParam(':id_escola', $id, PDO::PARAM_INT); $result = $stmt->execute(); $idAtividade = $this->db->lastInsertId(); $this->insertByLastId($idAtividade,$id_professor); $this->setDadosEstatisticosAtividades($idAtividade, $id_escola, $dominios); } Function called $escolas = explode(',', $id_escola); $dominio = explode(',', $dominios); foreach ($escolas as $id) { foreach ($dominio as $ids) { $stmt->bindparam(":id_atividades", $idAtividade); $stmt->bindParam(':id_escola', $id, PDO::PARAM_INT); $stmt->bindParam(':id_dominios', $ids, PDO::PARAM_INT); $result = $stmt->execute(); } if (!$result) { print_r($stmt->errorInfo()); } } Now i have this one and it works foreach ($myArray as $id) { $stmt->bindParam(':id_escola', $id, PDO::PARAM_INT); $result = $stmt->execute(); $idAtividade = $this->db->lastInsertId(); $this->insertByLastId($idAtividade,$id_professor); foreach ($dominio as $id_dominio){ $this->setDadosEstatisticosAtividades($idAtividade, $id, $id_dominio); } } As you can the variable $id_escola is in 2 different places...tha's why i had 9 instead of 3 Thanks
  9. The tags are correct. I ahve resolved the problem using str_replace Thanks alll
  10. Hi I'm having problem in my last function. I need to add into a relational table several records $myArray = explode(',', $id_escola); foreach ($myArray as $id) { print_r($id); $stmt->bindParam(':id_escola', $id, PDO::PARAM_INT); $result = $stmt->execute(); $idAtividade = $this->db->lastInsertId(); $this->insertByLastId($idAtividade,$id_professor); $this->setDadosEstatisticosAtividades($idAtividade, $id_escola, $dominios); } The return of this is ok. id_prof id_atividades avaliacao path ------- ------------- --------- -------- 364 1 0 0 364 2 0 0 364 3 0 0 Exemple... array of 3 returns in 3 records, the problem is this last function $this->setDadosEstatisticosAtividades($idAtividade, $id_escola, $dominios); This function is the following try{ $stmt = $this->db->prepare("INSERT INTO `estatistica_atividades` (`id_atividades`,`id_escola`,`id_dominios`) VALUES(:id_atividades,:id_escola,:id_dominios) ;"); $escolas = explode(',', $id_escola); $dominio = explode(',', $dominios); foreach ($escolas as $id) { foreach ($dominio as $ids) { $stmt->bindparam(":id_atividades", $idAtividade); $stmt->bindParam(':id_escola', $id, PDO::PARAM_INT); $stmt->bindParam(':id_dominios', $ids, PDO::PARAM_INT); $result = $stmt->execute(); } if (!$result) { print_r($stmt->errorInfo()); } } }catch (PDOException $e) { echo $e->getMessage(); } Instead of having 3 records.....i have 9 id_atividades id_escola id_dominios ------------- --------- ------------- 1 1 1 1 2 1 1 3 1 2 1 1 2 2 1 2 3 1 3 1 1 3 2 1 3 3 1 any explanation why?
  11. Is not a mess...is the way they should be open and close div tag, for each input
  12. Yes i want...but then i have this form destino=Madeira instead of destino = Madeira
  13. <div class="modal fade bs-example-modal-lg" id="myModalAvaliacaoVisita" role="dialog" aria-labelledby="confirmDeleteLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header modal-header-danger"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3><i class="glyphicon glyphicon-trash"></i> Avaliação da Visita</h3> </div> <div class="modal-body"> <form id="avaliacaoVisita" class="form"> <div class="form-group"> <label class="col-xs-12">Destino</label> <input class="form-control" name="destino" id="destino"> </div> <div class="form-group nivel"> <label class="col-xs-8">Nível de ensino em que se integra a visita (pode selecionar várias opções) *</label> <div class="col-xs-4"> <div class="checkbox"> <input type="checkbox" name="nivel[]" value="1º ciclo" id="nivel"/> <label for="nivel">1º ciclo</label> </div> <div class="checkbox"> <input type="checkbox" name="nivel[]" value="2º ciclo" id="nivel" /> <label for="nivel">2º ciclo</label> </div> <div class="checkbox"> <input type="checkbox" name="nivel[]" value="3º ciclo" id="nivel" /> <label for="nivel">3º ciclo</label> </div> <div class="checkbox"> <input type="checkbox" name="nivel[]" value="Secundário" id="nivel" /> <label for="nivel">Secundário</label> </div> <div class="checkbox"> <input type="checkbox" name="nivel[]" value="Cursos Profissionais" id="nivel" class="styled" /> <label for="nivel">Cursos Profissionais</label> </div> </div> </div> <div class="form-group"> <label class="col-xs-12 control-label"> Dinamizadores da Visita de Estudo</label> <input type="text" class="form-control" name="dinamizadores" id="dinamizadores" /> </div> <div class="form-group"> <label for="recipient-name" class="col-xs-12">Data:</label> <input class="form-control" name="data" id="data"> </div> <div class="form-group"> <label class="col-xs-4">A Visita de Estudo foi realizada na data prevista?</label> <div class="col-xs-8"> <div class="radio-inline"> <input type="radio" name="realizado" value="Sim" id="realizado" /> <label for="sim">Sim</label> </div> <div class="radio-inline"> <input type="radio" name="realizado" value="Realizou-se numa data diferente" id="realizado" class="styled" /> <label for="outradata">Realizou-se numa data diferente</label> </div> <div class="radio-inline"> <input type="radio" name="realizado" value="Não se realizou" id="realizado" class="styled" /> <label for="nao">Não se realizou</label> </div> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-danger">Atualizar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button> </div> </form> </div> </div> </div> </div> Thsi is my form
  14. Hi I have a problem regarding the serialized form This is the problem, when i press submit the values are correct in the main file destino Funchal nivel[] 1º ciclo nivel[] 2º ciclo nivel[] 3º ciclo dinamizadores sSasA data 2016-05-25 realizado Sim motivo ASasAS colaboradores adequacao 1 participacao 2 consecucao 3 disponibilidade 4 pontos SDASDASD aspetos DSADASDSA id_visita 1 avaliacaoVisita avaliacaoVisita But in the second file the form received is this one form destino=Madeira nivel[] 2º ciclo nivel[] Secundário dinamizadores dsasdasd data 2016-05-22 realizado Sim motivo colaboradores adequacao 1 participacao 2 consecucao 3 disponibilidade 4 pontos sdadsasd aspetos sdasdadsa id_visita 2 avaliacaoVisita avaliacaoVisita And i'm trying to get the variables to fill my pdf and the first value is wrong because i havedestino Funchal and the return is form destino=Madeira To send i use function criaAvaliacaoPdfVisita() { var myform = $('#avaliacaoVisita'); var formulario = myform.serialize(); window.open("http://xxxxxxxxx/xxxxx/pdf/pdfVisitas.php?form=" + formulario, "_blank"); } Any help?
  15. The problem was here: I miss those lines use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;
  16. Hi Can someone help me with the following issue Fatal error: Class 'PHPMailer' not found I have installed the phpmailer from composer....so i don't undertstand whats going on This is my composer.json { "name": "vendor_name/package_name", "description": "site esmaior", "minimum-stability": "stable", "license": "proprietary", "authors": [ { "name": "GMC", "email": "[email protected]" } ], "require": { "phpmailer/phpmailer": "6.0.x-dev" } } This is my function to send email file "class.esmaior.pt" public function enviarEmailVisitas(){ $mail = new PHPMailer; $mail->isSendmail(); $mail->setFrom('[email protected]', 'First Last'); $mail->addReplyTo('[email protected]', 'First Last'); $mail->addAddress('[email protected]', 'John Doe'); $mail->Subject = 'PHPMailer sendmail test'; $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); $mail->AltBody = 'This is a plain-text message body'; $mail->addAttachment('images/phpmailer_mini.png'); if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } } And the autoload is inserted in the file "class.esmaior.pt" error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once "dbconfig.php"; require_once __DIR__ . '/../vendor/autoload.php'; setlocale(LC_ALL, NULL); setlocale(LC_ALL, 'pt_PT'); Any help,
  17. Hi Jacques I have managed to put it working doing this $reservationsAry[$reservationID]['items'] = ' '.$row['equip1'].' ; '.$row['equip2'].' '; instead of creating another array $reservationsAry[$reservationID]['items'] = array(); Now it is working, i don't know if it is the best approach but it is working What do you thing? Thanks
  18. Hi Jacques I don't know, but it is possible to create another array to manage that? Thanks
  19. Hi I have an array who inside have another one This is how it is printed Array ( [0] => Array ( [idreserva] => 703 [sala] => 7 - INF [data] => 2016-05-28 [inicio] => 21:00:00 [fim] => 23:30:00 [equip1] => Leitor / CD/ USB [equip2] => Projetor [atividade] => [usernome] => xxxxx [items] => Array ( [0] => Leitor / CD/ USB ; Projetor ) [num] => 1 ) ) And when i try to tup this in a pdf, the last array can't be printed This is my code foreach ($result as $row){ $reservationID = $row['idreserva']; if(!isset($reservationsAry[$reservationID])) { $reservationsAry[$reservationID]['idreserva'] = $row['idreserva']; $reservationsAry[$reservationID]['sala'] = $row['sala']; $reservationsAry[$reservationID]['data'] = $row['data']; $reservationsAry[$reservationID]['inicio'] = $row['inicio']; $reservationsAry[$reservationID]['fim'] = $row['fim']; $reservationsAry[$reservationID]['equip1'] = $row['equip1']; $reservationsAry[$reservationID]['equip2'] = $row['equip2']; $reservationsAry[$reservationID]['atividade'] = $row['atividade']; $reservationsAry[$reservationID]['usernome'] = $row['usernome']; $reservationsAry[$reservationID]['items'] = array(); } //Adiciona os equipamentos $reservationsAry[$reservationID]['items'][] = ' '.$row['equip1'].' ; '.$row['equip2'].' '; } foreach($reservationsAry as $reservationID => $reservation) { $ixx = $ixx + 1; $data_chegada[] = array_merge($reservation, array('num' => $ixx)); print_r($data_chegada); } } And use this line to print the pdf $pdf->ezTable($data_chegada, $titles, '', $parametros_adicionales); All fields are printed but not "items" Any help?
  20. Hi Can someone help me with a query? I have a table named (ex order) and the related one named (order_detail) My main table has the order_id and the user_id and the related table has the order_id, the product_id etc. What i need i the get all the products from that order_id, each time i try it gives me several lines This is what i have idreserva idutilizador data atividade --------- ------------ ---------- ----------- 23 670 2016-05-14 and the related table idreserva idequipamento idtempoInicio idtempoFim idsala registado --------- ------------- ------------- ---------- ------ ------------ 23 1 1 2 6 2016-05-12 23 6 1 2 6 2016-05-12 23 11 1 2 6 2016-05-12 And i have this query SELECT t6.`idreserva`, t5.`sala`, t6.`data`,t3.`inicio`, t4.`fim`, t6.`atividade`, t2.`nome` FROM `req_reserva_detail` AS t1 INNER JOIN `req_material_equipamento` AS t2 ON (t1.`idequipamento` = t2.`idequipamento`) INNER JOIN `req_material_tempo` AS t3 ON (t1.`idtempoInicio` = t3.`idtempo`) INNER JOIN `req_material_tempo` AS t4 ON (t1.`idtempoFim` = t4.`idtempo`) INNER JOIN `req_material_sala` AS t5 ON (t1.`idsala` = t5.`idsala`) INNER JOIN `req_reservas` AS t6 ON (t1.`idreserva` = t6.`idreserva`) INNER JOIN `utilizador` AS t7 ON (t6.`idutilizador` = t7.`idutilizador`) WHERE t6.`idutilizador` = 670 AND t6.`data` >= CURDATE() ORDER BY DATA ASC Gives me this idreserva sala data inicio fim atividade nome --------- ------- ---------- -------- -------- --------- ------------------ 23 6 - INF 2016-05-14 08:15:00 09:45:00 Leitor / CD/ USB 23 6 - INF 2016-05-14 08:15:00 09:45:00 Projetor 23 6 - INF 2016-05-14 08:15:00 09:45:00 TV+DVD+VHS And i would like to have only one idreserva, sala, data, inicio, fim and all the "nome" like an invoice Any help?
  21. Hi I have fixed this with all of you. Thanks Barand,Mac_gyver and Jacques1 The problem was the return inside the loop. I used $result = $stmt->execute();~ //then if (!$result) Best regards
  22. Hi Barand moving the return outside the loop? Loop {} Retunr array Is that? Mac Yes it is true...i don't need the if statement to check since i have try/catch
  23. Still updating only the first one... I have checked the input 343,256,245,265,287,201,210,275,271,260 And when it go to my function i have this when i use print_r($idDocentes); echo "-----"; print_r($myArray); 124 343,256,245,265,287,201,210,275,271,260 Array ( [0] => 343 [1] => 256 [2] => 245 [3] => 265 [4] => 287 [5] => 201 [6] => 210 [7] => 275 [8] => 271 [9] => 260 )
  24. Hi Barand Only the first one is changed This is the code public function editMultiDocenteGrupo($idDocentes, $mudaGrupo){ try { $stmt = $this->db->prepare("UPDATE `esmaior_ca`.`professor` SET `teacher_grupo` = :teacher_grupo WHERE `idteacher` = :idteacher"); $myArray = explode(',', $idDocentes); foreach($myArray as $id){ $stmt->bindParam(':teacher_grupo', $mudaGrupo, PDO::PARAM_INT); $stmt->bindParam(':idteacher', $id, PDO::PARAM_STR); if (!$stmt->execute()) { print_r($stmt->errorInfo()); return array('status' => 'error', 'message' => 'Opppss...no updates..'); } else { return array('status' => 'success', 'message' => 'All changes updated...'); } } } catch (PDOException $e) { echo $e->getMessage(); } } I have 12, but only the first one is updated...
  25. Hi Barand I'm receiving two variables (idteacher, groupteacher) in this function One comes with delimited commas to put into an array With this array represents a teacher_id number. So if i want to update the groupteacher number in for examples 12 teachers my update function must be in a loop for every idteacher selected update groupteacher
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.