本文整理汇总了PHP中DateTimeField::getDBTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeField::getDBTimeZone方法的具体用法?PHP DateTimeField::getDBTimeZone怎么用?PHP DateTimeField::getDBTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeField
的用法示例。
在下文中一共展示了DateTimeField::getDBTimeZone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
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;
}
示例2: process
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;
}
示例3: saveentity
/** Function to save the user information into the database
* @param $module -- module name:: Type varchar
*/
function saveentity($module, $fileid = '')
{
global $current_user;
//$adb added by raju for mass mailing
$insertion_mode = $this->mode;
if (empty($this->column_fields['time_zone'])) {
$dbDefaultTimeZone = DateTimeField::getDBTimeZone();
$this->column_fields['time_zone'] = $dbDefaultTimeZone;
$this->time_zone = $dbDefaultTimeZone;
}
if (empty($this->column_fields['currency_id'])) {
$this->column_fields['currency_id'] = CurrencyField::getDBCurrencyId();
}
if (empty($this->column_fields['date_format'])) {
$this->column_fields['date_format'] = 'yyyy-mm-dd';
}
$this->db->println("TRANS saveentity starts {$module}");
$this->db->startTransaction();
foreach ($this->tab_name as $table_name) {
if ($table_name == 'vtiger_attachments') {
$this->insertIntoAttachment($this->id, $module, $fileid);
} else {
$this->insertIntoEntityTable($table_name, $module, $fileid);
}
}
require_once 'modules/Users/CreateUserPrivilegeFile.php';
createUserPrivilegesfile($this->id);
unset($_SESSION['next_reminder_interval']);
unset($_SESSION['next_reminder_time']);
if ($insertion_mode != 'edit') {
$this->createAccessKey();
}
$this->db->completeTransaction();
$this->db->println("TRANS saveentity ends");
}
示例4: saveentity
/** Function to save the user information into the database
* @param $module -- module name:: Type varchar
*
*/
function saveentity($module) {
global $current_user;//$adb added by raju for mass mailing
$insertion_mode = $this->mode;
if(empty($this->column_fields['time_zone'])) {
$dbDefaultTimeZone = DateTimeField::getDBTimeZone();
$this->column_fields['time_zone'] = $dbDefaultTimeZone;
$this->time_zone = $dbDefaultTimeZone;
}
if(empty($this->column_fields['currency_id'])) {
$this->column_fields['currency_id'] = CurrencyField::getDBCurrencyId();
}
if(empty($this->column_fields['date_format'])) {
$this->column_fields['date_format'] = 'yyyy-mm-dd';
}
if(empty($this->column_fields['start_hour'])) {
$this->column_fields['start_hour'] = '09:00';
}
if(empty($this->column_fields['dayoftheweek'])) {
//SalesPlatform.ru begin
$this->column_fields['dayoftheweek'] = 'Monday';
/*vtiger commented code
$this->column_fields['dayoftheweek'] = 'Sunday';
*/
//SalesPlatform.ru end
}
if(empty($this->column_fields['callduration'])) {
$this->column_fields['callduration'] = 5;
}
if(empty($this->column_fields['othereventduration'])) {
$this->column_fields['othereventduration'] = 5;
}
if(empty($this->column_fields['hour_format'])) {
$this->column_fields['hour_format'] = 12;
}
if(empty($this->column_fields['activity_view'])) {
$this->column_fields['activity_view'] = 'Today';
}
if(empty($this->column_fields['calendarsharedtype'])) {
$this->column_fields['calendarsharedtype'] = 'public';
}
if(empty($this->column_fields['default_record_view'])) {
$this->column_fields['default_record_view'] = 'Summary';
}
if(empty($this->column_fields['status'])) {
$this->column_fields['status'] = 'Active';
}
if(empty($this->column_fields['currency_decimal_separator'])) {
//SalesPlatform.ru begin
$this->column_fields['currency_decimal_separator'] = ",";
/*vtiger commented code
$this->column_fields['currency_decimal_separator'] = '.';
*/
//SalesPlatform.ru end
}
//SalesPlatform.ru begin
if(empty($this->column_fields["currency_grouping_pattern"])) {
$this->column_fields["currency_grouping_pattern"] = '123456789';
}
//SalesPlatform.ru end
if(empty($this->column_fields['currency_grouping_separator'])) {
//SalesPlatform.ru begin
$this->column_fields['currency_grouping_separator'] = '\'';
//$this->column_fields['currency_grouping_separator'] = ',';
//SalesPlatform.ru end
}
$this->db->println("TRANS saveentity starts $module");
$this->db->startTransaction();
foreach($this->tab_name as $table_name) {
if($table_name == 'vtiger_attachments') {
$this->insertIntoAttachment($this->id,$module);
}
else {
$this->insertIntoEntityTable($table_name, $module);
}
}
require_once('modules/Users/CreateUserPrivilegeFile.php');
createUserPrivilegesfile($this->id);
unset($_SESSION['next_reminder_interval']);
unset($_SESSION['next_reminder_time']);
if($insertion_mode != 'edit') {
$this->createAccessKey();
}
$this->db->completeTransaction();
//.........这里部分代码省略.........
示例5: fromUserRequest
public static function fromUserRequest($requestArray)
{
// All the information from the user is received in User Time zone
// Convert Start date and Time to DB Time zone
$startDateObj = DateTimeField::convertToDBTimeZone($requestArray["startdate"] . ' ' . $requestArray['starttime']);
$requestArray['startdate'] = $startDate = $startDateObj->format('Y-m-d');
$requestArray['starttime'] = $startTime = $startDateObj->format('H:i');
$endDateObj = DateTimeField::convertToDBTimeZone($requestArray["enddate"] . ' ' . $requestArray['endtime']);
$requestArray['enddate'] = $endDate = $endDateObj->format('Y-m-d');
$requestArray['endtime'] = $endTime = $endDateObj->format('H:i');
if (!empty($requestArray["recurringenddate"])) {
$reccurringDateObj = DateTimeField::convertToDBTimeZone($requestArray["recurringenddate"] . ' ' . $requestArray['endtime']);
$requestArray['recurringenddate'] = $reccurringDateObj->format('Y-m-d');
}
if ($requestArray['sun_flag']) {
$requestArray['dayofweek_to_repeat'][] = 0;
}
if ($requestArray['mon_flag']) {
$requestArray['dayofweek_to_repeat'][] = 1;
}
if ($requestArray['tue_flag']) {
$requestArray['dayofweek_to_repeat'][] = 2;
}
if ($requestArray['wed_flag']) {
$requestArray['dayofweek_to_repeat'][] = 3;
}
if ($requestArray['thu_flag']) {
$requestArray['dayofweek_to_repeat'][] = 4;
}
if ($requestArray['fri_flag']) {
$requestArray['dayofweek_to_repeat'][] = 5;
}
if ($requestArray['sat_flag']) {
$requestArray['dayofweek_to_repeat'][] = 6;
}
if ($requestArray['type'] == 'Weekly') {
if ($requestArray['dayofweek_to_repeat'] != null) {
$userStartDateTime = DateTimeField::convertToUserTimeZone($startDate . ' ' . $startTime);
$dayOfWeek = $requestArray['dayofweek_to_repeat'];
$dbDaysOfWeek = array();
for ($i = 0; $i < count($dayOfWeek); ++$i) {
$selectedDayOfWeek = $dayOfWeek[$i];
$currentDayOfWeek = $userStartDateTime->format('w');
$newDate = $userStartDateTime->format('d') + ($selectedDayOfWeek - $currentDayOfWeek);
$userStartDateTime->setDate($userStartDateTime->format('Y'), $userStartDateTime->format('m'), $newDate);
$dbDaysOfWeek[] = $userStartDateTime->format('w');
}
$requestArray['dayofweek_to_repeat'] = $dbDaysOfWeek;
}
} elseif ($requestArray['type'] == 'Monthly') {
$userStartDateTime = DateTimeField::convertToUserTimeZone($startDate . ' ' . $startTime);
if ($requestArray['repeatmonth_type'] == 'date') {
$dayOfMonth = $requestArray['repeatmonth_date'];
$userStartDateTime->setDate($userStartDateTime->format('Y'), $userStartDateTime->format('m'), $dayOfMonth);
$userStartDateTime->setTimezone(new DateTimeZone(DateTimeField::getDBTimeZone()));
$requestArray['repeatmonth_date'] = $userStartDateTime->format('d');
} else {
$dayOfWeek = $requestArray['dayofweek_to_repeat'][0];
if ($requestArray['repeatmonth_daytype'] == 'first') {
$userStartDateTime->setDate($userStartDateTime->format('Y'), $userStartDateTime->format('m'), 1);
$dayOfWeekForFirstDay = $userStartDateTime->format('N');
if ($dayOfWeekForFirstDay < $dayOfWeek) {
$date = $dayOfWeek - $dayOfWeekForFirstDay + 1;
} else {
$date = 7 - $dayOfWeekForFirstDay + $dayOfWeek + 1;
}
} elseif ($requestArray['repeatmonth_daytype'] == 'last') {
$daysInMonth = $userStartDateTime->format('t');
$userStartDateTime->setDate($userStartDateTime->format('Y'), $userStartDateTime->format('m'), $daysInMonth);
$dayOfWeekForLastDay = $userStartDateTime->format('N');
if ($dayOfWeekForLastDay < $dayOfWeek) {
$date = $daysInMonth - 7 + ($dayOfWeek - $dayOfWeekForLastDay);
} else {
$date = $daysInMonth - ($dayOfWeekForLastDay - $dayOfWeek);
}
}
$userStartDateTime->setDate($userStartDateTime->format('Y'), $userStartDateTime->format('m'), $date);
$userStartDateTime->setTimezone(new DateTimeZone(DateTimeField::getDBTimeZone()));
$requestArray['dayofweek_to_repeat'][0] = (int) $userStartDateTime->format('N') % 7;
}
}
return new RecurringType($requestArray);
}
示例6: saveentity
/** Function to save the user information into the database
* @param $module -- module name:: Type varchar
*
*/
function saveentity($module)
{
global $current_user;
//$adb added by raju for mass mailing
$insertion_mode = $this->mode;
if (empty($this->column_fields['time_zone'])) {
$dbDefaultTimeZone = DateTimeField::getDBTimeZone();
$this->column_fields['time_zone'] = $dbDefaultTimeZone;
$this->time_zone = $dbDefaultTimeZone;
}
if (empty($this->column_fields['currency_id'])) {
$this->column_fields['currency_id'] = CurrencyField::getDBCurrencyId();
}
if (empty($this->column_fields['date_format'])) {
$this->column_fields['date_format'] = 'yyyy-mm-dd';
}
if (empty($this->column_fields['start_hour'])) {
$this->column_fields['start_hour'] = '08:00';
}
if (empty($this->column_fields['dayoftheweek'])) {
$this->column_fields['dayoftheweek'] = 'Monday';
}
if (empty($this->column_fields['callduration'])) {
$this->column_fields['callduration'] = 5;
}
if (empty($this->column_fields['othereventduration'])) {
$this->column_fields['othereventduration'] = 5;
}
if (empty($this->column_fields['hour_format'])) {
$this->column_fields['hour_format'] = 24;
}
if (empty($this->column_fields['activity_view'])) {
$this->column_fields['activity_view'] = 'This Month';
}
if (empty($this->column_fields['calendarsharedtype'])) {
$this->column_fields['calendarsharedtype'] = 'public';
}
if (empty($this->column_fields['default_record_view'])) {
$this->column_fields['default_record_view'] = 'Summary';
}
if (empty($this->column_fields['status'])) {
$this->column_fields['status'] = 'Active';
}
if (empty($this->column_fields['currency_decimal_separator']) && $this->column_fields['currency_decimal_separator'] != ' ') {
$this->column_fields['currency_decimal_separator'] = '.';
}
if (empty($this->column_fields['currency_grouping_separator']) && $this->column_fields['currency_grouping_separator'] != ' ') {
$this->column_fields['currency_grouping_separator'] = ' ';
}
$this->db->println("TRANS saveentity starts {$module}");
$this->db->startTransaction();
foreach ($this->tab_name as $table_name) {
if ($table_name == 'vtiger_attachments') {
$this->insertIntoAttachment($this->id, $module);
} else {
$this->insertIntoEntityTable($table_name, $module);
}
}
if (Settings_Roles_Record_Model::getInstanceById($this->column_fields['roleid']) == null) {
$roleid = Settings_Roles_Record_Model::getInstanceByName($this->column_fields['roleid']);
if ($roleid) {
$this->column_fields['roleid'] = $roleid->getId();
} else {
$roles = Settings_Roles_Record_Model::getAll();
$this->column_fields['roleid'] = key($roles);
}
}
require_once 'modules/Users/CreateUserPrivilegeFile.php';
createUserPrivilegesfile($this->id);
unset($_SESSION['next_reminder_interval']);
unset($_SESSION['next_reminder_time']);
if ($insertion_mode != 'edit') {
$this->createAccessKey();
}
$this->db->completeTransaction();
$this->db->println("TRANS saveentity ends");
}
示例7: getEndDate
/**
* return End date in UTC of Google Record
* @return <date> end date
*/
function getEndDate($user = false)
{
if (isset($this->endUTC)) {
return $this->endUTC;
}
if (!$user) {
$user = Users_Record_Model::getCurrentUserModel();
}
$when = $this->data['entity']->getEnd();
if (empty($when)) {
$gEnd = date('Y-m-d');
} else {
if ($when->getDateTime()) {
$gEnd = $when->getDateTime();
} else {
if ($when->getDate()) {
$gEnd = $when->getDate();
} else {
$gEnd = date('Y-m-d');
}
}
}
$end = new DateTime($gEnd);
$timeZone = new DateTimeZone('UTC');
$end->setTimezone($timeZone);
$endDate = $end->format('Y-m-d');
$gDateTime = $when->getDateTime();
if ($end->format('H:i:s') == '00:00:00' && empty($gDateTime)) {
$userTimezone = $user->get('time_zone');
$endUTCObj = DateTimeField::convertTimeZone($endDate, $userTimezone, DateTimeField::getDBTimeZone());
$endDate = $endUTCObj->format('Y-m-d');
}
$this->endDate = $endDate;
return $endDate;
}
示例8: sendEmail
public function sendEmail()
{
$currentModule = vglobal('currentModule');
require_once 'vtlib/Vtiger/Mailer.php';
$vtigerMailer = new Vtiger_Mailer();
$recipientEmails = $this->getRecipientEmails();
foreach ($recipientEmails as $name => $email) {
$vtigerMailer->AddAddress($email, $name);
}
$currentTime = date('Y-m-d H:i:s');
$subject = $this->reportname . ' - ' . $currentTime . ' (' . DateTimeField::getDBTimeZone() . ')';
$contents = getTranslatedString('LBL_AUTO_GENERATED_REPORT_EMAIL', $currentModule) . '<br/><br/>';
$contents .= '<b>' . getTranslatedString('LBL_REPORT_NAME', $currentModule) . ' :</b> ' . $this->reportname . '<br/>';
$contents .= '<b>' . getTranslatedString('LBL_DESCRIPTION', $currentModule) . ' :</b><br/>' . $this->reportdescription . '<br/><br/>';
$vtigerMailer->Subject = $subject;
$vtigerMailer->Body = $contents;
$vtigerMailer->ContentType = "text/html";
$baseFileName = preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $this->reportname) . '__' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $currentTime);
$oReportRun = ReportRun::getInstance($this->id);
$reportFormat = $this->scheduledFormat;
$attachments = array();
if ($reportFormat == 'pdf' || $reportFormat == 'both') {
$fileName = $baseFileName . '.pdf';
$filePath = 'storage/' . $fileName;
$attachments[$fileName] = $filePath;
$pdf = $oReportRun->getReportPDF();
$pdf->Output($filePath, 'F');
}
if ($reportFormat == 'excel' || $reportFormat == 'both') {
$fileName = $baseFileName . '.xls';
$filePath = 'storage/' . $fileName;
$attachments[$fileName] = $filePath;
$oReportRun->writeReportToExcelFile($filePath);
}
foreach ($attachments as $attachmentName => $path) {
$vtigerMailer->AddAttachment($path, $attachmentName);
}
$vtigerMailer->Send(true);
foreach ($attachments as $attachmentName => $path) {
unlink($path);
}
}
示例9: sendEmail
public function sendEmail($ownerUser = "")
{
require_once 'vtlib/Vtiger/Mailer.php';
//error_reporting(63);ini_set('display_errors', 1);
$vtigerMailer = new Vtiger_Mailer();
$currentModule = 'ITS4YouReports';
$recipientEmails = $this->getRecipientEmails();
//$recipientEmails = array("olear@its4you.sk");
foreach ($recipientEmails as $name => $email) {
$vtigerMailer->AddAddress($email, $name);
}
$ITS4YouReports = new ITS4YouReports(true, $this->id);
$default_charset = vglobal('default_charset');
if (!isset($default_charset)) {
$default_charset = "UTF-8";
}
$ITS4YouReports_reportname = $this->generate_cool_url($ITS4YouReports->reportname);
$ITS4YouReports_reportdesc = $this->generate_cool_url($ITS4YouReports->reportdesc);
$currentTime = date('Y-m-d H:i:s');
$user_id = $ownerUser->id;
$report_filename = "Reports4You_{$user_id}" . "_" . $this->id;
$subject = $ITS4YouReports_reportname . ' - ' . $currentTime . ' (' . DateTimeField::getDBTimeZone() . ')';
$contents = getTranslatedString('LBL_AUTO_GENERATED_REPORT_EMAIL', $currentModule) . '<br/><br/>';
$contents .= '<b>' . getTranslatedString('LBL_REPORT_NAME', $currentModule) . ' :</b> ' . $ITS4YouReports_reportname . '<br/>';
$contents .= '<b>' . getTranslatedString('LBL_DESCRIPTION', $currentModule) . ' :</b><br/>' . $ITS4YouReports_reportdesc . '<br/><br/>';
//$vtigerMailer->Subject = "=?ISO-8859-15?Q?".imap_8bit($subject)."?=";
$vtigerMailer->Subject = html_entity_decode($ITS4YouReports->reportname, ENT_QUOTES, "UTF-8");
$vtigerMailer->Body = $contents;
$vtigerMailer->ContentType = "text/html";
$generate = new GenerateObj($ITS4YouReports);
$currentModule = 'ITS4YouReports';
$generate->setCurrentModule4You($currentModule);
$current_language = $ReportOwnerUser->language;
$generate->setCurrentLanguage4You($current_language);
$reportFormat = $this->scheduledFormat;
//$reportFormat = "pdf;xls";
$reportFormat = explode(";", $reportFormat);
$tmpDir = "test/ITS4YouReports/";
$attachments = array();
if (in_array('pdf', $reportFormat)) {
$generate->create_pdf_schedule = true;
$report_html = $generate->generateReport($this->id, "HTML", false);
$generate_pdf_filename = $tmpDir . $generate->pdf_filename;
$fileName = $rootDirectory . $tempFileName . $generate->pdf_filename . '.xls';
if ($generate_pdf_filename != "" && file_exists($generate_pdf_filename)) {
$fileName_arr = explode(".", $generate->pdf_filename);
$fileName_arr[0] .= '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $currentTime);
$fileName = implode(".", $fileName_arr);
$attachments[$fileName] = $generate_pdf_filename;
}
}
if (in_array('xls', $reportFormat)) {
$report_data = $generate->generateReport($this->id, "XLS", false);
$ITS4YouReports_xls = "Reports4You_1_" . $this->id . ".xls";
$fileName_arr = explode(".", $ITS4YouReports_xls);
$fileName_arr[0] .= '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $currentTime);
$fileName = implode(".", $fileName_arr);
$fileName_path = $tmpDir . $ITS4YouReports_xls;
$generate->writeReportToExcelFile($fileName_path, $report_data);
$attachments[$fileName] = $fileName_path;
}
foreach ($attachments as $attachmentName => $path) {
$vtigerMailer->AddAttachment($path, "=?ISO-8859-15?Q?" . imap_8bit(html_entity_decode($attachmentName, ENT_QUOTES, "UTF-8")) . "?=");
}
//exit;
$send_result = $vtigerMailer->Send(true);
echo "SEND RESULT -> " . $send_result . "<br />";
foreach ($attachments as $attachmentName => $path) {
unlink($path);
}
ITS4YouReports::cleanITS4YouReportsCacheFiles();
//echo "<pre>EXIST ? = ";print_r(method_exists(ITS4YouReports, "cleanITS4YouReportsCacheFiles"));echo "</pre>";
}
示例10: process
//.........这里部分代码省略.........
if (!empty($columnTableMapping[$fieldColumnMapping[$field]])) {
$tableList[$columnTableMapping[$fieldColumnMapping[$field]]] = '';
}
}
$tableList = array_keys($tableList);
$defaultTableList = $meta->getEntityDefaultTableList();
foreach ($defaultTableList as $defaultTable) {
if (!in_array($defaultTable, $tableList)) {
$tableList[] = $defaultTable;
}
}
if (count($tableList) > 0 && count($columnList) > 0) {
$sql = 'select ' . implode(', ', $columnList) . ' from ' . $tableList[0];
$moduleTableIndexList = $meta->getEntityTableIndexList();
foreach ($tableList as $index => $tableName) {
if ($tableName != $tableList[0]) {
$sql .= ' INNER JOIN ' . $tableName . ' ON ' . $tableList[0] . '.' . $moduleTableIndexList[$tableList[0]] . '=' . $tableName . '.' . $moduleTableIndexList[$tableName];
}
}
//If module is Leads and if you are not selected any leads fields then query failure is happening.
//By default we are checking where condition on base table.
if ($module == 'Leads' && !in_array('vtiger_leaddetails', $tableList)) {
$sql .= ' INNER JOIN vtiger_leaddetails ON vtiger_leaddetails.leadid = vtiger_crmentity.crmid';
}
$sql .= ' WHERE';
$deleteQuery = $meta->getEntityDeletedQuery();
if (!empty($deleteQuery)) {
$sql .= ' ' . $meta->getEntityDeletedQuery() . ' AND';
}
$sql .= ' ' . $tableList[0] . '.' . $moduleTableIndexList[$tableList[0]] . '=?';
$sqlparams = array($recordId);
$db = PearDatabase::getInstance();
$result = $db->pquery($sql, $sqlparams);
$it = new SqlResultIterator($db, $result);
//assuming there can only be one row.
$values = array();
foreach ($it as $row) {
foreach ($fieldList as $field) {
$values[$field] = $row->get($fieldColumnMapping[$field]);
}
}
$moduleFields = $meta->getModuleFields();
foreach ($moduleFields as $fieldName => $webserviceField) {
$presence = $webserviceField->getPresence();
if (!in_array($presence, array(0, 2))) {
continue;
}
if (isset($values[$fieldName]) && $values[$fieldName] !== null) {
if (strcasecmp($webserviceField->getFieldDataType(), 'reference') === 0) {
$details = $webserviceField->getReferenceList();
if (count($details) == 1) {
$referencedObjectHandler = vtws_getModuleHandlerFromName($details[0], $this->user);
} else {
$type = getSalesEntityType($values[$fieldName]);
$referencedObjectHandler = vtws_getModuleHandlerFromName($type, $this->user);
}
$referencedObjectMeta = $referencedObjectHandler->getMeta();
if (!$this->isProcessingReferenceField($params) && !empty($values[$fieldName])) {
$this->process(array('parentMeta' => $meta, 'referencedMeta' => $referencedObjectMeta, 'field' => $fieldName, 'id' => $values[$fieldName]));
}
$values[$fieldName] = $referencedObjectMeta->getName(vtws_getId($referencedObjectMeta->getEntityId(), $values[$fieldName]));
} elseif (strcasecmp($webserviceField->getFieldDataType(), 'owner') === 0) {
$referencedObjectHandler = vtws_getModuleHandlerFromName(vtws_getOwnerType($values[$fieldName]), $this->user);
$referencedObjectMeta = $referencedObjectHandler->getMeta();
/*
* operation supported for format $module-parentcolumn:childcolumn$
*/
if (in_array($fieldColumnMapping[$fieldName], array_keys($this->referencedFields))) {
$this->process(array('parentMeta' => $meta, 'referencedMeta' => $referencedObjectMeta, 'field' => $fieldName, 'id' => $values[$fieldName], 'owner' => true));
}
$values[$fieldName] = $referencedObjectMeta->getName(vtws_getId($referencedObjectMeta->getEntityId(), $values[$fieldName]));
} elseif (strcasecmp($webserviceField->getFieldDataType(), 'picklist') === 0) {
$values[$fieldName] = getTranslatedString($values[$fieldName], $module);
} elseif (strcasecmp($fieldName, 'salutationtype') === 0 && $webserviceField->getUIType() == '55') {
$values[$fieldName] = getTranslatedString($values[$fieldName], $module);
} elseif (strcasecmp($webserviceField->getFieldDataType(), 'datetime') === 0) {
$values[$fieldName] = $values[$fieldName] . ' ' . DateTimeField::getDBTimeZone();
}
}
}
if (!$this->isProcessingReferenceField($params)) {
foreach ($columnList as $column) {
$needle = '$' . strtolower($this->module) . "-{$column}\$";
$this->processedDescription = str_replace($needle, $values[array_search($column, $fieldColumnMapping)], $this->processedDescription);
}
// Is process Description will send false even that module don't have reference record set
$this->processedDescription = preg_replace("/\\\$(?:[a-zA-Z0-9]+)-(?:[a-zA-Z0-9]+)(?:_[a-zA-Z0-9]+)?(?::[a-zA-Z0-9]+)(?:[a-zA-Z0-9]+)?(?:_[a-zA-Z0-9]+)?\\\$/", '', $this->processedDescription);
} else {
foreach ($columnList as $column) {
$needle = '$' . strtolower($this->module) . '-' . $parentFieldColumnMapping[$params['field']] . ':' . $column . '$';
$this->processedDescription = str_replace($needle, $values[array_search($column, $fieldColumnMapping)], $this->processedDescription);
}
if (!$params['owner']) {
$this->processedmodules[$module] = true;
}
}
}
}
$this->processed = true;
}
示例11: process
public function process()
{
$variableList = $this->getTemplateVariableListForModule($this->module);
$handler = vtws_getModuleHandlerFromName($this->module, $this->user);
$meta = $handler->getMeta();
$referenceFields = $meta->getReferenceFieldDetails();
$fieldColumnMapping = $meta->getFieldColumnMapping();
$columnTableMapping = $meta->getColumnTableMapping();
$tableList = array();
$columnList = array();
$allColumnList = $meta->getUserAccessibleColumns();
if (count($variableList) > 0) {
foreach ($variableList as $column) {
if (in_array($column, $allColumnList)) {
$columnList[] = $column;
}
}
foreach ($columnList as $column) {
if (!empty($columnTableMapping[$column])) {
$tableList[$columnTableMapping[$column]] = '';
}
}
$tableList = array_keys($tableList);
$defaultTableList = $meta->getEntityDefaultTableList();
foreach ($defaultTableList as $defaultTable) {
if (!in_array($defaultTable, $tableList)) {
$tableList[] = $defaultTable;
}
}
// right now this is will be limited to module type, entities.
// need to extend it to non-module entities when we have a reliable way of getting
// record type from the given record id. non webservice id.
// can extend to non-module entity without many changes as long as the reference field
// refers to one type of entity, either module entities or non-module entities.
if (count($tableList) > 0) {
$sql = 'select ' . implode(', ', $columnList) . ' from ' . $tableList[0];
$moduleTableIndexList = $meta->getEntityTableIndexList();
foreach ($tableList as $index => $tableName) {
if ($tableName != $tableList[0]) {
$sql .= ' INNER JOIN ' . $tableName . ' ON ' . $tableList[0] . '.' . $moduleTableIndexList[$tableList[0]] . '=' . $tableName . '.' . $moduleTableIndexList[$tableName];
}
}
$sql .= ' WHERE';
$deleteQuery = $meta->getEntityDeletedQuery();
if (!empty($deleteQuery)) {
$sql .= ' ' . $meta->getEntityDeletedQuery() . ' AND';
}
$sql .= ' ' . $tableList[0] . '.' . $moduleTableIndexList[$tableList[0]] . '=?';
$params = array($this->recordId);
$db = PearDatabase::getInstance();
$result = $db->pquery($sql, $params);
$it = new SqlResultIterator($db, $result);
//assuming there can only be one row.
$values = array();
foreach ($it as $row) {
foreach ($columnList as $column) {
$values[$column] = $row->get($column);
}
}
$moduleFields = $meta->getModuleFields();
foreach ($moduleFields as $fieldName => $webserviceField) {
if (isset($values[$fieldColumnMapping[$fieldName]]) && $values[$fieldColumnMapping[$fieldName]] !== null) {
if (strcasecmp($webserviceField->getFieldDataType(), 'reference') === 0) {
$details = $webserviceField->getReferenceList();
if (count($details) == 1) {
$referencedObjectHandler = vtws_getModuleHandlerFromName($details[0], $this->user);
} else {
$type = getSalesEntityType($values[$fieldColumnMapping[$fieldName]]);
$referencedObjectHandler = vtws_getModuleHandlerFromName($type, $this->user);
}
$referencedObjectMeta = $referencedObjectHandler->getMeta();
$values[$fieldColumnMapping[$fieldName]] = $referencedObjectMeta->getName(vtws_getId($referencedObjectMeta->getEntityId(), $values[$fieldColumnMapping[$fieldName]]));
} elseif (strcasecmp($webserviceField->getFieldDataType(), 'owner') === 0) {
$referencedObjectHandler = vtws_getModuleHandlerFromName(vtws_getOwnerType($values[$fieldColumnMapping[$fieldName]]), $this->user);
$referencedObjectMeta = $referencedObjectHandler->getMeta();
$values[$fieldColumnMapping[$fieldName]] = $referencedObjectMeta->getName(vtws_getId($referencedObjectMeta->getEntityId(), $values[$fieldColumnMapping[$fieldName]]));
} elseif (strcasecmp($webserviceField->getFieldDataType(), 'picklist') === 0) {
$values[$fieldColumnMapping[$fieldName]] = getTranslatedString($values[$fieldColumnMapping[$fieldName]], $this->module);
} elseif (strcasecmp($webserviceField->getFieldDataType(), 'datetime') === 0) {
$values[$fieldColumnMapping[$fieldName]] = $values[$fieldColumnMapping[$fieldName]] . ' ' . DateTimeField::getDBTimeZone();
}
}
}
foreach ($columnList as $column) {
$needle = '$' . strtolower($this->module) . "-{$column}\$";
$this->processedDescription = str_replace($needle, $values[$column], $this->processedDescription);
}
}
}
$this->processed = true;
}
示例12: array
$log->debug(" InSide REMINDER");
$query_user = "SELECT vtiger_users.email1,vtiger_salesmanactivityrel.smid FROM vtiger_salesmanactivityrel inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where vtiger_salesmanactivityrel.activityid =? and vtiger_users.deleted=0";
$user_result = $adb->pquery($query_user, array($activity_id));
if ($adb->num_rows($user_result) >= 1) {
while ($user_result_row = $adb->fetch_array($user_result)) {
if ($user_result_row['email1'] != '' || $user_result_row['email1'] != NULL) {
$to_addr[] = $user_result_row['email1'];
}
}
}
// Retriving the Subject and message from reminder table
$sql = "select active,notificationsubject,notificationbody from vtiger_notificationscheduler where schedulednotificationid=8";
$result_main = $adb->pquery($sql, array());
$subject = $app_strings['Reminder'] . $result_set['activitytype'] . " @ " . $result_set['date_start'] . " " . $result_set['time_start'] . "] (" . DateTimeField::getDBTimeZone() . ")" . $adb->query_result($result_main, 0, 'notificationsubject');
//Set the mail body/contents here
$contents = nl2br($adb->query_result($result_main, 0, 'notificationbody')) . "\n\n " . $app_strings['Subject'] . " : " . $activity_sub . "\n " . $parent_content . " " . $app_strings['Date & Time'] . " : " . $date_start . " " . $time_start . "(" . DateTimeField::getDBTimeZone() . ")\n\n " . $app_strings['Visit_Link'] . " <a href='" . $site_URL . "/index.php?action=DetailView&module=Calendar&record=" . $activity_id . "&activity_mode=" . $activitymode . "'>" . $app_strings['Click here'] . "</a>";
if (count($to_addr) >= 1) {
send_mail($to_addr, $from, $subject, $contents, $mail_server, $mail_server_username, $mail_server_password);
$upd_query = "UPDATE vtiger_activity_reminder SET reminder_sent=1 where activity_id=?";
$upd_params = array($activity_id);
if ($recur_id != 0) {
$upd_query .= " and recurringid =?";
array_push($upd_params, $recur_id);
}
$adb->pquery($upd_query, $upd_params);
}
}
}
}
/**
This function is used to assign parameters to the mail object and send it.
示例13: process
public function process()
{
global $site_URL;
$imagefound = false;
$variableList = $this->getTemplateVariableListForModule($this->module);
$handler = vtws_getModuleHandlerFromName($this->module, $this->user);
$meta = $handler->getMeta();
$referenceFields = $meta->getReferenceFieldDetails();
$fieldColumnMapping = $meta->getFieldColumnMapping();
$columnTableMapping = $meta->getColumnTableMapping();
$tableList = array();
$columnList = array();
$columnList_full = array();
$allColumnList = $meta->getUserAccessibleColumns();
if (count($variableList) > 0) {
foreach ($variableList as $column) {
if (in_array($column, $allColumnList)) {
$columnList[] = $column;
$columnList_full[] = $columnTableMapping[$column] . '.' . $column;
}
}
foreach ($columnList as $column) {
if (!empty($columnTableMapping[$column])) {
$tableList[$columnTableMapping[$column]] = '';
}
}
$tableList = array_keys($tableList);
$defaultTableList = $meta->getEntityDefaultTableList();
$tableList = array_merge($tableList, $defaultTableList);
$leadtables = array('vtiger_leadsubdetails', 'vtiger_leadaddress', 'vtiger_leadscf');
$leadmerge = array_intersect($tableList, $leadtables);
if (count($leadmerge) > 0 and !in_array('vtiger_leaddetails', $tableList)) {
// we need this one because the where condition for Leads uses the converted column from the main table
$tableList[] = 'vtiger_leaddetails';
}
// right now this is will be limited to module type, entities.
// need to extend it to non-module entities when we have a reliable way of getting
// record type from the given record id. non webservice id.
// can extend to non-module entity without many changes as long as the reference field
// refers to one type of entity, either module entities or non-module entities.
if (count($tableList) > 0) {
$sql = 'select ' . implode(', ', $columnList_full) . ' from ' . $tableList[0];
$moduleTableIndexList = $meta->getEntityTableIndexList();
foreach ($tableList as $index => $tableName) {
if ($tableName != $tableList[0]) {
$sql .= ' INNER JOIN ' . $tableName . ' ON ' . $tableList[0] . '.' . $moduleTableIndexList[$tableList[0]] . '=' . $tableName . '.' . $moduleTableIndexList[$tableName];
}
}
$sql .= ' WHERE';
$deleteQuery = $meta->getEntityDeletedQuery();
if (!empty($deleteQuery)) {
$sql .= " {$deleteQuery} AND";
}
$sql .= ' ' . $tableList[0] . '.' . $moduleTableIndexList[$tableList[0]] . '=?';
$params = array($this->recordId);
$db = PearDatabase::getInstance();
$result = $db->pquery($sql, $params);
$it = new SqlResultIterator($db, $result);
//assuming there can only be one row.
$values = array();
foreach ($it as $row) {
foreach ($columnList as $column) {
$values[$column] = $row->get($column);
}
}
$moduleFields = $meta->getModuleFields();
foreach ($moduleFields as $fieldName => $webserviceField) {
if (isset($values[$fieldColumnMapping[$fieldName]]) && $values[$fieldColumnMapping[$fieldName]] !== null) {
$fieldtype = $webserviceField->getFieldDataType();
if (strcasecmp($fieldtype, 'reference') === 0) {
$details = $webserviceField->getReferenceList();
if (count($details) == 1) {
$referencedObjectHandler = vtws_getModuleHandlerFromName($details[0], $this->user);
} else {
$type = getSalesEntityType($values[$fieldColumnMapping[$fieldName]]);
$referencedObjectHandler = vtws_getModuleHandlerFromName($type, $this->user);
}
$referencedObjectMeta = $referencedObjectHandler->getMeta();
$values[$fieldColumnMapping[$fieldName]] = $referencedObjectMeta->getName(vtws_getId($referencedObjectMeta->getEntityId(), $values[$fieldColumnMapping[$fieldName]]));
} elseif (strcasecmp($fieldtype, 'owner') === 0) {
$referencedObjectHandler = vtws_getModuleHandlerFromName(vtws_getOwnerType($values[$fieldColumnMapping[$fieldName]]), $this->user);
$referencedObjectMeta = $referencedObjectHandler->getMeta();
$values[$fieldColumnMapping[$fieldName]] = $referencedObjectMeta->getName(vtws_getId($referencedObjectMeta->getEntityId(), $values[$fieldColumnMapping[$fieldName]]));
} elseif (strcasecmp($fieldtype, 'picklist') === 0 or $fieldName == 'salutationtype') {
$values[$fieldColumnMapping[$fieldName]] = getTranslatedString($values[$fieldColumnMapping[$fieldName]], $this->module);
} elseif (strcasecmp($fieldtype, 'datetime') === 0) {
$values[$fieldColumnMapping[$fieldName]] = $values[$fieldColumnMapping[$fieldName]] . ' ' . DateTimeField::getDBTimeZone();
} elseif (strcasecmp($fieldtype, 'currency') === 0 or strcasecmp($fieldtype, 'double') === 0) {
$currencyField = new CurrencyField($values[$fieldColumnMapping[$fieldName]]);
$values[$fieldColumnMapping[$fieldName]] = $currencyField->getDisplayValue(null, true);
} elseif ($webserviceField->getUIType() == 69) {
$query = 'select vtiger_attachments.name, vtiger_attachments.type, vtiger_attachments.attachmentsid, vtiger_attachments.path
from vtiger_attachments
inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid
inner join vtiger_seattachmentsrel on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid
where (vtiger_crmentity.setype LIKE "%Image" or vtiger_crmentity.setype LIKE "%Attachment")
and deleted=0 and vtiger_seattachmentsrel.crmid=?';
$params = array($this->recordId);
if (!empty($values[$fieldColumnMapping[$fieldName]])) {
$query .= ' and vtiger_attachments.name = ?';
//.........这里部分代码省略.........
示例14: sendEmail
public function sendEmail()
{
require_once 'modules/Emails/mail.php';
require_once 'modules/Emails/Emails.php';
global $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $currentModule;
$recipientEmails = $this->getRecipientEmails();
$emails_to = '';
foreach ($recipientEmails as $name => $email) {
$emails_to .= $email . ',';
}
$emails_to = trim($emails_to, ',');
$currentTime = date('Y-m-d H:i:s');
$subject = $this->reportname . ' - ' . $currentTime . ' (' . DateTimeField::getDBTimeZone() . ')';
$contents = getTranslatedString('LBL_AUTO_GENERATED_REPORT_EMAIL', $currentModule) . '<br/><br/>';
$contents .= '<b>' . getTranslatedString('LBL_REPORT_NAME', $currentModule) . ' :</b> ' . $this->reportname . '<br/>';
$contents .= '<b>' . getTranslatedString('LBL_DESCRIPTION', $currentModule) . ' :</b><br/>' . $this->reportdescription . '<br/><br/>';
$baseFileName = utf8_decode(preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $this->reportname) . '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', date('YmdHis')));
$oReportRun = new ReportRun($this->id);
$reportFormat = $this->scheduledFormat;
$attachments = array();
if ($reportFormat == 'pdf' || $reportFormat == 'both') {
$fileName = $baseFileName . '.pdf';
$filePath = 'storage/' . $fileName;
$attachments[$fileName] = $filePath;
$_REQUEST['filename_hidden_pdf'] = $filePath;
$pdf = $oReportRun->getReportPDF(NULL);
$pdf->Output($filePath, 'F');
}
if ($reportFormat == 'excel' || $reportFormat == 'both') {
$fileName = $baseFileName . '.xls';
$filePath = 'storage/' . $fileName;
$attachments[$fileName] = $filePath;
$_REQUEST['filename_hidden_xls'] = $filePath;
$oReportRun->writeReportToExcelFile($filePath, NULL);
}
$sendifempty = GlobalVariable::getVariable('Report_Send_Scheduled_ifEmpty', 1);
if ($sendifempty or $oReportRun->number_of_rows > 0) {
$mail_status = send_mail('Emails', $emails_to, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $subject, $contents, '', '', 'attReports');
foreach ($attachments as $attachmentName => $path) {
unlink($path);
}
}
}
示例15: array
$currentModule = 'ITS4YouReports';
}
// $recipientEmails = $this->getRecipientEmails();
$recipientEmails = array("olear@its4you.sk");
foreach ($recipientEmails as $name => $email) {
$vtigerMailer->AddAddress($email, $name);
}
$ITS4YouReports = new ITS4YouReports(true, 90);
global $default_charset;
if (!isset($default_charset)) {
$default_charset = "UTF-8";
}
$ITS4YouReports_reportname = generate_cool_url($ITS4YouReports->reportname);
$ITS4YouReports_reportdesc = generate_cool_url($ITS4YouReports->reportdesc);
$currentTime = date('Y-m-d H:i:s');
$subject = $ITS4YouReports_reportname . ' - ' . $currentTime . ' (' . DateTimeField::getDBTimeZone() . ')';
$contents = getTranslatedString('LBL_AUTO_GENERATED_REPORT_EMAIL', $currentModule) . '<br/><br/>';
$contents .= '<b>' . getTranslatedString('LBL_REPORT_NAME', $currentModule) . ' :</b> ' . $ITS4YouReports_reportname . '<br/>';
$contents .= '<b>' . getTranslatedString('LBL_DESCRIPTION', $currentModule) . ' :</b><br/>' . $ITS4YouReports_reportdesc . '<br/><br/>';
$vtigerMailer->Subject = "=?ISO-8859-15?Q?" . imap_8bit(html_entity_decode($subject, ENT_QUOTES, "UTF-8")) . "?=";
$vtigerMailer->Body = $contents;
$vtigerMailer->ContentType = "text/html";
$generate = new GenerateObj($ITS4YouReports);
//$reportFormat = $this->scheduledFormat;
$reportFormat = "pdf;xls";
$reportFormat = explode(";", $reportFormat);
$tmpDir = "test/ITS4YouReports/";
$attachments = array();
if (in_array('pdf', $reportFormat)) {
$report_html = $generate->generateReport(90, "HTML", false);
ITS4YouReports::sshow($report_html);