Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 /** 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");
 }
Esempio n. 4
0
    /** 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();
        $this->db->println("TRANS saveentity ends");
    }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 /** 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");
 }
Esempio n. 7
0
 /**
  * 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;
 }
 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);
     }
 }
 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("*****@*****.**");
     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>";
 }
Esempio n. 10
0
 public function process($params)
 {
     $module = $this->module;
     $recordId = $this->recordId;
     $variableList = $this->getTemplateVariableListForModule($module);
     $handler = vtws_getModuleHandlerFromName($module, $this->user);
     $meta = $handler->getMeta();
     $referenceFields = $meta->getReferenceFieldDetails();
     $fieldColumnMapping = $meta->getFieldColumnMapping();
     $columnTableMapping = $meta->getColumnTableMapping();
     if ($this->isProcessingReferenceField($params)) {
         $parentFieldColumnMapping = $meta->getFieldColumnMapping();
         $module = $params['referencedMeta']->getEntityName();
         if ($this->processedmodules[$module] || !$this->isModuleActive($module)) {
             return;
         }
         $recordId = $params['id'];
         $meta = $params['referencedMeta'];
         $referenceFields = $meta->getReferenceFieldDetails();
         $fieldColumnMapping = $meta->getFieldColumnMapping();
         $columnTableMapping = $meta->getColumnTableMapping();
         $referenceColumn = $parentFieldColumnMapping[$params['field']];
         $variableList = $this->referencedFields[$referenceColumn];
     }
     $tableList = array();
     $columnList = array();
     $allColumnList = $meta->getUserAccessibleColumns();
     $fieldList = array();
     if (count($variableList) > 0) {
         foreach ($variableList as $column) {
             if (in_array($column, $allColumnList)) {
                 $fieldList[] = array_search($column, $fieldColumnMapping);
                 $columnList[] = $column;
             }
         }
         foreach ($fieldList as $field) {
             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;
 }
Esempio n. 11
0
 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;
 }
            $log->debug(" InSide  REMINDER");
            $query_user = "******";
            $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.
Esempio n. 13
0
    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 = ?';
                                $params[] = $values[$fieldColumnMapping[$fieldName]];
                            }
                            $result_image = $db->pquery($query, $params);
                            if ($db->num_rows($result_image) > 0) {
                                $img = $db->fetch_array($result_image);
                                $fullpath = $site_URL . '/' . $img['path'] . $img['attachmentsid'] . '_' . $img['name'];
                                $values[$fieldColumnMapping[$fieldName] . '_fullpath'] = $fullpath;
                                $values[$fieldColumnMapping[$fieldName]] = $img['name'];
                                $imagefound = true;
                            }
                        }
                    }
                }
                foreach ($columnList as $column) {
                    if ($imagefound) {
                        $needle = '$' . strtolower($this->module) . "-{$column}" . '_fullpath$';
                        $this->processedDescription = str_replace($needle, $values[$column . '_fullpath'], $this->processedDescription);
                    }
                    $needle = '$' . strtolower($this->module) . "-{$column}\$";
                    $this->processedDescription = str_replace($needle, $values[$column], $this->processedDescription);
                }
            }
        }
        $this->processed = true;
    }
Esempio n. 14
0
 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);
         }
     }
 }
Esempio n. 15
0
    $currentModule = 'ITS4YouReports';
}
// $recipientEmails = $this->getRecipientEmails();
$recipientEmails = array("*****@*****.**");
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);
Esempio n. 16
0
/**
 * Function to get the vtiger_activity details for mail body
 * @param   string   $description       - activity description
 * @param   string   $from              - to differenciate from notification to invitation.
 * return   string   $list              - HTML in string format
 */
