Example #1
1
 public function run()
 {
     $items = [];
     $preContent = '';
     $isPost = \Yii::$app->request->isPost;
     $defaultLang = Lang::getLang()->code;
     foreach ($this->models as $k => $model) {
         $preContent .= $isPost && !$model->validate() ? '<div class="alert alert-warning" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4>' . $model->langModel->title . '</h4>' . Html::errorSummary($model) . '</div>' : '';
         $content = $this->view->render($this->template, ['model' => $model, 'k' => $k, 'form' => $this->form]);
         $items[] = ['label' => $model->langModel->title, 'content' => $content, 'active' => $model->lang == $defaultLang];
     }
     return $preContent . Tabs::widget(['items' => $items]);
 }
Example #2
0
 public static function errorSummary($models, $options = array())
 {
     $newOptions = ['class' => 'alert alert-danger'];
     $options = array_merge($options, $newOptions);
     $html = parent::errorSummary($models, $options);
     return $html;
 }
Example #3
0
 public function run($id)
 {
     $id = (int) $id;
     $userId = Adver::getUserIdFromAdver($id);
     $output = [];
     if ($userId != Yii::$app->getUser()->id) {
         $output = ['error' => true, 'message' => '<div class="alert alert-danger">' . Yii::t('app', 'The requested page does not exist.') . '</div>'];
     }
     if (empty($output) && !Gallery::checkLimitation($id)) {
         $output = ['error' => true, 'message' => '<div class="alert alert-danger">' . Yii::t('app', 'Image limitation per advertisement reached!') . '</div>'];
     }
     if (empty($output)) {
         $model = new Gallery(['scenario' => 'new']);
         if ($model->load(Yii::$app->request->post())) {
             $model->image = UploadedFile::getInstance($model, 'image');
             if ($model->image) {
                 $model->name = Yii::$app->helper->safeFile($model->image->baseName) . '-' . Yii::$app->getSecurity()->generateRandomString(6) . '-' . time() . '.' . $model->image->extension;
                 $path = $model->getImagePath($id) . DIRECTORY_SEPARATOR . $model->name;
                 $path = FileHelper::normalizePath($path);
                 $model->adver_id = $id;
                 if ($model->validate() && $model->image->saveAs($path, false)) {
                     if ($model->save()) {
                         $output = ['error' => false, 'message' => '<div class="alert alert-success">' . Yii::t('app', 'Image saved!') . '</div>'];
                     } else {
                         $output = ['error' => true, 'message' => '<div class="alert alert-danger">' . Yii::t('app', 'Error on saving image.') . '</div>'];
                     }
                 }
             }
         }
         if (empty($output)) {
             $output = ['error' => true, 'message' => \yii\helpers\Html::errorSummary($model, ["class" => "alert alert-danger"])];
         }
     }
     return \yii\helpers\Json::encode($output);
 }
Example #4
0
 /**
  * @param Model|string $message
  */
 public static function setFlashError($message)
 {
     if ($message instanceof Model) {
         $message = Html::errorSummary($message);
     }
     self::setFlash('error', $message);
 }
Example #5
0
 public function throwNewException($title)
 {
     if (!is_null($this)) {
         $title = '<h4>' . $title . '</h4>';
     }
     $options = ['header' => $title, 'footer' => ''];
     throw new Exception(Html::errorSummary($this, $options));
 }
 /**
  * @return \yii\web\Response
  */
 public function actionSearch()
 {
     $model = new RedisModel();
     if ($model->load(\Yii::$app->request->post()) && $model->storeFilter()) {
         \Yii::$app->session->setFlash('success', Redisman::t('redisman', 'Search query updated!'));
         return $this->redirect(['show']);
     } else {
         \Yii::$app->session->setFlash('error', Html::errorSummary($model));
         return $this->redirect(['index']);
     }
 }
