Jump to content

gmc1103

Members
  • Posts

    247
  • Joined

  • Last visited

gmc1103's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

2

Community Answers

  1. I'm trying to run a query but my outcome is not what i need. So the problem is: A user can be diretor and if this is the case he can see all activities from his department, and he can be user of another department too, in this case not director but only user. I have 8 departments each with one director, so the following query should give me the activities of the department and the activities of this particular user in other department: SELECT t1.idAtividade, t1.idProfessor, t2.Escola, t1.Atividade, t1.Periodo, t1.Mes, t1.haveClasses, t1.DataPrevista, t1.Destinatarios, t1.Orcamento, t1.PdfAtividade, t1.Avaliacao, t1.PdfAvaliacao, t1.idProfessor, p.Nome, d.Departamento, p2.Projeto, t1.idProjeto FROM atividades AS t1 INNER JOIN professores p on t1.idProfessor = p.idProfessor RIGHT JOIN atividadesgrupos ag on t1.idAtividade = ag.idAtividade RIGHT JOIN departamentosatividades da on t1.idAtividade = da.idAtividade RIGHT JOIN departamentos d on da.idDepartamento = d.idDepartamento INNER JOIN escolas AS t2 ON (t2.idEscola = t1.idEscola) INNER JOIN anosescolares AS ae ON (t1.idAnoEscolar = ae.idAnoEscolar) INNER JOIN projetos p2 on t1.idProjeto = p2.idProjeto WHERE ae.Estado = 1 AND da.idDepartamento = 8 ORDER BY (t1.idProfessor = 60) DESC, t1.idProfessor; This query is not working because the department have 22 activities but this user (idProfessor) has 5 in this department and 14 more in another department (defined by idGrupo) I think i will need a subquery right?
  2. Hi Kicken Thank's for helping me. You are right about your explanation. I have followed your explaination and tried your code but there is an error, the var_export of the code provided gives me this array array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-22', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-23', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-29', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-09-30', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-06', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-07', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-13', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-14', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '718', 'idCpModulos' => '318', 'dataAula' => '2020-10-20', 'tempos' => '1', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-10-20', 'tempos' => '3', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-10-27', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-10-28', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-03', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-04', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-10', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-11', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-17', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-18', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-24', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-11-25', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-02', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-09', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-15', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2020-12-16', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2021-01-05', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '719', 'idCpModulos' => '319', 'dataAula' => '2021-01-06', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-12', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-13', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-19', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-20', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-26', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-01-27', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-02-02', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-02-03', 'tempos' => '4', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( 'idPlan' => '720', 'idCpModulos' => '320', 'dataAula' => '2021-02-09', 'tempos' => '1', 'tempos2' => '0', 'dataCriado' => '2020-10-27 17:52:00', )array ( ) When it reachs this line in your code $date = $level2['dataAula']; I have this error <b>Warning</b>: Illegal string offset 'dataAula' But when i see the array, it looks right to me.....what do i missing? Thanks
  3. Hello I have an array where i want the join values (not sum) where the date are the same This my array(var_export) array ( 0 => array ( 0 => array ( 0 => array ( 'dataAula' => '2020-09-21', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 4, ), ), 1 => array ( 1 => array ( 'dataAula' => '2020-09-22', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 8, ), ), 2 => array ( 2 => array ( 'dataAula' => '2020-09-28', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 12, ), ), 3 => array ( 3 => array ( 'dataAula' => '2020-09-29', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 16, ), ), 4 => array ( 4 => array ( 'dataAula' => '2020-10-06', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 20, ), ), 5 => array ( 5 => array ( 'dataAula' => '2020-10-12', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 24, ), ), 6 => array ( 6 => array ( 'dataAula' => '2020-10-13', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 28, ), ), 7 => array ( 7 => array ( 'dataAula' => '2020-10-19', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 32, ), ), 8 => array ( 8 => array ( 'dataAula' => '2020-10-20', 'tempos' => 1, 'tempos2' => 'Terça', 'total' => 33, ), ), ), 1 => array ( 0 => array ( 0 => array ( 'dataAula' => '2020-10-20', 'tempos' => 3, 'tempos2' => 'Segunda', 'total' => 3, ), ), 1 => array ( 1 => array ( 'dataAula' => '2020-10-27', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 7, ), ), 2 => array ( 2 => array ( 'dataAula' => '2020-11-02', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 11, ), ), 3 => array ( 3 => array ( 'dataAula' => '2020-11-03', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 15, ), ), 4 => array ( 4 => array ( 'dataAula' => '2020-11-09', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 19, ), ), 5 => array ( 5 => array ( 'dataAula' => '2020-11-10', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 23, ), ), 6 => array ( 6 => array ( 'dataAula' => '2020-11-16', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 27, ), ), 7 => array ( 7 => array ( 'dataAula' => '2020-11-17', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 31, ), ), 8 => array ( 8 => array ( 'dataAula' => '2020-11-23', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 35, ), ), 9 => array ( 9 => array ( 'dataAula' => '2020-11-24', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 39, ), ), 10 => array ( 10 => array ( 'dataAula' => '2020-11-30', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 43, ), ), 11 => array ( 11 => array ( 'dataAula' => '2020-12-07', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 47, ), ), 12 => array ( 12 => array ( 'dataAula' => '2020-12-14', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 51, ), ), 13 => array ( 13 => array ( 'dataAula' => '2020-12-15', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 55, ), ), 14 => array ( 14 => array ( 'dataAula' => '2021-01-04', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 59, ), ), 15 => array ( 15 => array ( 'dataAula' => '2021-01-05', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 63, ), ), 16 => array ( 16 => array ( 'dataAula' => '2021-01-11', 'tempos' => 4, 'tempos2' => 'Segunda', 'total' => 67, ), ), ), 2 => array ( 0 => array ( 0 => array ( 'dataAula' => '2021-01-12', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 4, ), ), 1 => array ( 1 => array ( 'dataAula' => '2021-01-18', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 8, ), ), 2 => array ( 2 => array ( 'dataAula' => '2021-01-19', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 12, ), ), 3 => array ( 3 => array ( 'dataAula' => '2021-01-25', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 16, ), ), 4 => array ( 4 => array ( 'dataAula' => '2021-01-26', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 20, ), ), 5 => array ( 5 => array ( 'dataAula' => '2021-02-01', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 24, ), ), 6 => array ( 6 => array ( 'dataAula' => '2021-02-02', 'tempos' => '4', 'tempos2' => 'Terça', 'total' => 28, ), ), 7 => array ( 7 => array ( 'dataAula' => '2021-02-08', 'tempos' => '4', 'tempos2' => 'Segunda', 'total' => 32, ), ), 8 => array ( 8 => array ( 'dataAula' => '2021-02-09', 'tempos' => 1, 'tempos2' => 'Terça', 'total' => 33, ), ), ), )[] So, for example i have repeated the date 2020-10-20, one with "tempos =1" and another with "tempos=3" I'm looking to have only one date with concatened tempos field Example array ( 'dataAula' => '2020-10-20', 'tempos' => 1+3, 'tempos2' => 'Terça', 'total' => 33, ), So what i have now is this code but not getting what i need foreach ($finalCronograma as $sub) { $row = current($sub); if (isset($result[$row[0]['dataAula']])) { $result[$row[0]['dataAula']]['tempos'] .= '+' . $row[0]['tempos']; } else { $result[$row[0]['dataAula']] = $sub; } } any help?
  4. No, no limit But usually a class don't have more than 7/8 hours week in specific subject(for instance, multimedia have in one subject with 8 hours per week, 3 hours with all student class + 5 hours each group(class divided in 2) Sending my form to get full picture Regards
  5. Hi Barand Thanks for helping Let me explain all the process Here, in Portugal, we have professional school for students who don't want to go to unervisity. The student have 3 years to finish this. All subjects ( math , english, etc) have more than one module. I mean, Math have 10 modules, each one must have a grade to have a final classification, Portuguese have 12 modules, English 6...and so on. Every teacher must do a scheduler for all modules (The teacher choose the subject, then, the year (10,11,12),. After choosing the year the system print out wich modules he must give to students. After that he chooses the starting date, the days he gonna gives classes and the hours for each day. Finally the system will generate the scheduler for all year modules. What About your questions 1. what the inputs to this process are? Inputs are subjects, year, starting date, days, hours 2. what the goal of the process is . The goal is create a scheduler 3. what the rules are to achieve the goal and what the constraints are. Rules are only defined the school year calendar and holidays 4. what T1, T2, shift3, shift4 are . T1 is all classes for monday, T2 is all classes for tuesday,T3 is all classes for wednesday, etc shift1 is for monday when the classes is divided in 2 (covid 19) shift2 is for tuesday shift3 is for wednesday So imagine this scenario I choose Math,year 10, the system gonna print 3 modules Module 1 - 34 hours Module 2 - 44 hours Module 1 - 60 hours The classes is divided in 2 groups, each one in diffetent day, suppose monday and wednesday so i use an array shift1 to have all classes dates for group 1 in monday so i use an array shift3 to have all classes dates for group 2 in wedenesday it is clear now or more information is needed? Sorry about my english, Thanks
  6. Hi Iv'e create 5 differents arrays for each week day. Usually there is only 2 students groups, but in some cases, i can have all the student class in one day or more + 2 others days for groups (class divided in 2) $cronograma = array(); $shift1 = array(); $shift2 = array(); $shift3 = array(); $shift4 = array(); $shift5 = array(); So my main array is called cronograma, and the others are (by days week, monday,etc) at the end i'm using array_merge jo merge non empty arrays In the following example i have 2 week days with all class (Monday and Tuesday), T1 and T2 in array And i have 2 groups shifts in another 2 days (wednesday, thursday), Shift3 and shift4 This is the produced final array 2020-10-19 - 1 - T1 - 1 2020-10-20 - 2 - T2 - 3 2020-10-26 - 1 - T1 - 4 2020-10-27 - 2 - T2 - 6 2020-11-02 - 1 - T1 - 7 2020-11-03 - 2 - T2 - 9 2020-11-09 - 1 - T1 - 10 2020-11-10 - 2 - T2 - 12 2020-11-16 - 1 - T1 - 13 2020-11-17 - 2 - T2 - 15 2020-11-23 - 1 - T1 - 16 2020-11-24 - 2 - T2 - 18 2020-11-30 - 1 - T1 - 19 2020-12-07 - 1 - T1 - 20 2020-12-14 - 1 - T1 - 21 2020-12-15 - 2 - T2 - 23 2021-01-04 - 1 - T1 - 24 2021-01-05 - 2 - T2 - 26 2021-01-11 - 1 - T1 - 27 2021-01-12 - 2 - T2 - 29 2021-01-18 - 1 - T1 - 30 2021-01-19 - 2 - T2 - 32 2021-01-25 - 1 - T1 - 33 2021-01-26 - 2 - T2 - 35 2021-02-01 - 1 - T1 - 36 2021-02-02 - 2 - T2 - 38 2021-02-08 - 1 - T1 - 39 2021-02-09 - 2 - T2 - 41 2021-02-22 - 1 - T1 - 42 2021-02-23 - 2 - T2 - 44 2021-03-01 - 1 - T1 - 45 2021-03-02 - 2 - T2 - 47 2021-03-08 - 1 - T1 - 48 2021-03-09 - 2 - T2 - 50 2021-03-15 - 1 - T1 - 51 2021-03-16 - 2 - T2 - 53 2021-03-22 - 1 - T1 - 54 2021-03-23 - 2 - T2 - 56 2021-04-05 - 1 - T1 - 57 2021-04-06 - 2 - T2 - 59 2021-04-12 - 1 - T1 - 60 2021-04-13 - 2 - T2 - 62 2021-04-19 - 1 - T1 - 63 2021-04-20 - 2 - T2 - 65 2021-04-26 - 1 - T1 - 66 2021-04-27 - 2 - T2 - 68 2021-05-03 - 1 - T1 - 69 2021-05-04 - 2 - T2 - 71 2021-05-10 - 1 - T1 - 72 2021-05-11 - 2 - T2 - 74 2021-05-17 - 1 - T1 - 75 2021-05-18 - 2 - T2 - 77 2021-05-24 - 1 - T1 - 78 2021-05-25 - 2 - T2 - 80 2021-05-31 - 1 - T1 - 81 2021-06-01 - 2 - T2 - 83 2021-06-07 - 1 - T1 - 84 2021-06-08 - 2 - T2 - 86 2021-06-14 - 1 - T1 - 87 2021-06-15 - 2 - T2 - 89 2021-06-21 - 1 - T1 - 90 2021-06-22 - 2 - T2 - 92 2021-06-28 - 1 - T1 - 93 2021-06-29 - 2 - T2 - 95 2021-07-05 - 1 - T1 - 96 2021-07-06 - 2 - T2 - 98 2021-07-12 - 1 - T1 - 99 2021-07-13 - 1 - T2 - 100 2020-10-21 - 5 - Shift3 - 5 2020-10-28 - 5 - Shift3 - 10 2020-11-04 - 5 - Shift3 - 15 2020-11-11 - 5 - Shift3 - 20 2020-11-18 - 5 - Shift3 - 25 2020-11-25 - 5 - Shift3 - 30 2020-12-02 - 5 - Shift3 - 35 2020-12-09 - 5 - Shift3 - 40 2020-12-16 - 5 - Shift3 - 45 2021-01-06 - 5 - Shift3 - 50 2021-01-13 - 5 - Shift3 - 55 2021-01-20 - 5 - Shift3 - 60 2021-01-27 - 5 - Shift3 - 65 2021-02-03 - 5 - Shift3 - 70 2021-02-10 - 5 - Shift3 - 75 2021-02-17 - 5 - Shift3 - 80 2021-02-24 - 5 - Shift3 - 85 2021-03-03 - 5 - Shift3 - 90 2021-03-10 - 5 - Shift3 - 95 2021-03-17 - 5 - Shift3 - 100 2021-03-24 - 5 - Shift3 - 105 2021-04-07 - 5 - Shift3 - 110 2021-04-14 - 5 - Shift3 - 115 2021-04-21 - 5 - Shift3 - 120 2021-04-28 - 5 - Shift3 - 125 2021-05-05 - 5 - Shift3 - 130 2021-05-12 - 5 - Shift3 - 135 2021-05-19 - 5 - Shift3 - 140 2021-05-26 - 5 - Shift3 - 145 2021-06-02 - 5 - Shift3 - 150 2021-06-09 - 5 - Shift3 - 155 2021-06-16 - 5 - Shift3 - 160 2021-06-23 - 5 - Shift3 - 165 2021-06-30 - 1 - Shift3 - 166 2020-10-22 - 5 - Shift4 - 5 2020-10-29 - 5 - Shift4 - 10 2020-11-05 - 5 - Shift4 - 15 2020-11-12 - 5 - Shift4 - 20 2020-11-19 - 5 - Shift4 - 25 2020-11-26 - 5 - Shift4 - 30 2020-12-03 - 5 - Shift4 - 35 2020-12-10 - 5 - Shift4 - 40 2020-12-17 - 5 - Shift4 - 45 2021-01-07 - 5 - Shift4 - 50 2021-01-14 - 5 - Shift4 - 55 2021-01-21 - 5 - Shift4 - 60 2021-01-28 - 5 - Shift4 - 65 2021-02-04 - 5 - Shift4 - 70 2021-02-11 - 5 - Shift4 - 75 2021-02-18 - 5 - Shift4 - 80 2021-02-25 - 5 - Shift4 - 85 2021-03-04 - 5 - Shift4 - 90 2021-03-11 - 5 - Shift4 - 95 2021-03-18 - 5 - Shift4 - 100 2021-04-08 - 5 - Shift4 - 105 2021-04-15 - 5 - Shift4 - 110 2021-04-22 - 5 - Shift4 - 115 2021-04-29 - 5 - Shift4 - 120 2021-05-06 - 5 - Shift4 - 125 2021-05-13 - 5 - Shift4 - 130 2021-05-20 - 5 - Shift4 - 135 2021-05-27 - 5 - Shift4 - 140 2021-06-03 - 5 - Shift4 - 145 2021-06-17 - 5 - Shift4 - 150 2021-06-24 - 5 - Shift4 - 155 2021-07-01 - 5 - Shift4 - 160 2021-07-08 - 5 - Shift4 - 165 2021-07-15 - 1 - Shift4 - 166 So T1 and T2 must have 100 hours total - done Shift3 and shift4 must have 166 hours total - done Now i must: each id(subject) apply 50 hours of t1 and t2 each id(subject apply 80 hours of Shift3 and shift4 So i need foreach to iterate between them first is array of subject id second is array subjects hours and third is the main array right?
  7. Hello Ok iv'e changed my code and now i have arrays for each group. Now i must check wich array are not empty and compare with hours arrays, right? Regards
  8. Ok I will change the main code and let u know tomorrow...now here is 1 AM. Thanks mate, see u tomorrow.
  9. What i have so far is this $newAr = array(); //array $id = explode(',',$idPlan); //string to array (subjects id) foreach ($id as $idPlan) { foreach ($tot as $t){ //array with hours $tempos = (int)$t['tempos']; } foreach($cronograma as $c){ //where i have all dates and hours per day if($c[3]<= $tempos){ $newAr[] = $idPlan; $newAr[] = $c[0]; } } print "<br>"; echo "data: ".$idPlan; print "<br>"; print_r($newAr); } The result is this dados: 58 Array ( [0] => 58 [1] => 2020-09-21 [2] => 58 [3] => 2020-09-28 [4] => 58 [5] => 2020-10-12 [6] => 58 [7] => 2020-10-19 [8] => 58 [9] => 2020-10-26 [10] => 58 [11] => 2020-11-02 [12] => 58 [13] => 2020-11-09 [14] => 58 [15] => 2020-11-16 [16] => 58 [17] => 2020-11-23 [18] => 58 [19] => 2020-11-30 [20] => 58 [21] => 2020-12-07 [22] => 58 [23] => 2020-12-14 [24] => 58 [25] => 2021-01-04 [26] => 58 [27] => 2021-01-11 [28] => 58 [29] => 2021-01-18 [30] => 58 [31] => 2021-01-25 [32] => 58 [33] => 2021-02-01 ) dados: 60 Array ( [0] => 58 [1] => 2020-09-21 [2] => 58 [3] => 2020-09-28 [4] => 58 [5] => 2020-10-12 [6] => 58 [7] => 2020-10-19 [8] => 58 [9] => 2020-10-26 [10] => 58 [11] => 2020-11-02 [12] => 58 [13] => 2020-11-09 [14] => 58 [15] => 2020-11-16 [16] => 58 [17] => 2020-11-23 [18] => 58 [19] => 2020-11-30 [20] => 58 [21] => 2020-12-07 [22] => 58 [23] => 2020-12-14 [24] => 58 [25] => 2021-01-04 [26] => 58 [27] => 2021-01-11 [28] => 58 [29] => 2021-01-18 [30] => 58 [31] => 2021-01-25 [32] => 58 [33] => 2021-02-01 [34] => 60 [35] => 2020-09-21 [36] => 60 [37] => 2020-09-28 [38] => 60 [39] => 2020-10-12 [40] => 60 [41] => 2020-10-19 [42] => 60 [43] => 2020-10-26 [44] => 60 [45] => 2020-11-02 [46] => 60 [47] => 2020-11-09 [48] => 60 [49] => 2020-11-16 [50] => 60 [51] => 2020-11-23 [52] => 60 [53] => 2020-11-30 [54] => 60 [55] => 2020-12-07 [56] => 60 [57] => 2020-12-14 [58] => 60 [59] => 2021-01-04 [60] => 60 [61] => 2021-01-11 [62] => 60 [63] => 2021-01-18 [64] => 60 [65] => 2021-01-25 [66] => 60 [67] => 2021-02-01 ) So, my code is changing id subject but is starts again in first array element Iv'e checked and i know why, originaly hours array have 2 elements (34,34), so with this foreach foreach ($tot as $t){ $tempos = (int)$t['tempos']; } it is starting again with 0 until reaching 34 and no 68 like i pretend in second iteration Whats wrong?
  10. Exactly I'm trying to figure out how to do it...i'm lost 😄
  11. 2 groups, 2 subjects So i must have 4 in my array
  12. Yes, this chart belongs to a case with class with only 14 students and only one subject with 4 hours each time. For instance, the school have classes with only 14 students so no need more than one group. In this case or other similar there is 2 groups, and each group can have classes in different days (this case), that's why you see 2,2, 4,4, etc The most important is to separate subject by id getting the start date and the end date because i can store into database the start and the end of each subject
  13. I understand your questions and they are really important to avoid any problem. In this case the most important is last dates because is when the subjetcs end. If they are rescheduled a note must be writen by the teacher, Rigth now, the most important is to separate subject by id getting the start date and the end date. See the image with only one subject, now they ask me to have only one example like this with more than one subject
  14. Because this array is organized in 2 class groups, each group must have 68 hours Since covid 19, a class can't have more than 15 students In this case i must have 2 groups, thats why i have 2 different dates for 34 and 68 hours
  15. 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
×
×
  • 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.