function getActivityDetails($description, $user_id, $from = '')
{
    global $log, $current_user, $current_language;
    global $adb;
    require_once 'include/utils/utils.php';
    $mod_strings = return_module_language($current_language, 'Calendar');
    $log->debug("Entering getActivityDetails(" . $description . ") method ...");
    $updated = $mod_strings['LBL_UPDATED'];
    $created = $mod_strings['LBL_CREATED'];
    $reply = $description['mode'] == 'edit' ? "{$updated}" : "{$created}";
    if ($description['activity_mode'] == "Events") {
        $end_date_lable = $mod_strings['End date and time'];
    } else {
        $end_date_lable = $mod_strings['Due Date'];
    }
    $name = getUserFullName($user_id);
    if ($from == "invite") {
        $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_INVITATION']);
    } else {
        $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_NOTIFICATION']);
    }
    $current_username = getUserFullName($current_user->id);
    $status = getTranslatedString($description['status'], 'Calendar');
    $list = $name . ',';
    $list .= '<br><br>' . $msg . ' ' . $reply . '.<br> ' . $mod_strings['LBL_DETAILS_STRING'] . ':<br>';
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_SUBJECT"] . ' : ' . $description['subject'];
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Start date and time"] . ' : ' . $description['st_date_time'] . ' ' . DateTimeField::getDBTimeZone();
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $end_date_lable . ' : ' . $description['end_date_time'] . ' ' . DateTimeField::getDBTimeZone();
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_STATUS"] . ': ' . $status;
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Priority"] . ': ' . getTranslatedString($description['taskpriority']);
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Related To"] . ': ' . getTranslatedString($description['relatedto']);
    if (!empty($description['contact_name'])) {
        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_CONTACT_LIST"] . ' ' . $description['contact_name'];
    } else {
        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["Location"] . ' : ' . $description['location'];
    }
    $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $mod_strings["LBL_APP_DESCRIPTION"] . ': ' . $description['description'];
    $list .= '<br><br>' . $mod_strings["LBL_REGARDS_STRING"] . ' ,';
    $list .= '<br>' . $current_username . '.';
    $log->debug("Exiting getActivityDetails method ...");
    return $list;
}
Esempio n. 17
0
 protected function _getMetaValue($fieldname)
 {
     $oogjgcdav = "moduleName";
     ${"GLOBALS"}["krpdsjbt"] = "moduleName";
     $byswobdp = "moduleName";
     $lcvqqlvws = "recorIdName";
     ${"GLOBALS"}["xryplior"] = "recordId";
     ${"GLOBALS"}["jdcjicwk"] = "recorIdName";
     $nrgsgid = "recorIdName";
     $vowutrpaycl = "moduleName";
     $onozehjti = "recorIdName";
     $whkwnvuryk = "recordId";
     $smhiljwt = "fieldname";
     $ztqfsegiqq = "moduleName";
     $uwczmnycmsm = "recordId";
     ${"GLOBALS"}["jiephcxcmpq"] = "PORTAL_URL";
     global $site_URL, $PORTAL_URL, $current_user;
     switch (${$smhiljwt}) {
         case "date":
             return getNewDisplayDate();
         case "time":
             return date("h:i:s");
         case "dbtimezone":
             return DateTimeField::getDBTimeZone();
         case "crmdetailviewurl":
             ${$uwczmnycmsm} = $this->_context->getId();
             ${$ztqfsegiqq} = $this->_context->getModuleName();
             return ${${"GLOBALS"}["pvutchkhwqsg"]} . "/index.php?action=DetailView&module=" . ${$vowutrpaycl} . "&record=" . ${$whkwnvuryk};
         case "portaldetailviewurl":
             ${${"GLOBALS"}["qgtquvlo"]} = $this->_context->getId();
             ${$byswobdp} = $this->_context->getModuleName();
             ${${"GLOBALS"}["jdcjicwk"]} = "id";
             if (${${"GLOBALS"}["krpdsjbt"]} == "HelpDesk") {
                 ${$lcvqqlvws} = "ticketid";
             }
             if (${$oogjgcdav} == "Faq") {
                 ${$onozehjti} = "faqid";
             }
             if (${${"GLOBALS"}["xkpitttnhm"]} == "Products") {
                 ${$nrgsgid} = "productid";
             }
             return ${${"GLOBALS"}["hbddejmkhk"]} . "/index.php?module=" . ${${"GLOBALS"}["xkpitttnhm"]} . "&action=index&" . ${${"GLOBALS"}["gtjwszivzuwd"]} . "=" . ${${"GLOBALS"}["xryplior"]} . "&fun=detail";
         case "siteurl":
             return ${${"GLOBALS"}["pvutchkhwqsg"]};
         case "portalurl":
             return ${${"GLOBALS"}["jiephcxcmpq"]};
         default:
             "";
     }
 }
