Esempio n. 1
0
 public static function createEmptyStock($item)
 {
     $stock = $item->newStockOnLocation(Location::find(1));
     $stock->quantity = 0;
     $stock->reason = 'stock created';
     $stock->save();
     return $stock;
 }
Esempio n. 2
0
 /**
  * Поиск
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Location::find();
     $query->joinWith(['country', 'city', 'region', 'users']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['users.name', 'users.email', 'country', 'region', 'city']], 'pagination' => ['pagesize' => 5]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andWhere('country LIKE "%' . $this->country . '%"');
     $query->andWhere('city LIKE "%' . $this->city . '%"');
     $query->andWhere('region LIKE "%' . $this->region . '%"');
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Location::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created' => $this->created, 'updated' => $this->updated, 'is_active' => $this->is_active]);
     $query->andFilterWhere(['like', 'nickname', $this->nickname])->andFilterWhere(['like', 'fullname', $this->fullname]);
     return $dataProvider;
 }
Esempio n. 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Location::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'annual_budget' => $this->annual_budget]);
     $query->andFilterWhere(['like', 'location_name', $this->location_name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'country', $this->country]);
     return $dataProvider;
 }
Esempio n. 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Location::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
 /**
  * Filters inventory results by specified location.
  *
  * @param mixed      $query
  * @param int|string $locationId
  *
  * @return mixed
  */
 public function scopeLocation($query, $locationId = null)
 {
     if (!is_null($locationId)) {
         // Get descendants and self inventory category nodes
         $locations = Location::find($locationId)->getDescendantsAndSelf();
         // Perform a sub-query on main query
         $query->where(function ($query) use($locations) {
             // For each category, apply a orWhere query to the sub-query
             foreach ($locations as $location) {
                 $query->orWhere('location_id', $location->id);
             }
         });
     }
     return $query;
 }
Esempio n. 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Location::find();
     $query->joinWith(['room']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['room'] = ['asc' => ['room.name' => SORT_ASC], 'desc' => ['room.name' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'room.name', $this->room]);
     return $dataProvider;
 }
Esempio n. 8
0
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     $locationModels = Location::find()->where(['status' => Location::STATUS_ACTIVE])->all();
     $locations = [];
     foreach ($locationModels as $locationModel) {
         $locations[$locationModel->id] = $locationModel->title;
     }
     $categoryModels = Category::find()->where(['status' => Location::STATUS_ACTIVE])->all();
     $categories = [];
     foreach ($categoryModels as $categoryModel) {
         $categories[$categoryModel->id] = $categoryModel->title;
     }
     $searchBar = ['locations' => $locations, 'categories' => $categories];
     $this->view->params['search_bar'] = $searchBar;
     return true;
 }
Esempio n. 9
0
 /**
  *
  */
 public function save(Request $request)
 {
     $out = ['data' => $request->input()];
     if (!$request->has('id')) {
         $location = new \App\Models\Location();
         $geojsonLocation = new \App\Models\GeojsonLocation();
     } else {
         $location = \App\Models\Location::find($request->input('id'));
         $geojsonLocation = \App\Models\GeojsonLocation::find($request->input('id'));
     }
     $location->name = $request->input('name');
     $location->description = $request->input('description');
     // get the center
     $geometry = $request->input('geometryWkt');
     $polygon = \geoPHP::load($geometry);
     $polygon->setSRID(4326);
     $srid = $polygon->SRID();
     $geos = \geoPHP::geosInstalled();
     $valid = $polygon->checkValidity();
     $centroid = $polygon->getCentroid();
     $area = $polygon->getArea();
     $location->center = \DB::raw("ST_SetSRID(ST_PointFromText('POINT(" . $centroid->getX() . ' ' . $centroid->getY() . ")'), 4326)");
     $location->bounds = \DB::raw("ST_SetSRID(ST_PolygonFromText('" . $geometry . "'), 4326)");
     $location->area = $area;
     $location->save();
     // save it in the mongo model too...
     $geojsonLocation->name = $request->input('name');
     $geojsonLocation->description = $request->input('description');
     $geojsonLocation->area = $area;
     // save the center as GeoJSON
     $centroidWkt = \geoPHP::load('POINT(' . $centroid->getX() . ' ' . $centroid->getY() . ')', 'wkt');
     $geojsonLocation->center = json_decode($centroidWkt->out('json'));
     // save the geometry as geoJSON
     $geojsonLocation->bounds = json_decode($polygon->out('json'));
     $geojsonLocation->save();
     $out['data']['location'] = $location;
     $out['data']['geojsonLocation'] = $geojsonLocation;
     return Response::json($out);
 }
