public function insert($fieldsCols = null) { return parent::insert(['beforeInsert' => function ($fields) { $fields['date_insert'] = gmdate('YmdHis'); $fields['id_string'] = Str::rus2translit($fields['header']); return $fields; }]); }
/** * @param array $field * @param \cs\base\BaseForm $model * * @return array поля для обновления в БД */ public static function onUpdate($field, $model) { $fieldName = $field[BaseForm::POS_DB_NAME]; $content = $model->{$fieldName}; $destination = UploadFolderDispatcher::createFolder('HtmlContent', $model->getTableName(), $fieldName, $model->id); $content = self::process($content, $destination); return [$fieldName => $content]; }
public function insert($fieldsCols = null) { $item = parent::insert(['beforeInsert' => function ($fields) { $fields['date_insert'] = time(); return $fields; }]); return $item; }
public function insert($fieldsCols = null) { $row = parent::insert(['beforeInsert' => function ($fields) { $fields['date_insert'] = gmdate('YmdHis'); return $fields; }]); return $row; }
public function update($fieldsCols = null) { return parent::update(['beforeUpdate' => function ($fields) { if ($fields['description'] == '') { $fields['description'] = GsssHtml::getMiniText($fields['content']); } return $fields; }]); }
public function update($fieldsCols = null) { return parent::update(['beforeUpdate' => function ($fields, \app\models\Form\Blog $model) { if ($fields['description'] == '') { $fields['description'] = GsssHtml::getMiniText($fields['content']); } if ($model->is_add_image) { $fields['content'] = Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($model->image), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $fields['header']])) . $fields['content']; } return $fields; }]); }
public function update($fieldsCols = null) { parent::update(); $item = \app\models\Picture::find($this->id); $fields = []; if ($item->getField('description') == '') { $fields['description'] = GsssHtml::getMiniText($item->getField('content')); } if (count($fields) > 0) { $item->update($fields); } return true; }
/** * @param int $id идентификатор объединения gs_unions.id * @return array|bool */ public function update2($id) { if ($this->id) { return parent::update(); } else { $this->union_id = $id; return parent::insert(['beforeInsert' => function ($fields, \app\models\Form\Shop $model) { $fields['union_id'] = $model->union_id; (new Query())->createCommand()->insert('gs_unions_shop_tree', ['union_id' => $model->union_id, 'name' => 'Root'])->execute(); return $fields; }]); } }
public function update($fieldsCols = null) { $fields = parent::update(['beforeUpdate' => function ($fields, \app\models\Form\Article $model) { if ($fields['description'] == '') { $fields['description'] = GsssHtml::getMiniText($fields['content']); } }]); $item = \app\models\Article::find($this->id); if ($this->is_add_image) { $content = Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getImage()), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $item->getField('header')])) . $item->getField('content'); $item->update(['content' => $content]); } }
public function update($fieldsCols = null) { return parent::update(['beforeUpdate' => function ($fields) { if (Str::pos('<', $fields['content']) === false) { $rows = explode("\r", $fields['content']); $rows2 = []; foreach ($rows as $row) { if (trim($row) != '') { $rows2[] = Html::tag('p', trim($row)); } } $fields['content'] = join("\r\r", $rows2); } return $fields; }]); }
public function update2($id) { $item = parent::update(); $item['id'] = $id; $class = new \app\models\SubscribeHistory($item); $content = $class->getField('content'); require_once Yii::getAlias('@csRoot/services/simplehtmldom_1_5/simple_html_dom.php'); $content = str_get_html($content); foreach ($content->find('img') as $element) { $src = $element->attr['src']; if (StringHelper::startsWith($src, 'http') == false) { $element->attr['src'] = Url::to($src, true); } } $content = $content->root->outertext(); $class->setContent($content); return $item; }
/** * Делает заказ * * @param int $id идентификатор генератора * * @return boolean whether the model passes validation */ public function insert($fieldsCols = null) { $id = $fieldsCols; $request = parent::insert(['beforeInsert' => function ($fields) { $fields['email'] = strtolower($fields['email']); $fields['datetime'] = time(); $fields['status'] = \app\models\Request::STATUS_1_WAIT; return $fields; }]); if ($request === false) { return false; } $request['product_id'] = $id; $this->email = strtolower($this->email); if (!Yii::$app->user->isGuest) { $user = Yii::$app->user->identity; $request = new \app\models\Request($request); $request->update(['user_id' => Yii::$app->user->getId(), 'product_id' => $id]); // письмо клиенту $result = \cs\Application::mail($user->getEmail(), 'Вы сделали очередной заказ', 'next_request_client', ['user' => $user, 'request' => $request]); } else { $fields = ['email' => $this->email, 'datetime_reg' => gmdate('YmdHis'), 'is_active' => 1, 'is_confirm' => 0, 'subscribe_is_tesla' => 1, 'name_first' => $this->name, 'phone' => $this->phone]; $user = User::insert($fields); $fields = \app\services\RegistrationDispatcher::add($user->getId()); $request = new \app\models\Request($request); $request->update(['user_id' => $user->getId(), 'product_id' => $id]); // письмо им \cs\Application::mail($this->email, 'Поздравляем вы сделали первый шаг к своему полю коллективного счастья', 'new_request_client', ['url' => Url::to(['site/activate', 'code' => $fields['code']], true), 'user' => $user, 'request' => $request]); } foreach (\Yii::$app->params['requestMailList'] as $item) { // письмо нам $result = Application::mail($item, 'Появился заказ на TeslaGen', 'new_request', ['request' => $request, 'user' => $user]); // VarDumper::dump([$result,$item]); } return $request; }
/** * * * @param array $field * @param \cs\base\BaseForm $model */ public static function onLoadDb($field, $model) { $fieldName = $field[BaseForm::POS_DB_NAME]; $row = $model->getRow(); $model->{$fieldName} = $row[$fieldName]; }
function __construct($fields = []) { static::$fields = [['dateMin', 'Начало', 0, 'validateDates', 'widget' => ['cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['dateMax', 'Окончание', 0, 'validateDates', 'widget' => ['cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]]]; parent::__construct($fields); }
function __construct($fields = []) { static::$fields = [['title', 'Название', 1, 'string'], ['file', 'Файл', 1, 'default', 'widget' => [FileUpload::className(), ['options' => ['small' => [200, 200, \cs\Widget\FileUpload2\FileUpload::MODE_THUMBNAIL_CUT]]]]]]; parent::__construct($fields); }
/** * * * @param array $field * @param \cs\base\BaseForm $model * * @return array поля для обновления в БД */ public static function onLoadDb($field, $model) { $fieldName = $field[BaseForm::POS_DB_NAME]; $value = $model->getRow()[$fieldName]; $model->{$fieldName} = (new BitMask($value))->getArray(); }
function __construct($fields = []) { static::$fields = [['name_first', 'Имя', 1, 'string'], ['mission', 'Миссия', 0, 'string'], ['name_last', 'Фамилия', 0, 'string'], ['gender', 'Пол', 0, 'integer'], ['avatar', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => \app\services\GsssHtml::$formatIcon]]]], ['birth_date', 'Дата рождения', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => [\cs\Widget\DatePicker\DatePicker::className(), ['dateFormat' => 'php:d.m.Y']]]]; parent::__construct($fields); }
function __construct($fields = []) { static::$fields = [['html', 'HTML', 0, 'string'], ['img1', 'Картинка 1', 0, 'string', [], '1900x1080 JPG', 'widget' => [FileUpload::className(), ['options' => ['small' => [200, 200]]]]], ['img2', 'Картинка 2', 0, 'string', [], '1900x1080 JPG', 'widget' => [FileUpload::className(), ['options' => ['small' => [200, 200]]]]], ['img3', 'Картинка 3', 0, 'string', [], '1900x1080 JPG', 'widget' => [FileUpload::className(), ['options' => ['small' => [200, 200]]]]]]; parent::__construct($fields); }
function __construct($fields = []) { static::$fields = [['isRed', 'Есть красный', 0, 'cs\\Widget\\CheckBox2\\Validator', 'widget' => ['cs\\Widget\\CheckBox2\\CheckBox', []]], ['isBlue', 'Есть синий', 0, 'cs\\Widget\\CheckBox2\\Validator', 'widget' => ['cs\\Widget\\CheckBox2\\CheckBox', []]], ['isGreen', 'Есть курс', 0, 'cs\\Widget\\CheckBox2\\Validator', 'widget' => ['cs\\Widget\\CheckBox2\\CheckBox', []]]]; parent::__construct($fields); }
function __construct($fields = []) { static::$fields = [['data', 'Происхождение', 1, 'string']]; parent::__construct($fields); }
public function __construct($config = []) { self::$fields = [['name', 'Название', 1, 'string'], ['v', 'Напряжение', 1, 'integer'], ['kvt', 'Мощность', 1, 'integer'], ['price', 'Цена', 0, 'integer'], ['image', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => [370, 370, \cs\Widget\FileUpload2\FileUpload::MODE_THUMBNAIL_CUT]]]]], ['content', 'Описание', 0, 'string', 'widget' => ['cs\\Widget\\HtmlContent\\HtmlContent', []]]]; parent::__construct($config); }
function __construct($fields = []) { static::$fields = [['name_first', 'Имя', 0, 'string'], ['name_last', 'Фамилия', 0, 'string'], ['name_middle', 'Отчество', 0, 'string'], ['content', 'Описание', 0, 'string', 'widget' => ['cs\\Widget\\HtmlContent\\HtmlContent', []]], ['description', 'Описание краткое', 0, 'string'], ['image', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => \app\services\GsssHtml::$formatIcon]]]], ['date_born', 'Дата прихода', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['cs\\Widget\\DatePicker\\DatePicker', []]], ['date_death', 'Дата ухода', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['cs\\Widget\\DatePicker\\DatePicker', []]]]; parent::__construct($fields); }
public function update($fieldsCols = null) { return parent::update(['beforeUpdate' => function ($fields) { return $fields; }]); }
/** * Создает папку для загрузки * * @param array $field * @param \cs\base\BaseForm $model * * @return \cs\services\SitePath */ protected static function getFolderPath($field, $model) { $folder = ArrayHelper::getValue($field, 'type.1.folder', $model->getTableName()); return UploadFolderDispatcher::createFolder('FileUpload2', $folder, $model->id); }
function __construct($fields = []) { static::$fields = [['date1', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date2', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date3', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date4', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date5', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date6', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date7', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date8', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date9', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['date10', 'Дата', 0, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['kurs1', 'Курс', 0, 'double'], ['kurs2', 'Курс', 0, 'double'], ['kurs3', 'Курс', 0, 'double'], ['kurs4', 'Курс', 0, 'double'], ['kurs5', 'Курс', 0, 'double'], ['kurs6', 'Курс', 0, 'double'], ['kurs7', 'Курс', 0, 'double'], ['kurs8', 'Курс', 0, 'double'], ['kurs9', 'Курс', 0, 'double'], ['kurs10', 'Курс', 0, 'double'], ['stock_id', 'Курс', 0, 'integer']]; parent::__construct($fields); }
function __construct($fields = []) { static::$fields = [['monthCounter', 'Количество месяцев', 1, 'integer'], ['stockId', 'Котировка', 0, 'string'], ['finam_em', 'Идентификатор котировки', 0, 'integer']]; parent::__construct($fields); }
public function __construct($config = []) { self::$fields = [['username', 'Логин', 1, 'string'], ['name', 'Имя', 1, 'string']]; parent::__construct($config); }
public function __construct($config = []) { self::$fields = [['username', 'Логин', 1, 'string'], ['password', 'Пароль', 1, 'string'], ['rememberMe', 'Запомнить меня', 0, 'cs\\Widget\\CheckBox2\\Validator', 'widget' => ['cs\\Widget\\CheckBox2\\CheckBox', []]]]; parent::__construct($config); }
/** * @param array $field * @param \cs\base\BaseForm $model * * @return array поля для обновления в БД */ public static function onLoadDb($field, $model) { $fieldName = $field[BaseForm::POS_DB_NAME]; $row = $model->getRow(); if (isset($row[$fieldName])) { $model->{$fieldName} = $row[$fieldName] == 1; } else { $model->{$fieldName} = false; } }
public function __construct($config = []) { self::$fields = [['dateStart', 'Начало', 1, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['dateEnd', 'Конец', 1, 'cs\\Widget\\DatePicker\\Validator', 'widget' => ['\\cs\\Widget\\DatePicker\\DatePicker', ['dateFormat' => 'php:d.m.Y']]], ['isReplaceExisting', 'Заменять уже имеющиеся данные?', 0, 'cs\\Widget\\CheckBox2\\Validator', 'widget' => ['cs\\Widget\\CheckBox2\\CheckBox', []]]]; parent::__construct($config); }