Jump to content

gmc1103

Members
  • Posts

    258
  • Joined

  • Last visited

Everything posted by gmc1103

  1. Hi Thanks for your reply To explain you i must tell you what a want to achieve The first array ($cronograma) has information about dates,hours and total hours(last is incermented) My full array have this data 2020-09-21 - 2 - 0 - 2 2020-09-22 - 2 - 0 - 2 2020-09-28 - 2 - 0 - 4 2020-09-29 - 2 - 0 - 4 2020-10-06 - 2 - 0 - 6 2020-10-12 - 2 - 0 - 6 2020-10-13 - 2 - 0 - 8 2020-10-19 - 2 - 0 - 8 2020-10-20 - 2 - 0 - 10 2020-10-26 - 2 - 0 - 10 2020-10-27 - 2 - 0 - 12 2020-11-02 - 2 - 0 - 12 2020-11-03 - 2 - 0 - 14 2020-11-09 - 2 - 0 - 14 2020-11-10 - 2 - 0 - 16 2020-11-16 - 2 - 0 - 16 2020-11-17 - 2 - 0 - 18 2020-11-23 - 2 - 0 - 18 2020-11-24 - 2 - 0 - 20 2020-11-30 - 2 - 0 - 20 2020-12-07 - 2 - 0 - 22 2020-12-14 - 2 - 0 - 24 2020-12-15 - 2 - 0 - 22 2021-01-04 - 2 - 0 - 26 2021-01-05 - 2 - 0 - 24 2021-01-11 - 2 - 0 - 28 2021-01-12 - 2 - 0 - 26 2021-01-18 - 2 - 0 - 30 2021-01-19 - 2 - 0 - 28 2021-01-25 - 2 - 0 - 32 2021-01-26 - 2 - 0 - 30 2021-02-01 - 2 - 0 - 34 2021-02-02 - 2 - 0 - 32 2021-02-08 - 2 - 0 - 36 2021-02-09 - 2 - 0 - 34 2021-02-22 - 2 - 0 - 38 2021-02-23 - 2 - 0 - 36 2021-03-01 - 2 - 0 - 40 2021-03-02 - 2 - 0 - 38 2021-03-08 - 2 - 0 - 42 2021-03-09 - 2 - 0 - 40 2021-03-15 - 2 - 0 - 44 2021-03-16 - 2 - 0 - 42 2021-03-22 - 2 - 0 - 46 2021-03-23 - 2 - 0 - 44 2021-04-05 - 2 - 0 - 48 2021-04-06 - 2 - 0 - 46 2021-04-12 - 2 - 0 - 50 2021-04-13 - 2 - 0 - 48 2021-04-19 - 2 - 0 - 52 2021-04-20 - 2 - 0 - 50 2021-04-26 - 2 - 0 - 54 2021-04-27 - 2 - 0 - 52 2021-05-03 - 2 - 0 - 56 2021-05-04 - 2 - 0 - 54 2021-05-10 - 2 - 0 - 58 2021-05-11 - 2 - 0 - 56 2021-05-17 - 2 - 0 - 60 2021-05-18 - 2 - 0 - 58 2021-05-24 - 2 - 0 - 62 2021-05-25 - 2 - 0 - 60 2021-05-31 - 2 - 0 - 64 2021-06-01 - 2 - 0 - 62 2021-06-07 - 2 - 0 - 66 2021-06-08 - 2 - 0 - 64 2021-06-14 - 2 - 0 - 68 2021-06-15 - 2 - 0 - 66 2021-06-22 - 2 - 0 - 68 The second array " ids" is 2 differents school subjects (ex: Mat and English) The third array is related to hours of each school subjects (ex: Mat and English), in this case 34 hours each So my main array start with date (when it starts until when its end (68 hours) What i want is to slit this info So, since i have 2 ids (58, 60) id stardate endDate total 58 2020-09-21 2021-02-01 34 60 2021-02-08 2021-06-22 68 So i can insert into database those values So i started to put foreach for array ids, inside foreach for array cronograma, and inside hours array But the response given is not what i'm looking for
  2. Let me explain my problem. I have an array with dates and numbers in format ($cronograma) Ex: Array ( [2020-09-21] => Array ( [0] => 2020-09-21 [1] => 2 [2] => 2 [3] => 2 ) [2020-09-28] => Array ( [0] => 2020-09-28 [1] => 2 [2] => 2 [3] => 4 ) Then i have another array with 2 ids (in this case 58,60) ($id) Finally i have a third array with numbers only (in this case 34,34) $tot So what i want is cross information beween them, for example for id 58 I must get dates (first element and last element when $tot = 34) for id 60 I must get dates (first element after $tot =34 and last element of array) Whath i have so far is this foreach ($id as $idPlan) { foreach ($cronograma as $c) { $t1 = 0; foreach ($tot as $d) { $t1 += (int)$d['tempos']; if ($c[3] == $t1) { $newAr[] =$idPlan; $newAr[] = $c[0]; } } } } My response array(8) { [0]=> string(2) "58" [1]=> string(10) "2021-02-01" [2]=> string(2) "58" [3]=> string(10) "2021-06-14" [4]=> string(2) "60" [5]=> string(10) "2021-02-01" [6]=> string(2) "60" [7]=> string(10) "2021-06-14" } null So it's clear that i have all repeated I should have a line like: 58 - 2020-09-21 -2021-02-01 Any help?
  3. Hi It does do.. The problem is inside the foreach loop, i have put some echos and this is really strange, if you look my code you willsee a lot of echos to help me to debug if($haveDesdobramento === "1") { if ((isSegunda( $internal_date )) && !isExcludedDate( $internal_date )) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null) { if ($haveDesdobramento === "1" && $haveAllClass === null) { if($totais<=$horasTurnos){ $t = $sum + $temposSegunda; if($t > $horasTurnos){ $n1 = abs($t - $horasTurnos); $temposSegunda = $temposSegunda - $n1; } if ($sameDayShifts === "1") { $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = $temposSegunda; } else{ $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = 0; $total += $temposSegunda; $cronograma[$this_month][] = $total; } } } if ($haveDesdobramento === "1" && $haveAllClass === "1") { echo "1ª Soma:".$sum; print "<br>"; if($sum<$horasAll){ echo "2ª Soma:".$sum; print "<br>"; if(($sum+ $temposSegunda) > $horasAll){ echo "3ª Soma:".($sum+ $temposSegunda); print "<br>"; $n1 = abs(($sum+ $temposSegunda) - $horasAll); $temposSegunda = $temposSegunda - $n1; print "<br>"; } if ($sameDayShifts === "1") { $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = $temposSegunda; } else { echo "aqui 2"; print "<br>"; $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = 0; $total += $temposSegunda; $cronograma[$this_month][] = $total; $sum += $temposSegunda; } } } else{ echo "aqui"; $days = floor($horas/$temposSegunda); $hours_remaining = $horas - $days * $temposSegunda; $cronograma[$this_month][] = $hours_remaining; } } } } And with all those debugs i'm receiving this 1ª Soma:0 2ª Soma:0 aqui 2 1ª Soma:3 2ª Soma:3 aqui 2 1ª Soma:6 2ª Soma:6 aqui 2 1ª Soma:9 2ª Soma:9 aqui 2 1ª Soma:12 2ª Soma:12 aqui 2 1ª Soma:15 2ª Soma:15 aqui 2 1ª Soma:18 2ª Soma:18 aqui 2 1ª Soma:21 2ª Soma:21 aqui 2 1ª Soma:24 2ª Soma:24 aqui 2 1ª Soma:27 2ª Soma:27 aqui 2 1ª Soma:30 2ª Soma:30 aqui 2 1ª Soma:33 2ª Soma:33 aqui 2 1ª Soma:36 2ª Soma:36 aqui 2 1ª Soma:39 2ª Soma:39 aqui 2 1ª Soma:42 2ª Soma:42 aqui 2 1ª Soma:45 2ª Soma:45 aqui 2 1ª Soma:48 2ª Soma:48 aqui 2 1ª Soma:51 2ª Soma:51 aqui 2 1ª Soma:54 2ª Soma:54 aqui 2 1ª Soma:57 2ª Soma:57 aqui 2 1ª Soma:60 2ª Soma:60 aqui 2 1ª Soma:63 2ª Soma:63 aqui 2 1ª Soma:66 2ª Soma:66 aqui 2 1ª Soma:69 2ª Soma:69 aqui 2 1ª Soma:72 2ª Soma:72 aqui 2 1ª Soma:75 2ª Soma:75 aqui 2 1ª Soma:78 2ª Soma:78 aqui 2 1ª Soma:81 2ª Soma:81 aqui 2 1ª Soma:84 2ª Soma:84 aqui 2 1ª Soma:87 2ª Soma:87 aqui 2 1ª Soma:90 2ª Soma:90 aqui 2 1ª Soma:93 2ª Soma:93 aqui 2 1ª Soma:96 2ª Soma:96 aqui 2 1ª Soma:99 2ª Soma:99 3ª Soma:102 aqui 2 1ª Soma:100 1ª Soma:100 And the array is created i have this (last 3 lines) 2021-06-07 - 3 - 0 - 99 2021-06-14 - 1 - 0 - 100 2021-06-21 - 1 - 0 - 100 same in 2 differents dates but i have reached the 100 (hours) in first date (2021-06-14) I don't understand why this last line Thanks
  4. Hello I'm having problems regarding coding right the following problem One class (students) can have class all together or/and divided (haveDesdobramento) into 2 shifts So in the beginning i'm choosing all class and defined 100 hours Using a foreach because i need to check holidays, school breaks, start and end of school foreach (range( 0, $datediff ) as $day) { $internal_date = date( INTERNAL_FORMAT, strtotime( "{$startDate} + {$day} days" ) ); $this_day = date( INTERNAL_FORMAT, strtotime( $internal_date ) ); $this_month = date( INTERNAL_FORMAT, strtotime( $internal_date ) ); if($haveDesdobramento === "1") { if ((isSegunda( $internal_date )) && !isExcludedDate( $internal_date )) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null) { if($sum>=$horasAll){ $nhoras = $sum - $horasAll; $temposSegunda = $temposSegunda - $nhoras; echo "tSegunda: ".$temposSegunda; } if ($haveDesdobramento === "1" && $haveAllClass === null) { if($totais<=$horasTurnos){ if ($sameDayShifts === "1") { $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = $temposSegunda; } else{ $days = floor($horas/$temposSegunda); $hours_remaining = $horas - $days * $temposSegunda; $cronograma[$this_month][] = $hours_remaining; } } } if ($haveDesdobramento === "1" && $haveAllClass === "1") { if($sum<=$horasAll){ if ($sameDayShifts === "1") { $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = $temposSegunda; } else { $cronograma[$this_month][] = $temposSegunda; $cronograma[$this_month][] = 0; $total += $temposSegunda; $cronograma[$this_month][] = $total; } } } else{ $days = floor($horas/$temposSegunda); $hours_remaining = $horas - $days * $temposSegunda; $cronograma[$this_month][] = $hours_remaining; } } $sum += $temposSegunda; } } It works but it stops at 102, not 100 like it should (choosing 3 hours each time) and the array returned gives me this Any help? Thanks 2021-06-07 - 3 - 0 - 99 2021-06-14 - 3 - 0 - 102 Notice: Undefined offset: 1 in /home/esmaior/public_html/miga/db/crud/profissionais/response.php on line 661 2021-06-21 - - 0 - 102 Notice: Undefined offset: 1 in /home/esmaior/public_html/miga/db/crud/profissionais/response.php on line 670 Notice: Undefined offset: 1 in /home/esmaior/public_html/miga/db/crud/profissionais/response.php on line 661 2021-06-28 - - 0 - 102 Notice: Undefined offset: 1 in /home/esmaior/public_html/miga/db/crud/profissionais/response.php on line 670 Total: 102
  5. Hello Barand How are you? You are the best, great option, it works like i want Best regards
  6. Thanks for your reply I need this (58, 59 ), Comunicação Visual, ( 8599, 133) ,49, 11 60, Comunicação Visual, 134, 49, 10
  7. Hello Can somepne help me with this issue I have a query who is returning some records ID disciplina moduloUfcd idcpDisciplinas anoTurma 58, Comunicação Visual, 8599, 49, 11 59, Comunicação Visual, 133, 49, 11 60, Comunicação Visual, 134, 49, 10 When i trying to put this into an array with just one line (merge all with number 49 (idcpDisciplinas) and (anoTurma) 11) i can't get the desired output My sql query is this one select c.idPlan, cD.disciplina, cM.moduloUfcd, p.Nome, t.Turma, a.Ano, c2.curso, c.validCron, c.cronograma, c.dataLimite, c.idProfessor,cM.horas,cM.tempos, c.pdfCronograma, c2.curso, cM.discModulo, cM.idcpDisciplinas, cM.ano as anoTurma from cpDiscProfessores c inner join cpDisciplinas cD on c.idcpDisciplinas = cD.idCpDisciplinas inner join cpModulos cM on c.idCpModulos = cM.idCpModulos inner join professores p on c.idProfessor = p.idProfessor left join turmas t on c.idTurma = t.idTurma inner join anosescolares a on c.idAnoEscolar = a.idAnoEscolar left join cursos c2 on c.idCursos = c2.idCursos where a.Estado = 1; And in php what i have is this $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $final = array(); $json = array(); foreach ($result as $row) { $moduloUfcd= $row['moduloUfcd']; if (!isset($moduloUfcd[$moduloUfcd])) { $horas= $row['horas']; $final[$moduloUfcd]['idPlan'] = $row['idPlan']; $final[$moduloUfcd]['disciplina'] = $row['disciplina']; $final[$moduloUfcd]['Nome'] = $row['Nome']; $final[$moduloUfcd]['Turma'] = $row['Turma']; $final[$moduloUfcd]['anoTurma'] = $row['anoTurma']; $final[$moduloUfcd]['curso'] = $row['curso']; $final[$moduloUfcd]['validCron'] = $row['validCron']; $final[$moduloUfcd]['cronograma'] = $row['cronograma']; $final[$moduloUfcd]['dataLimite'] = $row['dataLimite']; $final[$moduloUfcd]['idProfessor'] = $row['idProfessor']; $final[$moduloUfcd]['pdfCronograma'] = $row['pdfCronograma']; $final[$moduloUfcd]['discModulo'] = $row['discModulo']; $final[$moduloUfcd]['idcpDisciplinas'] = $row['idcpDisciplinas']; $final[$moduloUfcd]['moduloUfcd'] = array(); } $final[$moduloUfcd]['moduloUfcd'][] = $row['moduloUfcd']; $final[$moduloUfcd]['horas'][] = $row['horas']; $final[$moduloUfcd]['tempos'][] = $row['tempos']; } foreach ($final as $moduloUfcd => $cron) { $json[] = $cron; } echo json_encode($json); What it gives is : [ { idPlan: "60", disciplina: "Comunicação Visual", Nome: "XXXXXXXXX", Turma: "11ºO", anoTurma: "11", curso: "Técnico de Audiovisuais", validCron: "-1", cronograma: "0", dataLimite: "2020-10-30", idProfessor: "168", pdfCronograma: "/XXXXX/pdf/profissionais/cronogramas/Cronograma -Técnico de Audiovisuais-8599.pdf", discModulo: "8599", idcpDisciplinas: "49", moduloUfcd: [ "8599" ], horas: [ "25" ], tempos: [ " 34 " ] } ]
  8. Hello Thanks, working Best regards
  9. Hello yes, this is what i'm looging for Thanks for helping me
  10. Hello I'm trying to remove null ou 0 values from my array but i can't get it to work properly This is my array Array ( [0] => Array ( [0] => 2020-09-21 [1] => 3 ) [1] => Array ( [0] => 2020-09-23 [1] => 2 ) [2] => Array ( [0] => 2020-09-28 [1] => 3 ) [3] => Array ( [0] => 2020-09-30 [1] => 2 ) [4] => Array ( [0] => 2020-10-07 [1] => 2 ) [5] => Array ( [0] => 2020-10-12 [1] => 3 ) [6] => Array ( [0] => 2020-10-14 [1] => 2 ) [7] => Array ( [0] => 2020-10-19 [1] => 3 ) [8] => Array ( [0] => 2020-10-21 [1] => 2 ) [9] => Array ( [0] => 2020-10-26 [1] => 3 ) [10] => Array ( [0] => 2020-10-28 [1] => 2 ) [11] => Array ( [0] => 2020-11-02 [1] => 3 ) [12] => Array ( [0] => 2020-11-04 [1] => 2 ) [13] => Array ( [0] => 2020-11-09 [1] => 3 ) [14] => Array ( [0] => 2020-11-11 [1] => 2 ) [15] => Array ( [0] => 2020-11-16 [1] => 3 ) [16] => Array ( [0] => 2020-11-18 [1] => 2 ) [17] => Array ( [0] => 2020-11-23 [1] => 3 ) [18] => Array ( [0] => 2020-11-25 [1] => 2 ) [19] => Array ( [0] => 2020-11-30 [1] => 3 ) [20] => Array ( [0] => 2020-12-02 [1] => 2 ) [21] => Array ( [0] => 2020-12-07 [1] => 3 ) [22] => Array ( [0] => 2020-12-09 [1] => 2 ) [23] => Array ( [0] => 2020-12-14 [1] => 3 ) [24] => Array ( [0] => 2020-12-16 [1] => 2 ) [25] => Array ( [0] => 2021-01-04 [1] => 3 ) [26] => Array ( [0] => 2021-01-06 [1] => 2 ) [27] => Array ( [0] => 2021-01-11 [1] => 3 ) [28] => Array ( [0] => 2021-01-13 [1] => 2 ) [29] => Array ( [0] => 2021-01-18 [1] => 3 ) [30] => Array ( [0] => 2021-01-20 [1] => 2 ) [31] => Array ( [0] => 2021-01-25 [1] => 3 ) [32] => Array ( [0] => 2021-01-27 [1] => 2 ) [33] => Array ( [0] => 2021-02-01 [1] => 3 ) [34] => Array ( [0] => 2021-02-03 [1] => 2 ) [35] => Array ( [0] => 2021-02-08 [1] => 3 ) [36] => Array ( [0] => 2021-02-10 [1] => 2 ) [37] => Array ( [0] => 2021-02-17 [1] => 2 ) [38] => Array ( [0] => 2021-02-22 [1] => 3 ) [39] => Array ( [0] => 2021-02-24 [1] => 2 ) [40] => Array ( [0] => 2021-03-01 [1] => 3 ) [41] => Array ( [0] => 2021-03-03 [1] => 2 ) [42] => Array ( [0] => 2021-03-08 [1] => 3 ) [43] => Array ( [0] => 2021-03-10 [1] => 2 ) [44] => Array ( [0] => 2021-03-15 [1] => 3 ) [45] => Array ( [0] => 2021-03-17 [1] => 2 ) [46] => Array ( [0] => 2021-03-22 [1] => 3 ) [47] => Array ( [0] => 2021-03-24 [1] => 2 ) [48] => Array ( [0] => 2021-04-05 [1] => 3 ) [49] => Array ( [0] => 2021-04-07 [1] => 2 ) [50] => Array ( [0] => 2021-04-12 [1] => 3 ) [51] => Array ( [0] => 2021-04-14 [1] => 2 ) [52] => Array ( [0] => 2021-04-19 [1] => 3 ) [53] => Array ( [0] => 2021-04-21 [1] => 2 ) [54] => Array ( [0] => 2021-04-26 [1] => 3 ) [55] => Array ( [0] => 2021-04-28 [1] => 2 ) [56] => Array ( [0] => 2021-05-03 [1] => 3 ) [57] => Array ( [0] => 2021-05-05 [1] => 2 ) [58] => Array ( [0] => 2021-05-10 [1] => 3 ) [59] => Array ( [0] => 2021-05-12 [1] => 0 ) [60] => Array ( [0] => 2021-05-17 [1] => 3 ) [61] => Array ( [0] => 2021-05-19 [1] => 0 ) [62] => Array ( [0] => 2021-05-24 [1] => 3 ) [63] => Array ( [0] => 2021-05-26 [1] => 0 ) [64] => Array ( [0] => 2021-05-31 [1] => 3 ) [65] => Array ( [0] => 2021-06-02 [1] => 0 ) [66] => Array ( [0] => 2021-06-07 [1] => 3 ) [67] => Array ( [0] => 2021-06-09 [1] => 0 ) [68] => Array ( [0] => 2021-06-14 [1] => 1 ) [69] => Array ( [0] => 2021-06-16 [1] => 0 ) [70] => Array ( [0] => 2021-06-21 [1] => 0 ) [71] => Array ( [0] => 2021-06-23 [1] => 0 ) [72] => Array ( [0] => 2021-06-28 [1] => 0 ) [73] => Array ( [0] => 2021-06-30 [1] => 0 ) ) And i'm using this code to remove but no success print_r(array_values(array_filter($cronograma))); Any help please Thanks
  11. Hello I'm having prblem regarding this query, it gives me the following error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':idCursos' at line 12 The query is the following select c.idPlan, cD.disciplina, cM.moduloUfcd, p.Nome, t.Turma, a.Ano, c2.curso, c.validPlan, c.planificacao, c.dataLimite, c.idProfessor, c.pdf,c.inicio,c.fim,c.objetivos,c.conteudos,c.competencias, c.estrategias, c.recursos, c.avaliacao,c.criado from cpDiscProfessores c inner join cpDisciplinas cD on c.idcpDisciplinas = cD.idCpDisciplinas inner join cpModulos cM on c.idCpModulos = cM.idCpModulos inner join professores p on c.idProfessor = p.idProfessor left join turmas t on c.idTurma = t.idTurma inner join anosescolares a on c.idAnoEscolar = a.idAnoEscolar left join cursos c2 on c.idCursos = c2.idCursos where a.Estado = 1 AND c2.idCursos=:idCursos"); $stmt->bindparam(":idCursos", $idCursos, PDO::PARAM_INT Ok, this query accept one pamater, and i have checked it is not empty array(4) { ["total"]=> string(1) "1" [0]=> string(1) "1" ["idCursos"]=> string(1) "1" [1]=> string(1) "1" } IdCursos: 1 isDC: 1 SOLVED: copy/paste and didn't see i was using "query" instead of "prepare"
  12. Hi Barand...you are the boss. Great solution, it works like a charm. Thank you
  13. Hi Thanks for reading and replying But it stops, you can see he has stopped when $sum > $hours what i expect is to get the same value in variable $hours, and in my array. For example i choose monday and i can work 6 hours, Task is 20 hours, so i need 6+6+6+2, but when the user define 6 hours for each monday i will have 6+6+6+6, total is 24. I was thinking in create a statement inside if($isSegunda != null && $sum<$horas){ if ((isSegunda($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null){ $cronograma[$this_month][] = $temposSegunda; } $sum += $temposSegunda; } So before adding the $temposSegunda into the array, i check the total sum and the task hours, and if i get more hours, i remove the number in excess, in this case i have task hours = 20 and the total is 24, the difference is 4, so how can alter this to write the correct value into the array? Any help? Thanks
  14. Hello I'm trying to get this working but i'm stuck I'm making a program who must define dates and time (hours) to a task So in the beginning i define: how many hours the task will have the week days the max hour per day The following code is working well except if the total is 20, and i have the sum of 18, the script allows to add more than 2 hours before stop the execution Example running the script hours defined: 20 Data: 2020-09-01 -Hours:4 Data: 2020-09-07 -Hours:2 Data: 2020-09-08 -Hours:4 Data: 2020-09-14 -Hours:2 Data: 2020-09-15 -Hours:4 Data: 2020-09-21 -Hours:2 Data: 2020-09-22 -Hours:4 Total: 22 This is my code ( the problem should be inside foreach range code) define('INTERNAL_FORMAT', 'Y-m-d'); $startDate = "2020-09-01"; $start_date1 = strtotime("2020-09-01"); $endDate = strtotime("2021-06-30"); $horas = "20"; $sum = 0; $datediff = round(($endDate - $start_date1) / (60 * 60 * 24)) ; $res = array('01-01','02-25','04-10','04-12','04-25','05-01','06-10', '06-11', '08-15', '10-05', '11-01', '12-01', '12-08', '12-25'); $period = new DatePeriod( new DateTime('2021-03-27'), new DateInterval('P1D'), new DateTime('2021-04-16') ); $arr = array(); foreach ($period as $key => $value) { $arr[] = $value->format('m-d'); } $excluded_dates = array_merge($res, $arr); function isSegunda($date) { return date('w', strtotime($date)) === '1'; } function isTerca($date) { return date('w', strtotime($date)) === '2'; } function isQuarta($date) { return date('w', strtotime($date)) === '3'; } function isQuinta($date) { return date('w', strtotime($date)) === '4'; } function isSexta($date) { return date('w', strtotime($date)) === '5'; } // handle the excluded dates function isExcludedDate($internal_date) { global $excluded_dates; $str2 = substr($internal_date, 5); foreach($excluded_dates as $row){ return in_array($str2, $excluded_dates); } } // something to store months and days $cronograma = array(); $isSegunda = "1"; $isTerca = "2"; $isQuarta = ""; $isQuinta = ""; $isSexta = ""; $temposSegunda = "2"; $temposTerca = "4"; $temposQuarta = "4"; $temposQuinta = "4"; $temposSexta = "4"; foreach(range(0,$datediff) as $day) { $internal_date = date(INTERNAL_FORMAT, strtotime("{$startDate} + {$day} days")); $this_day = date(INTERNAL_FORMAT, strtotime($internal_date)); $this_month = date(INTERNAL_FORMAT, strtotime($internal_date)); if($isSegunda != null && $sum<$horas){ if ((isSegunda($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSegunda != null){ $cronograma[$this_month][] = $temposSegunda; } $sum += $temposSegunda; } } if($isTerca != null && $sum<$horas){ if ((isTerca($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposTerca != null){ $cronograma[$this_month][] = $temposTerca; } $sum += $temposTerca; } } if($isQuarta != null){ if ((isQuarta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposQuarta != null){ $cronograma[$this_month][] = $temposQuarta; } } } if($isQuinta != null){ if ((isQuinta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposQuinta != null){ $cronograma[$this_month][] = $temposQuinta; } } } if($isSexta !=null){ if ((isSexta($internal_date)) && !isExcludedDate($internal_date)) { $cronograma[$this_month][] = $this_day; if($temposSexta != null){ $cronograma[$this_month][] = $temposSexta; } } } } $soma = 0; echo "hours defined: ".$horas; print "<br>"; foreach($cronograma as $month => $days) { $dias = $days[0]; $tempos = $days[1]; echo "Data: ".$dias." -Hours:".$tempos; print "<br>"; $soma+= $days[1]; } echo "Total: ".$soma; Any help? Thanks
  15. Hi Barand Done Thanks
  16. Hello In my query i have x activities, then i have the count of how many still to be executed, i need to get the percentage of the total executed I mean i have 200 activities, 20 have been executed, so i want to have 10% done My query is this one but missing the percentage field SELECT COUNT(*) AS total, IFNULL(SUM(CASE WHEN (t1.dataPrevista >= CURDATE() OR ae.Fim <= CURDATE()) THEN 1 ELSE 0 END),0) AS exec FROM atividades AS t1 INNER JOIN anosescolares AS ae ON (t1.`idAnoEscolar` = ae.idAnoEscolar) WHERE ae.Estado = 1; any help?
  17. Hi Thank you. For the first item yes it does, but i have 5 items, then i want the percentage of each one.
  18. Hi I need some help regarding a chart i'm trying to make regarding my table data This is the structure CREATE TABLE `rel_atividades_avaliacao` ( `id_avaliacao` int(11) NOT NULL AUTO_INCREMENT, `id_atividades` int(11) NOT NULL, `avaliado` varchar(3) COLLATE utf8_bin NOT NULL DEFAULT '-1', `data_prevista` varchar(50) COLLATE utf8_bin NOT NULL, `motivo` varchar(300) COLLATE utf8_bin DEFAULT '-', `adequacaos` int(11) NOT NULL, `participacaos` int(11) NOT NULL, `consecucaos` int(11) NOT NULL, `disps` int(11) NOT NULL, `mats` int(11) NOT NULL, `balanco` varchar(300) COLLATE utf8_bin NOT NULL, `ficheiro` varchar(300) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id_avaliacao`), KEY `id_atividades` (`id_atividades`), CONSTRAINT `rel_atividades_avaliacao_ibfk_1` FOREIGN KEY (`id_atividades`) REFERENCES `atividades` (`id_atividades`) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=533 DEFAULT CHARSET=utf8 COLLATE=utf8_bin The chart should be regarding those 5 elements `adequacaos` int(11) NOT NULL, `participacaos` int(11) NOT NULL, `consecucaos` int(11) NOT NULL, `disps` int(11) NOT NULL, `mats` int(11) NOT NULL, Those 5 elements accept numbers between 1 to 5, 1(poor) and 5 (Excellent) So my chart must be how many times 1, 2,3,4,5 has been chosed in each table atributes Any help? Thanks
  19. Thanks But i keep the rel_visitas_utilizador table? with id_visita and id_user?
  20. I understand the application, When the user schedule the study visit, the data is inserted into the visitas table, then the id generated in the table visitas is inserted into the rel_visitas_utilizador. My question was if that implementation (all tables are correct or can they can be improved). The table rel_visitas_utilizador is where is keeped some extra informations about that visit (like pdf file, validate or not, realizado(made or not), etc). About the 1-N, I doubt since rel_visitas_utilizador should only keep one id, can't be repeated
  21. Hi Requinix Right now is what i see in the database. For me it's sound a little confusing. I understand the schema, but regarding the point you mention it seems it's 1_N from visitas to rel_visitas_utilizador..
  22. Hi I'm still developing my database and now i have another task So in my school i have teachers, table Utilizador id_utilizador(teacher) The table visitas have the following data. id; classroom_id; place_visit; date_leaving; hour_leaving; date_arriving; hour_arriving; subjects(teachers subjects); teachers; objectives; transportation; price; students(how many); itinerary; observations; id_year (school year; registered (date) Classroom table turmas id_turma(classroom_id); classroom_name active(yes/no) My related table rel_visitas_utilizador id_visita(foreign key); id_utilizador(foreign key) done(yes/no) valid(yes/no) file(pdf generated and saved in webserver path) So right now this is how this work, teh process A teacher must can schedule a study visit, when he fill the form, all the data from form are sent the the manager and he must define if this visit is valid or no (rel_visitas_utilizador). So with the following explanation and the image provided can someone give me some suggestions to improve this database? Any questions, just ask
  23. Ok Let me show what i have Using this query SELECT dpt FROM visitas_estudo WHERE id_visita = 28 I have dpt --------- 4,6,2,3 this is 4 (id's) regarding the departamentos table So i need to get those values (ids) and using a foreach loop get all the subjects of that. That's why i have 2 query, first one to get all the id's and then with those id's making another query to get the subject, attach all the an array and then send it to pdf file the return should be something like Artes, Ciências Sociais e Humanas,Linguas Estrangeiras,Matemática e Informática,Português
  24. Hi Jacques No..let me explain What is stored into the database is some id's, that's the way they want. What i need is get all the id's and then return the values of those id's for instance id 1 ......Math 2.......Portuguese 3.......English and so on. So, when i want to get all the subjects, i need to get them from the id stored in the database. About the code, first i want to collect the id's stored in the dpt field; second, from the array, i execute the loop to get the values of each id and store them in an array; then i have all subjects in a string Maybe isn't the best approach but i'm still learning Regards
×
×
  • 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.