Esempio n. 10
0
     Route::get('{userId}/assets', ['as' => 'api.users.assetlist', 'uses' => 'UsersController@getAssetList']);
     Route::post('{userId}/upload', ['as' => 'upload/user', 'uses' => 'UsersController@postUpload']);
 });
 /*---Groups API---*/
 Route::group(['prefix' => 'groups'], function () {
     Route::get('list', ['as' => 'api.groups.list', 'uses' => 'GroupsController@getDatatable']);
 });
 /*---Licenses API---*/
 Route::group(['prefix' => 'licenses'], function () {
     Route::get('list', ['as' => 'api.licenses.list', 'uses' => 'LicensesController@getDatatable']);
 });
 /*---Locations API---*/
 Route::group(['prefix' => 'locations'], function () {
     Route::resource('/', 'LocationsController');
     Route::get('{locationID}/check', function ($locationID) {
         $location = Location::find($locationID);
         return $location;
     });
 });
 /*---Improvements API---*/
 Route::group(['prefix' => 'asset_maintenances'], function () {
     Route::get('list', ['as' => 'api.asset_maintenances.list', 'uses' => 'AssetMaintenancesController@getDatatable']);
 });
 /*---Models API---*/
 Route::group(['prefix' => 'models'], function () {
     Route::resource('/', 'AssetModelsController');
     Route::get('list/{status?}', ['as' => 'api.models.list', 'uses' => 'AssetModelsController@getDatatable']);
     Route::get('{modelID}/view', ['as' => 'api.models.view', 'uses' => 'AssetModelsController@getDataView']);
 });
 /*--- Categories API---*/
 Route::group(['prefix' => 'categories'], function () {
Esempio n. 11
0
use yii\widgets\ActiveForm;
AppAsset::register($this);
/* select info company */
$info = Infocompany::find()->one();
/* select slide */
$slides = Slide::find()->where(['position' => '1'])->all();
/* select article*/
$article = Article::find()->where(['hot' => '1'])->all();
/* select article services */
$articleService = Article::find()->where(['type' => "100"])->all();
$services = [];
for ($i = 0; $i < count($articleService); $i++) {
    $services[] = ['label' => $articleService[$i]->title, 'url' => ['article/' . implode('-', explode(' ', $articleService[$i]->title))]];
}
$this->title = $info->name;
$hotelInfo = \app\models\Location::find()->all();
$hotelMenu = [];
for ($i = 0; $i < count($hotelInfo); $i++) {
    $item = [];
    $item['label'] = 'Hotels in ' . $hotelInfo[$i]->name;
    $hotelName = implode('-', explode(" ", $hotelInfo[$i]->name));
    $item['url'] = ['hotel/' . $hotelName];
    $hotelMenu[] = $item;
}
?>

<?php 
$this->beginPage();
?>
    <!DOCTYPE html>
    <html lang="<?php 
Esempio n. 12
0
        <div class="row">
            <div class="col-lg-4">
                <h2>Топ стран</h2>

                <?php 
$dataProvider = new ActiveDataProvider(['query' => Location::find()->joinWith('country')->select(['country_id', 'country', 'COUNT(*) AS cnt'])->where('country != ""')->groupBy('country')->orderBy('cnt DESC')->limit(5)]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'country.country', 'cnt'], 'layout' => "{items}"]);
?>
            </div>
            <div class="col-lg-4">
                <h2>Топ регинов</h2>

                <?php 
$dataProvider = new ActiveDataProvider(['query' => Location::find()->joinWith('region')->select(['region_id', 'region', 'COUNT(*) AS cnt'])->where('region != ""')->groupBy('region')->orderBy('cnt DESC')->limit(5)]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'region.region', 'cnt'], 'layout' => "{items}"]);
?>
            </div>
            <div class="col-lg-4">
                <h2>Пустые города</h2>

                <?php 
$dataProvider = new ArrayDataProvider(['allModels' => Location::find()->joinWith('city', false, 'RIGHT JOIN')->select(['city_id', 'city.city'])->where('location.id IS NULL')->asArray()->all()]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'Город', 'value' => 'city']], 'layout' => "{items}"]);
?>

            </div>
        </div>

    </div>
