$var: ${$var}
";
}
/**
* @var $section Section
*/
/**
* @var $proj Project
*/
if ($dayplan_clear_all)
{
$str = "delete from asusg_dayplan";
mysqli_query($link, $str);
echo "clear";
}
if ($dayplan_clear)
{
$str = "delete from asusg_dayplan where day=cast(now() as date)";
mysqli_query($link, $str);
echo "clear";
}
if ($dayplan)
{
if ($loco_number && $date && $letter && $company && $priority)
{
$str = "insert into asusg_dayplan (letter, loco_num, priority, day, company) values ('$letter', $loco_number, $priority, '$date', $company)";
mysqli_query($link, $str);
echo "$loco_number $date $letter $company $priority";
}
}
if ($get_sections_from_twx)
{
// var_dump($get_sections_from_twx);
$proj = Project::Find($get_sections_from_twx);
if (isset($proj))
{
$sections = $proj->getSections();
foreach ($sections as $section)
{
$dm = $section->diagnostic_map;
// echo $section->getSectionSubnumber()." dm $dm";
echo $section->UpdateDiagnosticMap(true);
}
}
//request section from twx
//if ok - write to base, else = echo data fail
}
if ($letter_tasktype && $letter)
{
$tt = Tasktype::Find($letter_tasktype);
if ($tt != null)
{
$tt->letter = $letter;
$tt->Save();
}
//echo "letter_tasktype $letter_tasktype";
}
if ($project_complete)
{
$proj = Project::Find($project_complete);
if ($proj)
{
$res = $proj->Complete($userId);
echo "project_complete: $project_complete" ;
// var_dump($res);
}
}
if ($write_project_to_twx)
{
$proj = Project::Find($write_project_to_twx);
if ($proj)
{
$res = $proj->checkPointsWrite();
// echo "write_project_to_twx:" ;
// var_dump($res);
}
}
if ($pt_addseries)
{
$ptype = ProjectType::Find($pt_addseries);
if ($ptype != null) {
if (sizeof($ptype->series) > 0) {
echo "Доступные серии локомотивов:
";
foreach ($ptype->series as $serie)
echo "$serie->name
";
}
$serie = LocoSeries::Find($series);
if ($serie) {
$ptype->addSeries($serie);
$ptype->Save();
}
}
}
if ($showseries)
{
/**
* @var $ptype ProjectType
*/
$ptype = ProjectType::Find($showseries);
if ($ptype != null) {
if (sizeof($ptype->series) > 0) {
echo "Добавленные серии локомотивов:
";
foreach ($ptype->series as $serie)
echo "$serie->name
";
}
$tts = $ptype->getTasktypes();
if (sizeof($tts) > 0) {
/**
* @var $tt Tasktype
*/
$letters = array();
foreach ($tts as $tt) {
if ($tt->letter != '' && !in_array($tt->letter, $letters)) {
$letters[] = $tt->letter;
}
}
sort($letters);
if (sizeof($letters) > 0) {
echo "
Введите субномера секций:
";
foreach ($letters as $letter) {
echo "$letter:
";
}
}
}
}
}
if ($getsectionlist)
{
require_once "api_getsectionlist.php";
echo TWXrequest();
}
if (intval($delsection)> 0) {
$section = Section::Find($delsection);
if ($section) {
if (sizeof($section->projects) == 0) {
Section::Delete($delsection);
echo "Section $delsection deleted!!";
}
else
echo "Error: Section has projects";
}
}
if ($getseries)
{
if ($getseries > 0)
{
$pt = ProjectType::Find($getseries);
$series = $pt->series;
}
else
$series = LocoSeries::GetAll();
$arr = array();
//$series = $getseries
foreach ($series as $serie) {
/**
* @var $serie LocoSeries
*/
$numsec = sizeof($serie->getSectionsWithUUID());
$numproj = $serie->projectsAmount();
$numsecall = sizeof($serie->sections);
$arr[$serie->id] = array($serie->name, $numsec, $numsecall, $numproj);
}
echo json_encode($arr);
}
if ($addseries)
{
$serie = new LocoSeries();
$serie->name = $addseries;
$serie->Save();
}
/** @var string $addsections серия локомотива */
/** @var int $number номер локомотива */
/** @var int $subnumber номер секции */
/** @var string $section_letter буква секции */
if ($addsections)
{
$serie = LocoSeries::Find($addsections);
if ($serie != null) {
$section = new Section();
$section->setSectionNumber($number);
$section->setSectionSubnumber($subnumber);
$section->setLetter($section_letter);
$serie->addSection($section);
$serie->Save();
echo "Секция добавлена!";
} else {
echo "serie not found";
}
}
if ($getsections)
{
// FindBySeries
$arr = array();
$ls = LocoSeries::Find($getsections);
$sections = $ls->sections;
// $sections = $ls->getSectionsWithUUID(true);
// $sections = Section::FindBySeries($getsections, true);
// $array = $hydrator->extract($data);
foreach ($sections as $section) {
$section->projectsAmount = sizeof($section->projects);
array_push($arr, $section->toArray());
}
// echo sizeof($arr);
echo json_encode($arr);
// var_dump($arr);
// echo "Get Sections!! $section";
}
if ($getsectioncontent)
{
$section = Section::Find($getsectioncontent);
$retarr = array();
if ($section != null)
{
// $section->diagnostic_maps = $section->diagnostic_maps->toArray();
// $proj = $section->project;
$projIds = array();
foreach ($section->projects as $p)
{
array_push($projIds, $p->id);
}
$section->test = $projIds;
array_push($retarr,$section->toArray());
array_push($retarr,$section->diagnostic_maps->toArray());
array_push($retarr,$projIds);
// echo "DK: ".sizeof($section->diagnostic_maps);
echo json_encode($retarr);
//echo json_encode($section->toArray());
//echo json_encode($section->diagnostic_maps->toArray());
}
}