<div class="peoples-index"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'peopleFIO', ['attribute' => 'peopleBirthday', 'format' => 'raw', 'value' => function ($data) { return date('d.m.Y', strtotime($data->peopleBirthday)); }], ['attribute' => 'peopleWorking', 'value' => 'peopleWorking0.workingName'], ['attribute' => 'fluInfo', 'format' => 'raw', 'value' => function ($data) { $res = ""; if ($data->peopleFluResult == 0) { $res = '<span class="label label-danger">Патологія</span>'; } else { $res = '<span class="label label-success">Норма</span>'; } return $data->peopleFluNumber . "<br/>" . date('d.m.Y', strtotime($data->peopleFluDate)) . "<br/>" . $res; }], ['attribute' => 'graft', 'format' => 'raw', 'value' => function ($data) { $r = ""; $findRes = graftsPeoples::find()->where(['peopleId' => $data->peopleId])->all(); foreach ($findRes as $f) { $graftName = Grafts::find()->where(['graftId' => $f['graftId']])->all(); $r .= '<span class="label label-primary">' . $graftName[0]['graftName'] . '</span> '; } return $r; }], ['attribute' => 'chronic', 'format' => 'raw', 'value' => function ($data) { $r = ""; $findRes = chronicDiseasesPeoples::find()->where(['peopleId' => $data->peopleId])->all(); foreach ($findRes as $f) { $chronicDiseasesName = chronicDiseases::find()->where(['chronicDiseasesId' => $f['chronicDiseasesId']])->all(); $r .= '<span class="label label-primary">' . $chronicDiseasesName[0]['chronicDiseasesName'] . '</span> '; } return $r; }], ['attribute' => 'peopleStreet', 'value' => 'peopleStreet0.streetName', 'filter' => ArrayHelper::map(Streets::find()->all(), 'streetId', 'streetName')], 'peopleAdress', ['class' => 'yii\\grid\\ActionColumn']]]); ?>
/** * Экшн вывода формы для поиска людей по улице и сроку флюры. * @return mixed */ public function actionBackup() { /*$model = new Peoples; if ($model->load(Yii::$app->request->post())) { return $this->redirect(['pprintfind', 'streetId' => $model->streetId]); } else { return $this->render('pprint', [ 'model' => $model, ]); }*/ $file = fopen("c://backup.sql", "x+"); $text = "\n-- phpMyAdmin SQL Dump\n-- version 4.0.10.10\n-- http://www.phpmyadmin.net\n--\n-- Хост: 127.0.0.1:3306\n-- Время создания: Мар 07 2016 г., 19:18\n-- Версия сервера: 5.5.45\n-- Версия PHP: 5.4.44\n\nSET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';\nSET time_zone = '+00:00';\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8 */;\n\n--\n-- База данных: `medSys`\n--\n\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `chronicDiseases`\n--\n\nCREATE TABLE IF NOT EXISTS `chronicDiseases` (\n `chronicDiseasesId` int(5) NOT NULL AUTO_INCREMENT,\n `chronicDiseasesName` varchar(255) NOT NULL,\n PRIMARY KEY (`chronicDiseasesId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `chronicDiseases`\n--\nINSERT INTO `chronicDiseases` (`chronicDiseasesId`, `chronicDiseasesName`) VALUES\n"; $chronicDiseases = chronicDiseases::find()->all(); foreach ($chronicDiseases as $key => $cd) { if ($key + 1 == count($chronicDiseases)) { $text .= "(" . $cd['chronicDiseasesId'] . ", '" . $cd['chronicDiseasesName'] . "');\n"; } else { $text .= "(" . $cd['chronicDiseasesId'] . ", '" . $cd['chronicDiseasesName'] . "'),\n"; } } $text .= "\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `chronicDiseasesPeoples`\n--\n\nCREATE TABLE IF NOT EXISTS `chronicDiseasesPeoples` (\n `chronicDiseasesId` int(5) NOT NULL,\n `peopleId` int(5) NOT NULL,\n KEY `chronicDiseasesId` (`chronicDiseasesId`),\n KEY `peopleId` (`peopleId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `chronicDiseasesPeoples`\n--\n\nINSERT INTO `chronicDiseasesPeoples` (`chronicDiseasesId`, `peopleId`) VALUES"; $chronicDiseasesPeople = chronicDiseasesPeoples::find()->all(); foreach ($chronicDiseasesPeople as $key => $cd) { if ($key + 1 == count($chronicDiseasesPeople)) { $text .= "(" . $cd['chronicDiseasesId'] . ", " . $cd['peopleId'] . ");\n"; } else { $text .= "(" . $cd['chronicDiseasesId'] . ", " . $cd['peopleId'] . "),\n"; } } $text .= "\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `grafts`\n--\n\nCREATE TABLE IF NOT EXISTS `grafts` (\n `graftId` int(5) NOT NULL AUTO_INCREMENT,\n `graftName` varchar(255) NOT NULL,\n PRIMARY KEY (`graftId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `grafts`\n--\n\nINSERT INTO `grafts` (`graftId`, `graftName`) VALUES"; $grafts = grafts::find()->all(); foreach ($grafts as $key => $cd) { if ($key + 1 == count($grafts)) { $text .= "(" . $cd['graftId'] . ", '" . $cd['graftName'] . "');\n"; } else { $text .= "(" . $cd['graftId'] . ", '" . $cd['graftName'] . "'),\n"; } } $text .= "\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `graftsPeoples`\n--\n\nCREATE TABLE IF NOT EXISTS `graftsPeoples` (\n `graftId` int(5) NOT NULL,\n `peopleId` int(5) NOT NULL,\n KEY `graftId` (`graftId`),\n KEY `peopleId` (`peopleId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `graftsPeoples`\n--\n\nINSERT INTO `graftsPeoples` (`graftId`, `peopleId`) VALUES"; $graftsP = graftsPeoples::find()->all(); foreach ($graftsP as $key => $cd) { if ($key + 1 == count($graftsP)) { $text .= "(" . $cd['graftId'] . ", " . $cd['peopleId'] . ");\n"; } else { $text .= "(" . $cd['graftId'] . ", " . $cd['peopleId'] . "),\n"; } } $text .= "\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `peoples`\n--\n\nCREATE TABLE IF NOT EXISTS `peoples` (\n `peopleId` int(5) NOT NULL AUTO_INCREMENT,\n `peopleFIO` varchar(255) NOT NULL,\n `peopleBirthday` date NOT NULL,\n `peopleWorking` int(5) NOT NULL,\n `peopleFluNumber` varchar(255) NOT NULL,\n `peopleFluDate` date NOT NULL,\n `peopleFluResult` int(1) NOT NULL,\n `peopleFluTerm` int(2) NOT NULL,\n `peopleStreet` int(5) NOT NULL,\n `peopleAdress` varchar(255) NOT NULL,\n PRIMARY KEY (`peopleId`),\n KEY `peopleWorking` (`peopleWorking`),\n KEY `peopleFlu` (`peopleFluNumber`),\n KEY `peopleStreet` (`peopleStreet`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `peoples`\n--\n\nINSERT INTO `peoples` (`peopleId`, `peopleFIO`, `peopleBirthday`, `peopleWorking`, `peopleFluNumber`, `peopleFluDate`, `peopleFluResult`, `peopleFluTerm`, `peopleStreet`, `peopleAdress`) VALUES"; $peoples = peoples::find()->all(); foreach ($peoples as $key => $cd) { if ($key + 1 == count($peoples)) { $text .= "(" . $cd['peopleId'] . ", '" . $cd['peopleFIO'] . "', '" . $cd['peopleBirthday'] . "', " . $cd['peopleWorking'] . ", '" . $cd['peopleFluNumber'] . "', '" . $cd['peopleFluDate'] . "', " . $cd['peopleFluResult'] . ", " . $cd['peopleFluTerm'] . ", " . $cd['peopleStreet'] . ", '" . $cd['peopleAdress'] . "');\n"; } else { $text .= "(" . $cd['peopleId'] . ", '" . $cd['peopleFIO'] . "', '" . $cd['peopleBirthday'] . "', " . $cd['peopleWorking'] . ", '" . $cd['peopleFluNumber'] . "', '" . $cd['peopleFluDate'] . "', " . $cd['peopleFluResult'] . ", " . $cd['peopleFluTerm'] . ", " . $cd['peopleStreet'] . ", '" . $cd['peopleAdress'] . "'),\n"; } } $text .= "\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `streets`\n--\n\nCREATE TABLE IF NOT EXISTS `streets` (\n `streetId` int(2) NOT NULL AUTO_INCREMENT,\n `streetName` varchar(255) NOT NULL,\n PRIMARY KEY (`streetId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `streets`\n--\n\nINSERT INTO `streets` (`streetId`, `streetName`) VALUES"; $streets = streets::find()->all(); foreach ($streets as $key => $cd) { if ($key + 1 == count($streets)) { $text .= "(" . $cd['streetId'] . ", '" . $cd['streetName'] . "');\n"; } else { $text .= "(" . $cd['streetId'] . ", '" . $cd['streetName'] . "'),\n"; } } $text .= "\n-- --------------------------------------------------------\n\n--\n-- Структура таблицы `working`\n--\n\nCREATE TABLE IF NOT EXISTS `working` (\n `workingId` int(5) NOT NULL AUTO_INCREMENT,\n `workingName` varchar(255) NOT NULL,\n PRIMARY KEY (`workingId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Дамп данных таблицы `working`\n--\n\nINSERT INTO `working` (`workingId`, `workingName`) VALUES"; $working = working::find()->all(); foreach ($working as $key => $cd) { if ($key + 1 == count($working)) { $text .= "(" . $cd['workingId'] . ", '" . $cd['workingName'] . "');\n"; } else { $text .= "(" . $cd['workingId'] . ", '" . $cd['workingName'] . "'),\n"; } } $text .= "\n--\n-- Ограничения внешнего ключа сохраненных таблиц\n--\n\n--\n-- Ограничения внешнего ключа таблицы `chronicDiseasesPeoples`\n--\nALTER TABLE `chronicDiseasesPeoples`\n ADD CONSTRAINT `chd` FOREIGN KEY (`chronicDiseasesId`) REFERENCES `chronicDiseases` (`chronicDiseasesId`) ON UPDATE CASCADE,\n ADD CONSTRAINT `chp` FOREIGN KEY (`peopleId`) REFERENCES `peoples` (`peopleId`) ON UPDATE CASCADE;\n\n--\n-- Ограничения внешнего ключа таблицы `graftsPeoples`\n--\nALTER TABLE `graftsPeoples`\n ADD CONSTRAINT `gg` FOREIGN KEY (`graftId`) REFERENCES `grafts` (`graftId`) ON UPDATE CASCADE,\n ADD CONSTRAINT `gp` FOREIGN KEY (`peopleId`) REFERENCES `peoples` (`peopleId`) ON UPDATE CASCADE;\n\n--\n-- Ограничения внешнего ключа таблицы `peoples`\n--\nALTER TABLE `peoples`\n ADD CONSTRAINT `ws` FOREIGN KEY (`peopleStreet`) REFERENCES `streets` (`streetId`) ON UPDATE CASCADE,\n ADD CONSTRAINT `www` FOREIGN KEY (`peopleWorking`) REFERENCES `working` (`workingId`) ON UPDATE CASCADE;\n\n/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n"; fwrite($file, $text); fclose($file); echo "Базу даних збережено за адресою C://backup.sql<br>" . "<a href='http://medik/web/index.php'>Назад</a>"; }