</div>
Esempio n. 13
0
        </li>
        <li>
            <p>Status</p>
            <select name="Status" id="status" class="form-control">
                <option value=" ">All</option>
                <option value="1">Active</option>
                <option value="0">Deactive</option>
            </select>
        </li>
    </ul>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => 'yii\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'sr-only']], ['attribute' => 'smallimg', 'format' => 'image', 'value' => function ($model) {
    return '@web/images/' . $model->smallimg;
}], 'name', 'star', ['attribute' => 'id_location', 'value' => 'location.name', 'filter' => \yii\helpers\ArrayHelper::map(\app\models\Location::find()->all(), 'name', 'name'), 'options' => ['width' => '200px']], 'address', 'editdate', ['attribute' => 'status', 'headerOptions' => ['class' => 'sr-only'], 'filterOptions' => ['class' => 'sr-only'], 'contentOptions' => ['class' => 'sr-only']], ['class' => 'yii\\grid\\ActionColumn', 'urlCreator' => function ($action, $model, $key, $index) {
    if ($action === 'view') {
        $url = '/hotel/show-detail/' . $model->id;
        return $url;
    } elseif ($action === 'update') {
        $url = '/hotel/update/' . $model->id;
        return $url;
    } else {
        $url = '/hotel/delete/' . $model->id;
        return $url;
    }
}]]]);
?>

