public function actionPayment() { $employeePayment = $_POST['LbEmployeePayment']; for ($i = 0; $i < count($employeePayment); $i++) { if (isset($employeePayment[$i]['employee_id'])) { $datepay = date_format(date_create($_POST['datePaid']), 'Y-m-d'); $month = date('m', strtotime($datepay)); $year = date('Y', strtotime($datepay)); $model = new LbEmployeePayment(); $model->attributes = $employeePayment[$i]; $model->payment_note = $employeePayment[$i]['payment_note']; $model->payment_month = $month; $model->payment_year = $year; $model->payment_date = date('Y-m-d'); $model->payment_created_by = Yii::app()->user->id; $model->save(); //upodate status payment if ($model->caculatorAmount($employeePayment[$i]['employee_id']) > 0) { $model->payment_status = 2; } else { $model->payment_status = 1; } $model->save(); } } }