Example #7
0
 /**
  * Validate Form action
  * @param Model $model
  * @param string $action
  * @return array
  */
 public function setAjaxData(Model $model, $action = 'save', $json = false)
 {
     $response = ['status' => 0, 'errors' => '', 'text' => ''];
     if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
         if ($model->{$action}()) {
             $response['status'] = 1;
         } else {
             $response['errors'] = Html::errorSummary($model);
         }
     }
     return $json ? json_encode($response) : [$model, $response];
 }
 public function actionAddComment()
 {
     $productId = Yii::$app->request->post('productId');
     $rank = Yii::$app->request->post('rank');
     $content = Yii::$app->request->post('content');
     $comment = new Comment();
     $comment->attributes = ['product_id' => $productId, 'user_id' => Yii::$app->user->identity->id, 'rank' => $rank, 'content' => $content];
     if ($comment->save(true)) {
         return ['status' => true, 'message' => '成功'];
     } else {
         return ['status' => false, 'message' => '失败: ' . Html::errorSummary($comment)];
     }
 }
 public function actionImport()
 {
     $model = new ModificatorUpload();
     if ($model->load($_POST)) {
         $model->file = UploadedFile::getInstance($model, 'file');
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         if ($model->import()) {
             return $this->redirect(['/store/admin/product/update', 'id' => $model->productId, 'tab' => 'modificator']);
         }
     }
     echo Html::errorSummary($model);
 }
 /** 
  * Registers a user
  * @param $data
  * @return Bool
  */
 private function registerUser($data)
 {
     $userModel = new User();
     $userModel->scenario = 'registration';
     $profileModel = $userModel->profile;
     $profileModel->scenario = 'registration';
     // User: Set values
     $userModel->username = $data['username'];
     $userModel->email = $data['email'];
     $userModel->group_id = $data['group_id'];
     $userModel->status = User::STATUS_ENABLED;
     // Profile: Set values
     $profileModel->firstname = $data['firstname'];
     $profileModel->lastname = $data['lastname'];
     // Password: Set values
     $userPasswordModel = new Password();
     $userPasswordModel->setPassword($data['password']);
     if ($userModel->save()) {
         // Save user profile
         $profileModel->user_id = $userModel->id;
         $profileModel->save();
         // Save user password
         $userPasswordModel->user_id = $userModel->id;
         $userPasswordModel->save();
         // Join space / create then join space
         foreach ($data['space_names'] as $key => $space_name) {
             // Find space by name attribute
             $space = Space::findOne(['name' => $space_name]);
             // Create the space if not found
             if ($space == null) {
                 $space = new Space();
                 $space->name = $space_name;
                 $space->save();
             }
             // Add member into space
             $space->addMember($userModel->id);
         }
         return true;
     } else {
         Yii::$app->session->setFlash('error', Html::errorSummary($userModel));
         return false;
     }
 }
 /**
  * @inheritdoc
  */
 public function actionCreate()
 {
     $model = new Dump($this->getModule()->dbList, $this->getModule()->customDumpOptions);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $dbInfo = $this->getModule()->getDbInfo($model->db);
         $dumpOptions = $model->makeDumpOptions();
         $manager = $this->getModule()->createManager($dbInfo);
         $dumpPath = $manager->makePath($this->getModule()->path, $dbInfo, $dumpOptions);
         $dumpCommand = $manager->makeDumpCommand($dumpPath, $dbInfo, $dumpOptions);
         Yii::trace(compact('dumpCommand', 'dumpPath', 'dumpOptions'), get_called_class());
         if ($model->runInBackground) {
             $this->runProcessAsync($dumpCommand);
         } else {
             $this->runProcess($dumpCommand);
         }
     } else {
         Yii::$app->session->setFlash('error', Yii::t('dbManager', 'Dump request invalid.') . '<br>' . Html::errorSummary($model));
     }
     return $this->redirect(['index']);
 }
 public function actionAdd()
 {
     $addModel = new SourceMessage();
     $sourceMessage = SourceMessage::find()->where(['category' => Yii::$app->request->post('categoryId'), 'message' => Yii::$app->request->post('SourceMessage')['message']])->one();
     if (empty($sourceMessage)) {
         if ($addModel->load(Yii::$app->request->post()) && $addModel->validate()) {
             $addModel->category = !empty($messageCategory) ? $messageCategory->category : Yii::$app->request->post('categoryId');
             if (empty($addModel->category)) {
                 Yii::$app->session->setFlash('error', 'Category empty');
                 return $this->redirect(Yii::$app->request->referrer);
             }
             $addModel->save();
             Yii::$app->session->setFlash('success', 'Data success created.');
         } else {
             Yii::$app->session->setFlash('error', Html::errorSummary($addModel));
         }
     } else {
         Yii::$app->session->setFlash('error', 'Such category already exists.');
     }
     return $this->redirect(Yii::$app->request->referrer);
 }
