Esempio n. 1
0
 public static function showErrorPage($errorMessage, $errorDetails = false, $customActions = false)
 {
     $viewer = new Import_UI_Viewer();
     $viewer->assign('ERROR_MESSAGE', $errorMessage);
     $viewer->assign('ERROR_DETAILS', $errorDetails);
     $viewer->assign('CUSTOM_ACTIONS', $customActions);
     $viewer->display('ImportError.tpl');
 }
 public static function render($userInputObject, $user)
 {
     global $list_max_entries_per_page;
     $adb = PearDatabase::getInstance();
     $viewer = new Import_UI_Viewer();
     $ownerId = $userInputObject->get('foruser');
     $owner = new Users();
     $owner->id = $ownerId;
     $owner->retrieve_entity_info($ownerId, 'Users');
     if (!is_admin($user) && $user->id != $owner->id) {
         $viewer->display('OperationNotPermitted.tpl', 'Vtiger');
         exit;
     }
     $userDBTableName = Import_Utils::getDbTableName($owner);
     $moduleName = $userInputObject->get('module');
     $moduleMeta = self::getModuleMeta($moduleName, $user);
     $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL');
     $noOfRecords = $adb->num_rows($result);
     $importedRecordIds = array();
     for ($i = 0; $i < $noOfRecords; ++$i) {
         $importedRecordIds[] = $adb->query_result($result, $i, 'recordid');
     }
     if (count($importedRecordIds) == 0) {
         $importedRecordIds[] = 0;
     }
     $focus = CRMEntity::getInstance($moduleName);
     $queryGenerator = new QueryGenerator($moduleName, $user);
     $customView = new CustomView($moduleName);
     $viewId = $customView->getViewIdByName('All', $moduleName);
     $queryGenerator->initForCustomViewById($viewId);
     $list_query = $queryGenerator->getQuery();
     // Fetch only last imported records
     $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')';
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
         $count_result = $adb->query(mkCountQuery($list_query));
         $noofrows = $adb->query_result($count_result, 0, "count");
     } else {
         $noofrows = null;
     }
     $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false);
     $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
     $limit_start_rec = ($start - 1) * $list_max_entries_per_page;
     $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
     $viewer->assign('recordListRange', $recordListRangeMsg);
     $controller = new ListViewController($adb, $user, $queryGenerator);
     $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true);
     $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true);
     $viewer->assign('CURRENT_PAGE', $start);
     $viewer->assign('LISTHEADER', $listview_header);
     $viewer->assign('LISTENTITY', $listview_entries);
     $viewer->assign('FOR_MODULE', $moduleName);
     $viewer->assign('FOR_USER', $ownerId);
     $isAjax = $userInputObject->get('ajax');
     if (!empty($isAjax)) {
         echo $viewer->fetch('ListViewEntries.tpl');
     } else {
         $viewer->display('ImportListView.tpl');
     }
 }
 public static function runScheduledImport()
 {
     require_once 'modules/Emails/mail.php';
     require_once 'modules/Emails/Emails.php';
     global $current_user, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID;
     $scheduledImports = self::getScheduledImport();
     foreach ($scheduledImports as $scheduledId => $importDataController) {
         $current_user = $importDataController->user;
         $importDataController->batchImport = false;
         if (!$importDataController->initializeImport()) {
             continue;
         }
         $importDataController->importData();
         $importStatusCount = $importDataController->getImportStatusCount();
         $emailSubject = 'coreBOS - Scheduled Import Report for ' . $importDataController->module;
         $viewer = new Import_UI_Viewer();
         $viewer->assign('FOR_MODULE', $importDataController->module);
         $viewer->assign('IMPORT_RESULT', $importStatusCount);
         $importResult = $viewer->fetch('Import_Result_Details.tpl');
         $importResult = str_replace('align="center"', '', $importResult);
         $emailData = 'coreBOS has just completed your import process. <br/><br/>' . $importResult . '<br/><br/>' . 'We recommend you to login to the coreBOS and check few records to confirm that the import has been successful.';
         $userName = getFullNameFromArray('Users', $importDataController->user->column_fields);
         $userEmail = $importDataController->user->email1;
         send_mail('Emails', $userEmail, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $emailSubject, $emailData, '', '');
         $importDataController->finishImport();
     }
     Vtiger_Mailer::dispatchQueue(null);
 }