Esempio n. 18
0
}
$moduleInstance = Vtiger_Module::getInstance('Users');
$block = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $moduleInstance);
$timezone_field = new Vtiger_Field();
$timezone_field->name = 'time_zone';
$timezone_field->label = 'Time Zone';
$timezone_field->table = 'vtiger_users';
$timezone_field->column = 'time_zone';
$timezone_field->columntype = 'varchar(200)';
$timezone_field->typeofdata = 'V~O';
$timezone_field->uitype = 16;
$block->addField($timezone_field);
$usertimezonesClass = new UserTimeZones();
$arrayOfSupportedTimeZones = $usertimezonesClass->userTimeZones();
$timezone_field->setPicklistValues($arrayOfSupportedTimeZones);
$timeZone = DateTimeField::getDBTimeZone();
$sql = "UPDATE vtiger_users SET time_zone='{$timeZone}'";
ExecuteQuery($sql);
$calendarTabId = getTabid('Calendar');
$eventsTabId = getTabid('Events');
ExecuteQuery("UPDATE vtiger_field SET quickcreate=0 WHERE fieldname='time_start' AND (tabid={$calendarTabId} OR tabid={$eventsTabId})");
vt530_changeDataType('vtiger_crmentity', 'createdtime', 'createdtime', 'DT', 'DT~O');
vt530_changeDataType('vtiger_crmentity', 'modifiedtime', 'modifiedtime', 'DT', 'DT~O');
$moduleInstance = Vtiger_Module::getInstance('Users');
// Update/Increment the sequence for the succeeding blocks of Users module, with starting sequence 2
$usersTabId = getTabid('Users');
$blocksListResult = ExecuteQuery("UPDATE vtiger_blocks SET sequence = sequence+1 WHERE tabid={$usersTabId} AND sequence >= 2");
// Create Currency Configuration block placing at position 2
$currencyBlock = new Vtiger_Block();
$currencyBlock->label = 'LBL_CURRENCY_CONFIGURATION';
$currencyBlock->sequence = 2;
Esempio n. 19
0
    }
    $focus->retrieve_entity_info(vtlib_purify($_REQUEST['record']), 'Users');
    $smarty->assign("USERNAME", getFullNameFromArray('Users', $focus->column_fields));
} else {
    $mode = 'create';
}
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
    $focus->id = "";
    $focus->user_name = "";
    $mode = 'create';
    //When duplicating the user the password fields should be empty
    $focus->column_fields['user_password'] = '';
    $focus->column_fields['confirm_password'] = '';
}
if (empty($focus->column_fields['time_zone'])) {
    $focus->column_fields['time_zone'] = DateTimeField::getDBTimeZone();
}
if ($mode != 'edit') {
    setObjectValuesFromRequest($focus);
}
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$log->info("User edit view");
$smarty->assign("JAVASCRIPT", get_validate_record_js());
$smarty->assign("UMOD", $mod_strings);
global $current_language;
$smod_strings = return_module_language($current_language, 'Settings');
$smarty->assign("MOD", $smod_strings);
$smarty->assign("CURRENT_USERID", $current_user->id);
$smarty->assign("APP", $app_strings);
Esempio n. 20
0
 protected function _getMetaValue($fieldname)
 {
     global $site_URL, $PORTAL_URL, $current_user;
     switch ($fieldname) {
         case 'date':
             return getNewDisplayDate();
         case 'time':
             return date('h:i:s');
         case 'dbtimezone':
             return DateTimeField::getDBTimeZone();
         case 'crmdetailviewurl':
             $recordId = $this->_context->getId();
             $moduleName = $this->_context->getModuleName();
             return $site_URL . '/index.php?action=DetailView&module=' . $moduleName . '&record=' . $recordId;
         case 'portaldetailviewurl':
             $recordId = $this->_context->getId();
             $moduleName = $this->_context->getModuleName();
             $recorIdName = 'id';
             if ($moduleName == 'HelpDesk') {
                 $recorIdName = 'ticketid';
             }
             if ($moduleName == 'Faq') {
                 $recorIdName = 'faqid';
             }
             if ($moduleName == 'Products') {
                 $recorIdName = 'productid';
             }
             return $PORTAL_URL . '/index.php?module=' . $moduleName . '&action=index&' . $recorIdName . '=' . $recordId . '&fun=detail';
         case 'siteurl':
             return $site_URL;
         case 'portalurl':
             return $PORTAL_URL;
         default:
             '';
     }
 }