public function init() { parent::init(); $pageSize = Settings::findOne(['type' => 'main', 'key' => 'page_size']); if ($pageSize !== null) { self::$defaultPageSize = $pageSize->value; } }
public static function getSetting($setting_id) { $setting = Settings::findOne(['pm_id' => $setting_id]); if ($setting) { return $setting->{$setting_id}; } else { return false; } }
public function actionLock() { $is_locked = Settings::getSetting('locked'); $setting = Settings::findOne(['pm_id' => 'locked']); $setting->locked = $is_locked == 1 ? 0 : 1; if (true == $setting->save()) { Yii::$app->user->logout(); return $this->redirect(['/admin']); } else { return $this->redirect(['index']); } }
public function save() { if ($this->app_name) { \Yii::$app->db->createCommand('UPDATE settings SET `value`=:val WHERE `key`=:key', [':val' => $this->app_name, ':key' => 'app_name'])->execute(); } if ($this->app_description) { \Yii::$app->db->createCommand('UPDATE settings SET `value`=:val WHERE `key`=:key', [':val' => $this->app_description, ':key' => 'app_description'])->execute(); } if (empty($this->app_logo)) { $this->app_logo = \Yii::$app->db->createCommand('SELECT `value` FROM settings WHERE `key`="app_logo"')->queryScalar(); } else { $logoModel = Settings::findOne(['key' => 'app_logo']); $logoModel->saveFile($this->app_logo); \Yii::$app->db->createCommand('UPDATE settings SET `value`=:val WHERE `key`=:key', [':val' => $this->app_logo->name, ':key' => 'app_logo'])->execute(); } }
public function run() { $model = new Settings(); $dataProvider = new ActiveDataProvider(['query' => Settings::find(), 'pagination' => false]); if (Yii::$app->request->post()) { foreach (Yii::$app->request->post('Settings') as $k => $opt) { $obj = Settings::findOne($opt["id"]); //var_dump($obj); die; $obj->option_value = $opt["option_value"]; $obj->save(); } Yii::$app->session->setFlash('success', 'Site settings updated Successfully.'); } //var_dump(Yii::$app->request->post()); die(); $models = Settings::find()->all(); return $this->controller->render('settings', ['model' => $models, 'dataProvider' => $dataProvider]); }
public function actionAdmin() { /* used in the refnum selection */ if (isset($_POST['Settings'])) { if (isset($_POST['ajax'])) { $model = new Settings(); return $model->Tmvalidate($_POST['Settings']); } //$this->performAjaxValidation($_POST['Settings']); foreach ($_POST['Settings'] as $key => $value) { $model = Settings::findOne($key); $model->value = $value['value']; //will stop $model->save(); } //$comp = Company::findOne($this->company); //$comp->loadSettings(); \Yii::$app->getSession()->setFlash('success', Yii::t("app", "Saved")); } $models = Settings::find()->where(array("hidden" => "0"))->all(); //->addOrderBy(['priority'=>'desc']) return $this->render('view', array('models' => $models)); }
public function make($cid) { $this->id = rand(0, 999999); //$this->iniArr=array('b110'=>0,'b100'=>0,'m100'=>0,'c100'=>0,'d100'=>0,'d110'=>0,'d120'=>0,); //$this->docArr=array(0=>0,305=>0,300=>0,); $bkmv = ''; //$this->line=1; //$yiidatetimesec=Yii::$app->locale->getDateFormat('yiidatetimesec'); //$phpdbdatetime=Yii::$app->locale->getDateFormat('phpdbdatetime'); $from_date = $this->from_date . " 00:00:00"; $to_date = $this->to_date . " 23:59:59"; //$types=array(3,4,9,11,13,14); //accounts $accounts = Accounts::find()->All(); $record = array('id' => 'B110', 'name' => OpenFormatType::getDesc('B110'), 'count' => 0); foreach ($accounts as $account) { $this->line++; $bkmv .= $account->openfrmt($this->line, $from_date, $to_date); $record['count']++; } $this->iniArr[] = $record; //items $items = Item::find()->All(); $record = array('id' => 'M100', 'name' => OpenFormatType::getDesc('M100'), 'count' => 0); foreach ($items as $item) { $this->line++; $bkmv .= $item->openfrmt($this->line, $from_date, $to_date); $record['count']++; } $this->iniArr[] = $record; // //transactions $transactions = Transactions::find()->where(['BETWEEN', 'valuedate', $from_date, $to_date])->All(); $record = array('id' => 'B100', 'name' => OpenFormatType::getDesc('B100'), 'count' => 0); foreach ($transactions as $transaction) { $this->line++; $bkmv .= $transaction->openfrmt($this->line, $from_date, $to_date); $record['count']++; } $this->iniArr[] = $record; //docs $docs = Docs::find()->where(['BETWEEN', 'due_date', $from_date, $to_date])->All(); //OpenFormatType::getDesc('C100') $record = array('id' => 'C100', 'name' => OpenFormatType::getDesc('C100'), 'count' => 0); $d110 = array('id' => 'D110', 'name' => OpenFormatType::getDesc('D110'), 'count' => 0); $d120 = array('id' => 'D120', 'name' => OpenFormatType::getDesc('D120'), 'count' => 0); foreach ($docs as $doc) { if ($doc->docType->openformat != '0') { $this->line++; $bkmv .= $doc->openfrmt($this->line, $from_date, $to_date); foreach ($doc->docDetailes as $detial) { $this->line++; $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date); $d110['count']++; } foreach ($doc->docCheques as $detial) { $this->line++; $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date); $d120['count']++; } $type = $doc->OpenfrmtType(); $this->docArr[$type] = isset($this->docArr[$type]) ? $this->docArr[$type] + 1 : 0; $this->docSumArr[$type] = isset($this->docSumArr[$type]) ? $this->docSumArr[$type] + $doc->total : $doc->total; $record['count']++; } } $this->iniArr[] = $record; $this->iniArr[] = $d110; $this->iniArr[] = $d120; $company = \app\models\Settings::findOne(['company.name']); //A100 $bkmv = $company->a100(1, $this->id, $from_date, $to_date) . $bkmv; //Z900 $bkmv = $bkmv . $company->z900($this->line + 1, $this->id, $this->line + 1); $bkmvFile = new Files(); $bkmvFile->name = 'bkmvdata.txt'; $bkmvFile->path = 'openformat/'; // $bkmvFile->expire = 360; $bkmvFile->save(); $bkmvFile->writeFile($bkmv); $this->bkmvId = $bkmvFile->id; //A000 $ini = $company->a000(1, $this->id, $this->line + 1, $from_date, $to_date); foreach ($this->iniArr as $line) { $ini .= $line['id'] . sprintf("%015d", $line['count']) . "\r\n"; } //Z $iniFile = new Files(); $iniFile->name = 'ini.txt'; $iniFile->path = 'openformat/'; // $iniFile->expire = 360; $iniFile->save(); $iniFile->writeFile($ini); $this->iniId = $iniFile->id; return $this->id; }
private function warehouseSave($id) { $model = Settings::findOne("company." . $this->id . ".warehouse"); if ($model === null) { $model = new Settings(); $model->id = "company." . $this->id . ".warehouse"; $model->eavType = 'integer'; $model->hidden = 1; } $model->value = $id; $this->warehouse = $model->value; $model->save(); }
<div class="body-content"> <?php if (Yii::$app->session->hasFlash('success')) { ?> <div class="alert alert-success col-lg-12"> <?php echo Yii::$app->session->getFlash('success'); ?> </div> <?php } ?> <div class="col-lg-12"> <?php $gridColumns = [['class' => '\\kartik\\grid\\DataColumn', 'attribute' => 'order_id', 'format' => 'raw', 'value' => function ($model, $key, $index, $widget) { return Html::a($model->order_id, urldecode(str_replace('[orderID]', $model->order_id, Settings::findOne(['field' => 'app_order_path'])->value))); }], ['class' => '\\kartik\\grid\\DataColumn', 'attribute' => 'shipping_type'], ['class' => '\\kartik\\grid\\DataColumn', 'attribute' => 'shop_status'], ['class' => '\\kartik\\grid\\DataColumn', 'attribute' => 'status_time'], ['class' => '\\kartik\\grid\\DataColumn', 'attribute' => 'order_amount'], ['class' => '\\kartik\\grid\\DataColumn', 'attribute' => 'spi'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'value' => function ($model, $key, $index, $column) { return GridView::ROW_COLLAPSED; }, 'detailUrl' => Url::to(['site/parceldetail']), 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true, 'detailRowCssClass' => 'nohover'], ['class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => function ($model, $key, $index) { return ['header' => 'Cтатус посылки', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_DROPDOWN_LIST, 'data' => Parcels::listDeliveryStatus()]; }, 'vAlign' => 'middle', 'hAlign' => 'center', 'attribute' => 'delivery_status', 'filterType' => GridView::FILTER_SELECT2, 'filter' => Parcels::listDeliveryStatus(), 'filterInputOptions' => ['prompt' => 'Все'], 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true], 'hideSearch' => true], 'format' => 'raw'], ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'mailed', 'value' => function ($model, $key, $index, $widget) { if ($model->mailed == 'yes') { return true; } else { return false; } }, 'vAlign' => 'middle', 'trueLabel' => 'Отправлено', 'falseLabel' => 'Не отправлено'], ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'status', 'value' => function ($model, $key, $index, $widget) { if ($model->status == 'enabled') { return true; } else { return false;
public function actionDefault() { $setting = Settings::findOne(['pm_id' => 'style']); $styles = $this->getAvailableStyles(); if ($setting->populate(Yii::$app->request->post()) && $setting->save()) { return $this->redirect(['/styles/index/']); } else { return $this->render('default', ['model' => $setting, 'styles' => $styles]); } }
public function actionSettings() { $request = Yii::$app->request; if (isset($_POST['db-button'])) { foreach (Settings::find()->where(['like', 'field', 'db_'])->all() as $row) { $field = Settings::findOne(['field' => $row['field']]); $field->value = $request->post($row['field'], ''); $field->save(); } } if (isset($_POST['db-check'])) { $db = new \yii\db\Connection(['dsn' => 'mysql:host=' . $request->post('db_host', '') . ';dbname=' . $request->post('db_name', ''), 'username' => $request->post('db_user', ''), 'password' => $request->post('db_password', ''), 'emulatePrepare' => true, 'charset' => 'utf8']); try { $db->open(); Yii::$app->session->setFlash('success', 'Соединение успешно'); } catch (\Exception $e) { Yii::$app->session->setFlash('error', 'Ошибка подключения: ' . $e->getMessage()); } } // if (isset($_POST['ts-button'])) //сохранить типы отправлений // { // $field = Settings::findOne([ // 'field' => 'shipping_type', // ]); // $field->value = serialize($request->post('types', '')); // $field->save(); // } if (isset($_POST['os-button-mail'])) { $field = Settings::findOne(['field' => 'order_status_mail']); $field->value = serialize($request->post('statuses_mail', '')); $field->save(); } if (isset($_POST['os-button-sms'])) { $field = Settings::findOne(['field' => 'order_status_sms']); $field->value = serialize($request->post('statuses_sms', '')); $field->save(); } if (isset($_POST['app-button'])) { foreach (Settings::find()->where(['like', 'field', 'app_'])->all() as $row) { $field = Settings::findOne(['field' => $row['field']]); $field->value = $request->post($row['field'], ''); $field->save(); } } if (isset($_POST['mail-button'])) { $field = Settings::findOne(['field' => 'mails']); $field->value = serialize(array_filter($request->post('mails', ''))); $field->save(); foreach (Settings::find()->where(['like', 'field', 'mail_'])->all() as $row) { $field = Settings::findOne(['field' => $row['field']]); $field->value = $request->post($row['field'], ''); $field->save(); } } if (isset($_POST['sms-button'])) { foreach (Settings::find()->where(['like', 'field', 'sms_'])->all() as $row) { $field = Settings::findOne(['field' => $row['field']]); $field->value = $request->post($row['field'], ''); $field->save(); } } $settings = Settings::getSettings(); return $this->render('settings', ['settings' => $settings, 'types' => $types, 'statuses_mail' => $statuses_mail, 'statuses_sms' => $statuses_sms]); }
/** * Finds the Settings model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Settings the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Settings::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); } }
public static function findByUserAndParameterID($userID, $parameterID) { return Settings::findOne(['user_id' => $userID, 'parameter_id' => $parameterID]); }
public function getSettings() { $arr = array(); foreach ($this->loadPayment()->settings() as $setting) { $arr[] = Settings::findOne($setting); } return $arr; }
public static function GenerateSms($field, $model) { $field = Settings::findOne(['field' => $field]); $text = $field->value; $text = str_replace("#ORDER#", $model->order_id, $text); $text = str_replace("#FIO#", $model->fio, $text); $text = str_replace("#SPI#", $model->spi, $text); $text = str_replace("#AMOUNT#", $model->amount, $text); $text = str_replace("#DATE#", $model->delivery_time, $text); return $text; }
public static function getOrderStatusSms() { $db = Settings::getDbShopConnect(); if ($db) { $array = $db->createCommand('SELECT * FROM SC_order_status')->queryAll(); } else { $array = array(); } $checkedArray = unserialize(Settings::findOne(['field' => 'order_status_sms'])->value); if (empty($checkedArray)) { $checkedArray = array(); } for ($i = 0; $i < count($array); $i++) { if (in_array($array[$i]['statusID'], $checkedArray)) { $array[$i]['checked'] = true; } else { $array[$i]['checked'] = false; } } $provider = new ArrayDataProvider(['allModels' => $array]); return $provider; }
public static function setSetting($id, $value) { if (\Yii::$app->db->schema->getTableSchema('{{%config}}') === null) { return false; } $setting = \app\models\Settings::findOne($id); if ($setting === null) { return false; } else { $setting->value = $value; return $setting->save(); } }