示例#1
2
 /**
  * Gets all a combined map of all the settings.
  * @return array
  */
 public function getSettings()
 {
     $settings = static::find()->where(['active' => 1])->asArray()->all();
     return array_merge_recursive(ArrayHelper::map($settings, 'key', 'value', 'section'), ArrayHelper::map($settings, 'key', 'type', 'section'));
 }
示例#2
0
 /**
  * Получить массив собранных данных
  * @param array $condition
  * @return array
  */
 public static function listData($condition = [])
 {
     $query = self::find();
     if ($condition) {
         $query->where($condition[0], !empty($condition[1]) ? $condition[1] : []);
     }
     return ArrayHelper::map($query->all(), 'id', 'title');
 }
示例#3
0
 /**
  * Verificar si tiene unidad ejecutora asociada
  * @return bool
  */
 public function existe_uej()
 {
     $resultado = ArrayHelper::map(AcEspUej::find()->limit(1)->where('id_ac_esp= :id', ['id' => $this->id])->all(), 'id', 'id_ue');
     if (count($resultado) > 0) {
         return 1;
     } else {
         return 0;
     }
 }
示例#4
0
 public static function unserializeRecursive($value)
 {
     if (empty($value)) {
         return $value;
     }
     if (is_array($value)) {
         return ArrayHelper::map($value, function ($value) {
             return static::unserializeRecursive($value);
         }, true);
     }
     return static::unserialize($value, false);
 }
示例#5
0
 public static function createMultiple($modelClass, $multipleModels = [])
 {
     $model = new $modelClass();
     $formName = $model->formName();
     $post = Yii::$app->request->post($formName);
     $models = [];
     if (!empty($multipleModels)) {
         $keys = array_keys(ArrayHelper::map($multipleModels, 'id', 'id'));
         $multipleModels = array_combine($keys, $multipleModels);
     }
     if ($post && is_array($post)) {
         foreach ($post as $i => $item) {
             if (isset($item['id']) && !empty($item['id']) && isset($multipleModels[$item['id']])) {
                 $models[] = $multipleModels[$item['id']];
             } else {
                 $models[] = new $modelClass();
             }
         }
     }
     unset($model, $formName, $post);
     return $models;
 }
示例#6
0
文件: Books.php 项目: jav68/test_yii2
 /**
  * @param string $keyField
  * @param string $valueField
  * @param bool $asArray
  * @return mixed
  */
 public static function listAll($keyField = 'id', $valueField = 'name', $asArray = true)
 {
     $query = static::find();
     if ($asArray) {
         $query->select([$keyField, $valueField])->asArray();
     }
     return ArrayHelper::map($query->all(), $keyField, $valueField);
 }
示例#7
0
 public static function getUsersList()
 {
     $sql = 'SELECT `id`, `nickname` FROM ' . self::tableName() . ' ORDER BY `nickname`';
     $rows = Yii::$app->db->createCommand($sql)->queryAll();
     return ArrayHelper::map($clients, 'id', 'nickname');
 }
示例#8
0
 */
use yii\helpers\Html;
use kartik\grid\GridView;
use yii\widgets\Pjax;
/** @var IdentityInterface|ActiveRecord $identity */
$identity = Yii::$app->getUser()->identityClass;
$this->title = Module::t('Requests');
echo Breadcrumbs::widget(['links' => [$this->title]]);
?>
<div class="request-log-default-index">
    <h3><?php 
echo Html::encode($this->title);
?>
</h3>

    <?php 