</div>
Esempio n. 14
0
 /**
  * Lists all Location models (limit 20)
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Location::find(), 'totalCount' => 20, 'pagination' => ['defaultPageSize' => 20]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
 /**
  * Lists all Location models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Location::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
 public function actionGetLocationRoom($id)
 {
     echo Location::find()->orderBy('location ASC')->where(['id' => $id])->one()->room_id;
 }
Esempio n. 17
0
 /**
  * Exports the custom report to CSV
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see ReportsController::getCustomReport() method that generates form view
  * @since [v1.0]
  * @return \Illuminate\Http\Response
  */
 public function postCustom()
 {
     $assets = Asset::orderBy('created_at', 'DESC')->get();
     $customfields = CustomField::get();
     $rows = [];
     $header = [];
     if (e(Input::get('company_name')) == '1') {
         $header[] = 'Company Name';
     }
     if (e(Input::get('asset_name')) == '1') {
         $header[] = 'Asset Name';
     }
     if (e(Input::get('asset_tag')) == '1') {
         $header[] = 'Asset Tag';
     }
     if (e(Input::get('manufacturer')) == '1') {
         $header[] = 'Manufacturer';
     }
     if (e(Input::get('model')) == '1') {
         $header[] = 'Model';
         $header[] = 'Model Number';
     }
     if (e(Input::get('category')) == '1') {
         $header[] = 'Category';
     }
     if (e(Input::get('serial')) == '1') {
         $header[] = 'Serial';
     }
     if (e(Input::get('purchase_date')) == '1') {
         $header[] = 'Purchase Date';
     }
     if (e(Input::get('purchase_cost')) == '1' && e(Input::get('depreciation')) != '1') {
         $header[] = 'Purchase Cost';
     }
     if (e(Input::get('order')) == '1') {
         $header[] = 'Order Number';
     }
     if (e(Input::get('supplier')) == '1') {
         $header[] = 'Supplier';
     }
     if (e(Input::get('location')) == '1') {
         $header[] = 'Location';
     }
     if (e(Input::get('assigned_to')) == '1') {
         $header[] = 'Assigned To';
     }
     if (e(Input::get('username')) == '1') {
         $header[] = 'Username';
     }
     if (e(Input::get('status')) == '1') {
         $header[] = 'Status';
     }
     if (e(Input::get('warranty')) == '1') {
         $header[] = 'Warranty';
         $header[] = 'Warranty Expires';
     }
     if (e(Input::get('depreciation')) == '1') {
         $header[] = 'Purchase Cost';
         $header[] = 'Value';
         $header[] = 'Diff';
     }
     foreach ($customfields as $customfield) {
         if (e(Input::get($customfield->db_column_name())) == '1') {
             $header[] = $customfield->name;
         }
     }
     $header = array_map('trim', $header);
     $rows[] = implode($header, ',');
     foreach ($assets as $asset) {
         $row = [];
         if (e(Input::get('company_name')) == '1') {
             $row[] = is_null($asset->company) ? '' : e($asset->company->name);
         }
         if (e(Input::get('asset_name')) == '1') {
             $row[] = '"' . e($asset->name) . '"';
         }
         if (e(Input::get('asset_tag')) == '1') {
             $row[] = e($asset->asset_tag);
         }
         if (e(Input::get('manufacturer')) == '1') {
             if ($asset->model->manufacturer) {
                 $row[] = '"' . e($asset->model->manufacturer->name) . '"';
             } else {
                 $row[] = '';
             }
         }
         if (e(Input::get('model')) == '1') {
             $row[] = '"' . e($asset->model->name) . '"';
             $row[] = '"' . e($asset->model->modelno) . '"';
         }
         if (e(Input::get('category')) == '1') {
             $row[] = '"' . e($asset->model->category->name) . '"';
         }
         if (e(Input::get('serial')) == '1') {
             $row[] = e($asset->serial);
         }
         if (e(Input::get('purchase_date')) == '1') {
             $row[] = e($asset->purchase_date);
         }
         if (e(Input::get('purchase_cost')) == '1' && e(Input::get('depreciation')) != '1') {
             $row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
         }
         if (e(Input::get('order')) == '1') {
             if ($asset->order_number) {
                 $row[] = e($asset->order_number);
             } else {
                 $row[] = '';
             }
         }
         if (e(Input::get('supplier')) == '1') {
             if ($asset->supplier_id) {
                 $row[] = '"' . e($asset->supplier->name) . '"';
             } else {
                 $row[] = '';
             }
         }
         if (e(Input::get('location')) == '1') {
             $show_loc = '';
             if ($asset->assigned_to > 0 && $asset->assigneduser->location_id != '') {
                 $location = Location::find($asset->assigneduser->location_id);
                 if ($location) {
                     $show_loc .= '"' . e($location->name) . '"';
                 } else {
                     $show_loc .= 'User location ' . $asset->assigneduser->location_id . ' is invalid';
                 }
             } elseif ($asset->rtd_location_id != '') {
                 $location = Location::find($asset->rtd_location_id);
                 if ($location) {
                     $show_loc .= '"' . e($location->name) . '"';
                 } else {
                     $show_loc .= 'Default location ' . $asset->rtd_location_id . ' is invalid';
                 }
             }
             $row[] = $show_loc;
         }
         if (e(Input::get('assigned_to')) == '1') {
             if ($asset->assigned_to > 0) {
                 $user = User::find($asset->assigned_to);
                 $row[] = '"' . e($user->fullName()) . '"';
             } else {
                 $row[] = '';
                 // Empty string if unassigned
             }
         }
         if (e(Input::get('username')) == '1') {
             if ($asset->assigned_to > 0) {
                 $user = User::find($asset->assigned_to);
                 $row[] = '"' . e($user->username) . '"';
             } else {
                 $row[] = '';
                 // Empty string if unassigned
             }
         }
         if (e(Input::get('status')) == '1') {
             if ($asset->status_id == '0' && $asset->assigned_to == '0') {
                 $row[] = trans('general.ready_to_deploy');
             } elseif ($asset->status_id == '' && $asset->assigned_to == '0') {
                 $row[] = trans('general.pending');
             } elseif ($asset->assetstatus) {
                 $row[] = '"' . e($asset->assetstatus->name) . '"';
             } else {
                 $row[] = '';
             }
         }
         if (e(Input::get('warranty')) == '1') {
             if ($asset->warranty_months) {
                 $row[] = $asset->warranty_months;
                 $row[] = $asset->warrantee_expires();
             } else {
                 $row[] = '';
                 $row[] = '';
             }
         }
         if (e(Input::get('depreciation')) == '1') {
             $depreciation = $asset->getDepreciatedValue();
             $row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
             $row[] = '"' . Helper::formatCurrencyOutput($depreciation) . '"';
             $row[] = '"' . Helper::formatCurrencyOutput($asset->purchase_cost) . '"';
         }
         foreach ($customfields as $customfield) {
             $column_name = $customfield->db_column_name();
             if (e(Input::get($customfield->db_column_name())) == '1') {
                 $row[] = $asset->{$column_name};
             }
         }
         $rows[] = implode($row, ',');
     }
     // spit out a csv
     if (array_filter($rows)) {
         $csv = implode($rows, "\n");
         $response = Response::make($csv, 200);
         $response->header('Content-Type', 'text/csv');
         $response->header('Content-disposition', 'attachment;filename=report.csv');
         return $response;
     } else {
         return redirect()->to("reports/custom")->with('error', trans('admin/reports/message.error'));
     }
 }
