}
     gen_add_audit_log(PHREEFORM_TOOLS_REBUILD_TITLE);
     $messageStack->add(sprintf(PHREEFORM_TOOLS_REBUILD_SUCCESS, $rpt_cnt, $orph_cnt), 'success');
     break;
     /*** BOF - Added by PhreeSoft to convert PhreeBooks reports to phreeform format *************/
     // This script transfers stored reports from the reportwriter database used in PhreeBooks to phreeform
 /*** BOF - Added by PhreeSoft to convert PhreeBooks reports to phreeform format *************/
 // This script transfers stored reports from the reportwriter database used in PhreeBooks to phreeform
 case 'convert':
     require_once DIR_FS_MODULES . 'phreeform/functions/reportwriter.php';
     $result = $db->Execute("select * from " . TABLE_REPORTS);
     $count = 0;
     while (!$result->EOF) {
         $skip_report = false;
         $report = PrepReport($result->fields['id']);
         if (!($params = import_text_params($report))) {
             $messageStack->add(sprintf(PB_CONVERT_ERROR, $result->fields['description']), 'error');
             $skip_report = true;
         }
         // fix some fields
         $params->standard_report = $result->fields['standard_report'] ? 's' : 'c';
         // error check
         $duplicate = $db->Execute("select id from " . TABLE_PHREEFORM . " \n\t    where doc_title = '" . addslashes($params->title) . "' and doc_type <> '0'");
         if ($duplicate->RecordCount() > 0) {
             // the report name already exists, error
             $messageStack->add(sprintf(PHREEFORM_REPDUP, $params->title), 'error');
             $skip_report = true;
         }
         if (!$skip_report) {
             if (!($success = save_report($params))) {
                 $messageStack->add(sprintf(PB_CONVERT_SAVE_ERROR, $params->title), 'error');
예제 #2
0
function ImportReport($RptName = '', $RptFileName = '', $import_path = PF_DIR_DEF_REPORTS, $save_path = PF_DIR_MY_REPORTS)
{
    global $db, $messageStack;
    $rID = '';
    if ($RptFileName != '') {
        // then a locally stored report was chosen
        $path = $import_path . $RptFileName;
    } else {
        if (validate_upload('reportfile')) {
            $path = $_FILES['reportfile']['tmp_name'];
        } else {
            $messageStack->add(PHREEFORM_IMPORT_ERROR, 'error');
            return false;
        }
    }
    $handle = fopen($path, "r");
    $contents = fread($handle, filesize($path));
    fclose($handle);
    if (strpos($contents, 'Report Builder Export Tool')) {
        // it's an old style report
        require_once DIR_FS_MODULES . 'phreeform/functions/reportwriter.php';
        if (!($report = import_text_params(file($path)))) {
            return false;
        }
    } else {
        // assume it's a new xml type
        if (!($report = xml_to_object($contents))) {
            return false;
        }
        if (is_object($report->PhreeformReport)) {
            $report = $report->PhreeformReport;
        }
        // remove container tag
    }
    if ($RptName != '') {
        $report->title = $RptName;
    }
    // replace the title if provided
    // error check
    $result = $db->Execute("select id from " . TABLE_PHREEFORM . "\n\t  where doc_title = '" . addslashes($report->title) . "' and doc_type <> '0'");
    if ($result->RecordCount() > 0) {
        // the report name already exists, if file exists error, else write
        $rID = $result->fields['id'];
        if (file_exists($save_path . 'pf_' . $rID)) {
            // file exists - error and return
            $messageStack->add(sprintf(PHREEFORM_REPDUP, $report->title), 'error');
            return false;
        }
    }
    if (!($result = save_report($report, $rID, $save_path))) {
        return false;
    }
    return true;
}