Example #13
0
 /**
  * Send request to Teleduino API and return HTML formatted response.
  *
  * @throws HttpException if invalid method was specified.
  */
 public function actionSendApiRequest()
 {
     $api = $this->module->api;
     $requestPostData = Yii::$app->request->post($api->getRequestModelClass());
     $method = isset($requestPostData['r']) ? $requestPostData['r'] : '';
     try {
         $model = $api->createAndConfigureRequestModel($method);
     } catch (\Exception $e) {
         throw new HttpException(400, "Invalid method: {$method}.");
     }
     if (!($model->load(Yii::$app->request->post()) && $model->validate())) {
         return Html::errorSummary($model);
     }
     // If user selected RAW(JSON) response format
     if ('pretty' !== Yii::$app->request->post('response_formatting')) {
         try {
             $responseText = $api->requestRawFromModel($model);
         } catch (\Exception $e) {
             $responseText = 'Error: ' . $e->getMessage();
         }
         return $this->renderPartial('_responseRaw', ['rawResponse' => $responseText]);
     }
     $success = false;
     $time = null;
     try {
         $response = $api->requestFromModel($model);
         if ($response->isSuccessful()) {
             $success = true;
             $message = $api->formatResponseValuesHtml($method, $response->getValues());
             $time = $response->getTime();
         } else {
             $message = nl2br($response->getErrorMessage());
         }
     } catch (\Exception $e) {
         $message = 'Error: ' . $e->getMessage();
     }
     return $this->renderPartial('_responsePretty', ['success' => $success, 'message' => $message, 'time' => $time]);
 }
Example #14
0
 public function actionAjaxUpdate()
 {
     $model = new Poll();
     // Check if there is an Editable ajax request
     if (isset($_POST['hasEditable'])) {
         $id = Yii::$app->request->post('editableKey');
         $model = $this->findModel($id);
         $model->setScenario('editable');
         $message = '';
         // use Yii's response format to encode output as JSON
         \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         // fetch the first entry in posted data (there should
         // only be one entry anyway in this array for an
         // editable submission)
         // - $posted is the posted data for model without any indexes
         // - $post is the converted array for single model validation
         $post = [];
         $posted = current($_POST[$model->formName()]);
         $post[$model->formName()] = $posted;
         // read your posted model attributes
         if ($model->load($post)) {
             if (!$model->save()) {
                 $errors = \yii\helpers\Html::errorSummary($model);
                 $message .= Yii::t('app/error', 'Poll wasn\'t saved!{errors}', ['errors' => $errors]);
             }
             // custom output to return to be displayed as the editable grid cell
             // data. Normally this is empty - whereby whatever value is edited by
             // in the input by user is updated automatically.
             $output = '';
             return ['output' => $output, 'message' => $message];
         } else {
             // else if nothing to do always return an empty JSON encoded output
             return ['output' => '', 'message' => ''];
         }
     }
 }
 /**
  * Renders validator errors of filter model.
  * @return string the rendering result.
  */
 public function renderErrors()
 {
     if ($this->filterModel instanceof Model && $this->filterModel->hasErrors()) {
         return Html::errorSummary($this->filterModel, $this->filterErrorSummaryOptions);
     } else {
         return '';
     }
 }
Example #16
0
 /**
  * Generates a summary of the validation errors.
  * If there is no validation error, an empty error summary markup will still be generated, but it will be hidden.
  * @param Model|Model[] $models the model(s) associated with this form
  * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
  *
  * - header: string, the header HTML for the error summary. If not set, a default prompt string will be used.
  * - footer: string, the footer HTML for the error summary.
  *
  * The rest of the options will be rendered as the attributes of the container tag. The values will
  * be HTML-encoded using [[\yii\helpers\Html::encode()]]. If a value is null, the corresponding attribute will not be rendered.
  * @return string the generated error summary
  * @see errorSummaryCssClass
  */
 public function errorSummary($models, $options = [])
 {
     Html::addCssClass($options, $this->errorSummaryCssClass);
     $options['encode'] = $this->encodeErrorSummary;
     return Html::errorSummary($models, $options);
 }
