本文整理汇总了PHP中Vtiger_Time_UIType::getTimeValueWithSeconds方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Time_UIType::getTimeValueWithSeconds方法的具体用法?PHP Vtiger_Time_UIType::getTimeValueWithSeconds怎么用?PHP Vtiger_Time_UIType::getTimeValueWithSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Time_UIType
的用法示例。
在下文中一共展示了Vtiger_Time_UIType::getTimeValueWithSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRecordModelsFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
public function getRecordModelsFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordIds = $this->getRecordsListFromRequest($request);
$recordModels = array();
$fieldModelList = $moduleModel->getFields();
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleModel);
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
foreach ($fieldModelList as $fieldName => $fieldModel) {
$fieldValue = $request->get($fieldName, null);
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
} else {
if ($fieldDataType === 'date') {
$fieldValue = $fieldModel->getUITypeModel()->getDBInsertValue($fieldValue);
}
}
if (isset($fieldValue) && $fieldValue != null && !is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
$recordModel->set($fieldName, $fieldValue);
}
}
$recordModels[$recordId] = $recordModel;
}
return $recordModels;
}
示例2: createFollowupEvent
public function createFollowupEvent(Vtiger_Request $request)
{
$recordId = $request->get('record');
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
$subject = $recordModel->get('subject');
$followupSubject = "[Followup] " . $subject;
$recordModel->set('subject', $followupSubject);
//followup event is Planned
$recordModel->set('eventstatus', "Planned");
$activityType = $recordModel->get('activitytype');
if ($activityType == "Call") {
$eventDuration = $request->get('defaultCallDuration');
} else {
$eventDuration = $request->get('defaultOtherEventDuration');
}
$followupStartTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start'));
$followupStartDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $followupStartTime);
list($followupStartDate, $followupStartTime) = explode(' ', $followupStartDateTime);
//Duration of followup event based on activitytype
$durationMS = $eventDuration * 60;
$followupStartDateTimeMS = strtotime($followupStartDateTime);
$followupEndDateTimeMS = $followupStartDateTimeMS + $durationMS;
$followupEndDateTime = date("Y-m-d H:i:s", $followupEndDateTimeMS);
list($followupEndDate, $followupEndTime) = explode(' ', $followupEndDateTime);
$recordModel->set('date_start', $followupStartDate);
$recordModel->set('time_start', $followupStartTime);
$recordModel->set('due_date', $followupEndDate);
$recordModel->set('time_end', $followupEndTime);
$recordModel->save();
$response = new Vtiger_Response();
$result = array('created' => true);
$response->setResult($result);
$response->emit();
}
示例3: getRecordModelFromRequest
protected function getRecordModelFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$modelData = $recordModel->getData();
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$modelData = $recordModel->getData();
$recordModel->set('mode', '');
}
$fieldModelList = $moduleModel->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
if (in_array($fieldName, array('header_content', 'content', 'footer_content'))) {
$fieldValue = $request->getRaw($fieldName, null);
} else {
$fieldValue = $request->get($fieldName, null);
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
}
return $recordModel;
}
示例4: saveRecord
/**
* 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;
}
示例5: getRecordModelsFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
function getRecordModelsFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordIds = $this->getRecordsListFromRequest($request);
if (empty($recordIds) && $request->get('selected_ids') == 'all') {
$db = PearDatabase::getInstance();
$sql = "SELECT `id` FROM `vtiger_users`";
$result = $db->query($sql, true);
$uNum = $db->num_rows($result);
if ($uNum > 0) {
$recordIds = array();
for ($i = 0; $i < $uNum; $i++) {
$recordIds[] = $db->query_result($result, $i, 'id');
}
}
}
$recordModels = array();
$fieldModelList = $moduleModel->getFields();
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleModel);
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
foreach ($fieldModelList as $fieldName => $fieldModel) {
$fieldValue = $request->get($fieldName, null);
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if (isset($fieldValue) && $fieldValue != null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
} else {
$uiType = $fieldModel->get('uitype');
if ($uiType == 70) {
$recordModel->set($fieldName, $recordModel->get($fieldName));
} else {
$uiTypeModel = $fieldModel->getUITypeModel();
$recordModel->set($fieldName, $uiTypeModel->getUserRequestValue($recordModel->get($fieldName)));
}
}
}
$recordModels[$recordId] = $recordModel;
}
return $recordModels;
}
示例6: getRecordModelsFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
function getRecordModelsFromRequest(Vtiger_Request $request)
{
global $log;
$log->debug("Entering ./actions/MassSave.php::getRecordModelsFromRequest");
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordIds = $this->getRecordsListFromRequest($request);
$recordModels = array();
$fieldModelList = $moduleModel->getFields();
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleModel);
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
foreach ($fieldModelList as $fieldName => $fieldModel) {
$fieldValue = $request->get($fieldName, null);
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if (isset($fieldValue) && $fieldValue != null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
} else {
$uiType = $fieldModel->get('uitype');
if ($uiType == 70) {
$recordModel->set($fieldName, $recordModel->get($fieldName));
} else {
$uiTypeModel = $fieldModel->getUITypeModel();
$recordModel->set($fieldName, $uiTypeModel->getUserRequestValue($recordModel->get($fieldName)));
}
}
}
$recordModels[$recordId] = $recordModel;
}
return $recordModels;
}
示例7: getRecordModelFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
protected function getRecordModelFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
$user = Users_Record_Model::getCurrentUserModel();
$allDay = $request->get('allday');
if ('on' == $allDay) {
$request->set('time_start', $user->get('start_hour'));
$request->set('time_end', $user->get('end_hour'));
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$modelData = $recordModel->getData();
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
//Due to dependencies on the activity_reminder api in Activity.php(5.x)
$_REQUEST['mode'] = 'edit';
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$modelData = $recordModel->getData();
$recordModel->set('mode', '');
}
$fieldModelList = $moduleModel->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
$fieldValue = $request->get($fieldName, null);
// For custom time fields in Calendar, it was not converting to db insert format(sending as 10:00 AM/PM)
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
// End
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
}
//Start Date and Time values
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('time_start'));
$startDate = Vtiger_Date_UIType::getDBInsertedValue($request->get('date_start'));
if ($startTime) {
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($startTime);
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('date_start') . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
}
$recordModel->set('date_start', $startDate);
$recordModel->set('time_start', $startTime);
//End Date and Time values
$endTime = $request->get('time_end');
$endDate = Vtiger_Date_UIType::getDBInsertedValue($request->get('due_date'));
if ($endTime) {
$endTime = Vtiger_Time_UIType::getTimeValueWithSeconds($endTime);
$endDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('due_date') . " " . $endTime);
list($endDate, $endTime) = explode(' ', $endDateTime);
}
$recordModel->set('time_end', $endTime);
$recordModel->set('due_date', $endDate);
$activityType = $request->get('activitytype');
if (empty($activityType)) {
$recordModel->set('activitytype', 'Task');
$recordModel->set('visibility', 'Private');
}
//Due to dependencies on the older code
$setReminder = $request->get('set_reminder');
if ($setReminder) {
$_REQUEST['set_reminder'] = 'Yes';
} else {
$_REQUEST['set_reminder'] = 'No';
}
$time = strtotime($request->get('time_end')) - strtotime($request->get('time_start'));
$diffinSec = strtotime($request->get('due_date')) - strtotime($request->get('date_start'));
$diff_days = floor($diffinSec / (60 * 60 * 24));
$hours = (double) $time / 3600 + $diff_days * 24;
$minutes = ((double) $hours - (int) $hours) * 60;
$recordModel->set('duration_hours', (int) $hours);
$recordModel->set('duration_minutes', round($minutes, 0));
return $recordModel;
}
示例8: getRecordModelFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
public function getRecordModelFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
if ($request->get('field') == 'enable_recurring') {
$enableRecurrence = true;
}
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
$fieldModelList = $recordModel->getModule()->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
//For not converting createdtime and modified time to user format
$uiType = $fieldModel->get('uitype');
if ($uiType == 70) {
$fieldValue = $recordModel->get($fieldName);
} else {
$fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName));
}
if ($fieldName === $request->get('field')) {
$fieldValue = $request->get('value');
}
/**
* If field is enable recurrence then we need to pass related fields of
* recurrence to save,because untill enable recurrence is checked,the
* related field values wont get saved
*/
if ($enableRecurrence) {
$requestFieldValue = $request->get($fieldName);
if ($requestFieldValue != '') {
$fieldValue = $request->get($fieldName);
}
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
} else {
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$recordModel->set('mode', '');
$fieldModelList = $moduleModel->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
if ($request->has($fieldName)) {
$fieldValue = $request->get($fieldName, null);
} else {
$fieldValue = $fieldModel->getDefaultFieldValue();
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
}
}
return $recordModel;
}
示例9: Events
function Events($request, $moduleName)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$record = $request->get('record');
if (!empty($record) && $request->get('isDuplicate') == true) {
$recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
$viewer->assign('MODE', '');
} else {
if (!empty($record)) {
$recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
$viewer->assign('MODE', 'edit');
$viewer->assign('RECORD_ID', $record);
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$viewer->assign('MODE', '');
}
}
$eventModule = Vtiger_Module_Model::getInstance($moduleName);
$recordModel->setModuleFromInstance($eventModule);
$moduleModel = $recordModel->getModule();
$fieldList = $moduleModel->getFields();
$requestFieldList = array_intersect_key($request->getAll(), $fieldList);
foreach ($requestFieldList as $fieldName => $fieldValue) {
$fieldModel = $fieldList[$fieldName];
$specialField = false;
// We collate date and time part together in the EditView UI handling
// so a bit of special treatment is required if we come from QuickCreate
if (empty($record) && ($fieldName == 'time_start' || $fieldName == 'time_end') && !empty($fieldValue)) {
$specialField = true;
// Convert the incoming user-picked time to GMT time
// which will get re-translated based on user-time zone on EditForm
$fieldValue = DateTimeField::convertToDBTimeZone($fieldValue)->format("H:i");
}
if (empty($record) && ($fieldName == 'date_start' || $fieldName == 'due_date') && !empty($fieldValue)) {
if ($fieldName == 'date_start') {
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($requestFieldList['time_start']);
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($fieldValue . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
$fieldValue = Vtiger_Date_UIType::getDisplayDateValue($startDate);
} else {
$endTime = Vtiger_Time_UIType::getTimeValueWithSeconds($requestFieldList['time_end']);
$endDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($fieldValue . " " . $endTime);
list($endDate, $endTime) = explode(' ', $endDateTime);
$fieldValue = Vtiger_Date_UIType::getDisplayDateValue($endDate);
}
}
if ($fieldModel->isEditable() || $specialField) {
$recordModel->set($fieldName, $fieldModel->getDBInsertValue($fieldValue));
}
}
$recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDIT);
$viewMode = $request->get('view_mode');
if (!empty($viewMode)) {
$viewer->assign('VIEW_MODE', $viewMode);
}
$userChangedEndDateTime = $request->get('userChangedEndDateTime');
//If followup value is passed from request to process the value and sent to client
$requestFollowUpDate = $request->get('followup_date_start');
$requestFollowUpTime = $request->get('followup_time_start');
$followUpStatus = $request->get('followup');
$eventStatus = $request->get('eventstatus');
if (!empty($requestFollowUpDate)) {
$followUpDate = $requestFollowUpDate;
}
if (!empty($requestFollowUpTime)) {
$followUpTime = $requestFollowUpTime;
}
if ($followUpStatus == 'on') {
$viewer->assign('FOLLOW_UP_STATUS', TRUE);
}
if ($eventStatus == 'Held') {
$viewer->assign('SHOW_FOLLOW_UP', TRUE);
} else {
$viewer->assign('SHOW_FOLLOW_UP', FALSE);
}
$viewer->assign('USER_CHANGED_END_DATE_TIME', $userChangedEndDateTime);
$viewer->assign('FOLLOW_UP_DATE', $followUpDate);
$viewer->assign('FOLLOW_UP_TIME', $followUpTime);
$viewer->assign('RECURRING_INFORMATION', $recordModel->getRecurrenceInformation());
$viewer->assign('TOMORROWDATE', Vtiger_Date_UIType::getDisplayDateValue(date('Y-m-d', time() + 86400)));
$viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
$viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
$viewer->assign('MODULE', $moduleName);
$viewer->assign('CURRENTDATE', date('Y-n-j'));
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$existingRelatedContacts = $recordModel->getRelatedContactInfo();
//To add contact ids that is there in the request . Happens in gotoFull form mode of quick create
$requestContactIdValue = $request->get('contact_id');
if (!empty($requestContactIdValue)) {
$existingRelatedContacts[] = array('name' => Vtiger_Util_Helper::getRecordName($requestContactIdValue), 'id' => $requestContactIdValue);
}
$viewer->assign('RELATED_CONTACTS', $existingRelatedContacts);
$isRelationOperation = $request->get('relationOperation');
//if it is relation edit
$viewer->assign('IS_RELATION_OPERATION', $isRelationOperation);
if ($isRelationOperation) {
$viewer->assign('SOURCE_MODULE', $request->get('sourceModule'));
$viewer->assign('SOURCE_RECORD', $request->get('sourceRecord'));
}
//.........这里部分代码省略.........
示例10: process
//.........这里部分代码省略.........
}
$request->set('module', $moduleName);
// Delegate QuickCreate FormUI to the target view controller of module.
$quickCreateviewClassName = $moduleName . '_QuickCreateAjax_View';
if (!class_exists($quickCreateviewClassName)) {
$quickCreateviewClassName = 'Vtiger_QuickCreateAjax_View';
}
$quickCreateViewController = new $quickCreateviewClassName();
$quickCreateViewController->process($request);
// UI already sent
$response = false;
} else {
if ('create' == $this->getOperationArg($request)) {
$linkModule = $request->get('_mlinktotype');
$parent = $request->get('_mlinkto');
$foldername = $request->get('_folder');
if (!empty($foldername)) {
// This is to handle larger uploads
$memory_limit = MailManager_Config_Model::get('MEMORY_LIMIT');
ini_set('memory_limit', $memory_limit);
$connector = $this->getConnector($foldername);
$mail = $connector->openMail($request->get('_msgno'));
$attachments = $mail->attachments();
// Initialize attachments
}
$linkedto = MailManager_Relate_Action::getSalesEntityInfo($parent);
$recordModel = Vtiger_Record_Model::getCleanInstance($linkModule);
$fields = $recordModel->getModule()->getFields();
foreach ($fields as $fieldName => $fieldModel) {
if ($request->has($fieldName)) {
$fieldValue = $request->get($fieldName);
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
}
switch ($linkModule) {
case 'Calendar':
$activityType = $recordModel->get('activitytype');
if (!$activityType) {
$activityType = 'Task';
}
$recordModel->set('activitytype', $activityType);
//Start Date and Time values
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('time_start'));
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('date_start') . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
$recordModel->set('date_start', $startDate);
$recordModel->set('time_start', $startTime);
//End Date and Time values
$endDate = Vtiger_Date_UIType::getDBInsertedValue($request->get('due_date'));
if ($activityType != 'Task') {
$endTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('time_end'));
$endDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('due_date') . " " . $endTime);
list($endDate, $endTime) = explode(' ', $endDateTime);
} else {
$endTime = '';
}
$recordModel->set('time_end', $endTime);
$recordModel->set('due_date', $endDate);
if ($parent) {
if ($linkedto['module'] == 'Contacts') {
$recordModel->set('contact_id', $parent);
} else {
示例11: getRecordModelFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
public function getRecordModelFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
$fieldModelList = $recordModel->getModule()->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
$fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName));
if ($fieldName === $request->get('field')) {
$fieldValue = $request->get('value');
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
} else {
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$recordModel->set('mode', '');
$fieldModelList = $moduleModel->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
if ($request->has($fieldName)) {
$fieldValue = $request->get($fieldName, null);
} else {
$fieldValue = $fieldModel->getDefaultFieldValue();
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
}
}
return $recordModel;
}
示例12: process
public function process(Vtiger_Request $request)
{
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$record = $request->get('record');
if (!empty($record) && $request->get('isDuplicate') == true) {
$recordModel = $this->record ? $this->record : Vtiger_Record_Model::getInstanceById($record, $moduleName);
$viewer->assign('MODE', '');
$recordModel->set('id', '');
//While Duplicating record, If the related record is deleted then we are removing related record info in record model
$mandatoryFieldModels = $recordModel->getModule()->getMandatoryFieldModels();
foreach ($mandatoryFieldModels as $fieldModel) {
if ($fieldModel->isReferenceField()) {
$fieldName = $fieldModel->get('name');
if (Vtiger_Util_Helper::checkRecordExistance($recordModel->get($fieldName))) {
$recordModel->set($fieldName, '');
}
}
}
} else {
if (!empty($record)) {
$recordModel = $this->record ? $this->record : Vtiger_Record_Model::getInstanceById($record, $moduleName);
$viewer->assign('RECORD_ID', $record);
$viewer->assign('MODE', 'edit');
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$referenceId = $request->get('reference_id');
if ($referenceId) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($referenceId);
$recordModel->setRecordFieldValues($parentRecordModel);
}
$viewer->assign('MODE', '');
}
}
if (!$this->record) {
$this->record = $recordModel;
}
$moduleModel = $recordModel->getModule();
$fieldList = $moduleModel->getFields();
$requestFieldList = array_intersect_key($request->getAll(), $fieldList);
foreach ($requestFieldList as $fieldName => $fieldValue) {
$fieldModel = $fieldList[$fieldName];
$specialField = false;
// We collate date and time part together in the EditView UI handling
// so a bit of special treatment is required if we come from QuickCreate
if ($moduleName == 'Calendar' && empty($record) && $fieldName == 'time_start' && !empty($fieldValue)) {
$specialField = true;
// Convert the incoming user-picked time to GMT time
// which will get re-translated based on user-time zone on EditForm
$fieldValue = DateTimeField::convertToDBTimeZone($fieldValue)->format("H:i");
}
if ($moduleName == 'Calendar' && empty($record) && $fieldName == 'date_start' && !empty($fieldValue)) {
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($requestFieldList['time_start']);
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($fieldValue . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
$fieldValue = Vtiger_Date_UIType::getDisplayDateValue($startDate);
}
if ($fieldModel->isEditable() || $specialField) {
$recordModel->set($fieldName, $fieldModel->getDBInsertValue($fieldValue));
}
}
$recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDIT);
$picklistDependencyDatasource = Vtiger_DependencyPicklist::getPicklistDependencyDatasource($moduleName);
$viewer->assign('PICKIST_DEPENDENCY_DATASOURCE', Zend_Json::encode($picklistDependencyDatasource));
$mappingRelatedField = $moduleModel->getMappingRelatedField($moduleName);
$viewer->assign('MAPPING_RELATED_FIELD', Zend_Json::encode($mappingRelatedField));
$viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance);
$viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure());
$viewer->assign('MODULE', $moduleName);
$viewer->assign('MODULE_TYPE', $moduleModel->getModuleType());
$viewer->assign('RECORD', $recordModel);
$viewer->assign('BLOCK_LIST', $moduleModel->getBlocks());
$viewer->assign('CURRENTDATE', date('Y-n-j'));
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$viewer->assign('APIADDRESS', Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->getConfig());
$viewer->assign('APIADDRESS_ACTIVE', Settings_ApiAddress_Module_Model::isActive());
$isRelationOperation = $request->get('relationOperation');
//if it is relation edit
$viewer->assign('IS_RELATION_OPERATION', $isRelationOperation);
if ($isRelationOperation) {
$viewer->assign('SOURCE_MODULE', $request->get('sourceModule'));
$viewer->assign('SOURCE_RECORD', $request->get('sourceRecord'));
}
$viewer->assign('MAX_UPLOAD_LIMIT_MB', Vtiger_Util_Helper::getMaxUploadSize());
$viewer->assign('MAX_UPLOAD_LIMIT', vglobal('upload_maxsize'));
$viewer->view('EditView.tpl', $moduleName);
}
示例13: getRecordModelFromRequest
/**
* Function to get the record model based on the request parameters
* @param Vtiger_Request $request
* @return Vtiger_Record_Model or Module specific Record Model instance
*/
public function getRecordModelFromRequest(Vtiger_Request $request)
{
$recordModel = parent::getRecordModelFromRequest($request);
$startDate = $request->get('date_start');
if (!empty($startDate)) {
//Start Date and Time values
$startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('time_start'));
$startDate = Vtiger_Date_UIType::getDBInsertedValue($request->get('date_start'));
if ($startTime) {
$startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('date_start') . " " . $startTime);
list($startDate, $startTime) = explode(' ', $startDateTime);
}
$recordModel->set('date_start', $startDate);
$recordModel->set('time_start', $startTime);
}
$endDate = $request->get('due_date');
if (!empty($endDate)) {
//End Date and Time values
$endTime = $request->get('time_end');
$endDate = Vtiger_Date_UIType::getDBInsertedValue($request->get('due_date'));
if ($endTime) {
$endTime = Vtiger_Time_UIType::getTimeValueWithSeconds($endTime);
$endDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('due_date') . " " . $endTime);
list($endDate, $endTime) = explode(' ', $endDateTime);
}
$recordModel->set('time_end', $endTime);
$recordModel->set('due_date', $endDate);
}
$record = $request->get('record');
if (!$record) {
$activityType = $request->get('activitytype');
$visibility = $request->get('visibility');
if (empty($activityType)) {
$recordModel->set('activitytype', 'Task');
$visibility = 'Private';
$recordModel->set('visibility', $visibility);
}
}
if (empty($visibility)) {
$assignedUserId = $recordModel->get('assigned_user_id');
$sharedType = Calendar_Module_Model::getSharedType($assignedUserId);
if ($sharedType == 'selectedusers') {
$sharedType = 'public';
}
$recordModel->set('visibility', ucfirst($sharedType));
}
return $recordModel;
}
示例14: getRecordModelFromRequest
public function getRecordModelFromRequest(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$recordModel->set('id', $recordId);
$recordModel->set('mode', 'edit');
$fieldModelList = $recordModel->getModule()->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
//For not converting craetedtime and modified time to user format
$uiType = $fieldModel->get('uitype');
if ($uiType == 70) {
$fieldValue = $recordModel->get($fieldName);
} else {
$fieldValue = $fieldModel->getUITypeModel()->getUserRequestValue($recordModel->get($fieldName));
}
if ($fieldName === $request->get('field')) {
$fieldValue = $request->get('value');
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
} else {
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$recordModel->set('mode', '');
$fieldModelList = $moduleModel->getFields();
foreach ($fieldModelList as $fieldName => $fieldModel) {
if ($request->has($fieldName)) {
$fieldValue = $request->get($fieldName, null);
} else {
$fieldValue = $fieldModel->getDefaultFieldValue();
// to update the support_end_date and support_start_date in Quick create
if ($fieldName == 'support_end_date') {
$fieldValue = DateTimeField::convertToUserFormat(date('Y-m-d', strtotime("+1 year")));
} else {
if ($fieldName == 'support_start_date') {
$fieldValue = DateTimeField::convertToUserFormat(date('Y-m-d'));
}
}
}
$fieldDataType = $fieldModel->getFieldDataType();
if ($fieldDataType == 'time') {
$fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue);
}
if ($fieldValue !== null) {
if (!is_array($fieldValue)) {
$fieldValue = trim($fieldValue);
}
$recordModel->set($fieldName, $fieldValue);
}
}
}
return $recordModel;
}
示例15: save
/**
* Function to save the record
*/
public function save()
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$mode = $this->get('mode');
$db = PearDatabase::getInstance();
$this->setCheckBoxValue('enabled');
$this->setCheckBoxValue('captcha');
$this->setCheckBoxValue('roundrobin');
if (is_array($this->get('roundrobin_userid'))) {
$roundrobinUsersList = json_encode($this->get('roundrobin_userid'), JSON_FORCE_OBJECT);
}
//Saving data about webform
if ($mode) {
$updateQuery = "UPDATE vtiger_webforms SET description = ?, returnurl = ?, ownerid = ?, enabled = ?, captcha = ? , roundrobin = ?, roundrobin_userid = ?, roundrobin_logic = ? ,targetmodule = ? WHERE id = ?";
$params = array($this->get('description'), $this->get('returnurl'), $this->get('ownerid'), $this->get('enabled'), $this->get('captcha'), $this->get('roundrobin'), $roundrobinUsersList, 0, $this->get('targetmodule'), $this->getId());
$db->pquery($updateQuery, $params);
} else {
$insertQuery = "INSERT INTO vtiger_webforms(name, targetmodule, publicid, enabled, description, ownerid, returnurl, captcha, roundrobin, roundrobin_userid, roundrobin_logic) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$params = array($this->getName(), $this->get('targetmodule'), $this->generatePublicId(), $this->get('enabled'), $this->get('description'), $this->get('ownerid'), $this->get('returnurl'), $this->get('captcha'), $this->get('roundrobin'), $roundrobinUsersList, 0);
$db->pquery($insertQuery, $params);
$this->set('id', $db->getLastInsertID());
}
//Deleting existing data
$db->pquery("DELETE FROM vtiger_webforms_field WHERE webformid = ?", array($this->getId()));
//Saving data of source module fields info for this webform
$selectedFieldsData = $this->get('selectedFieldsData');
$sourceModuleModel = Vtiger_Module_Model::getInstance($this->get('targetmodule'));
$fieldInsertQuery = "INSERT INTO vtiger_webforms_field(webformid, fieldname, neutralizedfield, defaultvalue, required, sequence, hidden) VALUES(?, ?, ?, ?, ?, ?, ?)";
foreach ($selectedFieldsData as $fieldName => $fieldDetails) {
$params = array($this->getId());
$neutralizedField = $fieldName;
$fieldDefaultValue = $fieldDetails['defaultvalue'];
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $sourceModuleModel);
$dataType = $fieldModel->getFieldDataType();
//Updating custom field label
if (self::isCustomField($fieldName)) {
$neutralizedField = 'label:' . str_replace(' ', '_', decode_html($fieldModel->get('label')));
}
//Handling multi picklist
if (is_array($fieldDefaultValue)) {
$fieldDefaultValue = implode(" |##| ", $fieldDefaultValue);
}
//Handling Data format
if ($dataType === 'date') {
$fieldDefaultValue = Vtiger_Date_UIType::getDBInsertedValue($fieldDefaultValue);
}
if ($dataType === 'time') {
$fieldDefaultValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldDefaultValue);
}
//Handling CheckBox value
if ($dataType === 'boolean') {
if ($fieldDefaultValue) {
$fieldDefaultValue = 'on';
} else {
$fieldDefaultValue = '';
}
}
if ($dataType === 'reference') {
$referenceModule = $fieldDetails['referenceModule'];
$referenceObject = VtigerWebserviceObject::fromName($db, $referenceModule);
$referenceEntityId = $referenceObject->getEntityId();
$fieldDefaultValue = $referenceEntityId . "x" . $fieldDefaultValue;
}
if ($dataType === 'currency') {
$decimalSeperator = $currentUser->get('currency_decimal_separator');
$groupSeperator = $currentUser->get('currency_grouping_separator');
$fieldDefaultValue = str_replace($decimalSeperator, '.', $fieldDefaultValue);
$fieldDefaultValue = str_replace($groupSeperator, '', $fieldDefaultValue);
}
array_push($params, $fieldName, $neutralizedField, $fieldDefaultValue, $fieldDetails['required'], $fieldDetails['sequence'], $fieldDetails['hidden']);
$db->pquery($fieldInsertQuery, $params);
}
}