فهرست منبع

Закончена генерация таблиц

Вадим Королёв 1 سال پیش
والد
کامیت
bab14777fc
1فایلهای تغییر یافته به همراه51 افزوده شده و 68 حذف شده
  1. 51 68
      src/Common/Commands.php

+ 51 - 68
src/Common/Commands.php

@@ -55,11 +55,10 @@ class Commands {
 		"colors"=> [
 			"background"=> [220,220,220],
 			"title_color"=> [30, 30, 30],
-			"body_bg_even"=> [0, 255, 0],
-			"body_bg_odd" => [0, 255, 255],
-			//~ "body_bg_even"=> [180, 180, 170],
-			//~ "body_bg_odd" => [210, 210, 200],
-			"body_fg" => [40, 40, 40]
+			"body_bg_even"=> [180, 180, 170],
+			"body_bg_odd" => [210, 210, 200],
+			"body_fg" => [40, 40, 40],
+            "body_frame" => [25, 25, 25]
 		],
 		"title_font_size"=> 30,
 		"body_font_size"=> 20,
@@ -147,6 +146,26 @@ class Commands {
         $em         = Database::getEM();
         $cache_repo = $em->getRepository(Entities\ImageCache::class);
 
+        // Текст даты
+        switch ($intent) {
+            case DateSelect::ViewStudentRasp:
+                $date_component = \IntlDateFormatter::FULL;
+                $time_component = \IntlDateFormatter::NONE;
+                break;
+            default:
+                $date_component = \IntlDateFormatter::FULL;
+                $time_component = \IntlDateFormatter::FULL;
+                break;
+        }
+        $fmt = datefmt_create(
+            'ru_RU',
+            $date_component,
+            $time_component,
+            'Europe/Kirov',
+            \IntlDateFormatter::GREGORIAN
+        );
+        $date_text = datefmt_format($fmt, $time);
+
         switch ($intent) {
             case DateSelect::ViewStudentRasp:
                 // -1. Получить группу
@@ -179,54 +198,40 @@ class Commands {
                 // 2. Попросить подождать
                 self::askWait($driver, $u);
 
-                //~ // 3. Составить расписание
-                //~ $data = $em->getRepository(Entities\Pair::class)
-                //~ ->getPairsOfScheduleForGroup($schedule);
-
-                //~ $text = "";
-                //~ foreach ($data as $row) {
-                    //~ $time = $row->getTime();
-                    //~ $name = $row->getPairName()->getName();
-                    //~ $details = $row->getConductionDetails();
-
-                    //~ // Составление текста о преподавателе и месте проведения
-                    //~ $details_texts = [];
-                    //~ foreach ($details as $detail) {
-                        //~ $initials = $detail->getEmployee()->getNameWithInitials();
-                        //~ $place = $detail->getPlace()->getName();
-
-                        //~ $details_text[] = $initials.' '.$place;
-                    //~ }
-                    //~ $details_text = implode(' / ', $details_text);
-
-                    //~ $text .= $time->format('H:i');
-                    //~ $text .= $name;
-                    //~ $text .= ":".$details_text;
-                    //~ $text .= "\n";
-                //~ }
-
-                //$driver->sendMessage($u, Message::create($text));
-
-                $data =
-                [
-                    ["Время проведения", "Дисциплина", "Кто проводит"],
-                    ["12:28", "Матеша", "лол хз"],
-                    ["Виталий", "балбесина", "ахахах"],
-                    ["шучу", "шучу", "шучу"],
-                    ["12:28", "не матеша", "аааааааааааааааааааааааааааааааа я шучу жеееееееееееееееее"],
-                ];
+                // 3. Составить расписание
+                $data = $em->getRepository(Entities\Pair::class)
+                ->getPairsOfScheduleForGroup($schedule);
+
+                $table = [["Время", "Дисциплина", "Кто проводит"]];
+
+                foreach ($data as $row) {
+                    $pair_time = $row->getTime();
+                    $name = $row->getPairName()->getName();
+                    $details = $row->getConductionDetails();
+
+                    // Составление текста о преподавателе и месте проведения
+                    $details_texts = [];
+                    foreach ($details as $detail) {
+                        $initials = $detail->getEmployee()->getNameWithInitials();
+                        $place = $detail->getPlace()->getName();
+
+                        $details_text[] = $initials.' '.$place;
+                    }
+                    $details_text = implode(' - ', $details_text);
+
+                    $table[] = [$pair_time->format('H:i'), $name, $details_text];
+                }
 
                 $img = self::generateTable(
-                    $data,
-                    "Расписание на сегодня",
+                    $table,
+                    "Расписание на ".$date_text,
                     self::$theme_schedule,
                     [__CLASS__, "bodyLineDefault"]
                 );
 
                 $success = self::saveImage($img, "schedule");
-                $driver->varDump('success', $success);
 
-                //~ $driver->sendMessage($u, Message::create("gpicview ".$filename));
+                $driver->sendMessage($u, Message::create("OK"));
 
                 break;
             default:
@@ -671,10 +676,6 @@ class Commands {
             );
 		}
 
-        // DEBUG START
-        $gdcolors['dbg_red'] = imagecolorallocate($im, 255, 0, 0);
-        // DEBUG END
-
         // Заполнение заднего фона
 		imagefilledrectangle(
             $im,
@@ -690,24 +691,6 @@ class Commands {
 		$line_y = $theme['padding'] + $theme['title_line_height'];
 		foreach ($title_lines as $line) {
 
-            // DEBUG START
-            $dbgarea = imagettfbbox(
-                $theme['title_font_size'],
-                0,
-                $theme['font'],
-                $line);
-            imagefilledrectangle(
-                $im,
-
-                $theme['padding'],
-                $line_y,
-
-                $theme['padding'] + abs($dbgarea[2] - $dbgarea[0]),
-                $line_y - $theme['title_line_height'],
-
-                $gdcolors['dbg_red']);
-            // DEBUG END
-
             imagettftext(
                 $im,
                 $theme['title_font_size'],
@@ -781,7 +764,7 @@ class Commands {
             $theme['padding'] + $body_width,
             $body_y + $body_height,
 
-            $gdcolors['dbg_red']
+            $gdcolors['body_frame']
         );
         
         #endregion