Example #17
0
 /**
  * @inheritdoc
  */
 public static function errorSummary($models, $options = [])
 {
     static::addCssClasses($options, ['ui', 'message']);
     return parent::errorSummary($models, $options);
 }
Example #18
0
/* @var $categories app\models\master\PriceCategory[] */
$this->title = 'Create Price';
$this->params['breadcrumbs'][] = ['label' => 'Prices', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    #tabular-input input{
        text-align: right;
    }
</style>
<div class="col-lg-12 price-create">
    <?php 
echo Html::beginForm('', '', ['id' => 'price-form']);
?>
    <?php 
echo Html::errorSummary($products);
?>
    <?php 
echo Toolbar::widget(['items' => [['label' => 'Save', 'icon' => 'fa fa-save', 'linkOptions' => ['class' => 'btn btn-warning btn-sm', 'id' => 'save']]]]);
?>
    <?php 
echo ActionToolbar::widget(['items' => [['label' => 'Create', 'url' => ['create'], 'icon' => 'fa fa-plus-square'], ['label' => 'Purchase List', 'url' => ['index'], 'icon' => 'fa fa-list'], ['linkOptions' => ['class' => 'divider']], ['label' => 'Others', 'icon' => 'fa fa-check']]]);
?>
    
    <div class="box box-info">
        <div class="box-body">
            <?php 
echo Html::textInput('number', $purchase->number);
?>
            <?php 
echo Html::textInput('nmSupplier', $purchase->nmSupplier);
Example #19
0
 public function actionContact()
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $response = [];
     $data = json_decode(utf8_encode(file_get_contents("php://input")), false);
     $model = new Contact_form();
     $model->name = $data->name;
     $model->email = $data->email;
     $model->message = $data->message;
     $model->mobile = $data->mobile;
     $model->interest = $data->interest;
     $valid = $model->validate();
     if ($valid) {
         $subject = "Tropical Homes Ltd - Contact";
         $message_text = "Name: " . $model->name . "<br/>" . "Email: " . $model->email . "<br/>" . "Mobile: " . $model->mobile . "<br/>" . "Interest: " . $model->interest . "<br/>" . "Message: " . $model->message;
         try {
             $message = Yii::$app->mailer->compose();
             $message->setFrom($model->email);
             $message->setTo('*****@*****.**');
             $message->setSubject($subject);
             $message->setHtmlBody($message_text);
             if ($message->send()) {
                 $response['result'] = 1;
                 $response['msg'] = 'Thank you for your interest in Tropical homes.';
             }
         } catch (Exception $e) {
             $response['result'] = 0;
             $response['msg'] = $e;
         }
     } else {
         $response['result'] = 0;
         $response['msg'] = Html::errorSummary($model);
     }
     return $response;
 }
Example #20
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\widgets\Select2;
/* @var $this yii\web\View */
/* @var $model app\models\Teacher */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="teacher-form">

    <?php 
echo $model->hasErrors() ? Html::errorSummary($model) : null;
?>

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'gender')->dropDownList($model->getGendersArray());
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'phone')->textInput(['maxlength' => true]);
?>
Example #21
0
<?php

use common\helpers\LanguageHelper;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \backend\modules\configuration\components\ConfigurationModel */
$values = $model->getModels();
?>

<div class="menu-form">
    <?php 
echo Html::errorSummary($values, ['class' => 'alert alert-danger']);
?>
    <?php 
/** @var \metalguardian\formBuilder\ActiveFormBuilder $form */
$form = \metalguardian\formBuilder\ActiveFormBuilder::begin();
?>

    <?php 