Esempio n. 4
0
 public static function runScheduledImport()
 {
     global $current_user;
     $scheduledImports = self::getScheduledImport();
     $vtigerMailer = new Vtiger_Mailer();
     $vtigerMailer->IsHTML(true);
     foreach ($scheduledImports as $scheduledId => $importDataController) {
         $current_user = $importDataController->user;
         $importDataController->batchImport = false;
         if (!$importDataController->initializeImport()) {
             continue;
         }
         $importDataController->importData();
         $importStatusCount = $importDataController->getImportStatusCount();
         $emailSubject = 'vtiger CRM - Scheduled Import Report for ' . $importDataController->module;
         vimport('~~/modules/Import/ui/Viewer.php');
         $viewer = new Import_UI_Viewer();
         $viewer->assign('FOR_MODULE', $importDataController->module);
         $viewer->assign('INVENTORY_MODULES', getInventoryModules());
         $viewer->assign('IMPORT_RESULT', $importStatusCount);
         $importResult = $viewer->fetch('Import_Result_Details.tpl');
         $importResult = str_replace('align="center"', '', $importResult);
         $emailData = 'vtiger CRM has just completed your import process. <br/><br/>' . $importResult . '<br/><br/>' . 'We recommend you to login to the CRM and check few records to confirm that the import has been successful.';
         $userName = getFullNameFromArray('Users', $importDataController->user->column_fields);
         $userEmail = $importDataController->user->email1;
         $vtigerMailer->to = array(array($userEmail, $userName));
         $vtigerMailer->Subject = $emailSubject;
         $vtigerMailer->Body = $emailData;
         $vtigerMailer->Send();
         $importDataController->finishImport();
     }
     Vtiger_Mailer::dispatchQueue(null);
 }
	public static function deleteMap($userInputObject, $user) {
		$adb = PearDatabase::getInstance();
		$moduleName = $userInputObject->get('module');
		$mapId = $userInputObject->get('mapid');
		Import_Map::markAsDeleted($mapId);

		$viewer = new Import_UI_Viewer();
		$viewer->assign('FOR_MODULE', $moduleName);
		$viewer->assign('SAVED_MAPS', Import_Map::getAllByModule($moduleName));
		echo $viewer->fetch('Import_Saved_Maps.tpl');
	}
 public static function showScheduledStatus($importInfo)
 {
     $moduleName = $importInfo['module'];
     $importId = $importInfo['id'];
     $viewer = new Import_UI_Viewer();
     $viewer->assign('FOR_MODULE', $moduleName);
     $viewer->assign('IMPORT_ID', $importId);
     $viewer->display('ImportSchedule.tpl');
 }
function undoLastImport($obj, $user)
{
    global $adb;
    $moduleName = $obj->get('module');
    $ownerId = $obj->get('foruser');
    $owner = new Users();
    $owner->id = $ownerId;
    $owner->retrieve_entity_info($ownerId, 'Users');
    $dbTableName = Import_Utils_Helper::getDbTableName($owner);
    if (!is_admin($user) && $user->id != $owner->id) {
        $viewer = new Import_UI_Viewer();
        $viewer->display('OperationNotPermitted.tpl', 'Vtiger');
        exit;
    }
    $result = $adb->query("SELECT recordid FROM {$dbTableName} WHERE status = " . Import_Data_Controller::$IMPORT_RECORD_CREATED . " AND recordid IS NOT NULL GROUP BY subject");
    $noOfRecords = $adb->num_rows($result);
    $noOfRecordsDeleted = 0;
    for ($i = 0; $i < $noOfRecords; ++$i) {
        $recordId = $adb->query_result($result, $i, 'recordid');
        if (isRecordExists($recordId) && isPermitted($moduleName, 'Delete', $recordId) == 'yes') {
            $focus = CRMEntity::getInstance($moduleName);
            $focus->id = $recordId;
            $focus->trash($moduleName, $recordId);
            $noOfRecordsDeleted++;
        }
    }
    $viewer = new Import_UI_Viewer();
    $viewer->assign('FOR_MODULE', $moduleName);
    $viewer->assign('TOTAL_RECORDS', $noOfRecords);
    $viewer->assign('DELETED_RECORDS_COUNT', $noOfRecordsDeleted);
    $viewer->display('ImportUndoResult.tpl');
}