Pjax::begin();
echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $dataProvider, 'columns' => [['attribute' => 'id', 'value' => function ($model, $index, $dataColumn) {
    /** @var RequestLog $model */
    return $model->id;
}, 'filter' => false], 'app_id', 'route', 'params', ['attribute' => 'user_id', 'value' => function ($model, $index, $dataColumn) {
    return $model->user ? $model->user->{Module::getInstance()->usernameAttribute} : Module::t('Guest');
}, 'filter' => ArrayHelper::map($identity::find()->all(), 'id', Module::getInstance()->usernameAttribute)], 'ip', ['attribute' => 'datetime', 'value' => function ($model, $index, $dataColumn) {
    return $model->datetime;
}, 'filter' => false], ['attribute' => 'user_agent', 'value' => function ($model, $index, $dataColumn) {
    return $model->user_agent;
}, 'filter' => false]]]);
Pjax::end();
?>
</div>
示例#9
0
<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use common\models\Suppliers;
use common\models\Brands;
use common\models\Producttypes;
use common\models\Productcategories;
/* @var $this yii\web\View */
/* @var $model common\models\Products */
/* @var $form yii\bootstrap\ActiveForm */
$dataProductCategory = ArrayHelper::map(Productcategories::find()->asArray()->all(), 'ProductCategoryId', 'Name');
$dataSuppliers = ArrayHelper::map(Suppliers::find()->asArray()->all(), 'SupplierId', 'Name');
$dataBrands = ArrayHelper::map(Brands::find()->asArray()->all(), 'BrandId', 'Name');
$dataProducttypes = ArrayHelper::map(Producttypes::find()->asArray()->all(), 'ProducttypeId', 'Name');
?>
<div class="products-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal']);
?>

    <?php 
