/** * Function to save record * @param <Vtiger_Request> $request - values of the record * @return <RecordModel> - record Model of saved record */ public function saveRecord($request) { $adb = PearDatabase::getInstance(); $recordModel = $this->getRecordModelFromRequest($request); $recordModel->save(); $originalRecordId = $recordModel->getId(); if ($request->get('relationOperation')) { $parentModuleName = $request->get('sourceModule'); $parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName); $parentRecordId = $request->get('sourceRecord'); $relatedModule = $recordModel->getModule(); if ($relatedModule->getName() == 'Events') { $relatedModule = Vtiger_Module_Model::getInstance('Calendar'); } $relatedRecordId = $recordModel->getId(); $relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule); $relationModel->addRelation($parentRecordId, $relatedRecordId); } // Handled to save follow up event $followupMode = $request->get('followup'); //Start Date and Time values $startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start')); $startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $startTime); list($startDate, $startTime) = explode(' ', $startDateTime); $subject = $request->get('subject'); if ($followupMode == 'on' && $startTime != '' && $startDate != '') { $recordModel->set('eventstatus', 'Planned'); $recordModel->set('subject', '[Followup] ' . $subject); $recordModel->set('date_start', $startDate); $recordModel->set('time_start', $startTime); $currentUser = Users_Record_Model::getCurrentUserModel(); $activityType = $recordModel->get('activitytype'); if ($activityType == 'Call') { $minutes = $currentUser->get('callduration'); } else { $minutes = $currentUser->get('othereventduration'); } $dueDateTime = date('Y-m-d H:i:s', strtotime("{$startDateTime}+{$minutes} minutes")); list($startDate, $startTime) = explode(' ', $dueDateTime); $recordModel->set('due_date', $startDate); $recordModel->set('time_end', $startTime); $recordModel->set('recurringtype', ''); $recordModel->set('mode', 'create'); $recordModel->save(); $heldevent = true; } //TODO: remove the dependency on $_REQUEST if ($_REQUEST['recurringtype'] != '' && $_REQUEST['recurringtype'] != '--None--') { vimport('~modules/Calendar/RepeatEvents.php'); $focus = new Activity(); //get all the stored data to this object $focus->column_fields = $recordModel->getData(); Calendar_RepeatEvents::repeatFromRequest($focus); } return $recordModel; }
} if (isset($_REQUEST['month']) && $_REQUEST['month'] != '') { $month = vtlib_purify($_REQUEST['month']); } if (isset($_REQUEST['year']) && $_REQUEST['year'] != '') { $year = vtlib_purify($_REQUEST['year']); } if (isset($_REQUEST['viewOption']) && $_REQUEST['viewOption'] != '') { $viewOption = vtlib_purify($_REQUEST['viewOption']); } if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] != '') { $subtab = vtlib_purify($_REQUEST['subtab']); } if ($_REQUEST['recurringcheck']) { include_once 'modules/Calendar/RepeatEvents.php'; Calendar_RepeatEvents::repeatFromRequest($focus); } //code added for returning back to the current view after edit from list view if ($_REQUEST['return_viewname'] == '') { $return_viewname = '0'; } if ($_REQUEST['return_viewname'] != '') { $return_viewname = vtlib_purify($_REQUEST['return_viewname']); } $parenttab = getParentTab(); if (!empty($_REQUEST['start'])) { $page = '&start=' . vtlib_purify($_REQUEST['start']); } if (!empty($_REQUEST['pagenumber'])) { $page = "&start=" . vtlib_purify($_REQUEST['pagenumber']); }
} if (isset($_REQUEST['month']) && $_REQUEST['month'] != '') { $month = vtlib_purify($_REQUEST['month']); } if (isset($_REQUEST['year']) && $_REQUEST['year'] != '') { $year = vtlib_purify($_REQUEST['year']); } if (isset($_REQUEST['viewOption']) && $_REQUEST['viewOption'] != '') { $viewOption = vtlib_purify($_REQUEST['viewOption']); } if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] != '') { $subtab = vtlib_purify($_REQUEST['subtab']); } if ($_REQUEST['recurringcheck']) { include_once dirname(__FILE__) . '/RepeatEvents.php'; Calendar_RepeatEvents::repeat($focus); } //code added for returning back to the current view after edit from list view if ($_REQUEST['return_viewname'] == '') { $return_viewname = '0'; } if ($_REQUEST['return_viewname'] != '') { $return_viewname = vtlib_purify($_REQUEST['return_viewname']); } $parenttab = getParentTab(); if (!empty($_REQUEST['start'])) { $page = '&start=' . vtlib_purify($_REQUEST['start']); } if (!empty($_REQUEST['pagenumber'])) { $page = "&start=" . vtlib_purify($_REQUEST['pagenumber']); }