public function show($personId) { $person = Person::find($personId); $tree = $person->buildRelationsTree(); JavaScript::put(['gentree' => $tree, 'currentElementId' => $personId]); return view('person.gentree.show'); }
public function actionIncoming($id) { $user_id = NULL; $from = Yii::$app->request->post('From'); $body = Yii::$app->request->post('Body'); // Lookup user based on a few different methods // First, check with basic number with +1 removed $number = str_replace('+1', '', $from); $person = Person::find()->where(['phone' => $number])->one(); // If no results, add hyphens if (!$person) { $formatted_number = preg_replace("/^(\\d{3})(\\d{3})(\\d{4})\$/", "\$1-\$2-\$3", $number); $person = Person::find()->where(['phone' => $formatted_number])->one(); } if ($person) { $user_id = $person->id; } if ($from) { $message = new Message(); $message->message = $body; $message->project_id = $id; $message->time = time(); $message->user_id = $user_id; $message->status = 2; $message->type = 'text'; $message->number = $from; $message->save(); } }
public function listFiles($target, $target_action, $target_id) { $resource_type = 'App\\Models\\' . ucfirst(str_singular($target)); $uploader_id = Auth::user()->active_contact->id; if ($target == "posts") { if ($target_action == "create") { $post = Post::where('author_id', $uploader_id)->where("status_id", "=", POST_DRAFT_STATUS_ID)->where("ticket_id", $target_id)->first(); } elseif ($target_action == "edit") { $post = Post::where("id", $target_id)->first(); } $id = isset($post->id) ? $post->id : null; } elseif ($target == "tickets") { if ($target_action == "create") { $ticket = Ticket::where('status_id', TICKET_DRAFT_STATUS_ID)->where('creator_id', $uploader_id)->first(); } else { $ticket = Ticket::where("id", $target_id)->first(); } $id = isset($ticket->id) ? $ticket->id : null; } elseif ($target == "people") { $target_id = is_null($target_id) ? Auth::user()->owner->id : $target_id; $person = Person::find($target_id); $id = $person->id; } $files = is_null($id) ? [] : File::where('resource_type', $resource_type)->where("resource_id", $id)->get(); foreach ($files as $file) { $file->size = filesize(RESOURCES . DS . $file->file_path . DS . $file->file_name); } return $files; }
public function checkIfChildAndParentsAreInTheSameFamily(Person $father, Person $mother, Person $child) { $fathersFamily = Person::find($father->id)->family_id; $mothersFamily = Person::find($mother->id)->family_id; $childFamily = Person::find($child->id)->family_id; $families = array_unique([$fathersFamily, $mothersFamily, $childFamily]); $this->assertEquals(1, count($families)); }
public function actionPerson($query) { Yii::$app->response->format = Response::FORMAT_JSON; $fullName = new Expression('CONCAT(`person_last_name`, " ", `person_first_name`, " ", `person_second_name`)'); $model = Person::find()->select(['full_name' => $fullName, 'person_id'])->where(['like', $fullName, $query])->orderBy('full_name')->asArray()->all(); return array_map(function ($value) { return ['id' => $value['person_id'], 'value' => $value['full_name']]; }, $model); }
public function searchPerson($full_name) { $query = Person::find(); $query->where('user.id <> ' . Yii::$app->user->getId()); $query->joinWith('user'); $query->limit(10); $query->andFilterWhere(['like', 'CONCAT(person.first_name, person.last_name)', $full_name]); $query->select(['user.id', 'CONCAT(person.first_name, " ", person.last_name) as full_name']); return $query->asArray()->all(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $name = Input::get('data'); if ($name == 'lesson') { $data = Person::find($id)->lesson; } elseif ($name == 'seminar') { $data = Lessons::find($id)->seminar; } return response()->json($data); }
public function actionIndex() { $sort = isset($_GET['sort']) ? \Yii::$app->request->get('sort') : 'firstname'; $order = isset($_GET['order']) ? strtoupper(\Yii::$app->request->get('order')) : 'ASC'; $q = isset($_GET['q']) ? \Yii::$app->request->get('q') : ''; if ($q != '') { $persons = Person::find()->where("firstname LIKE '%{$q}%' OR lastname LIKE '%{$q}%'")->orderBy("{$sort} {$order}")->all(); } else { $persons = Person::find()->orderBy("{$sort} {$order}")->all(); } return $this->render('index', ['persons' => $persons, 'sort' => $sort, 'order' => $order, 'q' => $q]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name_eng', $this->name_eng]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::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, 'sex' => $this->sex, 'address_id' => $this->address_id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]); $query->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'mname', $this->mname])->andFilterWhere(['like', 'birthday', $this->birthday])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::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, 'register_date' => $this->register_date, 'person_type_id' => $this->person_type_id, 'tud_id' => $this->tud_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'emailaddress', $this->emailaddress])->andFilterWhere(['like', 'picture', $this->picture]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::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(['person_id' => $this->person_id, 'is_student' => $this->is_student, 'is_coach' => $this->is_coach, 'person_rate' => $this->person_rate, 'recommend_by' => $this->recommend_by]); $query->andFilterWhere(['like', 'person_wechat_id', $this->person_wechat_id])->andFilterWhere(['like', 'person_name', $this->person_name])->andFilterWhere(['like', 'phone_number', $this->phone_number]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::find()->asArray(); $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, 'birth_date' => $this->birth_date, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'zip_code', $this->zip_code]); return $dataProvider; }
public function store(Requests\StorePersonChildrenRequest $request) { $childId = $request->get('child'); $fatherId = $request->get('father'); $motherId = $request->get('mother'); // Check if persons in the same family $fathersFamily = Person::find($childId)->family_id; $mothersFamily = Person::find($fatherId)->family_id; $childFamily = Person::find($motherId)->family_id; if ($fathersFamily == $childFamily and $mothersFamily == $childFamily) { return \Redirect::back()->withErrors(['Потомок уже находится в одной семье с родителями']); } Person::find($childId)->makeChild($fatherId, $motherId); return \Redirect::route('person.gentree.show', $childId); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::find(); $query->innerJoin('job'); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new Sort(['attributes' => ['name', 'firstname', 'lastname', 'job_name' => ['asc' => ['job.name' => SORT_ASC], 'desc' => ['job.name' => SORT_DESC]], 'created_at', 'updated_at']])]); $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(['job_id' => $this->job_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'document', $this->document])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'job.name', $this->job_name]); return $dataProvider; }
public function profile_submit() { $data = \Request::all(); if (isset($data['image'])) { $file_name = \Common::get_img_filename($data['image']); \Common::make_square_img($file_name, 140); $res = \Common::s3_upload($file_name, 'person/'); if ($res['success']) { $person = Person::find(\Auth::user()->id); $person->image = $res['filename']; $person->save(); } } return \Redirect()->action('PersonController@profile'); }
public function update($id, UpdatePersonRequest $request) { $person = Person::find($id); if (Input::file('profile_picture') && Input::file('profile_picture')->isValid()) { $request['file'] = Input::file('profile_picture'); $request['target'] = "people"; $request['target_id'] = $person->id; $request['uploader_id'] = Auth::user()->active_contact->id; $repo = new FilesRepository(); $result = $repo->upload($request); if (!$result['error']) { $old_profile_picture = $person->profile_picture_id; if (!is_null($old_profile_picture)) { $person->profile_picture_id = NULL; $person->save(); $repo->destroy($old_profile_picture); } $person->profile_picture_id = $result['id']; $person->save(); } } $person->update($request->all()); return redirect()->route('people.show', $id)->with('successes', ['person updated successfully']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $aDop = []) { $query = Person::find(); $query->with(Yii::$app->user->can(User::USER_GROUP_MODERATOR) ? ['section', 'section.conference'] : []); $dataProvider = new ActiveDataProvider(['query' => $query]); $sFormname = $this->formName(); if (!isset($params[$sFormname])) { $params[$sFormname] = []; } $params[$sFormname] = array_merge($params[$sFormname], $aDop); $this->load($params); if (!empty($this->conferenceid)) { $query->joinWith(['section']); $query->andFilterWhere([Section::tableName() . '.sec_cnf_id' => $this->conferenceid]); } 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(['prs_id' => $this->prs_id, 'prs_active' => $this->prs_active, 'prs_type' => $this->prs_type, 'prs_sec_id' => $this->prs_sec_id, 'prs_doc_id' => $this->prs_doc_id, 'ekis_id' => $this->ekis_id, 'prs_hischool' => $this->prs_hischool]); $query->andFilterWhere(['like', 'prs_fam', $this->prs_fam])->andFilterWhere(['like', 'prs_name', $this->prs_name])->andFilterWhere(['like', 'prs_otch', $this->prs_otch])->andFilterWhere(['like', 'prs_email', $this->prs_email])->andFilterWhere(['like', 'prs_phone', $this->prs_phone])->andFilterWhere(['like', 'prs_org', $this->prs_org])->andFilterWhere(['like', 'prs_group', $this->prs_group])->andFilterWhere(['like', 'prs_position', $this->prs_position])->andFilterWhere(['like', 'prs_lesson', $this->prs_lesson]); return $dataProvider; }
<h1><?php //echo Html::encode($this->title) ?> </h1> <?php //echo $this->render('_search', ['model' => $searchModel]); ?> <p class='pull-left'> <?php echo \yii\helpers\Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'Create new'), ['create'], ['class' => 'btn btn-success']); ?> </p> <div class="clearfix"></div> <?php \yii\widgets\Pjax::begin(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'person_id' => ['attribute' => 'person_id', 'value' => 'person.fullname', 'filter' => ArrayHelper::map(\app\models\Person::find()->active()->orderBy('lname')->all(), 'id', 'lname')], 'professionNames' => ['attribute' => 'resumeProfessions', 'value' => 'professionNames', 'filter' => ArrayHelper::map(\app\models\Profession::find()->active()->orderBy('name')->all(), 'id', 'name')], 'salary', ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'white-space: nowrap;']]], 'tableOptions' => ['class' => 'table table-striped table-hover']]); ?> <?php \yii\widgets\Pjax::end(); ?> </div>
public function sendText($selection, $message) { if (!$message) { return false; } $numbers = array(); // Initiate Twilio $sid = Yii::$app->params['twilioId']; $token = Yii::$app->params['twilioToken']; $client = new Twilio\Rest\Client($sid, $token); foreach ($selection as $user_id) { $person = Person::find()->where(['id' => $user_id])->one(); $number = preg_replace("/[^0-9]/", "", $person->phone); if (is_numeric($number) && $number >= 1000000000 && $number <= 9999999999) { try { $sms[] = $client->messages->create('+1' . $number, array('from' => $this->twilio_number, 'body' => $message)); $messageModel = new Message(); $messageModel->message = $message; $messageModel->user_id = $person->id; $messageModel->project_id = $this->id; $messageModel->time = time(); $messageModel->type = 'text'; $messageModel->status = 1; $messageModel->save(); } catch (Exception $e) { echo "Error: " . $e->getMessage(); } } //end if not 10 digit number } // echo '<pre>'; // var_dump($sms); // echo '</pre>'; }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $person = Person::find($this->route('id')); return Auth::user()->can('update-person') || Auth::user()->can('update-own-person') && Auth::user()->active_contact->person->id == $person->id; }
/** * Finds the Doclad model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Person the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findGuest($id) { if (($model = Person::find(['prs_id' => $id, 'prs_type' => Person::PERSON_TYPE_GUEST])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Person::find(); // echo $this->ethnicity; $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date_added' => SORT_DESC]], 'pagination' => ['pageSize' => 30]]); // var_dump($params); $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; } if ($this->no_agent) { $query->andWhere(['agent' => '']); } if ($this->ethnicity) { $where = ['or']; foreach ($this->ethnicity as $ethnicity) { if (!$ethnicity) { array_push($where, ['ethnicity' => '']); } else { array_push($where, ['ethnicity' => $ethnicity]); } } $query->andWhere($where); } if ($this->hair) { $where = ['or']; foreach ($this->hair as $hair) { if (!$hair) { array_push($where, ['hair' => '']); } else { array_push($where, ['hair' => $hair]); } } $query->andWhere($where); } if ($this->age_low && $this->age_high) { // calculate age $low_date = time() - $this->age_low * 31536000; $high_date = time() - $this->age_high * 31536000 - 31536000; $where = ['or']; $query->andFilterWhere(['between', 'dob_num', $high_date, $low_date]); } // Location search if ($this->radius && $this->zipcode) { $where = ['or']; try { $json = file_get_contents('http://www.zipcodeapi.com/rest/' . Yii::$app->params['zipCodeApiKey'] . '/radius.json/' . $this->zipcode . '/' . $this->radius . '/mile'); } catch (\yii\base\ErrorException $exception) { Yii::$app->session->setFlash('error', 'The results below are not being filtered by location. You have reached the limit of 50 searches per hour using the nearby zip code limit function. You can upgrade your account at zipcodeapi.com, or search without nearby zipcodes. In one hour, your usage limits will reset and you can continue to search nearby zipcodes.'); } if (isset($json)) { $obj = json_decode($json); foreach ($obj->zip_codes as $zipcode) { array_push($where, ['zipcode' => $zipcode->zip_code]); } $query->andWhere($where); } } // $query->andFilterWhere([ // 'id' => $this->id, // 'userID' => $this->userID, // 'deactivated' => $this->deactivated, // 'agencyID' => $this->agencyID, // 'hips' => $this->hips, // 'chest' => $this->chest, // 'hat' => $this->hat, // 'pants' => $this->pants, // ]); $query->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'date_added', $this->date_added])->andFilterWhere(['like', 'date_updated', $this->date_updated])->andFilterWhere(['like', 'address1', $this->address1])->andFilterWhere(['like', 'address2', $this->address2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['=', 'gender', $this->gender])->andFilterWhere(['like', 'eyes', $this->eyes])->andFilterWhere(['like', 'height', $this->height])->andFilterWhere(['like', 'picture1', $this->picture1])->andFilterWhere(['like', 'dress_size', $this->dress_size])->andFilterWhere(['like', 'waist_size', $this->waist_size])->andFilterWhere(['like', 'shirt_size', $this->shirt_size])->andFilterWhere(['like', 'suit_size', $this->suit_size])->andFilterWhere(['like', 'inseam_size', $this->inseam_size])->andFilterWhere(['like', 'children_size', $this->children_size])->andFilterWhere(['like', 'shoe_size', $this->shoe_size])->andFilterWhere(['like', 'tattoos', $this->tattoos])->andFilterWhere(['like', 'stand_in_experience', $this->stand_in_experience])->andFilterWhere(['like', 'cosmetic_surgery', $this->cosmetic_surgery])->andFilterWhere(['like', 'breast_augmentation', $this->breast_augmentation])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'agent', $this->agent])->andFilterWhere(['like', 'agent_email', $this->agent_email])->andFilterWhere(['like', 'fl_resident', $this->fl_resident])->andFilterWhere(['like', '_union', $this->_union])->andFilterWhere(['like', 'skills', $this->skills])->andFilterWhere(['like', 'licenses', $this->licenses])->andFilterWhere(['like', 'bust', $this->bust])->andFilterWhere(['like', 'disability', $this->disability]); return $dataProvider; }
'clientOptions' => [ 'source' => \app\models\Person::find() ->select(['fname as value'])->active()->distinct()->orderBy('fname asc')->asArray()->all(), 'autoFocus' => true, 'minLength' => '1', 'delay' => '100', ], ]); */ ?> <?php echo $form->field($model, 'fname')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\Person::find()->select(['fname'])->active()->distinct()->orderBy('fname asc')->asArray()->all(), 'fname', 'fname'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'fname', 'labelField' => 'fname', 'searchField' => ['fname']]])->hint(''); ?> <?php echo $form->field($model, 'mname')->widget(\dosamigos\selectize\SelectizeDropDownList::className(), ['items' => \yii\helpers\ArrayHelper::map(\app\models\Person::find()->select(['mname'])->active()->distinct()->orderBy('mname asc')->asArray()->all(), 'mname', 'mname'), 'options' => ['multiple' => false, 'class' => 'form-control', 'prompt' => ''], 'clientOptions' => ['selectOnTab' => true, 'openOnFocus' => false, 'persist' => false, 'maxItems' => 1, 'create' => true, 'valueField' => 'mname', 'labelField' => 'mname', 'searchField' => ['mname']]])->hint(''); ?> <?php //echo $form->field($model, 'birthday')->textInput() ?> <?php echo $form->field($model, 'birthday')->widget(\dosamigos\datepicker\DatePicker::className(), ['language' => 'ru', 'options' => ['class' => 'form-control', 'autocomplete' => 'off'], 'clientOptions' => ['forceParse' => true, 'todayBtn' => true, 'clearBtn' => true, 'autoclose' => true, 'todayHighlight' => true, 'format' => 'dd.mm.yyyy']]); ?> <?php echo $form->field($model, 'sex')->radioList($model::$list_sex, ['class' => 'btn-group', 'data-toggle' => 'buttons', 'unselect' => null, 'item' => function ($index, $label, $name, $checked, $value) { return '<label class="btn btn-default' . ($checked ? ' active' : '') . '">' . Html::radio($name, $checked, ['value' => $value, 'class' => 'project-status-btn']) . $label . '</label>'; }]); ?>
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Performer::find($id)->Festival()->detach(); Performer::find($id)->Association()->detach(); $person = Person::find($id); $a = Person::where('id', $id)->delete(); $response = []; $response["name"] = $person->name; if ($a > trashed()) { $statusCode = 200; $response['result'] = "deleted"; } else { $statusCode = 422; $response['result'] = "Cannot delete."; } return Response::json($response, $statusCode); }
<?php echo $form->field($model, 'tel')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'comment')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'pricipal_id')->dropdownlist(Person::find()->select(['name'])->indexBy('id')->column(), ['prompt' => '选择负责人']); ?> <?php echo $form->field($model, 'connecter_id')->dropdownlist(Person::find()->select(['name'])->indexBy('id')->column(), ['prompt' => '选择联系人']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
echo Html::submitButton('Գեներացնել (Generate)', ['class' => 'btn btn-primary']); ?> <?php ActiveForm::end(); ?> <div class="site-index" style="width: 3500px;"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{delete}', 'urlCreator' => function ($action, $model, $key, $index) { if ($action === 'update') { $arrayParams = ['MainSearch' => ['region' => $model->region]]; $arrayParams['id'] = $model->id; $params = array_merge(["site/main"], $arrayParams); $url = Yii::$app->urlManager->createUrl($params); return $url; } if ($action === 'delete') { $arrayParams = ['MainSearch' => ['region' => $model->region], 'id' => $model->id]; $params = array_merge(["site/delete"], $arrayParams); $url = Yii::$app->urlManager->createUrl($params); return $url; } }], ['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'city', 'value' => 'city0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'city', ArrayHelper::map(City::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'type', 'value' => 'type0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'type', ArrayHelper::map(Type::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'resident', 'children', 'employee', 'retiree', ['attribute' => 'dominant', 'value' => 'dominant0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'retiree', ArrayHelper::map(Dominant::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'mainTrashPlaces.trash_place_id', 'value' => 'trashPlaceMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashPlaces.trash_place_id', ArrayHelper::map(TrashPlace::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'mainTrashMen.trash_man_id', 'value' => 'trashManMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashMen.trash_man_id', ArrayHelper::map(TrashMan::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'filter_trash_out', 'value' => 'trash_out', 'filter' => Html::activeDropDownList($searchModel, 'filter_trash_out', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_trash_count', 'value' => 'trash_count', 'filter' => Html::activeDropDownList($searchModel, 'filter_trash_count', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_1', 'value' => 'summer_count_1', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_1', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_2', 'value' => 'summer_count_2', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_2', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_3', 'value' => 'summer_count_3', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_3', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_summer_4', 'value' => 'summer_count_4', 'filter' => Html::activeDropDownList($searchModel, 'filter_summer_4', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_1', 'value' => 'winter_count_1', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_1', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_2', 'value' => 'winter_count_2', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_2', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_3', 'value' => 'winter_count_3', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_3', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'filter_winter_4', 'value' => 'winter_count_4', 'filter' => Html::activeDropDownList($searchModel, 'filter_winter_4', array('1' => '1-5', '2' => '6-10', '3' => '11-20', '4' => '20+'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'paper', 'value' => 'paper0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'paper', ArrayHelper::map(Paper::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'mainTrashRelations.trash_relation_id', 'value' => 'trashRelationMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashRelations.trash_relation_id', ArrayHelper::map(TrashRelation::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category']), 'contentOptions' => ['style' => 'width: ' . $width . ';']], ['attribute' => 'mainTrashRecycles.trash_recycle_id', 'value' => 'trashRecycleMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainTrashRecycles.trash_recycle_id', ArrayHelper::map(TrashRecycle::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], ['attribute' => 'mainRubberItems.rubber_item_id', 'value' => 'rubberItemsMulti', 'filter' => Html::activeDropDownList($searchModel, 'mainRubberItems.rubber_item_id', ArrayHelper::map(RubberItems::find()->all(), 'id', 'nameBoth'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'answer_count', 'woman_count', ['attribute' => 'person', 'value' => 'person0.nameBothShort', 'filter' => Html::activeDropDownList($searchModel, 'person', ArrayHelper::map(Person::find()->all(), 'id', 'nameBothShort'), ['class' => 'form-control', 'prompt' => 'Select Category'])], 'date', 'interrogatory']]); ?> </div>
$form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'person_wechat_id')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'person_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'phone_number')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'recommend_by')->widget(Select2::className(), ['data' => ArrayHelper::map(Person::find()->all(), 'person_id', 'person_name'), 'options' => ['placeholder' => 'Select recommendation person ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * Lists all Person models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Person::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public function actionDashboard() { $projectGraphs = NULL; $availableGraph = NULL; $unavailableGraph = NULL; $finalListGraph = NULL; $requestsGraph = NULL; // Get Messages $messages = \app\models\Message::find()->andWhere('status != 3')->andWhere('status != 1')->limit(15)->orderBy('time DESC')->all(); // Get Project Data $projectDataProvider = new ActiveDataProvider(['query' => \app\models\Project::find()->orderBy('date DESC')->limit(5), 'pagination' => ['pageSize' => 5]]); // Get Talent Data $personDataProvider = new ActiveDataProvider(['query' => \app\models\Person::find()->orderBy('date_updated DESC')->limit(5), 'pagination' => ['pageSize' => 5]]); // Get data for graphs $projects = \app\models\Project::find()->limit(5)->all(); foreach ($projects as $project) { $projectGraphs[] = $project->title; $finalListGraph[] = \app\models\Project::countList($project->id, 2); $availableGraph[] = \app\models\Project::countList($project->id, 1, 3); $unavailableGraph[] = \app\models\Project::countList($project->id, 1, 4); $requestsGraph[] = \app\models\Project::countList($project->id, 1, 2); } Yii::$app->view->title = 'Dashboard'; return $this->render('dashboard', ['messages' => $messages, 'projectDataProvider' => $projectDataProvider, 'personDataProvider' => $personDataProvider, 'projectGraphs' => $projectGraphs, 'availableGraph' => $availableGraph, 'unavailableGraph' => $unavailableGraph, 'finalListGraph' => $finalListGraph, 'requestsGraph' => $requestsGraph]); }