echo $form->field($model, 'Name', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->textInput(['maxlength' => 500]);
?>

    <?php 
echo $form->field($model, 'ProductCategoryId', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList($dataProductCategory, ['prompt' => '----------Choose a Category----------']);
?>

    <?php 
示例#10
0
 /**
  * Updates an existing Dealership model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdatedealer($id)
 {
     $modelDealership = $this->findModel($id);
     $modelsShowroom = $modelDealership->Showroomes;
     if ($modelDealership->load(Yii::$app->request->post())) {
         $oldIDs = ArrayHelper::map($modelsShowroom, 'id', 'id');
         $modelsShowroom = Model::createMultiple(Showroom::classname(), $modelsShowroom);
         Model::loadMultiple($modelsShowroom, Yii::$app->request->post());
         $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsShowroom, 'id', 'id')));
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ArrayHelper::merge(ActiveForm::validateMultiple($modelsShowroom), ActiveForm::validate($modelDealership));
         }
         // validate all models
         $valid = $modelDealership->validate();
         $valid = $modelDealeraccount->validate();
         $valid = Model::validateMultiple($modelsShowroom) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if (($flag = $modelDealership->save(false)) && ($flag = $modelDealeraccount->save(false))) {
                     if (!empty($deletedIDs)) {
                         Showroom::deleteAll(['id' => $deletedIDs]);
                     }
                     foreach ($modelsShowroom as $modelShowroom) {
                         $modelShowroom->Dealership_id = $modelDealership->id;
                         if (!($flag = $modelShowroom->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $modelDealership->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('update', ['modelDealership' => $modelDealership, 'modelsShowroom' => empty($modelsShowroom) ? [new Showroom()] : $modelsShowroom, 'modelsService' => empty($modelsService) ? [new Service()] : $modelsService]);
 }
示例#11
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\PacienteSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="paciente-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>

    <?php 
echo $form->field($model, 'persona_id')->dropDownList(ArrayHelper::map(Persona::find()->all(), 'id', 'fullName'), ['prompt' => 'Seleccionar Persona']);
?>


    <?php 
echo $form->field($model, 'descripcion');
?>

    <div class="form-group">
        <?php 
echo Html::submitButton('Buscar', ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::resetButton('Reiniciar', ['class' => 'btn btn-default']);
?>
    </div>
示例#12
0
 public function createFromInvoice($data, $model = null)
 {
     $pay_vals = ArrayHelper::map($data['details'], 'id_invoice', 'value');
     $ids = array_keys($pay_vals);
     $invoice_values = Invoice::find()->where(['id_invoice' => $ids])->indexBy('id_invoice')->asArray()->all();
     $vendor = $inv_type = null;
     $vendors = $inv_types = [];
     foreach ($invoice_values as $row) {
         $vendor = $row['id_vendor'];
         $vendors[$vendor] = true;
         $inv_type = $row['invoice_type'];
         $inv_types[$inv_type] = true;
     }
     if (count($vendors) !== 1) {
         throw new UserException('Vendor harus sama');
     }
     if (count($inv_types) !== 1) {
         throw new UserException('Type invoice harus sama');
     }
     $invoice_paid = PaymentDtl::find()->select(['id_invoice', 'total' => 'sum(payment_value)'])->joinWith('idPayment')->where(['payment_type' => $inv_type, 'id_invoice' => $ids])->groupBy('id_invoice')->indexBy('id_invoice')->asArray()->all();
     $data['id_vendor'] = $vendor;
     $data['payment_type'] = $inv_type;
     $details = [];
     foreach ($inv_vals as $id => $value) {
         $sisa = $invoice_values[$id]['invoice_value'];
         if (isset($invoice_paid[$id])) {
             $sisa -= $invoice_paid[$id]['total'];
         }
         if ($value > $sisa) {
             throw new UserException('Tagihan lebih besar dari sisa');
         }
         $details[] = ['id_invoice' => $id, 'payment_value' => $value];
     }
     $data['details'] = $details;
     return static::create($data, $model);
 }
$colorPluginOptions = ['showPalette' => true, 'showPaletteOnly' => true, 'showSelectionPalette' => true, 'showAlpha' => false, 'allowEmpty' => false, 'preferredFormat' => 'name', 'palette' => [["white", "black", "grey", "silver", "gold", "brown"], ["red", "orange", "yellow", "indigo", "maroon", "pink"], ["blue", "green", "violet", "cyan", "magenta", "purple"]]];
$gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '36px', 'header' => '', 'headerOptions' => ['class' => 'kartik-sheet-style']], ['class' => 'kartik\\grid\\RadioColumn', 'width' => '36px', 'headerOptions' => ['class' => 'kartik-sheet-style']], ['class' => 'kartik\\grid\\ExpandRowColumn', 'width' => '50px', 'value' => function ($model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
    return Yii::$app->controller->renderPartial('_expand-row-details', ['model' => $model]);
}, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'name', 'pageSummary' => 'Total', 'vAlign' => 'middle', 'width' => '210px', 'readonly' => function ($model, $key, $index, $widget) {
    return !$model->status;
    // do not allow editing of inactive records
}, 'editableOptions' => function ($model, $key, $index) use($colorPluginOptions) {
    return ['header' => 'Name', 'size' => 'md', 'afterInput' => function ($form, $widget) use($model, $index, $colorPluginOptions) {
        return $form->field($model, "color")->widget(\kartik\widgets\ColorInput::classname(), ['showDefaultPalette' => false, 'options' => ['id' => "color-{$index}"], 'pluginOptions' => $colorPluginOptions]);
    }];
}], ['attribute' => 'color', 'value' => function ($model, $key, $index, $widget) {
    return "<span class='badge' style='background-color: {$model->color}'> </span>  <code>" . $model->color . '</code>';
}, 'width' => '8%', 'filterType' => GridView::FILTER_COLOR, 'filterWidgetOptions' => ['showDefaultPalette' => false, 'pluginOptions' => $colorPluginOptions], 'vAlign' => 'middle', 'format' => 'raw', 'noWrap' => $this->noWrapColor], ['attribute' => 'author_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($model, $key, $index, $widget) {
    return Html::a($model->author->name, '#', ['title' => 'View author detail', 'onclick' => 'alert("This will open the author page.\\n\\nDisabled for this demo!")']);
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Author::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Any author'], 'format' => 'raw'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'publish_date', 'hAlign' => 'center', 'vAlign' => 'middle', 'width' => '9%', 'format' => 'date', 'xlFormat' => "mmm\\-dd\\, \\-yyyy", 'headerOptions' => ['class' => 'kv-sticky-column'], 'contentOptions' => ['class' => 'kv-sticky-column'], 'readonly' => function ($model, $key, $index, $widget) {
    return !$model->status;
    // do not allow editing of inactive records
}, 'editableOptions' => ['header' => 'Publish Date', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_WIDGET, 'widgetClass' => 'kartik\\datecontrol\\DateControl', 'options' => ['type' => \kartik\datecontrol\DateControl::FORMAT_DATE, 'displayFormat' => 'dd.MM.yyyy', 'saveFormat' => 'php:Y-m-d', 'options' => ['pluginOptions' => ['autoclose' => true]]]]], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'buy_amount', 'readonly' => function ($model, $key, $index, $widget) {
    return !$model->status;
    // do not allow editing of inactive records
}, 'editableOptions' => ['header' => 'Buy Amount', 'inputType' => \kartik\editable\Editable::INPUT_SPIN, 'options' => ['pluginOptions' => ['min' => 0, 'max' => 5000]]], 'hAlign' => 'right', 'vAlign' => 'middle', 'width' => '7%', 'format' => ['decimal', 2], 'pageSummary' => true], ['attribute' => 'sell_amount', 'vAlign' => 'middle', 'hAlign' => 'right', 'width' => '7%', 'format' => ['decimal', 2], 'pageSummary' => true], ['class' => 'kartik\\grid\\FormulaColumn', 'header' => 'Buy + Sell<br>(BS)', 'vAlign' => 'middle', 'value' => function ($model, $key, $index, $widget) {
    $p = compact('model', 'key', 'index');
    return $widget->col(7, $p) + $widget->col(8, $p);
}, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'hAlign' => 'right', 'width' => '7%', 'format' => ['decimal', 2], 'mergeHeader' => true, 'pageSummary' => true, 'footer' => true], ['class' => 'kartik\\grid\\FormulaColumn', 'header' => 'Buy %<br>(100 * B/BS)', 'vAlign' => 'middle', 'hAlign' => 'right', 'width' => '7%', 'value' => function ($model, $key, $index, $widget) {
    $p = compact('model', 'key', 'index');
    return $widget->col(9, $p) != 0 ? $widget->col(7, $p) * 100 / $widget->col(9, $p) : 0;
}, 'format' => ['decimal', 2], 'headerOptions' => ['class' => 'kartik-sheet-style'], 'mergeHeader' => true, 'pageSummary' => true, 'pageSummaryFunc' => GridView::F_AVG, 'footer' => true], ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'status', 'vAlign' => 'middle'], ['class' => 'kartik\\grid\\ActionColumn', 'dropdown' => $this->dropdown, 'dropdownOptions' => ['class' => 'pull-right'], 'urlCreator' => function ($action, $model, $key, $index) {
    return '#';
}, 'viewOptions' => ['title' => 'This will launch the book details page. Disabled for this demo!', 'data-toggle' => 'tooltip'], 'updateOptions' => ['title' => 'This will launch the book update page. Disabled for this demo!', 'data-toggle' => 'tooltip'], 'deleteOptions' => ['title' => 'This will launch the book delete action. Disabled for this demo!', 'data-toggle' => 'tooltip'], 'headerOptions' => ['class' => 'kartik-sheet-style']], ['class' => 'kartik\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'kartik-sheet-style']]];
示例#14
0
$this->title = 'Заказы';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="orders-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать заказ', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'consumer_id', 'label' => 'Заказчик', 'format' => 'text', 'content' => function ($data) {
    return $data->getConsumerName();
}], 'qty', 'sum', 'paid', ['attribute' => 'order_status_id', 'label' => 'Статус', 'format' => 'text', 'content' => function ($data) {
    return $data->getOrderStatusName();
}, 'value' => function ($model, $key, $index, $column) {
    return Html::activeDropDownList($model, 'order_status_id', ArrayHelper::map(backend\models\OrdersStatus::find()->all(), 'id', 'name'));
}, 'filter' => backend\models\Orders::getOrderStatusList()], 'comment:ntext', ['attribute' => 'created_at', 'label' => 'Создано', 'format' => ['date', 'dd/MM/Y HH:mm:ss'], 'headerOptions' => ['width' => '200']], ['attribute' => 'updated_at', 'format' => ['date', 'dd/MM/Y HH:mm:ss'], 'options' => ['width' => '200']], ['label' => 'Содержимое', 'format' => 'raw', 'value' => function ($data) {
    return Html::a('Перейти', $data->getUrlReservationInfo(), ['title' => 'Смелей вперед!', 'target' => '_blank']);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
示例#15
0
 /**
  * Updates an existing Po model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelsPoItem = $model->poItems;
     if ($model->load(Yii::$app->request->post())) {
         $oldIDs = ArrayHelper::map($modelsPoItem, 'id', 'id');
         $modelsPoItem = Model::createMultiple(Address::classname(), $modelsPoItem);
         Model::loadMultiple($modelsPoItem, Yii::$app->request->post());
         $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsPoItem, 'id', 'id')));
         // ajax validation
         /*if (Yii::$app->request->isAjax) {
               Yii::$app->response->format = Response::FORMAT_JSON;
               return ArrayHelper::merge(
                   ActiveForm::validateMultiple($modelsPoItem),
                   ActiveForm::validate($model)
               );
           }*/
         // validate all models
         $valid = $model->validate();
         $valid = Model::validateMultiple($modelsPoItem) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $model->save(false)) {
                     if (!empty($deletedIDs)) {
                         Address::deleteAll(['id' => $deletedIDs]);
                     }
                     foreach ($modelsPoItem as $modelPoItem) {
                         $modelPoItem->po_id = $model->id;
                         if (!($flag = $modelPoItem->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('update', ['model' => $model, 'modelsPoItem' => empty($modelsPoItem) ? [new PoItem()] : $modelsPoItem]);
 }
示例#16
0
            <div>
                <!--COUNTRY-->
                <?php 
echo $form->field($product, 'country_id', ['inputOptions' => ['class' => 'form-control']])->dropDownList(['' => '-- no countries --'] + ArrayHelper::map(ProductCountryTranslation::find()->where(['language_id' => $selectedLanguage->id])->all(), 'country_id', 'title'))->label(\Yii::t('shop', 'Country'));
?>
            </div>
            <div>
                <!--VENDOR-->
                <?php 
echo $form->field($product, 'vendor_id', ['inputOptions' => ['class' => 'form-control']])->dropDownList(['' => '-- no vendor --'] + ArrayHelper::map(Vendor::find()->all(), 'id', 'title'))->label(\Yii::t('shop', 'Vendor'));
?>
            </div>
            <div>
                <!--AVAILABILITY-->
                <?php 
echo $form->field($product, 'availability', ['inputOptions' => ['class' => 'form-control']])->dropDownList(ArrayHelper::map(ProductAvailability::find()->all(), 'id', 'translation.title'))->label(\Yii::t('shop', 'Availability'));
?>
            </div>
        </div>
    </div>


    <!--SALE-->
    <?php 
echo $form->field($product, 'sale', ['inputOptions' => ['class' => '']])->checkbox(['class' => '']);
?>

    <!--SHORT DESCRIPTION-->
    <?php 
echo $form->field($products_translation, 'description', ['inputOptions' => ['class' => 'form-control']])->widget(Summernote::className())->label(\Yii::t('shop', 'Short description'));
?>
示例#17
0
 /**
  * Updates an existing Reserva model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $modelHora = $model->horaMedica;
     $modelsExamen = $modelHora->horaExamenSolicitados;
     if ($model->load(Yii::$app->request->post()) && $modelHora->load(Yii::$app->request->post())) {
         $oldIDHora = ArrayHelper::map($modelHora, 'id', 'id');
         $modelHora = new Hora();
         Model::load($modelHora, Yii::$app->request->post());
         $deletedIDHora = array_diff($oldIDHora, array_filter(ArrayHelper::map($modelHora, 'id', 'id')));
         $oldIDsExamen = ArrayHelper::map($modelsExamen, 'id', 'id');
         $modelsExamen = Model::createMultiple(Pago::classname(), $modelsExamen);
         Model::loadMultiple($modelsExamen, Yii::$app->request->post());
         $deletedIDsExamen = array_diff($oldIDsExamen, array_filter(ArrayHelper::map($modelsExamen, 'id', 'id')));
         $valid = $model->validate();
         $valid = $modelHora->validate();
         $valid = Model::validateMultiple($modelsExamen) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $model->save(false)) {
                     if (!empty($deletedIDHora)) {
                         Hora::deleteAll(['id' => $deletedIDHora]);
                     } else {
                         if (!empty($deletedIDsExamen)) {
                             HoraExamenSolicitado::deleteAll(['id' => $deletedIDsExamen]);
                         }
                     }
                     foreach ($modelsExamen as $modelExamen) {
                         $modelExamen->hora_id = $model->hora_medica_id;
                         if (!($flag = $modelExamen->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('update', ['model' => $model, 'modelHora' => $modelHora, 'modelsExamen' => empty($modelsExamen) ? [new HoraExamenSolicitado()] : $modelsExamen]);
 }
 /**
  * @inheritdoc
  */
 protected function getMigrationHistory($limit)
 {
     if ($this->db->schema->getTableSchema($this->migrationTable, true) === null) {
         $this->createMigrationHistoryTable();
     }
     $query = new Query();
     $rows = $query->select(['version', 'apply_time'])->from($this->migrationTable)->orderBy('apply_time DESC, version DESC')->limit($limit)->createCommand($this->db)->queryAll();
     $history = ArrayHelper::map($rows, 'version', 'apply_time');
     unset($history[self::BASE_MIGRATION]);
     return $history;
 }
示例#19
0
 /**
  * @return array
  */
 public static function getSelect2Data($text = 'name', $sort = 'name')
 {
     $query = self::find()->select(['id', $text])->orderBy($sort);
     $array = $query->asArray()->all();
     return ArrayHelper::map($array, 'id', $text);
 }
示例#20
0
        }
    </style>

    <!-- Nav tabs -->
    <ul class="nav nav-tabs">
        <li class="active"><a href="#uoms" data-toggle="tab">Uoms</a></li>
        <li><a href="#cogs" data-toggle="tab">Cogs</a></li>
        <li><a href="#price" data-toggle="tab">Price</a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div class="tab-pane active" id="uoms">
            <?php 
if ($model->isNewRecord) {
    echo $form->field($model, 'productUoms[id_uom]')->dropDownList(ArrayHelper::map(Uom::find()->all(), 'id_uom', 'nm_uom'), ['style' => 'width:200px;']);
    echo $form->field($model, 'productUoms[isi]')->textInput(['style' => 'width:120px;']);
} else {
    $dPro = new ActiveDataProvider(['query' => $model->getProductUoms(), 'pagination' => ['pageSize' => 10]]);
    echo GridView::widget(['dataProvider' => $dPro, 'tableOptions' => ['class' => 'table table-striped'], 'layout' => '{items}', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'idUom.nm_uom', 'idUom.cd_uom', 'isi']]);
}
?>
        </div>
        <div class="tab-pane" id="cogs">
            <?php 
if (!$model->isNewRecord) {
    $dCogs = new ActiveDataProvider(['query' => $model->getCogs(), 'pagination' => ['pageSize' => 10]]);
    echo GridView::widget(['dataProvider' => $dCogs, 'tableOptions' => ['class' => 'table table-striped'], 'layout' => '{items}', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'idUom.nm_uom', 'idUom.cd_uom', ['header' => 'Cogs', 'value' => function ($model) {
        return number_format($model->cogs, 2);
    }]]]);
}
示例#21
0
 /**
  * @return array [[DropDownList]] массив пользователей.
  */
 public static function getUserArray()
 {
     $key = self::CACHE_USERS_LIST_DATA;
     $value = Yii::$app->getCache()->get($key);
     if ($value === false || empty($value)) {
         $value = self::find()->select(['id', 'username'])->orderBy('username ASC')->asArray()->all();
         $value = ArrayHelper::map($value, 'id', 'username');
         Yii::$app->cache->set($key, $value);
     }
     return $value;
 }
示例#22
0
echo $form->field($model, 'number')->textInput();
?>
        </div>
        <div class="col-md-3">
            <?php 
echo $form->field($model, 'date_accept')->textInput();
?>
        </div>
        <div class="col-md-3">
            <?php 
echo $form->field($model, 'bill_no')->textInput();
?>
        </div>
        <div class="col-md-3">
            <?php 
echo $form->field($model, 'budget_id')->dropdownList(ArrayHelper::map(Budget::find()->all(), 'id', 'name'), ['id' => 'ddl-province', 'prompt' => 'เลือกหมวดหมู่', 'required' => '']);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-md-3">
            <?php 
echo $form->field($model, 'partner_id')->textInput();
?>
        </div>
        <div class="col-md-3">

        </div>
        <div class="col-md-3">
示例#23
0
 public function getAplicaciones()
 {
     $datos = AplicacionesDb::find()->asArray()->all();
     return ArrayHelper::map($datos, 'id', 'nombre');
 }
 /**
  * Updates an existing User model.
  * @param integer $id
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new UserForm();
     $model->setScenario('create');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     }
     return $this->render('create', ['model' => $model, 'roles' => ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name')]);
 }
示例#25
0
<?php

/* extensions */
use yii\helpers\Html;
use kartik\form\ActiveForm;
use kartik\widgets\FileInput;
/* namespace models */
use lukisongroup\hrd\models\Corp;
$drop = ArrayHelper::map(Corp::find()->where(['CORP_STS' => 1])->all(), 'CORP_ID', 'CORP_NM');
?>

<div class="profile-form">

    <?php 
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL, 'method' => 'post', 'id' => $model->formName(), 'enableClientValidation' => true]);
?>

    <div class="row">
      <div class="col-sm-6">

      </div>
     <div class="col-sm-6">
    <?php 
