예제 #1
0
 private function getPrepIds($rows)
 {
     $prepIds = ArrayHelper::getColumn($rows, 'prep_id');
     return array_unique($prepIds);
 }
예제 #2
0
 /**
  * Form ids assigned to this user
  *
  * @return array
  */
 public function getAssignedFormIds()
 {
     /** @var \app\models\User $user */
     $user = Yii::$app->user->identity;
     $userForms = $user->getUserForms()->asArray()->all();
     $userForms = ArrayHelper::getColumn($userForms, 'form_id');
     return $userForms;
 }
예제 #3
0
파일: index.php 프로젝트: tsyrya/mybriop
<?php

use app\entities\RabotaFizLica;
use app\helpers\ArrayHelper;
use yii\data\ActiveDataProvider;
use yii\grid\ActionColumn;
use yii\grid\GridView;
use yii\helpers\Html;
/**
 * @var $data ActiveDataProvider
 */
echo GridView::widget(['dataProvider' => $data, 'layout' => '{items}', 'columns' => ['organizaciyaRel.nazvanie:text:Учреждение', 'org_tip:orgTipRaboty:Совместительство', 'telefon:htmlTelefon:Телефон', ['label' => 'Должности', 'format' => 'html', 'value' => function ($model) {
    /* @var $model RabotaFizLica */
    $text = implode(', ', ArrayHelper::getColumn($model->dolzhnostiFizLicaNaRaboteRel, 'dolzhnostRel.nazvanie'));
    return $text ? Html::a($text, ['/lichnye-dannye-dolzhnost/index', 'rabota' => $model->hashids]) : Html::a('добавить должность', ['/lichnye-dannye-dolzhnost/create', 'rabota' => $model->hashids]);
}], ['class' => ActionColumn::className(), 'template' => '{update} {delete}']]]);
echo Html::a('Добавить работу', ['create'], ['class' => 'btn btn-primary']);
예제 #4
0
파일: Graph.php 프로젝트: qimus/graph
 /**
  * Поменять позиции местами
  *
  * @param int $parentId
  * @param int $nodeId1
  * @param int $nodeId2
  * @throws DatabaseException
  * @throws GraphException
  */
 public function swapPositions($parentId, $nodeId1, $nodeId2)
 {
     $directChilds = $this->edgesGateway->findDirectChildren($parentId);
     if (empty($directChilds)) {
         throw new GraphException('Child nodes not found.');
     }
     $childNodeIds = ArrayHelper::getColumn($directChilds, 'end');
     if (!in_array($nodeId1, $childNodeIds) || !in_array($nodeId2, $childNodeIds)) {
         throw new GraphException('Specified node is not a child.');
     }
     $sourcePosition = ArrayHelper::first(ArrayHelper::find($directChilds, ['end' => $nodeId1]));
     $targetPosition = ArrayHelper::first(ArrayHelper::find($directChilds, ['end' => $nodeId2]));
     $tmpPos = $sourcePosition['pos'];
     $sourcePosition['pos'] = $targetPosition['pos'];
     $targetPosition['pos'] = $tmpPos;
     $this->edgesGateway->updatePositions([$sourcePosition, $targetPosition]);
 }
예제 #5
0
 /**
  * Update an existing User model. If update is successful, the browser
  * will be redirected to the 'view' page.
  *
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     // set up user and profile
     $user = $this->findModel($id);
     $user->setScenario("admin");
     $profile = $user->profile;
     // load post data and validate
     $post = Yii::$app->request->post();
     if ($user->load($post) && $user->validate() && $profile->load($post) && $profile->validate()) {
         //Save user
         $user->save(false);
         // Save profile
         $profile->setUser($user->id)->save(false);
         // Remove old forms permissions
         FormUser::deleteAll(['user_id' => $user->id]);
         // Save new forms permissions
         $forms = Yii::$app->request->post('forms');
         if (isset($forms) && is_array($forms)) {
             // Set news
             foreach ($forms as $form_id) {
                 $formUser = new FormUser();
                 $formUser->form_id = $form_id;
                 $formUser->user_id = $user->id;
                 $formUser->save();
             }
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The user has been successfully updated.'));
         return $this->redirect(['index']);
     }
     // Get all forms
     $forms = Form::find()->select(['id', 'name'])->orderBy('updated_at DESC')->all();
     // Map id => name
     $forms = ArrayHelper::map($forms, 'id', 'name');
     // Get forms of the selected user
     $userForms = FormUser::find()->select(['form_id'])->where(['user_id' => $user->id])->asArray()->all();
     // Get only ids
     $userForms = ArrayHelper::getColumn($userForms, 'form_id');
     // render
     return $this->render('update', ['user' => $user, 'profile' => $profile, 'forms' => $forms, 'userForms' => $userForms]);
 }
예제 #6
0
파일: index.php 프로젝트: qimus/graph
    $graphData = ['nodes' => [], 'edges' => []];
    $colors = ['green', 'blue', 'red'];
    foreach ($nodes as $nodeData) {
        $graphData['nodes'][$nodeData['id']] = ['color' => $colors[array_rand($colors)], 'shape' => 'dot', 'label' => $nodeData['name']];
    }
    foreach ($edges as $edgeInfo) {
        $graphData['edges'][$edgeInfo['start']][$edgeInfo['end']] = [];
    }
    return $graphData;
}
$allNodes = $nodesGateway->getAll();
$childsNodes[] = $nodesGateway->getNodeByName('D');
$parentNodes[] = $nodesGateway->getNodeByName('G');
$allNodesGraph = getDataForGraph($allNodes, $edgesGateway->getByNodes(\app\helpers\ArrayHelper::getColumn($allNodes, 'id')));
$childDataGraph = getDataForGraph($childsNodes, $edgesGateway->getByNodes(\app\helpers\ArrayHelper::getColumn($childsNodes, 'id')));
$parentDataGraph = getDataForGraph($parentNodes, $edgesGateway->getByNodes(\app\helpers\ArrayHelper::getColumn($parentNodes, 'id')));
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script src="assets/js/arbor.js"></script>
    <script src="assets/js/renderer.js"></script>
    <script src="assets/js/graphics.js"></script>
</head>

<style type="text/css">
    div.graph-container {
예제 #7
0
 public function getNazvaniyaKategorijSlushatelej()
 {
     return ArrayHelper::getColumn($this->kategoriiSlushatelejRel, 'nazvanie', false);
 }