123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- require_once "doctrine/bootstrap.php";
- require_once "auth.php";
- //пример 461 3ЭС5К
- function GetCounters($projectId, $checkpointtype)
- {
- global $link;
- $cs = array();
- $str = "select spl.tid, spl.value,tt.name from (select t.id as tid, t.parent_id as id, ch.value from checkpoints as ch
- LEFT JOIN tasks AS t ON ch.parent_task_id = t.id
- LEFT JOIN projects_locotech AS pl ON t.input_id = pl.id
- WHERE pl.id = $projectId and ch.type = $checkpointtype ) as spl
- LEFT JOIN tasks AS ts ON spl.id = ts.id
- LEFT JOIN tasktypes AS tt ON ts.type = tt.id";
- $query1 = mysqli_query($link, $str);
- while ($res1 = mysqli_fetch_assoc($query1)) {
- $cs[] = $res1;
- }
- return $cs;
- }
- function GetCounterArray($loco_number, $loco_type)
- {
- global $entityManager;
- $retarr = array();
- //limit=1: последний проект по данному локомотиву
- $projs = $entityManager->getRepository('Project')->findBy(array('loco_number' => $loco_number, 'loco_type' => $loco_type),
- array('id' => 'DESC'), 1);
- foreach ($projs as $proj) {
- $sectionArr = array();
- $thrust = GetCounters($proj->id, 310);
- $recuperation = GetCounters($proj->id, 311);
- $i = 0;
- foreach ($thrust as $thr)
- {
- $task = Task::Find($thr['tid']);
- if ($task)
- {
- $section = $task->getSection();
- $sectionArr[] = $loco_number.$section->letter."/".$section->getSectionSubnumber();
- $sectionArr[] = $thr['value'];
- $sectionArr[] = $recuperation[$i]['value'];
- }
- $i++;
- }
- $retarr[] = $sectionArr;
- }
- //var_dump($retarr);
- return $retarr;
- }
|