Example #1
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Employees::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['branch_id' => SORT_ASC, 'snp' => SORT_ASC]], 'pagination' => ['pagesize' => 100]]);
     $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->joinWith('branch');
     $query->andFilterWhere(['employees.id' => $this->id]);
     $query->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'patronymic', $this->patronymic])->andFilterWhere(['like', 'job_title', $this->job_title])->andFilterWhere(['like', 'employee_number', $this->employee_number])->andFilterWhere(['like', 'unique_1c_number', $this->unique_1c_number])->andFilterWhere(['like', 'LOWER(snp)', mb_strtolower($this->snp) . '%', false])->andFilterWhere(['like', 'branches.branch_title', $this->branch_id]);
     return $dataProvider;
 }
Example #2
0
/* @var $model backend\models\WpOwners */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="wp-owners-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(Workplaces::find()->all(), 'id', 'workplaces_title'), ['prompt' => 'Выберите рабочее место...']);
?>

    <?php 
echo $form->field($model, 'employee_id')->dropDownList(ArrayHelper::map(Employees::find()->all(), 'id', function ($model) {
    return $model->surname . ' ' . $model->name;
}), ['prompt' => 'Выберите сотрудника...']);
?>

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

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

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
Example #3
0
    <?php 
$form = ActiveForm::begin();
?>

    <?php 
//echo $form->field($model, 'date_create')->textInput()
?>
    <?php 
//echo $form->field($model, 'date_confirm')->textInput()
?>
    <?php 
//echo $form->field($model, 'status')->textInput()
?>

    <?php 
echo $form->field($model, 'employee_name')->widget(AutoComplete::className(), ['clientOptions' => ['source' => Employees::arraySnpId(), 'minLength' => '1', 'autoFill' => true, 'select' => new JsExpression("function( event, ui ) {\n                    \$('#employee_id_hidd').val(ui.item.id);\n                 }")], 'options' => ['class' => 'form-control']]);
?>
    <?php 
echo $form->field($model, 'employee_id')->hiddenInput(['id' => 'employee_id_hidd'])->label(false);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Редактировать', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #4
0
 /**
  * @return $this
  */
 public function getOwner()
 {
     $res = $this->hasMany(Employees::className(), ['id' => 'employee_id'])->viaTable('wp_owners', ['workplace_id' => 'id']);
     //var_dump($res);
     return $res;
 }
Example #5
0
 /**
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function arraySnpId()
 {
     return Employees::find()->select("snp as value, snp as label, id as id")->where("snp > ''")->orderBy('snp')->asArray()->all();
 }
Example #6
0
 /**
  * Finds the Employees model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Employees the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Employees::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #7
0
 public function getEmployee()
 {
     return $this->hasOne(Employees::className(), ['id' => 'employee_id'])->viaTable('wp_owners', ['workplace_id' => 'workplace_id']);
 }
Example #8
0
 public function getEmployee()
 {
     return $this->hasOne(Employees::className(), ['id' => 'id_employee']);
 }
Example #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEmployees()
 {
     return $this->hasMany(Employees::className(), ['office_id' => 'office_id']);
 }
Example #10
0
/* @var $model backend\models\DtEnquiries */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="dt-enquiries-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
//echo $form->field($model, 'employee_id')->textInput()
?>

    <?php 
echo $form->field($model, 'employee_name')->widget(AutoComplete::className(), ['clientOptions' => ['source' => Employees::arraySnp()], 'options' => ['class' => 'form-control']]);
?>

    <?php 
echo $form->field($model, 'create_date')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control']]);
?>

    <?php 
echo $form->field($model, 'do_date')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control']]);
?>

    <?php 
//echo $form->field($model, 'create_time')->textInput()
?>

    <?php 
Example #11
0
 /**
  * Обрабатываем загруженный файл
  */
 public function actionReadFile()
 {
     $filename = 'in/cellnumbers.txt';
     //$fsz = filesize($filename);
     $readfile = fopen($filename, 'r');
     $err = '';
     //инвертируем статус. номера, не прошедшие обработку, останутся с отрицательным статусом
     Yii::$app->db->createCommand('UPDATE cell_numbers SET status = status*(-1)')->execute();
     while ($str = fgets($readfile, 1024)) {
         //$items = explode(chr(9), $str);
         $items = explode(";", $str);
         if (count($items) != 3) {
             Yii::$app->db->createCommand('UPDATE cell_numbers SET status = status*(-1)')->execute();
             //возвращаем статусы
             Yii::$app->session->setFlash('error', 'Файл не соответствует формату');
             break;
         }
         if (stristr($str, 'Абонент') > '') {
             continue;
         }
         $str_cell = str_replace('-', '', $items[2]);
         $cell = CellNumbers::findOne(['cell_number' => $str_cell]);
         $emp = Employees::findOne(['snp' => $items[0]]);
         if (isset($cell)) {
             if (!isset($emp)) {
                 continue;
             }
             if ($cell->employee_id != $emp->id) {
                 $cell_count = CellNumbers::find()->where(['employee_id' => $emp->id])->count();
                 $cell->employee_id = $emp->id;
                 $cell->status = $cell_count + 1;
                 $cell->save();
             } else {
                 $cell->status = $cell->status * -1;
                 if ($cell->validate()) {
                     $cell->save();
                 } else {
                     //если не прошли валидацию - собираем ошибки
                     foreach ($cell->errors as $key => $error) {
                         $err .= '<b>' . $key . '</b> ' . implode('   ', $error) . '<br>';
                     }
                     Yii::$app->session->setFlash('error', $err);
                 }
             }
         } else {
             $cell = new CellNumbers();
             if ($emp) {
                 $cell_count = CellNumbers::find()->where(['employee_id' => $emp->id])->count();
                 $cell->status = $cell_count + 1;
                 $cell->employee_id = $emp->id;
             }
             $cell->cell_number = $str_cell;
             $cell->save();
         }
     }
     //номерам, не попавшим в обработку (статус < 0), удаляем владельцев и сбрасываем статус на 1
     Yii::$app->db->createCommand('UPDATE cell_numbers SET employee_id = NULL, status = 1 WHERE status < 0')->execute();
 }