Esempio n. 18
0
echo Html::encode($this->title);
?>
</h2>
    <hr/>
    <?php 
echo $this->render('_search', ['model' => $searchModel]);
?>
    <hr/>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-striped table-hover'], 'emptyText' => '</br><p class="text-danger">Nenhuma solicitação encontrada!</p>', 'summary' => "<p class=\"text-primary \">Você possui {totalCount} solicitações</p>", 'filterModel' => $searchModel, 'rowOptions' => function ($model) {
    if ($model->status_id == 98) {
        return ['class' => 'text-muted'];
    }
}, 'columns' => [['attribute' => 'id', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 6%;text-align:left']], ['attribute' => 'created', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 7%;text-align:center'], 'format' => ['date', 'php:d/m/Y']], ['attribute' => 'location_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    return $model->location->nickname;
}, 'filter' => ArrayHelper::map(Location::find()->orderBy('nickname')->asArray()->all(), 'id', 'nickname'), 'contentOptions' => ['style' => 'width: 7%;text-align:left']], ['attribute' => 'cpf_cnpj', 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['attribute' => 'typeperson_id', 'enableSorting' => true, 'value' => function ($model) {
    return $model->typeperson->name;
}, 'filter' => ArrayHelper::map(Typeperson::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'contentOptions' => ['style' => 'width: 12%;text-align:left']], ['attribute' => 'typesolicitation_id', 'enableSorting' => true, 'value' => function ($model) {
    return $model->typesolicitation->name;
}, 'filter' => ArrayHelper::map(Typesolicitation::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['attribute' => 'status_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    //return $model->status->name;
    return '<span style="color:' . $model->status->color . '"><i class="fa fa-circle"></i> ' . $model->status->name . '</span>';
}, 'filter' => ArrayHelper::map(Status::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['attribute' => 'analyst_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    return $model->analyst ? $model->analyst->username : '******';
}, 'contentOptions' => ['style' => 'width: 15%;text-align:left']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width: 10%;text-align:right'], 'template' => '{view} {update}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open" ></span>', $url, ['title' => 'Visualizar']);
}, 'update' => function ($url, $model) {
    return $model->status_id < 98 ? Html::a('<span class="glyphicon glyphicon-pencil" ></span>', $url, ['title' => 'Alterar']) : Html::a('<span class="glyphicon glyphicon-ban-circle" ></span>', "#", ['title' => 'Alteração não permitida!']);
}, 'upload' => function ($url, $model) {
    return $model->status_id != 98 ? Html::a('<span class="glyphicon glyphicon-upload" ></span>', $url, ['title' => 'Anexar Arquivo']) : '';
}]]]]);
Esempio n. 19
0
 /**
  * Returns a JSON response that contains the assets association with the
  * selected location, to be used by the location detail view.
  *
  * @todo This is broken for accessories and consumables.
  * @todo This is a very naive implementation. Should clean this up with query scopes.
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see LocationsController::getView() method that creates the display view
  * @param int $locationID
  * @since [v1.8]
  * @return View
  */
 public function getDataViewAssets($locationID)
 {
     $location = Location::find($locationID)->load('assignedassets.model');
     $assets = Asset::AssetsByLocation($location);
     if (Input::has('search')) {
         $assets = $assets->TextSearch(e(Input::get('search')));
     }
     $assets = $assets->get();
     $rows = array();
     foreach ($assets as $asset) {
         $rows[] = array('name' => (string) link_to(config('app.url') . '/hardware/' . $asset->id . '/view', e($asset->showAssetName())), 'asset_tag' => e($asset->asset_tag), 'serial' => e($asset->serial), 'model' => e($asset->model->name));
     }
     $data = array('total' => $assets->count(), 'rows' => $rows);
     return $data;
 }
Esempio n. 20
0
 /**
  * Получаем данные (расположение) для dropDownList()
  */
 public function getLocationList()
 {
     $id = Location::find()->all();
     $items = ArrayHelper::map($id, 'id', 'name');
     return $items;
 }
Esempio n. 21
0
    <div class="row">
        <div class="col-md-4">
            <?php 
