Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(startdate='startdate' between startdate(Y-m-(d+'daysleave')->where('status'=='approved')
- {
- $_post = 'status'=rejected,
- 'applydate=date('Y-m-d'),
- 'startdate';
- )
- } else {
- }
- if ($model->load(Yii::$app->request->post()))
- {
- //Proses Validasi if no more quota left
- if($model->daysleaveleft(Yii::$app->user->id,date('Y',strtotime($model->startdate)))>0)
- {
- //Validate if startdate< applydate
- if($model->startdate < $model->applydate)
- {
- echo "Cannot proceed";
- }
- else
- {
- $model->save();
- return $this->redirect(['view', 'id' => $model->id]);
- }
- }
- else
- {
- echo"Maximum Quota";
- }
- }
- else
- {
- return $this->render('create', [
- 'model' => $model,
- ]);
- }
- public function DaysLeaveLeft($id,$year) {
- $models = Leave::find()->select(['daysleave'=>'sum(daysleave)'])->where(['status'=>'approved','EmpId' => $id,'year(startdate)'=>$year])->One();
- $Setting = Setting::find()->where(['Var'=>'MaxLeave'])->One();
- return $Setting->Val - $models['daysleave'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement