- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
public function actionView($id = null) {
$user = Yii::$app->user->identity;
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : $id;
$new_model = 0;
if (empty($id)) {
$draft_model = Applicant::find()->where(['draft' => 1, 'created_by' => $user->id])->one();
if (empty($draft_model)) {
$draft_model = new Applicant();
$new_model = 1;
$draft_model->draft = 1;
$draft_model->save();
}
if (!empty($draft_model->id)) {
$id = $draft_model->id;
}
}
$model = $this->findModel($id);
$allow_sections = [];
if (empty($model->draft)) {
$updateRequest = \app\models\UserRequest::find()->where(['user_id' => $user->id, 'object_id' => $id, 'status' => 2])->one();
if (!empty($updateRequest)) {
$allow_sections = explode(";", $updateRequest->additional_info);
}
}
if (isset($_GET['done']) && $_GET['done'] == 1) {
$result['success'] = false;
$userRequest = \app\models\UserRequest::find()->where(['user_id' => $user->id, 'object_id' => $id, 'status' => 2])->one();
if (!empty($userRequest)) {
$userRequest->status = 3;
if ($userRequest->save()) {
$result['success'] = true;
} else {
$error = \yii\widgets\ActiveForm::validate($userRequest);
if ($error != '[]') {
$result['msg'] = $error;
}
}
}
echo(json_encode($result));
exit;
} elseif (isset($_FILES['files']['name'][0]) && isset($_FILES['files']['type'][0]) && isset($_FILES['files']['tmp_name'][0]) && isset($_FILES['files']['size'][0])) {
$result['success'] = false;
$filename = strtotime("now") . "_" . $_FILES['files']['name'][0];
$size = $_FILES['files']['size'][0];
$uploaddir = realpath('../web') . '/images/applicant/';
if (!file_exists($uploaddir)) {
mkdir($uploaddir);
}
$uploadfile = $uploaddir . basename($filename);
$path_image = '/images/applicant/' . basename($filename);
if (move_uploaded_file($_FILES['files']['tmp_name'][0], $uploadfile)) {
if (!empty($model->photo_id)) {
$photo_model = \app\models\File::findOne($model->photo_id);
}
if (empty($photo_model->id)) {
$photo_model = new \app\models\File();
}
$photo_model->original = $filename;
$photo_model->name = $filename;
$photo_model->size = $size;
$photo_model->mime = $_FILES['files']['type'][0];
$photo_model->hash = $photo_model->generateHash();
if ($photo_model->save()) {
$model->photo_id = $photo_model->id;
if ($model->save()) {
$result['img'] = $filename;
$result['success'] = true;
}
}
$image = new Image();
$image->load($uploadfile);
if($image->getWidth()>640){
$image->resizeToWidth(640);
$image->save($uploadfile);
}
}
echo(json_encode($result));
exit;
} elseif (isset($_REQUEST['name'])) {
$result['success'] = false;
$model_attributes = $model->getAttributes();
$model_attributes['education'] = '';
unset($model_attributes['id']);
if ($_REQUEST['name'] == 'address_properties') {
$values = json_decode($_REQUEST['value'], true);
$names_values = ['address_region', 'address_city', 'address_street', 'address_house'];