echo $form->field($model, 'KD_DISTRIBUTOR')->widget(Select2::classname(), ['data' => $drop, 'options' => ['placeholder' => 'Pilih Perusahaan ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'CORP_ID')->widget(Select2::classname(), ['data' => $dropunit, 'options' => ['placeholder' => 'Pilih Perusahaan ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    </div>
示例#26
0
?>

<div class = "form">
    <?php 
$form = $this->beginWidget('ActiveForm', array('id' => 'update-topic-form', 'enableAjaxValidation' => true, 'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false)));
?>
        <?php 
echo $form->errorSummary($model);
?>
        
        <div class = "row">
            <?php 
echo $form->labelEx($model, 'forum_id');
?>
            <?php 
echo Html::dropDownList($model, 'forum_id', ArrayHelper::map(BbiiForum::find()->forum()->findAll(), 'id', 'name'), array('onchange' => 'refreshTopics(this, "' . \Yii::$app->urlManager->createAbsoluteUrl('moderator/refreshTopics') . '")'));
?>
            <?php 
echo $form->error($model, 'forum_id');
?>
        </div>
        
        <div class = "row">
            <?php 
echo $form->labelEx($model, 'merge');
?>
            <?php 
echo Html::dropDownList($model, 'merge', array());
?>
            <?php 
echo $form->error($model, 'merge');
示例#27
0
 /**
  * [[@doctodo method_description:familiarObjectsList]].
  *
  * @param [[@doctodo param_type:model]] $model [[@doctodo param_description:model]]
  * @param integer                       $limit [[@doctodo param_description:limit]] [optional]
  *
  * @return [[@doctodo return_type:familiarObjectsList]] [[@doctodo return_description:familiarObjectsList]]
  */
 public static function familiarObjectsList($model, $limit = 10)
 {
     $f = self::familiarObjects($model, $limit);
     return ArrayHelper::map($f, 'id', 'descriptor');
 }
示例#28
0
use yii\bootstrap\ActiveForm;
//use yii\widgets\ActiveForm;
use backend\models\FaqType;
/* @var $this yii\web\View */
/* @var $model backend\models\Faq */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="faq-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
echo $form->field($model, 'faq_type_id')->dropDownList(ArrayHelper::map(FaqType::find()->all(), 'faq_type_id', 'type'), ['prompt' => 'Select Type']);
?>
            
    <?php 
echo $form->field($model, 'question')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'answer')->textarea(['rows' => 6]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        <?php 
 /** TESTING FROM HERE FOR DROP DOWNS **/
 public function actionTest()
 {
     $model = new SomeModel();
     $items = ArrayHelper::map(\app\models\Course::find()->all(), 'id', 'courseName');
     $this->view->params['items'] = $items;
     return $this->render('view', ['model' => $model, 'items' => $items]);
 }
示例#30
-1
 public function actionAssign($id)
 {
     $incoming = $this->loadModel($id);
     $endpoint = new Endpoint();
     $deptList = ArrayHelper::map(\app\models\Department::getAll(), 'id', 'name');
     return $this->render('assign', ['incoming' => $incoming, 'endpoint' => $endpoint, 'deptList' => $deptList]);
 }