$items = [];
$content = null;
foreach ($values as $value) {
    $attribute = '[' . $value->id . ']value';
    $configuration = $value->getValueFieldConfig();
    $configuration['label'] = $value->description . ' [key: ' . $value->id . '] [language: ' . LanguageHelper::getCurrent()->code . ']';
    $content .= $form->renderField($value, $attribute, $configuration);
    if ($value instanceof \common\components\model\Translateable && $value->isTranslateAttribute($attribute)) {
        foreach ($value->getTranslationModels() as $languageModel) {
            $configuration['label'] = $value->description . ' [key: ' . $value->id . '] [language: ' . $languageModel->language . ']';
            $content .= $form->renderField($languageModel, '[' . $languageModel->language . ']' . $attribute, $configuration);
        }
Example #22
0
 /**
  * Deletes an existing Post model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete()
 {
     if (Yii::$app->request->isAjax) {
         $id = $_POST['id'];
         if ($this->findModel($id)->delete()) {
             $response['files'] = ['ok'];
             $response['result'] = 'success';
             return json_encode($response);
         } else {
             $response['result'] = 'error';
             $response['files'] = Html::errorSummary($model);
             return json_encode($response);
         }
     }
 }
Example #23
0
 public function actionEditable($name)
 {
     if (!\Yii::$app->request->post('hasEditable')) {
         throw new BadRequestHttpException();
     }
     /** @var $model \yii\db\ActiveRecord */
     $model = $this->module->loadModel($name, \Yii::$app->request->post('editableKey'));
     $output = '';
     $message = '';
     $modelShortName = $model->formName();
     $post = \Yii::$app->request->post($modelShortName);
     $modelAttributes = current($post);
     if ($model->load([$modelShortName => $modelAttributes])) {
         if (!$model->save()) {
             $message = Html::errorSummary($model);
         }
     }
     return Json::encode(['output' => $output, 'message' => $message]);
 }
Example #24
0
 /**
  * Performs state changes.
  */
 public function execute()
 {
     $this->targetState = Yii::$app->request->getQueryParam('targetState');
     $baseModel = $this->initModel();
     list($stateChange, $sourceState) = $this->getTransition($baseModel);
     $response = $this->checkTransition($baseModel, $stateChange, $sourceState, true);
     $stateAuthItem = isset($stateChange['state']->auth_item_name) ? $stateChange['state']->auth_item_name : null;
     $transaction = $this->beforeExecute($baseModel);
     if ($this->singleQuery) {
         throw new yii\base\InvalidConfigException('Not implemented - the singleQuery option has not been implemented yet.');
     }
     $dataProvider = $this->getDataProvider($baseModel, $this->getQuery($baseModel));
     $skippedModels = [];
     $failedModels = [];
     $successModels = [];
     if ($response !== true) {
         return $dataProvider;
     }
     foreach ($dataProvider->getModels() as $model) {
         /** @var IStateful|\netis\crud\db\ActiveRecord $model */
         if (!$this->controller->hasAccess('update', $model) || $stateAuthItem !== null && !Yii::$app->user->can($stateAuthItem, ['model' => $model])) {
             $skippedModels[] = $model;
             continue;
         }
         $model->scenario = IStateful::SCENARIO;
         $model->setTransitionRules($this->targetState);
         if (!$this->performTransition($model, $stateChange, $sourceState, true)) {
             //! @todo errors should be gathered and displayed somewhere, maybe add a postSummary action in this class
             $failedModels[$model->__toString()] = \yii\helpers\Html::errorSummary($model, ['header' => '']);
         } else {
             $successModels[] = $model;
         }
     }
     $this->afterExecute($baseModel, $transaction);
     $this->setSuccessMessage($baseModel, $skippedModels, $failedModels, $successModels);
     $route = is_callable($this->postRoute) ? call_user_func($this->postRoute, $baseModel) : $this->postRoute;
     $response = Yii::$app->getResponse();
     $response->setStatusCode(201);
     $response->getHeaders()->set('Location', Url::toRoute($route, true));
     return $dataProvider;
 }
Example #25
0
?>
                </div>
            </div>
        </div>
        <div class="col-lg-6 animated bounceInRight" id="assign-section">
            <div class="row">
                <div class="col-lg-12">
                    <div class="headline">
                        <h2> Assign <?php 
echo $authModel->actionType == 2 ? "Permission" : "Role";
?>
</h2>
                    </div>
                    <div>
                        <?php 
echo Html::errorSummary($authModel);
?>
                        <?php 
echo Html::beginForm(['authorization/assign'], 'post', ['class' => 'sky-form form-inline', 'style' => 'border:none']);
?>
                        <section>
                            <label class="contorl-label">Select <?php 
echo $authModel->actionType == 2 ? "permission" : "role";
?>
 to assign to <?php 
echo $model->name;
?>
</label>
                            <label class="select">
                                <?php 
echo Html::activeDropDownList($authModel, 'name', $authModel->getAvailableOptions(), ['prompt' => 'Required to select']);
Example #26
0
	</div>
</div>
<!-- 页面头部 end -->

<div style="clear:both;"></div>

<?php 
echo Html::beginForm(["order/create"], "post", ["id" => 'create-order-form']);
?>
    <?php 
echo Html::csrfMetaTags();
?>
    <!-- 主体部分 start -->
    <div class="fillin w990 bc mt15">
        <p><?php 
echo Html::errorSummary($model);
?>
</p>
        <div class="fillin_hd">
            <h2>填写并核对订单信息</h2>
        </div>

        <div class="fillin_bd">
            <!-- 收货人信息  start-->
            <div class="address">
                <h3>收货人信息</h3>

                <div class="address_select">
                    <form action="" class="" name="address_form">
                        <ul>
                            <li>
Example #27
0
 public function importStuData($model)
 {
     $dispResults = [];
     $totalSuccess = 0;
     $objPHPExcel = PHPExcel_IOFactory::load($model->importFilePath . $model->importFile);
     $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     //print_r($sheetData); exit;
     unset($sheetData[1]);
     //start import student row by row
     foreach ($sheetData as $k => $line) {
         //print_r($line); exit;
         if (!array_filter($line)) {
             continue;
         }
         $line = array_map('trim', $line);
         $line = array_map(function ($value) {
             return empty($value) ? NULL : $value;
         }, $line);
         $stuMaster = new StuMaster();
         $stuInfo = new StuInfo();
         $stuInfo->scenario = 'import-stu';
         $stuAddress = new StuAddress();
         $user = new User();
         $auth_assign = new AuthAssignment();
         //set student info attributes
         $stuInfo->stu_unique_id = $stuInfo->getUniqueId();
         // Student Unique Id
         $stuInfo->stu_title = $this->valueReplace($line['A'], $stuInfo->getTitleOptions());
         //Title Name
         $stuInfo->stu_first_name = $line['B'];
         //First Name
         $stuInfo->stu_last_name = $line['C'];
         //Last Name
         $stuInfo->stu_dob = Yii::$app->dateformatter->getDateFormat($line['D']);
         //Date of Birth
         $stuInfo->stu_admission_date = Yii::$app->dateformatter->getDateFormat($line['H']);
         //Student Admission Date
         $stuInfo->stu_gender = $this->valueReplace($line['I'], $stuInfo->getGenderOptions());
         // Gender
         $stuInfo->stu_email_id = $line['J'];
         // Email ID
         $stuInfo->stu_mobile_no = $line['K'];
         // Mobile No
         //set student master attribute
         $stuMaster->stu_master_course_id = $this->valueReplace($line['E'], Courses::getStuCourse());
         // Course
         $stuMaster->stu_master_batch_id = $this->valueReplace($line['F'], Batches::getStuBatches());
         // Batch
         $stuMaster->stu_master_section_id = $this->valueReplace($line['G'], Section::getStuSection());
         // Section
         $stuMaster->stu_master_category_id = $this->valueReplace($line['L'], StuCategory::getStuCategoryId());
         //Admission Category
         $stuMaster->stu_master_nationality_id = $this->valueReplace($line['M'], Nationality::getNationality());
         //Nationality
         //set student address attribute
         $stuAddress->stu_cadd = $line['N'];
         //Current Address
         $stuAddress->stu_cadd_city = $this->valueReplace($line['O'], City::getAllCity());
         //City
         $stuAddress->stu_cadd_state = $this->valueReplace($line['P'], State::getAllState());
         //State
         $stuAddress->stu_cadd_country = $this->valueReplace($line['Q'], Country::getAllCountry());
         //Country
         $stuAddress->stu_cadd_pincode = $line['R'];
         //Pincode
         $stuAddress->stu_cadd_house_no = $line['S'];
         //House No
         $stuAddress->stu_cadd_phone_no = $line['T'];
         //Phone No
         //set user login info attributes
         $uniq_id = $stuInfo->getUniqueId();
         $login_id = \app\models\Organization::find()->one()->org_stu_prefix . $uniq_id;
         $user->user_login_id = $login_id;
         //user login id
         $user->user_password = md5($user->user_login_id . $user->user_login_id);
         //user password
         $user->user_type = "S";
         //user type
         $user->created_by = Yii::$app->getid->getId();
         //created by
         $user->created_at = new \yii\db\Expression('NOW()');
         //created at
         if ($user->validate() && $stuInfo->validate() && $stuAddress->validate()) {
             $transaction = Yii::$app->db->beginTransaction();
             try {
                 if ($stuInfo->save() && $user->save() && $stuAddress->save()) {
                     $stuMaster->stu_master_stu_info_id = $stuInfo->stu_info_id;
                     $stuMaster->stu_master_user_id = $user->user_id;
                     $stuMaster->stu_master_stu_address_id = $stuAddress->stu_address_id;
                     $stuMaster->created_by = Yii::$app->getid->getId();
                     $stuMaster->created_at = new \yii\db\Expression('NOW()');
                     if ($stuMaster->save()) {
                         $stuInfo->stu_info_stu_master_id = $stuMaster->stu_master_id;
                         if ($stuInfo->save(false)) {
                             $auth_assign->item_name = 'Student';
                             $auth_assign->user_id = $user->user_id;
                             $auth_assign->created_at = date_format(date_create(), 'U');
                             $auth_assign->save(false);
                             $transaction->commit();
                             $totalSuccess += 1;
                             $dispResults[] = array_merge($line, ['type' => 'S', 'stuMasterId' => $stuMaster->stu_master_id, 'message' => 'Success']);
                         }
                     } else {
                         $dispResults[] = array_merge($line, ['type' => 'E', 'message' => Html::errorSummary($stuMaster)]);
                     }
                 }
                 // end stuInfo, user, StuAddress
                 $transaction->rollback();
             } catch (\Exception $e) {
                 $transaction->rollBack();
                 $dispResults[] = array_merge($line, ['type' => 'E', 'message' => $e->getMessage()]);
             }
         } else {
             $dispResults[] = array_merge($line, ['type' => 'E', 'message' => Html::errorSummary([$user, $stuInfo, $stuMaster, $stuAddress])]);
         }
         //end validated if
     }
     //end foreach
     return ['dispResults' => $dispResults, 'totalSuccess' => $totalSuccess];
 }
Example #28
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use backend\models\master\Warehouse;
/* @var $this yii\web\View */
/* @var $model backend\models\inventory\StockOpname */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="stock-opname-form">
    <?php 
echo Html::errorSummary($model, ['class' => 'alert alert-danger alert-dismissible']);
?>
    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
    <div class="row">
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'number')->textInput(['maxlength' => true]);
?>

            <?php 
echo $form->field($model, 'warehouse_id')->dropDownList(Warehouse::selectOptions());
?>

            <?php 
echo $form->field($model, 'Date')->widget('yii\\jui\\DatePicker', ['dateFormat' => 'dd-MM-yyyy', 'options' => ['class' => 'form-control', 'style' => 'width:60%;']]);
?>
        </div>
<?php

/* @var $this yii\web\View */
/* @var $shop corpsepk\yml\models\Shop */
use yii\helpers\Html;
echo Html::errorSummary($shop);
Example #30
0
 /**
  * @return \yii\web\Response
  */
 public function actionMove()
 {
     $model = new RedisItem();
     $model->scenario = 'move';
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $model->move();
         \Yii::$app->session->setFlash('success', Redisman::t('redisman', 'Key moved from Db№ {from} to {to}', ['from' => $this->module->getCurrentDb(), 'to' => $model->db]));
     } else {
         \Yii::$app->session->setFlash('error', Html::errorSummary($model, ['encode' => true]));
     }
     return $this->redirect(Url::to(['/redisman/default/show']));
 }