/**
  * @return array
  * handel search conditions
  */
 function handel_search()
 {
     $query = Schedule::find();
     switch ($_REQUEST['st']) {
         case 1:
             $_REQUEST['search_input'] ? $arr['employee_id'] = Employee::findOne(['name' => $_REQUEST['search_input']])->id : '';
             //search  employee name
             break;
         case 2:
             //($_REQUEST['search_input'])?$arr['mobile']=$_REQUEST['search_input']:'';
             $_REQUEST['search_input'] ? $condition['mobile'] = $_REQUEST['search_input'] : '';
             break;
         default:
     }
     $arr['agency_id'] = Yii::$app->user->identity->id;
     $query->where($arr);
     if ($_REQUEST['st']) {
         //($_REQUEST['status'])?$arr['job_id']=PostJob::findOne(['job_status'=>$_REQUEST['status']])->id:'';      //search job status
         // ($_REQUEST['service_type'])?$arr['job_id']=$_REQUEST['service_type']:'';                //search service_type
         $_REQUEST['status'] ? $condition['job_status'] = $_REQUEST['status'] : '';
         $_REQUEST['service_type'] ? $condition['service_type'] = $_REQUEST['service_type'] : '';
         $res = PostJob::find()->where($condition)->all();
         if (count($res) > 0) {
             foreach ($res as $k => $v) {
                 $ids[] = $v->id;
             }
             $query->andWhere(['in', 'job_id', $ids]);
         } else {
             $query->andWhere(['job_id' => '-1']);
         }
     }
     return $query;
 }
 /**
  * Finds the Employee model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Employee the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Employee::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #3
0
 public function actionAssignEmployee($id)
 {
     $selections = Yii::$app->request->post('selection');
     if (count($selections) > 0) {
         foreach ($selections as $employee_id) {
             $employee = Employee::findOne($employee_id);
             if (isset($_POST['assign'])) {
                 $employee->company_id = $id;
             } else {
                 if (isset($_POST['unassign'])) {
                     $employee->company_id = 0;
                 }
             }
             if (!$employee->save()) {
                 Yii::$app->session->setFlash('error', 'Error saving employee.');
             }
         }
     }
     return $this->redirect(['view', 'id' => $id]);
 }
 /**
  * Finds the Employee model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $employee_id
  * @param integer $position_id
  * @return Employee the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($employee_id, $position_id)
 {
     if (($model = Employee::findOne(['employee_id' => $employee_id, 'position_id' => $position_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #5
0
 public function actionAssignEmployee($id)
 {
     $selections = Yii::$app->request->post('selection');
     if (count($selections) > 0) {
         foreach ($selections as $employee_id) {
             $employee = Employee::findOne($employee_id);
             if (isset($_POST['assign'])) {
                 $group_id = $id;
                 Yii::$app->db->createCommand("UPDATE wolf_employee SET groups=CONCAT(groups,'," . $group_id . "') WHERE NOT FIND_IN_SET(" . $group_id . ",groups) AND employee_id=:column2")->bindValue(':column2', $employee_id)->execute();
             } else {
                 if (isset($_POST['unassign'])) {
                     $group_id = $id;
                     Yii::$app->db->createCommand("UPDATE wolf_employee SET groups=TRIM(BOTH ',' FROM REPLACE(CONCAT(',', groups, ','), '," . $group_id . ",', ',')) WHERE FIND_IN_SET(" . $group_id . ",groups) AND employee_id=:column2")->bindValue(':column2', $employee_id)->execute();
                 }
             }
             Yii::$app->session->setFlash('sucess', 'Employee assigned');
         }
     }
     return $this->redirect(['update', 'id' => $id]);
 }
Beispiel #6
0
?>
</h1>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['fullname', 'email:email', 'NRIC', 'mobiletel'], 'template' => '<tr><th width=40%>{label}</th><td>{value}</td></tr>']);
?>

    <h1>Group</h1>
    <?php 
$form = ActiveForm::begin(array('action' => Yii::$app->getUrlManager()->createUrl('employee/assign-group?id=' . $model->employee_id)));
?>
    <div class="grey-col">
    <?php 
echo ListView::widget(['dataProvider' => $groupData, 'itemOptions' => ['class' => 'item'], 'itemView' => function ($group, $key, $index, $widget) {
    $employee_id = Yii::$app->request->getQueryParams()['id'];
    $model = Employee::findOne($employee_id);
    $group_arr = explode(",", $model->groups);
    $checked = in_array($group->id, $group_arr) ? true : false;
    $layout = '<div class="col-xs-6" style="border-bottom:1px solid #bdbdbd;padding:8px 0px 8px 0px">';
    $layout .= '' . Html::checkbox('groups[]', $checked, array('value' => $group->id, 'label' => Html::encode($group->name) . ' (' . Html::encode($group->notes) . ')')) . ' &nbsp; ';
    // $layout .='     '.Html::encode($group->name).' ('.Html::encode($group->notes).')';
    $layout .= '</div>';
    return $layout;
}]);
?>
    </div>

    <div class="clear">&nbsp;</div>

    <p class="float-left">
        <?php 
Beispiel #7
0
                    </td>
                </tr>
            </table>
        </div>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'layout' => "<div class='wrap'>{summary}{pager}</div>{items}\n<div class='wrap'>{summary}{pager}</div>", 'columns' => ['job_id', 'update_time', ['label' => '工作种类', 'format' => 'raw', 'value' => function ($model) {
    return Yii::$app->params['empl_type'][PostJob::findOne($model->job_id)['service_type']];
}], ['label' => '工作状态', 'format' => 'raw', 'value' => function ($model) {
    return Yii::$app->params['job_status'][PostJob::findOne($model->job_id)['job_status']];
}], ['label' => '地区', 'format' => 'raw', 'value' => function ($model) {
    return PostJob::findOne($model->user_id)['district'];
}], ['label' => '地址', 'format' => 'raw', 'value' => function ($model) {
    return PostJob::findOne($model->user_id)['address'];
}], ['label' => '配置工作人员', 'format' => 'raw', 'value' => function ($model) {
    return Employee::findOne($model->employee_id)['name'];
}], ['label' => '客户', 'format' => 'raw', 'value' => function ($model) {
    return User::findOne($model->user_id)['display_name'];
}], ['label' => '客户电话', 'format' => 'raw', 'value' => function ($model) {
    return PostJob::findOne($model->job_id)['mobile'];
}], ['label' => '付款记录', 'format' => 'raw', 'value' => function ($model) {
    return '记录';
}]]]);
?>

    </div>
</div>
<script src="<?php 
echo $this->context->get_path();
?>
/custom/search.js" type="text/javascript"></script>