Jump to content

gmc1103

Members
  • Posts

    251
  • Joined

  • Last visited

Everything posted by gmc1103

  1. 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?
  2. 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...
  3. 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
  4. The tags are correct. I ahve resolved the problem using str_replace Thanks alll
  5. 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?
  6. Is not a mess...is the way they should be open and close div tag, for each input
  7. Yes i want...but then i have this form destino=Madeira instead of destino = Madeira
  8. <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
  9. 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?
  10. The problem was here: I miss those lines use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception;
  11. 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": "test@gmail.com" } ], "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('xxxxx@xxxx.pt', 'First Last'); $mail->addReplyTo('xxxxx@xxxx.pt', 'First Last'); $mail->addAddress('xxxxx@xxxx.pt', '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,
  12. 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
  13. Hi Jacques I don't know, but it is possible to create another array to manage that? Thanks
  14. 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?
  15. 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?
  16. 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
  17. 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
  18. 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 )
  19. 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...
  20. 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
  21. Hi I'm having problems(no updates) in my databases using this 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=> $mudaGrupo){ $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(); } } The array is this one when i user print_r Array ( [0] => 343 [1] => 256 [2] => 245 [3] => 265 [4] => 287 [5] => 201 [6] => 210 [7] => 275 [8] => 271 [9] => 260 ) i receive the success message but no changes are registered in the table Any help?
  22. Hi Barand So, do you suggest to have a foreign key between "apoio" and "timetable"?
  23. Hi Barand Ok, let me try to clarify everything This is a school management system. Teachers have timetable Timetable have teachears, students and subject I need to for every teachers timetable to have a lesson. So, if my season starts on september and i have 35 school weeks, i must "give" 35 lessons, so must store 35 lessons in database. To do so, today, regarding my timetable, i have classe between 2 PM and 4 PM, so after or during the class time i must be able to fill that form( regarding the plan lesson, missing students, etc), but if i forgot to do it, i want to have a warning to remember that lesson x has not been registered. To avoid any confusion...this is my sql script Hope now it can be clear.. esmaior_ca.zip
  24. Hi Barand The data is inserted into the database, this table "apoios" CREATE TABLE `apoios` ( `idtimetable` int(11) NOT NULL AUTO_INCREMENT, `sala_id` int(11) NOT NULL, `data` date NOT NULL, `inicio_id` time NOT NULL, `grupo` time NOT NULL, `teacher_sub_teacher_idteacher` int(11) NOT NULL, `teacher_sub_subject_idsubject` int(11) NOT NULL, `teacher_sub_turma_idturma` int(11) NOT NULL, PRIMARY KEY (`idtimetable`), KEY `fk_timetable_teacher_sub1_idx` (`teacher_sub_teacher_idteacher`,`teacher_sub_subject_idsubject`,`teacher_sub_turma_idturma`), KEY `sala_id` (`sala_id`), CONSTRAINT `apoios_ibfk_1` FOREIGN KEY (`sala_id`) REFERENCES `salas` (`idsala`), CONSTRAINT `fk_timetable_teacher_sub1` FOREIGN KEY (`teacher_sub_teacher_idteacher`, `teacher_sub_subject_idsubject`, `teacher_sub_turma_idturma`) REFERENCES `prof_disc` (`teacher_idteacher`, `subject_idsubject`, `turma_idturma`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEF This is the table where the data inserted in the form will be saved. My main issue here is this table CREATE TABLE `timetable` ( `id_timetable` int(11) NOT NULL AUTO_INCREMENT, `id_grupo` int(11) NOT NULL, `id_dia` int(11) NOT NULL, `id_tempo` int(11) NOT NULL, `id_prof` int(11) NOT NULL, PRIMARY KEY (`id_timetable`), KEY `id_grupo` (`id_grupo`), KEY `id_dia` (`id_dia`), KEY `id_tempo` (`id_tempo`), CONSTRAINT `timetable_ibfk_1` FOREIGN KEY (`id_grupo`) REFERENCES `grupos` (`id_grupos`), CONSTRAINT `timetable_ibfk_2` FOREIGN KEY (`id_dia`) REFERENCES `dias` (`id_dia`), CONSTRAINT `timetable_ibfk_3` FOREIGN KEY (`id_tempo`) REFERENCES `tempos` (`id_tempo`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; This is my timetable table where i have all classes scheduled. So, between those two tables how i can check if teacher A has filled the form for hhis scheduled classes? Thanks
  25. Hi Barand Sorry for not be so clear as i should. Well, in every classe the teacher must insert into the datatable the subject of the classe, for example if i have a classe of math on monday at 12:00, i must fill in a form the following data Subject Data Classe Missing Student Somy question is, how can i prevent a teacher of not fill the form...since every week (monday) i have this classe and he must fill that form every monday? Thanks
×
×
  • 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.