本文整理汇总了PHP中Vtiger_Date_UIType::getDBInsertedValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Date_UIType::getDBInsertedValue方法的具体用法?PHP Vtiger_Date_UIType::getDBInsertedValue怎么用?PHP Vtiger_Date_UIType::getDBInsertedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Date_UIType
的用法示例。
在下文中一共展示了Vtiger_Date_UIType::getDBInsertedValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$linkId = $request->get('linkid');
$data = $request->get('data');
$createdTime = $request->get('createdtime');
//Date conversion from user to database format
if (!empty($createdTime)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$data = $moduleModel->getCountriesByRating($request->get('owner'), $dates);
$listViewUrl = $moduleModel->getListViewUrl();
for ($i = 0; $i < count($data); $i++) {
$data[$i]["links"] = $listViewUrl . $this->getSearchParams($data[$i][2], $request->get('owner'), $dates);
}
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
//Include special script and css needed for this widget
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
$viewer->assign('CURRENTUSER', $currentUser);
$accessibleUsers = $currentUser->getAccessibleUsersForModule($moduleName);
$viewer->assign('ACCESSIBLE_USERS', $accessibleUsers);
$content = $request->get('content');
if (!empty($content)) {
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
} else {
$viewer->view('dashboards/CountriesByRating.tpl', $moduleName);
}
}
示例2: save
public function save(Vtiger_Request $request)
{
$fieldId = $request->get('fieldid');
$fieldInstance = Vtiger_Field_Model::getInstance($fieldId);
$fields = ['presence', 'quickcreate', 'summaryfield', 'helpinfo', 'generatedtype', 'masseditable', 'displaytype'];
foreach ($request->getAll() as $key => $value) {
if ($key == 'mandatory') {
$fieldInstance->updateTypeofDataFromMandatory($value);
}
if (in_array($key, $fields)) {
$fieldInstance->set($key, $value);
}
}
$defaultValue = $request->get('fieldDefaultValue');
if ($fieldInstance->getFieldDataType() == 'date') {
$dateInstance = new Vtiger_Date_UIType();
$defaultValue = $dateInstance->getDBInsertedValue($defaultValue);
}
if ($request->has('fieldMask')) {
$fieldInstance->set('fieldparams', $request->get('fieldMask'));
}
if (is_array($defaultValue)) {
$defaultValue = implode(' |##| ', $defaultValue);
}
$fieldInstance->set('defaultvalue', $defaultValue);
$response = new Vtiger_Response();
try {
$fieldInstance->save();
$response->setResult(array('success' => true, 'presence' => $request->get('presence'), 'mandatory' => $fieldInstance->isMandatory(), 'label' => vtranslate($fieldInstance->get('label'), $request->get('sourceModule'))));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例3: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$linkId = $request->get('linkid');
$expectedclosedate = $request->get('expectedclosedate');
//Date conversion from user to database format
if (!empty($expectedclosedate)) {
$closingdates['start'] = Vtiger_Date_UIType::getDBInsertedValue($expectedclosedate['start']);
$closingdates['end'] = Vtiger_Date_UIType::getDBInsertedValue($expectedclosedate['end']);
}
$createdTime = $request->get('createdtime');
//Date conversion from user to database format
if (!empty($createdTime)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$data = $moduleModel->getForecast($closingdates, $dates);
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
//Include special script and css needed for this widget
$viewer->assign('SCRIPTS', $this->getHeaderScripts($request));
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
$content = $request->get('content');
if (!empty($content)) {
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
} else {
$viewer->view('dashboards/Forecast.tpl', $moduleName);
}
}
示例4: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$linkId = $request->get('linkid');
$owner = $request->get('owner');
$dates = $request->get('expectedclosedate');
//Date conversion from user to database format
if (!empty($dates)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($dates['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($dates['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$data = $moduleModel->getCampaignsWidget($owner, $dates);
$listViewUrl = $moduleModel->getListViewUrl();
for ($i = 0; $i < count($data); $i++) {
$data[$i][] = $listViewUrl . $this->getSearchParams($data[$i][0], $owner, $dates);
}
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
//Include special script and css needed for this widget
$viewer->assign('STYLES', $this->getHeaderCss($request));
$viewer->assign('CURRENTUSER', $currentUser);
$content = $request->get('content');
if (!empty($content)) {
$viewer->view('dashboards/CampaignsWidget.tpl', $moduleName);
} else {
$viewer->view('dashboards/CampaignsWidget.tpl', $moduleName);
}
}
示例5: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$linkId = $request->get('linkid');
$owner = $request->get('owner');
$dates = $request->get('expectedclosedate');
//Date conversion from user to database format
if (!empty($dates)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($dates['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($dates['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$data = $moduleModel->getPotentialsCountBySalesStage($owner, $dates);
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
//Include special script and css needed for this widget
$viewer->assign('SCRIPTS', $this->getHeaderScripts($request));
$viewer->assign('STYLES', $this->getHeaderCss($request));
$viewer->assign('CURRENTUSER', $currentUser);
$content = $request->get('content');
if (!empty($content)) {
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
} else {
$viewer->view('dashboards/GroupBySalesStage.tpl', $moduleName);
}
}
示例6: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$linkId = $request->get('linkid');
$createdTime = $request->get('createdtime');
$owner = $request->get('owner');
//Date conversion from user to database format
if (!empty($createdTime)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$data = $moduleModel->getLeadsCreated($owner, $dates);
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
//Include special script and css needed for this widget
$viewer->assign('SCRIPTS', $this->getHeaderScripts($request));
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
$viewer->assign('CURRENTUSER', $currentUser);
$accessibleUsers = $currentUser->getAccessibleUsersForModule('Leads');
$viewer->assign('ACCESSIBLE_USERS', $accessibleUsers);
$content = $request->get('content');
if (!empty($content)) {
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
} else {
$viewer->view('dashboards/LeadsCreated.tpl', $moduleName);
}
}
示例7: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$linkId = $request->get('linkid');
$data = $request->get('data');
$createdTime = $request->get('createdtime');
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
if (!$request->has('owner')) {
$owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget, 'Leads');
} else {
$owner = $request->get('owner');
}
$ownerForwarded = $owner;
if ($owner == 'all') {
$owner = '';
}
//Date conversion from user to database format
if (!empty($createdTime)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$data = $owner === false ? array() : $moduleModel->getLeadsByStatusConverted($owner, $dates);
$listViewUrl = $moduleModel->getListViewUrl();
for ($i = 0; $i < count($data); $i++) {
$data[$i]["links"] = $listViewUrl . $this->getSearchParams($data[$i][2], $owner, $dates);
}
//Include special script and css needed for this widget
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
$viewer->assign('CURRENTUSER', $currentUser);
$accessibleUsers = $currentUser->getAccessibleUsersForModule('Leads');
$accessibleGroups = $currentUser->getAccessibleGroupForModule('Leads');
$viewer->assign('ACCESSIBLE_USERS', $accessibleUsers);
$viewer->assign('ACCESSIBLE_GROUPS', $accessibleGroups);
$viewer->assign('OWNER', $ownerForwarded);
$content = $request->get('content');
if (!empty($content)) {
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
} else {
$viewer->view('dashboards/LeadsByStatusConverted.tpl', $moduleName);
}
}
示例8: process
public function process(Vtiger_Request $request)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = "ITS4YouReports";
$recordId = $request->get("record");
$viewer->assign('recordid', $recordId);
$linkId = $request->get('linkid');
$data = $request->get('data');
$createdTime = $request->get('createdtime');
//Date conversion from user to database format
if (!empty($createdTime)) {
$dates['start'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['start']);
$dates['end'] = Vtiger_Date_UIType::getDBInsertedValue($createdTime['end']);
}
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$recordModel = ITS4YouReports_Record_Model::getInstanceById($recordId);
$data = $moduleModel->getReports4You($recordId, $request->get('smownerid'), $dates);
$detailViewUrl = 'index.php?module=ITS4YouReports&view=Detail&record=' . $recordId;
$viewer->assign('detailViewUrl', $detailViewUrl);
//echo "<pre>";print_r("<textarea>".$data."</textarea>");echo "</pre>";
$widget = Vtiger_Widget_Model::getInstance($linkId, $currentUser->getId());
$widget->set('title', $recordModel->getName());
//Include special script and css needed for this widget
$viewer->assign('WIDGET', $widget);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('DATA', $data);
$viewer->assign('CURRENTUSER', $currentUser);
$accessibleUsers = $currentUser->getAccessibleUsersForModule('Leads');
$viewer->assign('ACCESSIBLE_USERS', $accessibleUsers);
$viewer->assign('SETTING_EXIST', false);
$content = $request->get('content');
if (!empty($content)) {
$display_widget_header = false;
} else {
$display_widget_header = true;
}
$viewer->assign('display_widget_header', $display_widget_header);
$viewer->view('dashboards/DashBoardWidgetContents.tpl', $moduleName);
}
示例9: save
public function save(Vtiger_Request $request)
{
$fieldId = $request->get('fieldid');
$fieldInstance = Vtiger_Field_Model::getInstance($fieldId);
$fieldInstance->updateTypeofDataFromMandatory($request->get('mandatory'))->set('presence', $request->get('presence'))->set('quickcreate', $request->get('quickcreate'))->set('summaryfield', $request->get('summaryfield'))->set('masseditable', $request->get('masseditable'));
$defaultValue = $request->get('fieldDefaultValue');
if ($fieldInstance->getFieldDataType() == 'date') {
$dateInstance = new Vtiger_Date_UIType();
$defaultValue = $dateInstance->getDBInsertedValue($defaultValue);
}
if (is_array($defaultValue)) {
$defaultValue = implode(' |##| ', $defaultValue);
}
$fieldInstance->set('defaultvalue', $defaultValue);
$response = new Vtiger_Response();
try {
$fieldInstance->save();
$response->setResult(array('success' => true, 'presence' => $request->get('presence'), 'mandatory' => $fieldInstance->isMandatory(), 'label' => vtranslate($fieldInstance->get('label'), $request->get('sourceModule'))));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例10: 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;
}
示例11: 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);
}
}
示例12: save
/**
* Function to save the record
*/
public function save()
{
$mode = $this->get('mode');
$db = PearDatabase::getInstance();
if ($this->get('enabled') == "on") {
$this->set('enabled', 1);
} else {
$this->set('enabled', 0);
}
//Saving data about webform
if ($mode) {
$updateQuery = "UPDATE vtiger_webforms SET description = ?, returnurl = ?, ownerid = ?, enabled = ? WHERE id = ?";
$params = array($this->get('description'), $this->get('returnurl'), $this->get('ownerid'), $this->get('enabled'), $this->getId());
$db->pquery($updateQuery, $params);
} else {
$insertQuery = "INSERT INTO vtiger_webforms(name, targetmodule, publicid, enabled, description, ownerid, returnurl) VALUES(?, ?, ?, ?, ?, ?, ?)";
$params = array($this->getName(), $this->get('targetmodule'), $this->generatePublicId(), $this->get('enabled'), $this->get('description'), $this->get('ownerid'), $this->get('returnurl'));
$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) 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 = '';
}
}
array_push($params, $fieldName, $neutralizedField, $fieldDefaultValue, $fieldDetails['required']);
$db->pquery($fieldInsertQuery, $params);
}
}
示例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
*/
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');
//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);
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'));
$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 == 'on') {
$_REQUEST['set_reminder'] = 'Yes';
} else {
$_REQUEST['set_reminder'] = 'No';
}
$time = strtotime($request->get('due_date')) - strtotime($request->get('date_start'));
$hours = (double) $time / 3600;
$minutes = ((double) $hours - (int) $hours) * 60;
$recordModel->set('duration_hours', (int) $hours);
$recordModel->set('duration_minutes', $minutes);
return $recordModel;
}
示例14: process
//.........这里部分代码省略.........
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 {
$recordModel->set('parent_id', $parent);
}
}
$recordModel->set('visibility', 'Public');
break;
case 'HelpDesk':
$from = $mail->from();
if ($parent) {
if ($linkedto['module'] == 'Contacts') {
$referenceFieldName = 'contact_id';
} elseif ($linkedto['module'] == 'Accounts') {
$referenceFieldName = 'parent_id';
}
}
$recordModel->set($referenceFieldName, $this->setParentForHelpDesk($parent, $from));
break;
case 'ModComments':
$recordModel->set('assigned_user_id', $currentUserModel->getId());
$recordModel->set('commentcontent', $request->getRaw('commentcontent'));
示例15: 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;
}