Executes the query and returns a single row of result.
public one ( |
||
$db | the database connection used to generate the SQL statement. If this parameter is not given, the `db` application component will be used. | |
return | array | boolean | the first row (in terms of an array) of the query result. False is returned if the query results in nothing. |
public static function mostPopular() { $query = new Query(); $query->select('meme_id, COUNT(meme_id) AS n_memes')->from('meme_vidmage')->groupBy('meme_id')->orderBy(['n_memes' => SORT_DESC])->limit(1); $row = $query->one(); return self::findOne($row['meme_id']); }
public function Auth($username = null) { $db = new Query(); $db->select("*")->from("masuser")->where("username = '******' ")->limit("1"); $rows = $db->one(); return $rows; }
public function actionIndex($id) { $session = \Yii::$app->session; $request = \Yii::$app->request; $donateForm = new DonateForm(); $buyForm = new BuyForm(); $supportForm = new SupportForm(); if ($donateForm->load($request->post()) && $donateForm->submit()) { $session->set('donate', $request->post('DonateForm')); return $this->redirect('@web/index.php?r=support/donate'); } else { if ($buyForm->load($request->post()) && $buyForm->submit()) { $session->set('bought', $request->post('BuyForm')); return $this->redirect('@web/index.php?r=support/buy'); } else { if ($supportForm->load($request->post()) && $supportForm->submit()) { $session->set('motive', $request->post('SupportForm')); return $this->redirect('@web/index.php?r=support/motivation'); } } } $query = new Query(); // compose the query $query->from('hero')->where('Hid=:id', array(':id' => $id)); $hero = $query->one(); $session->set('hero', $hero); return $this->render('support', array('hero' => $hero)); }
public function Edit($id_apteka, $id_preparat) { $query = new Query(); $query->from('preparats_ansver'); $query->where(['=', 'id_apteka', $id_apteka]); $query->andWhere(['=', 'id_o', $id_preparat]); return $query->one(); }
public function GetItem($id = 0) { $query = new Query(); $query->from($this->table); $query->where(["id" => $id]); $result = $query->one(); return $result; }
public function actionSuccess($id) { $query = new Query(); // compose the query $query->from('event')->where('Eid=:id', array(':id' => $id)); // build and execute the query $detail = $query->one(); return $this->render('success', array('detail' => $detail)); }
public function GetTableForModel($module_name = "") { if (!empty($module_name)) { $_module_name = strtolower($module_name); $query = new Query(); $query->select('db.name')->from("backend__id_db as db")->join('LEFT JOIN', "module as m", "m.name = '{$_module_name}'")->where("m.model = db.model_id"); $result = $query->one(); return $result["name"]; } }
public function actionProfile($id) { $query = new Query(); // compose the query $query->from('hero')->where('Hid=:id', array(':id' => $id)); $hero = $query->one(); $q = new Query(); $q->from('takespart')->innerJoin('event', 'takespart.EventId=event.Eid')->where('HeroId=:id', array(':id' => $id)); $event = $q->one(); return $this->render('profile', array('hero' => $hero, 'event' => $event)); }
public function PageContentForCheck($type_page = 0) { list($module, $controller, $action) = explode("/", yii::$app->request->pathInfo); $query = new Query(); $query->select("COUNT(p.id) as count")->innerJoin("module as m", "m.id = p.module and m.name = '{$module}'")->from("backend__pages as p")->where("p.id = {$type_page}"); $result = $query->one(); if ($result["count"] == 1) { return true; } else { return false; } }
public function actionIndex($id) { $session = \Yii::$app->session; $request = \Yii::$app->request; $challengeForm = new ChallengeForm(); if ($challengeForm->load($request->post()) && $challengeForm->submit()) { $session->set('dump', $request->post('ChallengeForm')); return $this->redirect('@web/index.php?r=site/dump'); } else { $query = new Query(); // compose the query $query->from('hero')->where('Hid=:id', array(':id' => $id)); $hero = $query->one(); return $this->render('challenge', ['challengeForm' => $challengeForm, 'hero' => $hero]); } }
public function up() { $people_to_city = ['Маша' => [1, 2], 'Ваня' => [1, 2, 3, 4, 5], 'Оля' => [4, 5], 'Женя' => [2, 3], 'Вася' => [], 'Коля' => [6], 'Олег' => [3]]; foreach ($people_to_city as $name => $cities) { $query = new Query(); // compose the query $query->select('id')->from('people'); $query->andFilterWhere(['like', 'name', $name]); $row = $query->one(); var_dump($row); if (!empty($cities)) { foreach ($cities as $cityId) { $this->insert('people_city', ['people_id' => $row['id'], 'city_id' => $cityId]); } } } }
/** * Validate a client * * @param string $clientId The client's ID * @param string $clientSecret The client's secret (default = "null") * @param string $redirectUri The client's redirect URI (default = "null") * @param string $grantType The grant type used (default = "null") * * @return \League\OAuth2\Server\Entity\ClientEntity */ public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null) { $client = null; $selectTargets = "{{%oauth_clients}}.id, {{%oauth_clients}}.name"; if ($redirectUri !== null && is_string($redirectUri) && strlen($redirectUri) > 0) { $selectTargets = "{{%oauth_clients}}.*, {{%oauth_client_redirect_uris}}.*"; } $clientStorageQueryBuilder = new Query(); $clientStorageQueryBuilder->select($selectTargets)->from("{{%oauth_clients}}")->where("{{%oauth_clients}}.id=:oauth_client_id AND {{%oauth_clients}}.secret=:oauth_client_secret_where", [":oauth_client_id" => $clientId, ":oauth_client_secret_where" => $clientSecret]); /** * Regarding oauth_client_redirect_uris: * You may or may not have this table. If you don't, and don't need it , as described in the league docs for each grant, * you won't really pass this condition, and that's why it's implemented this way */ if ($redirectUri !== null && is_string($redirectUri) && strlen($redirectUri) > 0) { $clientStorageQueryBuilder->innerJoin("{{%oauth_client_redirect_uris}}", "{{%oauth_clients}}.id = {{%oauth_client_redirect_uris}}.client_id")->where(["{{%oauth_client_redirect_uris}}.redirect_uri" => $redirectUri]); } $clientStorageResult = $clientStorageQueryBuilder->one(); if (isset($clientStorageResult['id']) && isset($clientStorageResult['name'])) { $client = (new ClientEntity($this->getServer()))->hydrate(["id" => $clientStorageResult["id"], "name" => $clientStorageResult["name"]]); } return $client; }
} echo '<tr class="bgdark"> <td class="bgdark"></td> <td class="bgdark"></td> <td class="bgdark"></td> <td class="bgdark"></td> <td class="bgdark"><div class="price">' . app\components\NumericLib::indoStyle($debit, 0, ',', '.') . '</div></td> <td class="bgdark"><div class="price">' . app\components\NumericLib::indoStyle($credit, 0, ',', '.') . '</div></td> <td class="bgdark"></td> </tr>'; } } else { echo '<tr>'; $accquery = new Query(); $accquery->select('code , name')->from('account_account')->where(['id' => $account]); $res = $accquery->one(); echo '<td>' . $res['code'] . '</td>'; echo '<td colspan="6">' . $res['name'] . '</td>'; echo '</tr>'; $queryline = new Query(); $queryline->select('aml.ref as ref, aml.name as name ,aml.date as date, aml.debit as debit, aml.credit as credit')->from('account_move_line aml')->join('LEFT JOIN', 'account_move as am', 'am.id=aml.move_id')->where(['>=', 'aml.date', $from])->andWhere(['<=', 'aml.date', $to])->andWhere(['am.state' => 'posted'])->andWhere(['aml.account_id' => $account])->addOrderBy(['aml.date' => SORT_ASC]); $lines = $queryline->all(); $debit = 0; $credit = 0; foreach ($lines as $line) { echo '<tr> <td></td> <td>' . $line['name'] . '</td> <td>' . Yii::$app->formatter->asDatetime($line['date'], "php:d-m-Y") . '</td> <td>' . $line['ref'] . '</td> <td><div class="price">' . app\components\NumericLib::indoStyle($line['debit'], 0, ',', '.') . '</div></td>
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->parent === null || $this->parent->isNewRecord) { $this->level = 0; } else { $this->level = $this->parent->level + 1; } if ($this->isNewRecord) { $query = new Query(); $query->select(['position']); $query->from(self::tableName()); $query->orderBy('position DESC'); if ($this->parent_id) { $query->where('parent_id=:parent_id'); $query->params([':parent_id' => $this->parent_id]); } else { $query->where('parent_id is NULL'); } $last = $query->one(); $this->position = $last ? $last['position'] + 1 : 0; } return true; } else { return false; } }
public function beforeSave($insert) { if (!parent::beforeSave($insert)) { return false; } $query = new Query(); $query->select('COUNT(*)')->where(['post_id' => $this->post_id])->from(static::tableName()); $count = $query->scalar(static::getDb()); if ($count == 0) { $this->left = 1; $this->right = 2; $this->level = 1; } else { if (empty($this->parent_id)) { $query = new Query(); $query->select('MAX({{right}})')->where(['post_id' => $this->post_id])->from(static::tableName()); $maxRight = $query->scalar(static::getDb()); $this->left = $maxRight + 1; $this->right = $maxRight + 2; $this->level = 1; } else { /*$query = new Query(); $query ->select(['{{left}} left', '{{level}} level']) ->where(['post_id' => $this->post_id, 'id' => $this->parent_id]) ->from(static::tableName()); $data1 = $query->all(static::getDb()); static::getDb() ->createCommand('UPDATE ' . static::tableName() . ' SET {{right}} = {{right}} + 2 WHERE {{right}} > :left') ->bindValue(':left', $data1[0]['left']) ->execute(); static::getDb() ->createCommand('UPDATE ' . static::tableName() . ' SET {{left}} = {{left}} + 2 WHERE {{left}} > :left') ->bindValue(':left', $data1[0]['left']) ->execute(); $this->left = $data1[0]['left'] + 1; $this->right = $data1[0]['left'] + 2; $this->level = $data1[0]['level'] + 1;*/ $query = new Query(); $query->select(['id', '{{left}} left', '{{right}} right', '{{level}} level'])->where(['post_id' => $this->post_id, 'id' => $this->parent_id])->from(static::tableName()); $data1 = $query->all(static::getDb()); if ($data1[0]['left'] != $data1[0]['right'] - 1) { $query = new Query(); $query->select(['id', '{{left}} left', '{{right}} right', '{{level}} level', '{{text}}'])->where(['post_id' => $this->post_id, 'level' => $data1[0]['level']])->andWhere('{{left}} > :r AND {{id}} != :id', [':r' => $data1[0]['right'], ':id' => $data1[0]['id']])->from(static::tableName()); $data2 = $query->one(static::getDb()); static::getDb()->createCommand('UPDATE ' . static::tableName() . ' SET {{right}} = {{right}} + 2 WHERE {{right}} > :left')->bindValue(':left', $data2['left'] - 2)->execute(); static::getDb()->createCommand('UPDATE ' . static::tableName() . ' SET {{left}} = {{left}} + 2 WHERE {{left}} > :left')->bindValue(':left', $data2['left'] - 2)->execute(); $this->left = $data2['right'] - 2; $this->right = $data2['right'] - 1; $this->level = $data1[0]['level'] + 1; } else { static::getDb()->createCommand('UPDATE ' . static::tableName() . ' SET {{right}} = {{right}} + 2 WHERE {{right}} > :left')->bindValue(':left', $data1[0]['left'])->execute(); static::getDb()->createCommand('UPDATE ' . static::tableName() . ' SET {{left}} = {{left}} + 2 WHERE {{left}} > :left')->bindValue(':left', $data1[0]['left'])->execute(); $this->left = $data1[0]['left'] + 1; $this->right = $data1[0]['left'] + 2; $this->level = $data1[0]['level'] + 1; } } } return true; }
/** * Session read handler. * Do not call this method directly. * @param string $id session ID * @return string the session data */ public function readSession($id) { $query = new Query(); $query->from($this->sessionTable)->where('[[expire]]>:expire AND [[id]]=:id', [':expire' => time(), ':id' => $id]); if (isset($this->readCallback)) { $fields = $query->one($this->db); return $fields === false ? '' : $this->extractData($fields); } $data = $query->select(['data'])->scalar($this->db); return $data === false ? '' : $data; }
public static function getStatusText($status) { $query = new Query(); $query->select(['name'])->from(['cprj_projectstatus'])->limit(1)->where(['id' => $status]); return $query->one()['name']; }
public function getLastRunEbayOrderDownload() { $query = new Query(); $query->select('*'); $query->from('t_run_ebay_order_download'); $query->where('1=1'); $query->orderBy(['id' => SORT_DESC]); $posts = $query->one(); return $posts; }
/** * Личные данные */ public function actionPersonal() { if (!Yii::$app->user->isGuest) { $model = new PersonalForm(); // создание реферальной ссылки if (Yii::$app->request->getIsPost()) { Yii::$app->db->createCommand('update users set referral = uuid() where id = ' . Yii::$app->user->getId() . ' and coalesce(referral, \'\') = \'\'')->execute(); return $this->refresh(); } // загрузка текущей реферальной ссылки $query = new Query(); $query->select('referral')->from('users')->where('id = :id', array(':id' => Yii::$app->user->getId())); $rows = $query->one(); return $this->render('personal', ['model' => $model, 'data' => $model->getUsers(), 'referral' => $rows['referral']]); } }
/** * Creates a new ReclamoSugerencia model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new ReclamoSugerencia(); if (Yii::$app->request->isAjax && $model->load($_POST)) { Yii::$app->response->format = 'json'; return \yii\widgets\ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { $model->REC_FECHA = date('Y-m-d'); $model->REC_HORA = date('H:i:s'); $query = new Query(); $query->select('REC_NUMERO')->from('RECLAMO_SUGERENCIA')->where('YEAR(REC_FECHA) = DATEPART(yyyy,getDate())')->orderBy('REC_NUMERO DESC')->limit('1'); $rows = $query->one(); $current_year = date('Y'); if ($rows) { $past = implode($rows); $id = explode("-", $past); $tmp_last_id = (int) $id[0] + 1; if ($current_year != $id[1]) { $tmp_last_id = 0; } $digits_count = preg_match_all("/[0-9]/", $tmp_last_id); $last_id = $tmp_last_id . "-" . $current_year; if ($digits_count < 2) { $last_id = 0 . $last_id; } } else { $new_id = 0 . "-" . $current_year; $last_id = 0 . $new_id; } $model->REC_NUMERO = $last_id; $model->ERS_ID = 1; //Instancia para el adjunto $name = 'solicitud ' . $model->REC_NUMERO . ' ' . $model->REC_FECHA . ' ' . date('H i'); $model->file = UploadedFile::getInstance($model, 'file'); $model->save(); //si el archivo no es null, entonces lo guarda y guarda el adjunto en la bd. if ($model->file != null) { $model->file->saveAs('uploads/reclamo-sugerencia/Adjunto ' . $name . '.' . $model->file->extension); //guardar la ruta en la bd $adjunto = new Adjuntos(); $adjunto->REC_NUMERO = $model->REC_NUMERO; $adjunto->ADJ_TIPO = 'Reclamo-Sugerencia'; $adjunto->ADJ_URL = 'uploads/reclamo-sugerencia/Adjunto ' . $name . '.' . $model->file->extension; $adjunto->save(); } //guardar Creacion en el Historial $historial = new HistorialEstados(); $historial->REC_NUMERO = $model->REC_NUMERO; $historial->ERS_ID = $model->ERS_ID; $historial->USU_RUT = $model->USU_RUT; $historial->HES_FECHA_HORA = date('Y-m-d H:i:s'); if ($model->TRS_ID == 1) { $historial->HES_COMENTARIO = "El usuario " . $historial->USU_RUT . " ha ingresado el Reclamo Nº " . $historial->REC_NUMERO . " el día " . $historial->HES_FECHA_HORA; } else { $historial->HES_COMENTARIO = "El usuario " . $historial->USU_RUT . " ha ingresado la Sugerencia Nº " . $historial->REC_NUMERO . " el día " . $historial->HES_FECHA_HORA; } $historial->save(); return $this->redirect(['view', 'id' => $model->REC_NUMERO]); } else { return $this->render('create', ['model' => $model]); } }
protected function resetRank() { $author = YBoardMember::findOne($this->user_id); if ($author !== null) { $query = new Query(); $query->select('id')->from('YBoardRank')->orderBy('min_posts ASC')->where('min_posts>=' . $author->totalReplies)->limit(1); $count = $query->count(); $id = $query->one(); if ($author->rank_id != $id['id'] && $count > 0) { $author->setAttribute('rank_id', $id['id']); $author->save(); } } }
/** * @inheritdoc */ public function one($db = null) { $row = parent::one($db); if ($row !== false) { list($row) = $this->fillUpSnippets([$row]); } return $row; }
/** * 获取等待运行的一个条件,锁定,运行 */ public function getPlanGetOrderDownload() { $query = new Query(); $query->select('*'); $query->from('t_run_ebay_order_download'); $query->where('1=1'); $query->andWhere(['status' => 0]); $query->orderBy(['id' => SORT_ASC]); $this->planDownload = $query->one(); if (empty($this->planDownload)) { throw new \Exception('没有符合条件的下载任务'); } }
public function getStatusText() { $query = new Query(); $query->select(['name'])->from(['cprj_taskstatus'])->where(['id' => $this->status]); return $query->one()['name']; }
public function actionUpdate($date = null, $apt) { // && $model->validate() if (is_numeric($apt)) { $model = Visitors::find()->andFilterWhere(['LIKE', 'date', $date])->andFilterWhere(['=', 'apteki_id', $apt])->one(); if (!$model) { $model = new Visitors(); } $model->apteki_id = $apt; } else { $model = new Visitors(); } if (!$model->date) { $model->date = $date; } if ($model->load(\Yii::$app->request->post())) { $model->date = (int) \Yii::$app->request->post('date_y') . '-' . (int) \Yii::$app->request->post('date_m') . '-' . (int) \Yii::$app->request->post('date_d'); if (\Yii::$app->request->post('date_type')) { $model->date_type = 2; } else { $model->date_type = 1; } if ($model->save()) { $user_id = (int) \Yii::$app->request->post('user_id'); return $this->redirect(["/visitors/?user={$user_id}&scroll={$model->apteki_id}"]); } } // $apteka = Apteki::find()->where(['id' => $apt, 'farmopeka' => '1'])->one(); $query = new Query(); $query->select(['apteki.*', 'ur_l.name']); $query->from('apteki'); $query->InnerJoin('ur_l', 'apteki.ur_l_id = ur_l.id'); $query->andFilterWhere(['=', 'apteki.farmopeka', '1']); $query->andFilterWhere(['=', 'apteki.id', $apt]); $apteka = $query->one(); return $this->render('update', ['apteka' => $apteka, 'model' => $model]); }
use yii\db\Expression; use yii\helpers\Html; use app\models\ToursDates; use app\models\Tours; $this->title = 'Booking tours'; ?> <div class="site-index"> <div class="jumbotron"> <h1>Welcome to Booking Tours service!</h1> <p class="lead">Chose available tour to continue</p> </div> <div class="body-content"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'emptyText' => 'No available tours at this moment', 'columns' => [['class' => DataColumn::className(), 'attribute' => Tours::FIELD_TITLE], ['class' => DataColumn::className(), 'label' => 'Nearest Tour', 'value' => function ($model) { /* @var $model Tours*/ $query = new Query(); $query->select(ToursDates::FIELD_DATE)->from(ToursDates::tableName())->where([ToursDates::FIELD_TOUR_ID => $model->tour_id])->andWhere(['>=', ToursDates::FIELD_DATE, date('Y-m-d')])->orderBy([ToursDates::FIELD_DATE => SORT_ASC]); $result = $query->one(); return $result[ToursDates::FIELD_DATE]; }], ['class' => ActionColumn::className(), 'contentOptions' => ['class' => 'text-center'], 'template' => '{view}', 'buttons' => ['view' => function ($url, $model, $key) { /* @var $model Tours */ return Html::a('View Details', ['booking/tour-details', Tours::FIELD_TOUR_ID => $model->tour_id], ['class' => 'btn btn-success']); }]]]]); ?> </div> </div>
/** * Executes query and returns a single row of result. * @param Connection $db the DB connection used to create the DB command. * If null, the DB connection returned by [[modelClass]] will be used. * @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]], * the query result may be either an array or an ActiveRecord object. Null will be returned * if the query results in nothing. */ public function one($db = null) { $row = parent::one($db); if ($row !== false) { $models = $this->populate([$row]); return reset($models) ?: null; } else { return null; } }
} if ($value['jenis'] == "") { $jenis = $value['product_name']; } else { $jenis = $value['jenis']; } if ($value['partner_id']) { $cekpartner = new Query(); $cekpartner->select('parent_id')->from('res_partner')->where(['id' => $value['partner_id']]); $res = $cekpartner->one(); if ($res['parent_id'] == "") { $partner = $value['partner']; } else { $parent = new Query(); $parent->select('name')->from('res_partner')->where(['id' => $res['parent_id']]); $r = $parent->one(); $partner = $r['name']; } } $body[] = '<tr> <td>' . $no . '</td> <td>' . $jenis . '</td> <td>' . Yii::$app->formatter->asDatetime($value['date'], "php:d-m-Y") . '</td> <td>' . $no_surat . '</td> <td>' . $no_pb . '</td> <td class=right>' . floatval($qty) . '</td> <td>' . $value['location'] . '</td> <td>' . $value['desc_location'] . '</td> <td>' . $partner . '</td> </tr>'; $no++;
public static function generateTablePdf($id) { $mains = ValidationMain::find()->orderBy('npp')->all(); $html1 = ""; $html1 .= "\n<style>\nbody{\n\n \n font-size: 16px;\n font-family: 'open', sans-serif;\n\n\n \n\n}\n\nspan{\nfont-size: 17px;\nfont-family: 'roboto', sans-serif;\n}\n\ntd{\nbackground-color:#fff;\nfont-size: 14px;\nfont-family: 'open', sans-serif;\n\n}\n.main td{\nbackground-color:#64b5f6;\nfont-size: 15px;\nfont-family: 'roboto', sans-serif;\n}\n.main2 td{\nbackground-color:#87cefa;\n}\n.header{\nline-height:30px;\n}\nh1,h2,h3,h4{\nfont-family: 'roboto', sans-serif;\n color: #c62828;\n\n\n}\n\n</style>\n\n<body>\n<div id=\"background\">\n<div align='center'><img src=\"http://sojuzpharma.ru/images/logo_04.jpg\"></div><br>"; $table = ""; $priceAll = 0; // $table.= "<pagebreak />"; foreach ($mains as $main) { $params = ValidationParams::find()->where(['validation_main_id' => $main['id']])->all(); $table2 = ''; foreach ($params as $param) { $err = null; //$violations = Validationviolation::find()->where(['validation_params_id' => $param['id']])->all(); $query = new Query(); $query->select('validation_violation.name,validation_violation.price'); $query->InnerJoin('validation_report_violation', 'validation_report_violation.`violation_id`=validation_violation.id'); $query->where(['report_id' => $id]); $query->andWhere(['validation_params_id' => $param['id']]); $query->from('validation_violation'); $val = $query->all(); if (count($val) > 0) { $table2 .= ""; $table2 .= "<tr>"; $table2 .= "<td rowspan='" . count($val) . "' width=10.5%>" . $param['name'] . "</td>"; $table2 .= "<td width='15%'>" . $val[0]['name'] . "</td>"; if ($val[0]['price'] == "") { $table2 .= "<td rowspan='" . count($val) . "' align='center'><b>" . $param['price'] . "</b></td>"; $priceAll = $priceAll + $param['price']; } else { $table2 .= "<td align='center'><b>" . $val[0]['price'] . "<b></td>"; $priceAll = $priceAll + $val[0]['price']; } $table2 .= "<td rowspan='" . count($val) . "' valign=top>" . $param['nd'] . "</td>"; $table2 .= "<td rowspan='" . count($val) . "' valign=top width=45%>" . $param['sankcii'] . "</td>"; $table2 .= "</tr>\n"; $n = 0; foreach ($val as $violation) { if ($n != 0) { $table2 .= "<tr nobr=\"false\">"; $table2 .= "<td>" . $violation['name'] . "</td>"; if ($violation['price'] != "") { $table2 .= "<td align='center'><b>" . $violation['price'] . "</b></td>"; $priceAll = $priceAll + $violation['price']; } $table2 .= "</tr>\n"; } $n++; } $err = 1; } } if ($table2) { $table .= ""; $table .= "<h4 align='center'>" . $main['name'] . "</h4>"; $table .= "<table border='1' cellpadding='3' cellspacing='0' width='100%'>"; $table .= "<thead><tr align='center' class='main'>"; $table .= "<td align='center'>Проверяемый параметр</td>"; $table .= "<td align='center'>Выявленные нарушения</td>"; $table .= "<td align='center'>Риск применения санкций для юр.лица (max)</td>"; $table .= "<td align='center'>п. НД, регламентирующий указанное в колонке 2 требование</td>"; $table .= "<td align='center'>Риск применения санкций возможный контролирующий орган, ст. КоАП и др…</td>"; $table .= "</tr></thead>\n\n"; $table .= "<tr align='center' class='main2'>"; //$table .= "<td colspan='5'>" . $main['name'] . "</td>"; $table .= "</tr>"; $table .= $table2; $table .= "</table>"; } } $table .= "</div></body>"; $query = new Query(); $query->select('validation_report.`created_at`,ur_l.`name`,apteki.`address`,users.`username`'); $query->InnerJoin('apteki', 'apteki.id = validation_report.`apteka_id` '); $query->InnerJoin('ur_l', 'apteki.ur_l_id = ur_l.id'); $query->LeftJoin('users', 'users.id = validation_report.user_id'); $query->where(['validation_report.id' => $id]); $query->from('validation_report'); $val = $query->one(); $dat = new \DateTime($val['created_at']); $dat2 = $dat->format('d.m.Y'); $html2 = ""; $html2 .= "<h1 align='CENTER'>АКТ ОБСЛЕДОВАНИЯ АПТЕЧНОГО УЧРЕЖДЕНИЯ </h1>"; $html2 .= "<h4 align='CENTER'>В РАМКАХ ПРОЕКТА ФАРМОПЕКА (конфиденциально, только для внутреннего пользования) </h4>"; $html2 .= "<br><br><div class='header'>"; $html2 .= "<span>Дата проверки: </span>" . $dat2; $html2 .= "<br><br>"; $html2 .= "<span>Юридическое лицо: </span>" . $val['name']; $html2 .= "<br>"; $html2 .= "<span>Адрес объекта:</span> " . $val['address']; $html2 .= "<br>"; $html2 .= "<span>ФИО инспектирующего лица: </span>" . $val['username']; $html2 .= "<br>"; $html2 .= "<br><br><br><br>"; $html2 .= "<span>Выявлены несоответствия (графа 2) в соблюдение лицензионных условий и фармацевтического порядка на сумму <b>" . \number_format($priceAll, 0) . "</b> руб.</span>"; $html2 .= "</div>"; $html = $html1 . $html2 . $table; return $html; }
public function getRate() { $res = null; if (!$this->isNewRecord) { $query = new Query(); $query->select('avg(r.rate) as rate')->from('rates r')->groupBy('r.rated_id')->where('r.rated_id = :uid', [':uid' => $this->id])->limit(1); $res = $query->one(); } return $res ? sprintf("%.2f", $res['rate']) : null; }