protected function DoBeforeCreate() { $this->dataset = new TableDataset(new PgConnectionFactory(), GetConnectionOptions(), '"public"."ods_lectura"'); $field = new IntegerField('id_lectura', null, null, true); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('id_persona'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new IntegerField('id_lugar'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new IntegerField('id_origen_lectura'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new DateTimeField('fe_fecha_lectura'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new StringField('no_usuario'); $this->dataset->AddField($field, false); $field = new StringField('ds_usuario'); $this->dataset->AddField($field, false); $field = new IntegerField('co_lector'); $this->dataset->AddField($field, false); $field = new StringField('ds_observaciones'); $this->dataset->AddField($field, false); $field = new IntegerField('id_carga'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $this->dataset->AddLookupField('id_persona', 'public.ods_persona', new IntegerField('id_persona', null, null, true), new IntegerField('id_tipo_persona', 'id_persona_id_tipo_persona', 'id_persona_id_tipo_persona_public_ods_persona'), 'id_persona_id_tipo_persona_public_ods_persona'); $this->dataset->AddLookupField('id_lugar', 'public.ods_lugar', new IntegerField('id_lugar', null, null, true), new StringField('co_lugar', 'id_lugar_co_lugar', 'id_lugar_co_lugar_public_ods_lugar'), 'id_lugar_co_lugar_public_ods_lugar'); $this->dataset->AddLookupField('id_origen_lectura', 'public.ods_origen_lectura', new IntegerField('id_origen_lectura'), new StringField('co_origen_lectura', 'id_origen_lectura_co_origen_lectura', 'id_origen_lectura_co_origen_lectura_public_ods_origen_lectura'), 'id_origen_lectura_co_origen_lectura_public_ods_origen_lectura'); }
/** * Function to get Date and Time value for Display * @param <type> $date * @return <String> */ public static function getDBDateTimeValue($date) { global $log; $log->debug("Entering ./uitypes/Datetime.php::staticgetDBDateTimeValue"); $date = new DateTimeField($date); return $date->getDBInsertDateTimeValue(); }
function getRequestedToData() { $mail_data = array(); $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"]; $mail_data['subject'] = $_REQUEST['task_subject']; $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus']; $mail_data['activity_mode'] = $_REQUEST['activity_mode']; $mail_data['taskpriority'] = $_REQUEST['taskpriority']; $mail_data['relatedto'] = $_REQUEST['task_parent_name']; $mail_data['contact_name'] = $_REQUEST['task_contact_name']; $mail_data['description'] = $_REQUEST['task_description']; $mail_data['assign_type'] = $_REQUEST['task_assigntype']; $mail_data['group_name'] = getGroupName($_REQUEST['task_assigned_group_id']); $mail_data['mode'] = $_REQUEST['task_mode']; $startTime = $_REQUEST['task_time_start']; $date = new DateTimeField($_REQUEST['task_date_start'] . " " . $startTime); $endTime = $_REQUEST['task_time_end']; $endDate = new DateTimeField($_REQUEST['task_due_date'] . " " . $startTime); $startTime = $date->getDisplayTime(); $endTime = $endDate->getDisplayTime(); $value = getaddEventPopupTime($startTime, $endTime, '24'); $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt']; $mail_data['st_date_time'] = $date->getDisplayDateTimeValue(); $mail_data['end_date_time'] = $endDate->getDisplayDate(); return $mail_data; }
/** * Function to get display value for time * @param <String> time * @return <String> time */ public static function getDisplayTimeValue($time) { global $log; $log->debug("Entering ./uitypes/Time.php::staticgetDisplayTimeValue"); $date = new DateTimeField($time); return $date->getDisplayTime(); }
/** * Function to get the Audit Trail Information values of the actions performed by a particular User. * @param integer $userid - User's ID * @param $navigation_array - Array values to navigate through the number of entries. * @param $sortorder - DESC * @param $orderby - actiondate * Returns the audit trail entries in an array format. **/ function getAuditTrailEntries($userid, $navigation_array, $sorder = '', $orderby = '') { global $log; $log->debug("Entering getAuditTrailEntries(" . $userid . ") method ..."); global $adb, $current_user; if ($sorder != '' && $order_by != '') { $list_query = "Select * from vtiger_audit_trial where userid =? order by " . $order_by . " " . $sorder; } else { $list_query = "Select * from vtiger_audit_trial where userid =? order by " . $this->default_order_by . " " . $this->default_sort_order; } $result = $adb->pquery($list_query, array($userid)); $entries_list = array(); if ($navigation_array['end_val'] != 0) { for ($i = $navigation_array['start']; $i <= $navigation_array['end_val']; $i++) { $entries = array(); $userid = $adb->query_result($result, $i - 1, 'userid'); $entries[] = getTranslatedString($adb->query_result($result, $i - 1, 'module')); $entries[] = $adb->query_result($result, $i - 1, 'action'); $entries[] = $adb->query_result($result, $i - 1, 'recordid'); $date = new DateTimeField($adb->query_result($result, $i - 1, 'actiondate')); $entries[] = $date->getDBInsertDateValue(); $entries_list[] = $entries; } $log->debug("Exiting getAuditTrailEntries() method ..."); return $entries_list; } }
public function getEntity() { $db = PearDatabase::getInstance(); $module = 'Calendar'; $currentUser = Users_Record_Model::getCurrentUserModel(); $query = getListQuery($module); $params = array(); if ($this->get('start') && $this->get('end')) { $dbStartDateOject = DateTimeField::convertToDBTimeZone($this->get('start')); $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s'); $dbEndDateObject = DateTimeField::convertToDBTimeZone($this->get('end')); $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s'); $query .= " AND (concat(date_start, ' ', time_start) >= ? AND concat(due_date, ' ', time_end) <= ?) "; $params[] = $dbStartDateTime; $params[] = $dbEndDateTime; } if ($this->get('types')) { $query .= " AND vtiger_activity.activitytype IN ('" . implode("','", $this->get('types')) . "')"; } if ($this->get('user')) { if (is_array($this->get('user'))) { $query .= ' AND vtiger_crmentity.smownerid IN (' . implode(",", $this->get('user')) . ')'; } else { $query .= ' AND vtiger_crmentity.smownerid IN (' . $this->get('user') . ')'; } } $query .= ' ORDER BY date_start,time_start ASC'; $queryResult = $db->pquery($query, $params); $result = array(); for ($i = 0; $i < $db->num_rows($queryResult); $i++) { $record = $db->raw_query_result_rowdata($queryResult, $i); $item = array(); $crmid = $record['activityid']; $activitytype = $record['activitytype']; $item['id'] = $crmid; $item['title'] = $record['subject']; $item['url'] = 'index.php?module=' . $module . '&view=Detail&record=' . $crmid; $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']); $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; $startTimeFormated = $dateTimeComponents[1]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $startDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']); $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; $endTimeFormated = $dateTimeComponents[1]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $endDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['start'] = $startDateFormated . ' ' . $startTimeFormated; $item['end'] = $endDateFormated . ' ' . $endTimeFormated; $item['allDay'] = $record['allday'] == 1 ? true : false; $item['className'] = ' userCol_' . $record['smownerid'] . ' calCol_' . $activitytype; $result[] = $item; } return $result; }
protected function DoBeforeCreate() { $this->dataset = new TableDataset(new SqlSrvConnectionFactory(), GetConnectionOptions(), '[dbo].[procesosbd]'); $field = new IntegerField('Process ID'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('HostName'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('User'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('Database'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('Query'); $this->dataset->AddField($field, true); $field = new StringField('Status'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('Open Transactions'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('Command'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('ApplicatiON'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('Wait Time'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('Wait Type'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('CPU'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('Physical IO'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('Memory Usage'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new DateTimeField('Login Time'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new DateTimeField('Last Batch'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('Blocked By'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('Blocked By Query'); $this->dataset->AddField($field, true); $field = new IntegerField('Blocking'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); }
protected function DoBeforeCreate() { $selectQuery = 'SELECT task.task_name, project.project_name, timesheet.name, timesheet.date, timesheet.hours, timesheet.staff_id, pay_period.start_date, pay_period.end_date, pay_period.pay_period_number, pay_period.YEAR, staff.position, staff.emp_number FROM timesheet LEFT JOIN task ON timesheet.task_id = task.task_id LEFT JOIN project ON task.project_id = project.project_id LEFT JOIN staff ON timesheet.staff_id = staff.staff_id LEFT JOIN pay_period ON timesheet.date BETWEEN pay_period.start_date AND pay_period.end_date'; $insertQuery = array(); $updateQuery = array(); $deleteQuery = array(); $this->dataset = new QueryDataset(new MyConnectionFactory(), GetConnectionOptions(), $selectQuery, $insertQuery, $updateQuery, $deleteQuery, 'View Pay Period'); $field = new StringField('task_name'); $this->dataset->AddField($field, false); $field = new StringField('project_name'); $this->dataset->AddField($field, false); $field = new StringField('name'); $this->dataset->AddField($field, false); $field = new DateField('date'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('hours'); $this->dataset->AddField($field, true); $field = new IntegerField('staff_id'); if (!$this->GetSecurityInfo()->AdminGrant()) { $field->SetReadOnly(true, GetApplication()->GetCurrentUserId()); } $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new DateTimeField('start_date'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new DateTimeField('end_date'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('pay_period_number'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('YEAR'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('position'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new StringField('emp_number'); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); }
public function getEntity() { $db = PearDatabase::getInstance(); $module = 'Reservations'; $currentUser = Users_Record_Model::getCurrentUserModel(); $query = getListQuery($module); $params = array(); if ($this->get('start') && $this->get('end')) { $query .= ' AND vtiger_reservations.date_start >= ? AND vtiger_reservations.due_date <= ?'; $params[] = $this->get('start'); $params[] = $this->get('end'); } if ($this->get('types')) { $query .= " AND vtiger_reservations.type IN ('" . implode("','", $this->get('types')) . "')"; } if ($this->get('user')) { if (is_array($this->get('user'))) { $query .= ' AND vtiger_crmentity.smownerid IN (' . implode(",", $this->get('user')) . ')'; } else { $query .= ' AND vtiger_crmentity.smownerid IN (' . $this->get('user') . ')'; } } $instance = CRMEntity::getInstance($module); $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser); if ($securityParameter != '') { $query .= ' AND ' . $securityParameter; } $query .= ' ORDER BY date_start,time_start ASC'; $queryResult = $db->pquery($query, $params); $result = array(); for ($i = 0; $i < $db->num_rows($queryResult); $i++) { $record = $db->raw_query_result_rowdata($queryResult, $i); $item = array(); $crmid = $record['reservationsid']; $item['id'] = $crmid; $item['title'] = vtranslate($record['name'], $module); $item['url'] = 'index.php?module=Reservations&view=Detail&record=' . $crmid; $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']); $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['start'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1]; $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']); $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser); $dateTimeComponents = explode(' ', $userDateTimeString); $dateComponent = $dateTimeComponents[0]; //Conveting the date format in to Y-m-d . since full calendar expects in the same format $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format')); $item['end'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1]; $item['className'] = ' userCol_' . $record['smownerid'] . ' calCol_' . $record['type']; $result[] = $item; } return $result; }
public function getWidgetTimeControl($user, $time) { if (!$time) { return array(); } $db = PearDatabase::getInstance(); $param = array('OSSTimeControl', $user, $time['start'], $time['end']); $sql = "SELECT SUM(sum_time) AS daytime, due_date FROM vtiger_osstimecontrol\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_osstimecontrol.osstimecontrolid = vtiger_crmentity.crmid\n\t\t\t\t\tWHERE vtiger_crmentity.setype = ? AND vtiger_crmentity.smownerid = ? "; $sql .= "AND (vtiger_osstimecontrol.date_start >= ? AND vtiger_osstimecontrol.due_date <= ?) GROUP BY due_date"; $result = $db->pquery($sql, $param); $data = array(); $countDays = 0; $average = 0; for ($i = 0; $i < $db->num_rows($result); $i++) { $due_date = $db->query_result_raw($result, $i, 'due_date'); $daytime = $db->query_result_raw($result, $i, 'daytime'); $due_date = DateTimeField::convertToUserFormat($due_date); $data[] = array($daytime, $due_date); $countDays++; $average = $average + $daytime; } if ($average > 0) { $average = $average / $countDays; } return array('data' => $data, 'countDays' => $countDays, 'average' => number_format($average, 2, '.', ' ')); }
public static function assignMessages($crmid, $viewer) { $chwmfkvuq = "current_user"; $dpddjpchus = "row"; ${"GLOBALS"}["pvcpgoobkx"] = "sql"; ${"GLOBALS"}["dbjyloqr"] = "cu_model"; ${$chwmfkvuq} = ${${"GLOBALS"}["dbjyloqr"]} = \Users_Record_Model::getCurrentUserModel(); ${${"GLOBALS"}["gmbukkbbs"]} = \PearDatabase::getInstance(); $twasrbuxi = "result"; ${${"GLOBALS"}["uxfpyp"]} = "SELECT * FROM vtiger_wf_messages WHERE\n (\n (crmid = " . ${${"GLOBALS"}["podklxc"]} . " AND target = \"record\") OR\n (crmid = " . $current_user->id . " AND target = \"user\")\n )\n AND (show_until = \"0000-00-00 00:00:00\" OR show_until >= NOW())"; ${${"GLOBALS"}["ciokylfx"]} = $adb->query(${${"GLOBALS"}["pvcpgoobkx"]}); ${"GLOBALS"}["esusgmf"] = "sql"; ${${"GLOBALS"}["hbelbc"]} = array(); while (${$dpddjpchus} = $adb->fetchByAssoc(${$twasrbuxi})) { $wyoevilr = "row"; ${"GLOBALS"}["wtiuxgl"] = "messages"; ${"GLOBALS"}["txeedjxevu"] = "row"; if (${$wyoevilr}["show_until"] != "0000-00-00 00:00:00") { $ticepvccqsn = "row"; ${"GLOBALS"}["kemkeniiqmz"] = "row"; ${${"GLOBALS"}["kemkeniiqmz"]}["show_until"] = getTranslatedString("LBL_VISIBLE_UNTIL", "Workflow2") . ": " . \DateTimeField::convertToUserFormat(${$ticepvccqsn}["show_until"]); } else { ${${"GLOBALS"}["wiurqquqjut"]}["show_until"] = ""; } ${${"GLOBALS"}["wtiuxgl"]}[] = ${${"GLOBALS"}["txeedjxevu"]}; } $viewer->assign("messages", ${${"GLOBALS"}["hbelbc"]}); ${${"GLOBALS"}["esusgmf"]} = "DELETE FROM vtiger_wf_messages WHERE\n (\n (crmid = " . intval($_REQUEST["record"]) . " AND target = 'record') OR\n (crmid = " . intval($current_user->id) . " AND target = 'user')\n ) AND\n (show_once = '1' OR (show_until != '0000-00-00 00:00:00' AND show_until < NOW()))"; $adb->query(${${"GLOBALS"}["uxfpyp"]}); }
/** * Save date * @param <Object> $request * @return true if saved, false otherwise */ public function save(Vtiger_Request $request) { $response = new Vtiger_Response(); $moduleName = 'Settings:' . $request->getModule(); try { $id = $request->get('holidayId'); $date = DateTimeField::convertToDBFormat($request->get('holidayDate')); $name = $request->get('holidayName'); $type = $request->get('holidayType'); if (empty($name) || empty($date)) { $response->setResult(array('success' => false, 'message' => vtranslate('LBL_FILL_FORM_ERROR', $moduleName))); } else { if (!empty($id)) { if (Settings_PublicHoliday_Module_Model::edit($id, $date, $name, $type)) { $response->setResult(array('success' => true, 'message' => vtranslate('LBL_EDIT_DATE_OK', $moduleName))); } else { $response->setResult(array('success' => false, 'message' => vtranslate('LBL_EDIT_DATE_ERROR', $moduleName))); } } else { if (Settings_PublicHoliday_Module_Model::save($date, $name, $type)) { $response->setResult(array('success' => true, 'message' => vtranslate('LBL_NEW_DATE_OK', $moduleName))); } else { $response->setResult(array('success' => false, 'message' => vtranslate('LBL_NEW_DATE_ERROR', $moduleName))); } } } } catch (Exception $e) { $response->setError($e->getCode(), $e->getMessage()); } $response->emit(); }
function preProcess(Vtiger_Request $request) { parent::preProcess($request); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $recordId = $request->get('record'); $page = $request->get('page'); $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId); $reportModel = $detailViewModel->getRecord(); $reportModel->setModule('Reports'); $pagingModel = new Vtiger_Paging_Model(); $pagingModel->set('page', $page); $pagingModel->set('limit', self::REPORT_LIMIT); $this->reportData = $reportModel->getReportData($pagingModel); $this->calculationFields = $reportModel->getReportCalulationData(); $primaryModule = $reportModel->getPrimaryModule(); $secondaryModules = $reportModel->getSecondaryModules(); $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule); $currentUser = Users_Record_Model::getCurrentUserModel(); $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId()); $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId()); if (!$permission) { $viewer->assign('MODULE', $primaryModule); $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED'); $viewer->view('OperationNotPermitted.tpl', $primaryModule); exit; } $detailViewLinks = $detailViewModel->getDetailViewLinks(); // Advanced filter conditions $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter()); $viewer->assign('PRIMARY_MODULE', $primaryModule); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel); $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure(); $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure(); $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure); $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures); $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar'); if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('LINEITEM_FIELD_IN_CALCULATION', $reportModel->showLineItemFieldsInFilter(false)); $viewer->assign('DETAILVIEW_LINKS', $detailViewLinks); $viewer->assign('REPORT_MODEL', $reportModel); $viewer->assign('RECORD_ID', $recordId); $viewer->assign('COUNT', count($this->reportData)); $viewer->assign('MODULE', $moduleName); $viewer->view('ReportHeader.tpl', $moduleName); }
function process(Mobile_API_Request $request) { $response = new Mobile_API_Response(); $username = $request->get('username'); $password = $request->get('password'); $current_user = CRMEntity::getInstance('Users'); $current_user->column_fields['user_name'] = $username; if (vtlib_isModuleActive('Mobile') === false) { $response->setError(1501, 'Service not available'); return $response; } if (!$current_user->doLogin($password)) { $response->setError(1210, 'Authentication Failed'); } else { // Start session now $sessionid = Mobile_API_Session::init(); if ($sessionid === false) { echo "Session init failed {$sessionid}\n"; } $current_user->id = $current_user->retrieve_user_id($username); $current_user->retrieveCurrentUserInfoFromFile($current_user->id); $this->setActiveUser($current_user); $result = array(); $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'user_currency' => $current_user->currency_code, 'session' => $sessionid, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'date_format' => $current_user->date_format, 'mobile_module_version' => Mobile_WS_Utils::getVersion()); $response->setResult($result); $this->postProcess($response); } return $response; }
function content_56962c9ceece3($_smarty_tpl) { if ($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getName() == 'date_start') { $_smarty_tpl->tpl_vars['DATE_FIELD'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value, null, 0); $_smarty_tpl->tpl_vars['MODULE_MODEL'] = new Smarty_variable($_smarty_tpl->tpl_vars['RECORD_STRUCTURE_MODEL']->value->getModule(), null, 0); $_smarty_tpl->tpl_vars['TIME_FIELD'] = new Smarty_variable($_smarty_tpl->tpl_vars['MODULE_MODEL']->value->getField('time_start'), null, 0); } elseif ($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->getName() == 'due_date') { $_smarty_tpl->tpl_vars['DATE_FIELD'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value, null, 0); $_smarty_tpl->tpl_vars['MODULE_MODEL'] = new Smarty_variable($_smarty_tpl->tpl_vars['RECORD_STRUCTURE_MODEL']->value->getModule(), null, 0); $_smarty_tpl->tpl_vars['TIME_FIELD'] = new Smarty_variable($_smarty_tpl->tpl_vars['MODULE_MODEL']->value->getField('time_end'), null, 0); } $_smarty_tpl->tpl_vars['DATE_TIME_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_MODEL']->value->get('fieldvalue'), null, 0); $_smarty_tpl->tpl_vars['DATE_TIME_COMPONENTS'] = new Smarty_variable(explode(' ', $_smarty_tpl->tpl_vars['DATE_TIME_VALUE']->value), null, 0); $_smarty_tpl->tpl_vars['TIME_FIELD'] = new Smarty_variable($_smarty_tpl->tpl_vars['TIME_FIELD']->value->set('fieldvalue', $_smarty_tpl->tpl_vars['DATE_TIME_COMPONENTS']->value[1]), null, 0); $_smarty_tpl->tpl_vars['DATE_TIME_CONVERTED_VALUE'] = new Smarty_variable(DateTimeField::convertToUserTimeZone($_smarty_tpl->tpl_vars['DATE_TIME_VALUE']->value)->format('Y-m-d H:i:s'), null, 0); $_smarty_tpl->tpl_vars['DATE_TIME_COMPONENTS'] = new Smarty_variable(explode(' ', $_smarty_tpl->tpl_vars['DATE_TIME_CONVERTED_VALUE']->value), null, 0); $_smarty_tpl->tpl_vars['DATE_FIELD'] = new Smarty_variable($_smarty_tpl->tpl_vars['DATE_FIELD']->value->set('fieldvalue', $_smarty_tpl->tpl_vars['DATE_TIME_COMPONENTS']->value[0]), null, 0); ?> <div><?php echo $_smarty_tpl->getSubTemplate(vtemplate_path('uitypes/Date.tpl', $_smarty_tpl->tpl_vars['MODULE']->value), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array('BLOCK_FIELDS' => $_smarty_tpl->tpl_vars['BLOCK_FIELDS']->value, 'FIELD_MODEL' => $_smarty_tpl->tpl_vars['DATE_FIELD']->value), 0); ?> </div><div><?php echo $_smarty_tpl->getSubTemplate(vtemplate_path('uitypes/Time.tpl', $_smarty_tpl->tpl_vars['MODULE']->value), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array('BLOCK_FIELDS' => $_smarty_tpl->tpl_vars['BLOCK_FIELDS']->value, 'FIELD_MODEL' => $_smarty_tpl->tpl_vars['TIME_FIELD']->value), 0); ?> </div><?php }
public function process(Vtiger_Request $request) { $recordId = $request->get('record'); $modules = $request->get('modules'); $assignId = $request->get('assigned_user_id'); $currentUser = Users_Record_Model::getCurrentUserModel(); $entityValues = array(); $entityValues['transferRelatedRecordsTo'] = $request->get('transferModule'); //■権限なぜか、エラーになるので権限を固定するinouchi //$entityValues['assignedTo'] = vtws_getWebserviceEntityId(vtws_getOwnerType($assignId), $assignId); $entityValues['assignedTo'] = vtws_getWebserviceEntityId(vtws_getOwnerType(1), 1); $entityValues['leadId'] = vtws_getWebserviceEntityId($request->getModule(), $recordId); $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $request->getModule()); $convertLeadFields = $recordModel->getConvertLeadFields(); $availableModules = array('Accounts', 'Contacts', 'Potentials'); foreach ($availableModules as $module) { if (vtlib_isModuleActive($module) && in_array($module, $modules)) { $entityValues['entities'][$module]['create'] = true; $entityValues['entities'][$module]['name'] = $module; foreach ($convertLeadFields[$module] as $fieldModel) { $fieldName = $fieldModel->getName(); $fieldValue = $request->get($fieldName); //Potential Amount Field value converting into DB format if ($fieldModel->getFieldDataType() === 'currency') { $fieldValue = Vtiger_Currency_UIType::convertToDBFormat($fieldValue); } elseif ($fieldModel->getFieldDataType() === 'date') { $fieldValue = DateTimeField::convertToDBFormat($fieldValue); } elseif ($fieldModel->getFieldDataType() === 'reference' && $fieldValue) { $ids = vtws_getIdComponents($fieldValue); if (count($ids) === 1) { $fieldValue = vtws_getWebserviceEntityId(getSalesEntityType($fieldValue), $fieldValue); } } $entityValues['entities'][$module][$fieldName] = $fieldValue; } } } try { $result = vtws_convertlead($entityValues, $currentUser); } catch (Exception $e) { $this->showError($request, $e); exit; } if (!empty($result['Accounts'])) { $accountIdComponents = vtws_getIdComponents($result['Accounts']); $accountId = $accountIdComponents[1]; } if (!empty($result['Contacts'])) { $contactIdComponents = vtws_getIdComponents($result['Contacts']); $contactId = $contactIdComponents[1]; } if (!empty($accountId)) { header("Location: index.php?view=Detail&module=Accounts&record={$accountId}"); } elseif (!empty($contactId)) { header("Location: index.php?view=Detail&module=Contacts&record={$contactId}"); } else { $this->showError($request); exit; } }
function process(Mobile_API_Request $request) { $response = new Mobile_API_Response(); $username = $request->get('username'); $password = $request->get('password'); $current_user = CRMEntity::getInstance('Users'); $current_user->column_fields['user_name'] = $username; if (vtlib_isModuleActive('Mobile') === false) { $response->setError(1501, 'Service not available'); return $response; } if (!$current_user->load_user($password) || !$current_user->authenticated) { global $mod_strings; $response->setError(1210, $mod_strings['ERR_INVALID_PASSWORD']); } else { // Start session now $sessionid = Mobile_API_Session::init(); if ($sessionid === false) { echo "Session init failed {$sessionid}\n"; } include_once 'config.php'; global $application_unique_key; $current_user->id = $current_user->retrieve_user_id($username); $this->setActiveUser($current_user); $_SESSION["authenticated_user_id"] = $current_user->id; $_SESSION["app_unique_key"] = $application_unique_key; $result = array(); $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'session' => $sessionid, 'language' => $current_user->language, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'mobile_module_version' => Mobile_WS_Utils::getVersion()); $response->setResult($result); $this->postProcess($response); } return $response; }
public function process($module, $id, Vtiger_PDF_Model $pdf) { $db = PearDatabase::getInstance(); $query = 'SELECT `createdtime` FROM `vtiger_crmentity` WHERE `crmid` = ? LIMIT 1;'; $result = $db->pquery($query, [$id]); $createdTime = $db->getSingleValue($result); return DateTimeField::convertToUserFormat($createdTime); }
/** * Function to get the calendar event call duration value in hour format * @param type $fieldName * @param type $value * @return <Vtiger_Time_UIType> - getTimeValue */ public function getDisplayTimeDifferenceValue($fieldName, $value) { $userModel = Users_Privileges_Model::getCurrentUserModel(); $date = new DateTime($value); //No need to set the time zone as DateTimeField::getDisplayTime API is already doing this /*if(empty($value)) { $timeZone = $userModel->get('time_zone'); $targetTimeZone = new DateTimeZone($timeZone); $date->setTimezone($targetTimeZone); }*/ if ($fieldName == 'time_end' && empty($value)) { $date->modify("+15 minutes"); } $dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s')); $value = $dateTimeField->getDisplayTime(); return $value; }
function vtSaveTask($adb, $request) { $util = new VTWorkflowUtils(); $module = new VTWorkflowApplication("savetask"); $mod = return_module_language($current_language, $module->name); if (!$util->checkAdminAccess()) { $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']); $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']); return; } $tm = new VTTaskManager($adb); if (isset($request["task_id"])) { $task = $tm->retrieveTask($request["task_id"]); } else { $taskType = vtlib_purifyForSql($request["task_type"]); $workflowId = $request["workflow_id"]; $task = $tm->createTask($taskType, $workflowId); } $task->summary = $request["summary"]; if ($request["active"] == "true") { $task->active = true; } else { if ($request["active"] == "false") { $task->active = false; } } if (isset($request['check_select_date'])) { $trigger = array('days' => ($request['select_date_direction'] == 'after' ? 1 : -1) * (int) $request['select_date_days'], 'field' => $request['select_date_field']); $task->trigger = $trigger; } else { $task->trigger = null; } $fieldNames = $task->getFieldNames(); foreach ($fieldNames as $fieldName) { $task->{$fieldName} = $request[$fieldName]; if ($fieldName == 'calendar_repeat_limit_date') { $task->{$fieldName} = DateTimeField::convertToDBFormat($request[$fieldName]); } } $tm->saveTask($task); if (isset(vtlib_purify($request["return_url"]))) { $returnUrl = vtlib_purify($request["return_url"]); } else { $returnUrl = $module->editTaskUrl($task->id); } ?> <script type="text/javascript" charset="utf-8"> window.location="<?php echo $returnUrl; ?> "; </script> <a href="<?php echo $returnUrl; ?> ">Return</a> <?php }
function preProcess(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $recordId = $request->get('record'); $this->record = $detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId); parent::preProcess($request); $reportModel = $detailViewModel->getRecord(); $reportModel->setModule('Reports'); $primaryModule = $reportModel->getPrimaryModule(); $secondaryModules = $reportModel->getSecondaryModules(); $primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule); $currentUser = Users_Record_Model::getCurrentUserModel(); $userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId()); $permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId()); if (!$permission) { $viewer->assign('MODULE', $primaryModule); $viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED'); $viewer->view('OperationNotPermitted.tpl', $primaryModule); exit; } $isAdmin = $currentUser->isAdminUser(); $viewer->assign('isAdmin', $isAdmin); // Advanced filter conditions $viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter()); $viewer->assign('PRIMARY_MODULE', $primaryModule); $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel); $primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure(); $secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure(); $viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure); $viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures); $secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar'); if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) { $advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType(); } else { $advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType(); } $viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $moduleName); $dateFilters[$comparatorKey] = $comparatorInfo; } $reportChartModel = Reports_Chart_Model::getInstanceById($reportModel); $viewer->assign('PRIMARY_MODULE_FIELDS', $reportModel->getPrimaryModuleFieldsForAdvancedReporting()); $viewer->assign('SECONDARY_MODULE_FIELDS', $reportModel->getSecondaryModuleFieldsForAdvancedReporting()); $viewer->assign('CALCULATION_FIELDS', $reportModel->getModuleCalculationFieldsForReport()); $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('REPORT_MODEL', $reportModel); $viewer->assign('RECORD', $recordId); $viewer->assign('MODULE', $moduleName); $viewer->assign('CHART_MODEL', $reportChartModel); $viewer->view('ChartReportHeader.tpl', $moduleName); }
protected function DoBeforeCreate() { $this->dataset = new TableDataset(new MyConnectionFactory(), GetConnectionOptions(), '`pay_period`'); $field = new IntegerField('pay_period_id', null, null, true); $field->SetIsNotNull(true); $this->dataset->AddField($field, true); $field = new IntegerField('year'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new IntegerField('pay_period_number'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new DateTimeField('start_date'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); $field = new DateTimeField('end_date'); $field->SetIsNotNull(true); $this->dataset->AddField($field, false); }
/** * Function to save the Scheduled Reports data */ public function saveScheduleReport() { $adb = PearDatabase::getInstance(); $reportid = $this->get('reportid'); $scheduleid = $this->get('scheduleid'); $schtime = $this->get('schtime'); if(!preg_match('/^[0-2]\d(:[0-5]\d){1,2}$/', $schtime) or substr($schtime,0,2)>23) { // invalid time format $schtime='00:00'; } $schtime .=':00'; $schdate = null; $schdayoftheweek = null; $schdayofthemonth = null; $schannualdates = null; if ($scheduleid == self::$SCHEDULED_ON_SPECIFIC_DATE) { $date = $this->get('schdate'); $dateDBFormat = DateTimeField::convertToDBFormat($date); $nextTriggerTime = $dateDBFormat.' '.$schtime; $currentTime = Vtiger_Util_Helper::getActiveAdminCurrentDateTime(); if($nextTriggerTime > $currentTime) { $this->set('next_trigger_time', $nextTriggerTime); } else { $this->set('next_trigger_time', date('Y-m-d H:i:s', strtotime('+10 year'))); } $schdate = Zend_Json::encode(array($dateDBFormat)); } else if ($scheduleid == self::$SCHEDULED_WEEKLY) { $schdayoftheweek = Zend_Json::encode($this->get('schdayoftheweek')); $this->set('schdayoftheweek', $schdayoftheweek); } else if ($scheduleid == self::$SCHEDULED_MONTHLY_BY_DATE) { $schdayofthemonth = Zend_Json::encode($this->get('schdayofthemonth')); $this->set('schdayofthemonth', $schdayofthemonth); } else if ($scheduleid == self::$SCHEDULED_ANNUALLY) { $schannualdates = Zend_Json::encode($this->get('schannualdates')); $this->set('schannualdates', $schannualdates); } $recipients = Zend_Json::encode($this->get('recipients')); $specificemails = Zend_Json::encode($this->get('specificemails')); $isReportScheduled = $this->get('isReportScheduled'); if($scheduleid != self::$SCHEDULED_ON_SPECIFIC_DATE) { $nextTriggerTime = $this->getNextTriggerTime(); } if ($isReportScheduled == '0' || $isReportScheduled == '' || $isReportScheduled == false) { $deleteScheduledReportSql = "DELETE FROM vtiger_schedulereports WHERE reportid=?"; $adb->pquery($deleteScheduledReportSql, array($reportid)); } else { $checkScheduledResult = $adb->pquery('SELECT 1 FROM vtiger_schedulereports WHERE reportid=?', array($reportid)); if ($adb->num_rows($checkScheduledResult) > 0) { $scheduledReportSql = 'UPDATE vtiger_schedulereports SET scheduleid=?, recipients=?, schdate=?, schtime=?, schdayoftheweek=?, schdayofthemonth=?, schannualdates=?, specificemails=?, next_trigger_time=? WHERE reportid=?'; $adb->pquery($scheduledReportSql, array($scheduleid, $recipients, $schdate, $schtime, $schdayoftheweek, $schdayofthemonth, $schannualdates, $specificemails, $nextTriggerTime, $reportid)); } else { $scheduleReportSql = 'INSERT INTO vtiger_schedulereports (reportid,scheduleid,recipients,schdate,schtime,schdayoftheweek,schdayofthemonth,schannualdates,next_trigger_time,specificemails) VALUES (?,?,?,?,?,?,?,?,?,?)'; $adb->pquery($scheduleReportSql, array($reportid, $scheduleid, $recipients, $schdate, $schtime, $schdayoftheweek, $schdayofthemonth, $schannualdates, $nextTriggerTime, $specificemails)); } } }
public static function getDateFilter($moduleName) { $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $moduleName); $dateFilters[$comparatorKey] = $comparatorInfo; } return $dateFilters; }
public function process($ModuleName, $ID, $record_form, $config) { $projectmilestoneid = $record_form['projectmilestoneid']; if (!isset($projectmilestoneid) || $projectmilestoneid == 0 || $projectmilestoneid == '') { return array('save_record' => true); } $moduleModel = Vtiger_Record_Model::getInstanceById($projectmilestoneid, 'ProjectMilestone'); $projectMilestoneDate = $moduleModel->get('projectmilestonedate'); if (!isset($projectMilestoneDate) || $projectMilestoneDate == 0 || $projectMilestoneDate == '') { return array('save_record' => true); } $dateField = new DateTimeField($projectMilestoneDate); $projectMilestoneDateUserFormat = $dateField->convertToUserFormat($projectMilestoneDate); $dateField = new DateTimeField($record_form['targetenddate']); $targetEndDateUserFormat = $dateField->convertToDBFormat($record_form['targetenddate']); if (strtotime($targetEndDateUserFormat) > strtotime($projectMilestoneDate)) { return array('save_record' => false, 'type' => 0, 'info' => array('text' => vtranslate('Date can not be greater', 'DataAccess') . ' ( ' . $record_form['targetenddate'] . ' < ' . $projectMilestoneDateUserFormat . ')', 'type' => 'error')); } else { return array('save_record' => true); } }
/** * @param $value * @param $name * @param $type * @param \Workflow\VTEntity $context * @return \type */ public function getValue($value, $name, $type, $context) { if ($type == 'date') { $value = \DateTimeField::convertToDBFormat($value); } if ($type == 'file') { // var_dump($value, $name, $type, $_FILES, $this); $context->addTempFile($_FILES['fileUpload']['tmp_name'][$name], $value, $_FILES['fileUpload']['name'][$name]); return '1'; } return $value; }
/** * Function to get the calendar event call duration value in hour format * @param type $fieldName * @param type $value * @return <Vtiger_Time_UIType> - getTimeValue */ public function getDisplayTimeDifferenceValue($fieldName, $value) { $userModel = Users_Privileges_Model::getCurrentUserModel(); $date = new DateTime($value); //No need to set the time zone as DateTimeField::getDisplayTime API is already doing this /*if(empty($value)) { $timeZone = $userModel->get('time_zone'); $targetTimeZone = new DateTimeZone($timeZone); $date->setTimezone($targetTimeZone); }*/ if ($fieldName == 'time_end' && empty($value)) { $defaultCallDuration = $userModel->get('callduration'); $date->modify("+{$defaultCallDuration} minutes"); } $dateTimeField = new DateTimeField($date->format('Y-m-d H:i:s')); $value = $dateTimeField->getDisplayTime(); if ($userModel->get('hour_format') == '12') { return Vtiger_Time_UIType::getTimeValueInAMorPM($value); } return $value; }
public function beforeSave(&$values) { global $adb, $vtiger_current_version; if (version_compare($vtiger_current_version, '5.3.0', '>=')) { foreach ($values["setter"] as $key => $field) { // I have to respect Users timezone if (strpos($field["value"], "\$") === false && ($field["field"] == "time_start" || $field["field"] == "time_end")) { $date = DateTimeField::convertToDBTimeZone(date("Y-m-d") . " " . $field["value"]); $values["setter"][$key]["value"] = date("H:i", $date->format('U')); } } } }
function track_email($user_name, $password, $contact_ids, $date_sent, $email_subject, $email_body) { if (authentication($user_name, $password)) { global $current_user; global $adb; global $log; require_once 'modules/Users/Users.php'; require_once 'modules/Emails/Emails.php'; $current_user = new Users(); $user_id = $current_user->retrieve_user_id($user_name); $query = "select email1 from vtiger_users where id =?"; $result = $adb->pquery($query, array($user_id)); $user_emailid = $adb->query_result($result, 0, "email1"); $current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id); $email = new Emails(); //$log->debug($msgdtls['contactid']); $emailbody = str_replace("'", "''", $email_body); $emailsubject = str_replace("'", "''", $email_subject); $datesent = substr($date_sent, 1, 10); $mydate = date('Y-m-d', $datesent); $mydate = DateTimeField::convertToDBFormat($mydate); $email->column_fields[subject] = $emailsubject; $email->column_fields[assigned_user_id] = $user_id; $email->column_fields[date_start] = $mydate; $email->column_fields[description] = $emailbody; $email->column_fields[activitytype] = 'Emails'; $email->plugin_save = true; $email->save("Emails"); $query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4 and vtiger_field.presence in (0,2)"; $result = $adb->pquery($query, array()); $field_id = $adb->query_result($result, 0, "fieldid"); $email->set_emails_contact_invitee_relationship($email->id, $contact_ids); $email->set_emails_se_invitee_relationship($email->id, $contact_ids); $email->set_emails_user_invitee_relationship($email->id, $user_id); $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid=?"; $result = $adb->pquery($sql, array($contact_ids)); $camodulerow = $adb->fetch_array($result); if (isset($camodulerow)) { $emailid = $camodulerow["email"]; //added to save < as $lt; and > as > in the database so as to retrive the emailID $user_emailid = str_replace('<', '<', $user_emailid); $user_emailid = str_replace('>', '>', $user_emailid); $query = 'insert into vtiger_emaildetails values (?,?,?,?,?,?,?,?)'; $params = array($email->id, $emailid, $user_emailid, "", "", "", $user_id . '@-1|' . $contact_ids . '@' . $field_id . '|', "THUNDERBIRD"); $adb->pquery($query, $params); } return $email->id; } }
/** * Function to get Edit view display value * @param <String> Data base value * @return <String> value */ public function getEditViewDisplayValue($value) { $fieldName = $this->getName(); //Set the start date and end date if (empty($value)) { if ($fieldName === 'date_start') { return DateTimeField::convertToUserFormat(date('Y-m-d')); } elseif ($fieldName === 'due_date') { //$currentUser = Users_Record_Model::getCurrentUserModel(); $minutes = 15; return DateTimeField::convertToUserFormat(date('Y-m-d', strtotime("+{$minutes} minutes"))); } } return parent::getEditViewDisplayValue($value); }