/**
  * Als een contract wordt aangeboden d.m.v. de contractdialoog (_daialogContr.php).  
  *
  **/
 public function actionUpdateContractContracterenFromDialog()
 {
     $model = new ContractDeals();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if (isset($_POST['ContractDeals']) && isset($_POST['CalendarEvents'])) {
         $prev_codetitle = ArrayHelper::getValue($_POST['CalendarEvents'], 'code_title');
         $calendereventId = ArrayHelper::getValue($_POST['CalendarEvents'], 'id');
         $location = ArrayHelper::getValue($_POST['ContractDeals'], 'location');
         $city = ArrayHelper::getValue($_POST['ContractDeals'], 'city');
         $aanvangstijd = ArrayHelper::getValue($_POST['ContractDeals'], 'aanvangstijd');
         $newCodeTitleMdl = $this->getNextCodeTitles($prev_codetitle);
         $CalendarEvent = CalendarEvents::findOne(['id' => $calendereventId]);
         if ($CalendarEvent) {
             $CalendarEvent->title = $newCodeTitleMdl->title;
             $CalendarEvent->color = $newCodeTitleMdl->color;
             $CalendarEvent->code_title = $newCodeTitleMdl->code_title;
             $CalendarEvent->approximated_by = Yii::$app->user->id;
             if ($CalendarEvent->save(false)) {
                 $new_contractdeal = ContractDeals::newContractDeal($CalendarEvent, $city, $location, $aanvangstijd);
                 $this->sendEmailToContractOntvanger($CalendarEvent);
             }
         }
     }
     $this->redirect(array('mijnkalender', '_id' => $CalendarEvent->user_id));
 }