Пример #1
1
 public function actionPrintRaspisanie()
 {
     if (!isset($_GET['kurs'])) {
         throw new ErrorException('Kurs is required');
     }
     $kurs_id = $_GET['kurs'];
     $schedule = [];
     $sql = 'select
                 z.data,
                 z.nomer,
                 t.nazvanie as tema,
                 z.forma,
                 fl.familiya,
                 fl.imya,
                 fl.otchestvo,
                 a.nazvanie as auditoriya,
                 rpt.nazvanie as tip_rabot
             from zanyatie as z
             inner join zanyatie_chasti_temy as zct on z.id = zct.zanyatie
             inner join tema as t on zct.tema = t.id
             inner join podrazdel_kursa as pk on t.podrazdel = pk.id
             inner join razdel_kursa as rk on pk.razdel = rk.id
             inner join auditoriya as a on z.auditoriya = a.id
             inner join fiz_lico as fl on z.prepodavatel = fl.id
             inner join rabota_po_teme as rpt on t.tip_raboty = rpt.id
             where rk.kurs = :kurs_id
             order by z.data, z.nomer';
     $data = Yii::$app->db->createCommand($sql)->bindValue(':kurs_id', $kurs_id)->queryAll();
     foreach ($data as $item) {
         if (!isset($schedule[$item['data']])) {
             $schedule[$item['data']] = [];
         }
         $schedule[$item['data']][] = $item;
     }
     $kurs = \app\records\Kurs::findOne($kurs_id);
     $content = $this->renderPartial('/pdf/raspisanie.php', ['kurs' => $kurs, 'schedule' => $schedule]);
     $pdf = new Pdf($this->getPdfSeetings($content, 'Расписание курса "' . $kurs->nazvanie . '"'));
     // return the pdf output as per the destination setting
     return $pdf->render();
 }
Пример #2
0
 private function saveInternal()
 {
     parent::save(false);
     $this->unlinkAll('kategorii_slushatelej_rel', true);
     // user select
     foreach ($this->kategorii_slushatelej as $id) {
         /* @var $kat KategoriyaSlushatelya */
         if ($kat = KategoriyaSlushatelya::findOne($id)) {
             $this->link('kategorii_slushatelej_rel', $kat);
         }
     }
     // user input
     if (isset($this->kategorii_slushatelej_input)) {
         foreach ($this->kategorii_slushatelej_input as $name) {
             $kat = new KategoriyaSlushatelya();
             $kat->nazvanie = $name;
             $kat->save();
             $this->link('kategorii_slushatelej_rel', $kat);
         }
     }
     //garbage-collect unused kategorii
     $unusedKats = KategoriyaSlushatelya::find()->select('kategoriya_slushatelya.id')->leftJoin('kategoriya_slushatelya_kursa', 'kategoriya_slushatelya.id = kategoriya_slushatelya_kursa.kategoriya_slushatelya')->where(['kategoriya_slushatelya_kursa.kategoriya_slushatelya' => null])->groupBy('kategoriya_slushatelya.id');
     foreach ($unusedKats->asArray()->batch() as $rows) {
         KategoriyaSlushatelya::deleteAll(['id' => array_filter($rows)]);
     }
     return true;
 }
Пример #3
0
 public function search($params)
 {
     $query = Kurs::find()->joinWith('kategorii_slushatelej_rel')->joinWith('rukovoditel_rel')->groupBy(['kurs.id', 'fiz_lico.id'])->orderBy('kurs.id')->filterWhere(['extract(year from {{kurs}}.[[plan_prospekt_god]])' => ArrayHelper::getValue($params, 'year')]);
     if ($this->load($params) && $this->validate()) {
         $query->andFilterWhere(['like', 'lower(kurs.nazvanie)', $this->nazvanie])->andFilterWhere(['kategoriya_slushatelya.id' => $this->kategorii_slushatelej])->andFilterWhere(['tip' => $this->tip])->andFilterWhere(['rukovoditel' => $this->rukovoditel])->andFilterWhere(['raschitano_chasov' => $this->raschitano_chasov])->andFilterWhere(['>=', 'least([[ochnoe_nachalo]], [[zaochnoe_nachalo]])', $this->nachnutsya_posle])->andFilterWhere(['<=', 'greatest([[ochnoe_konec]], [[zaochnoe_konec]])', $this->zakonchatsya_do]);
     }
     $sort = new Sort(['attributes' => ['nazvanie', 'formy_obucheniya', 'raschitano_slushatelej', 'finansirovanie', 'tip', 'raschitano_chasov', 'rukovoditel_rel' => ['asc' => ['fiz_lico.familiya' => SORT_ASC, 'fiz_lico.imya' => SORT_ASC, 'fiz_lico.otchestvo' => SORT_ASC], 'desc' => ['fiz_lico.familiya' => SORT_DESC, 'fiz_lico.imya' => SORT_DESC, 'fiz_lico.otchestvo' => SORT_DESC]], 'vremya_provedeniya' => ['asc' => ['least([[ochnoe_nachalo]], [[zaochnoe_nachalo]])' => SORT_ASC], 'desc' => ['least([[ochnoe_nachalo]], [[zaochnoe_nachalo]])' => SORT_DESC]]]]);
     return new ActiveDataProvider(['sort' => $sort, 'query' => $query]);
 }
Пример #4
0
 public function actionIndex($kurs)
 {
     // todo can rule
     $kursRecord = Kurs::findOne($kurs);
     if (!$kursRecord) {
         throw new NotFoundHttpException();
     }
     $query = Slushatel::findForKurs($kurs)->orderBy(['kurs_fiz_lica.status' => SORT_ASC, 'fiz_lico.familiya' => SORT_ASC, 'fiz_lico.imya' => SORT_ASC, 'fiz_lico.otchestvo' => SORT_ASC]);
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     return $this->render('index', compact('provider', 'kursRecord'));
 }
Пример #5
0
 public function init()
 {
     parent::init();
     $this->modules = ['raspisanie' => RaspisanieModule::className(), 'potok' => PotokModule::className()];
     $this->activeRelationMap = [\app\records\FizLico::className() => FizLico::className(), \app\records\Kurs::className() => Kurs::className(), \app\records\RabotaFizLica::className() => RabotaFizLica::className()];
 }
Пример #6
0
 private function deleteImpl()
 {
     $this->unlinkAll('kategorii_slushatelej_rel', true);
     return parent::delete();
 }
Пример #7
0
 /**
  * @return ActiveQuery
  */
 public function getKurs_rel()
 {
     return $this->hasOne(Kurs::className(), ['id' => 'kurs'])->inverseOf('razdely_kursa_rel');
 }