echo '<label class="control-label">Período</label>';
echo DatePicker::widget(['model' => $model, 'attribute' => 'start_date', 'attribute2' => 'end_date', 'language' => 'pt', 'type' => DatePicker::TYPE_RANGE, 'separator' => 'até', 'options' => ['placeholder' => ''], 'pluginOptions' => ['autoclose' => true, 'todayHighlight' => true, 'format' => 'yyyy-mm-dd']]);
?>
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(User::find()->where(['role_id' => 2])->orderBy("username ASC")->all(), 'id', 'username'), ['prompt' => 'Todos']);
?>
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'location_id')->dropDownList(ArrayHelper::map(Location::find()->where(['is_active' => 1])->orderBy("fullname ASC")->all(), 'id', 'fullname'), ['prompt' => 'Todos']);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'typeperson_id')->dropDownList(ArrayHelper::map(Typeperson::find()->orderBy("name ASC")->all(), 'id', 'name'), ['prompt' => 'Todos']);
?>
        </div>
        <div class="col-md-4">
            <?php 
echo $form->field($model, 'typesolicitation_id')->dropDownList(ArrayHelper::map(Typesolicitation::find()->orderBy("name ASC")->all(), 'id', 'name'), ['prompt' => 'Todos']);
?>
        </div>
        <div class="col-md-4">
Esempio n. 22
0
 public function actionListLocations($id)
 {
     $locations = Location::find()->where(['room_id' => $id])->all();
     echo "<option value=''>" . Yii::t('app', 'Selecciona una Ubicación...') . "</option>";
     foreach ($locations as $location) {
         echo "<option value='" . $location->id . "'>" . $location->location . "</option>";
     }
 }
Esempio n. 23
0
				'id',
				'location'
			),
			[
				'prompt' => 'Selecciona una Ubicación',
				'onchange' => '$.post("'.Yii::$app->urlManager->createUrl('incident/list-equipment-types?id=').'"+$(this).val(), function(data){
					$("#incident-equipment_type_id").html(data);
				})',
			]
		)
	?-->
	
	<?php 
$locationData = [];
if (!empty($model->room_id)) {
    $locationData = ArrayHelper::map(Location::find()->orderBy('location ASC')->where(['room_id' => $model->room_id])->all(), 'id', 'location');
}
?>
	
	<?php 
echo $form->field($model, 'location_id')->dropDownList($locationData, ['prompt' => 'Selecciona una Ubicación', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl('incident/list-equipment-types?id=') . '"+$(this).val(), function(data){
					$("#incident-equipment_type_id").html(data);
				})']);
?>
	
	<?php 
$equipmentTypeData = [];
if (!empty($model->location_id)) {
    $equipmentTypeData = ArrayHelper::map(Equipment::find()->where(['location_id' => $model->location_id])->all(), 'id', 'nameWithInventory');
}
?>
Esempio n. 24
0
//$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Todas las asignaciones');
?>

<h1 align="center"><?php 
echo 'Todas las Asignaciones', Html::a('Regresar', ['index'], ['class' => 'btn btn-success btn-md', 'style' => 'float:right; margin-left:4px;']), Html::a('', ['assignations'], ['class' => 'btn btn-primary btn-md glyphicon glyphicon-refresh', 'style' => 'float:right;']);
?>
</h1>	

<div class="assignation-index">

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

	<?php 
$locationQuery = Location::find()->joinWith(['room'])->where(['location.active' => 1, 'room.available' => 1]);
if (!empty(Yii::$app->request->queryParams['AssignationSearch']) && !empty(Yii::$app->request->queryParams['AssignationSearch']['room'])) {
    $locationQuery->andWhere(['room.id' => Yii::$app->request->queryParams['AssignationSearch']['room']]);
}
?>
	
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'date', ['attribute' => 'client', 'value' => 'client.client_id', 'label' => Yii::t('app', 'Client ID')], ['attribute' => 'room', 'value' => 'room.name', 'label' => Yii::t('app', 'Room ID'), 'filter' => ArrayHelper::map(Room::find()->where(['available' => 1])->all(), 'id', 'name')], ['attribute' => 'location', 'value' => 'location.location', 'label' => Yii::t('app', 'Location ID'), 'filter' => ArrayHelper::map($locationQuery->all(), 'id', 'fullLocation'), 'filterInputOptions' => ['id' => 'search-assignation-location-id', 'class' => 'form-control']], ['attribute' => 'equipment', 'value' => 'equipment.inventory', 'label' => Yii::t('app', 'Inventory')], 'purpose', 'duration', 'start_time', 'end_time']]);
?>

</div>
Esempio n. 25
0
 /**
  * Show location detail
  *
  * @param integer $identifier
  * @return string<json>
  */
 public function show($identifier = null)
 {
     $location = Location::find($identifier);
     exit($identifier);
 }