Ejemplo n.º 1
0
function createPDFAndSaveFile($templates, $focus, $modFocus, $file_name, $moduleName, $language)
{
    global $x0b, $x0c, $x0d, $x0e, $x0f, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x1a, $x1b, $x1c, $x1d, $x1e, $x1f, $x20, $x21, $x22, $x23, $x24, $x25, $x26;
    $db = "adb";
    $cu = "current_user";
    $dl = "default_language";
    global ${$db}, ${$cu}, ${$dl};
    $date_var = $x10("Y-m-d H:i:s");
    $ownerid = $focus->column_fields["assigned_user_id"];
    if (!isset($ownerid) || $ownerid == "") {
        $ownerid = ${$cu}->id;
    }
    $current_id = ${$db}->getUniqueID("vtiger_crmentity");
    $templates = $x1d($templates, ";");
    $Templateids = $x11(";", $templates);
    $x17("memory_limit", "128M");
    $name = "";
    if (!$language || $language == "") {
        $language = ${$dl};
    }
    foreach ($Templateids as $templateid) {
        $PDFContent = new PDFContent($templateid, $moduleName, $modFocus, $language);
        $pdf_content = $PDFContent->getContent();
        $Settings = $PDFContent->getSettings();
        if ($name == "") {
            $name = $PDFContent->getFilename();
        }
        $header_html = $x14($pdf_content["header"], ENT_COMPAT, "utf-8");
        $body_html = $x14($pdf_content["body"], ENT_COMPAT, "utf-8");
        $footer_html = $x14($pdf_content["footer"], ENT_COMPAT, "utf-8");
        $encoding = $Settings["encoding"];
        if ($Settings["orientation"] == "landscape") {
            $format = $Settings["format"] . "-L";
        } else {
            $format = $Settings["format"];
        }
        if (!isset($mpdf)) {
            $mpdf = new mPDF('', $format, '', 'Arial', $Settings["margin_left"], $Settings["margin_right"], 0, 0, $Settings["margin_top"], $Settings["margin_bottom"]);
            $mpdf->SetAutoFont();
            @$mpdf->SetHTMLHeader($header_html);
        } else {
            @$mpdf->SetHTMLHeader($header_html);
            @$mpdf->WriteHTML('<pagebreak sheet-size="' . $format . '" margin-left="' . $Settings["margin_left"] . 'mm" margin-right="' . $Settings["margin_right"] . 'mm" margin-top="0mm" margin-bottom="0mm" margin-header="' . $Settings["margin_top"] . 'mm" margin-footer="' . $Settings["margin_bottom"] . 'mm" />');
        }
        @$mpdf->SetHTMLFooter($footer_html);
        @$mpdf->WriteHTML($body_html);
    }
    $upload_file_path = decideFilePath();
    if ($name != "") {
        $file_name = $name . ".pdf";
    }
    $mpdf->Output($upload_file_path . $current_id . "_" . $file_name);
    $filesize = $x13($upload_file_path . $current_id . "_" . $file_name);
    $filetype = "application/pdf";
    $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)";
    $params1 = array($current_id, ${$cu}->id, $ownerid, "Documents Attachment", $focus->column_fields["description"], ${$db}->formatDate($date_var, true), ${$db}->formatDate($date_var, true));
    ${$db}->pquery($sql1, $params1);
    $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)";
    $params2 = array($current_id, $file_name, $focus->column_fields["description"], $filetype, $upload_file_path);
    $result = ${$db}->pquery($sql2, $params2);
    $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)';
    ${$db}->pquery($sql3, array($focus->id, $current_id));
    $sql4 = "UPDATE vtiger_notes SET filesize=?, filename=? WHERE notesid=?";
    ${$db}->pquery($sql4, array($filesize, $file_name, $focus->id));
    return true;
}
Ejemplo n.º 2
0
    $xx12->id = $xx10;
}
if ($xx11 == "Invoice") {
    $xx13 = "1";
} elseif ($xx11 == "SalesOrder") {
    $xx13 = "2";
} elseif ($xx11 == "PurchaseOrder") {
    $xx13 = "3";
} elseif ($xx11 == "Quotes") {
    $xx13 = "4";
} else {
    $xx13 = "";
}
if ($xx13 != "") {
    $xx14 = $xx11 . "_" . $xx10;
    $xx15 = new PDFContent($xx13, $xx11, $xx12, $_REQUEST["language"]);
    $xx16 = $xx15->getContent();
    $xx17 = $xx15->getSettings();
    $xx18 = $xx1d($xx16["header"], ENT_COMPAT, "utf-8");
    $xx19 = $xx1d($xx16["body"], ENT_COMPAT, "utf-8");
    $xx1a = $xx1d($xx16["footer"], ENT_COMPAT, "utf-8");
    if ($xx17["orientation"] == "landscape") {
        $xx1b = $xx17["format"] . "-L";
    } else {
        $xx1b = $xx17["format"];
    }
    if (!isset($xx1c)) {
        $xx1c = new mPDF('', $xx1b, '', 'Arial', $xx17["margin_left"], $xx17["margin_right"], 0, 0, $xx17["margin_top"], $xx17["margin_bottom"]);
        $xx1c->SetAutoFont();
        @$xx1c->SetHTMLHeader($xx18);
    } else {
Ejemplo n.º 3
0
$xx10 = CRMEntity::getInstance($xx0f);
if ($xx0f == "Invoice") {
    $xx11 = "1";
} elseif ($xx0f == "SalesOrder") {
    $xx11 = "2";
} elseif ($xx0f == "PurchaseOrder") {
    $xx11 = "3";
} elseif ($xx0f == "Quotes") {
    $xx11 = "4";
} else {
    $xx11 = "";
}
if ($xx11 != "") {
    $xx10->retrieve_entity_info($xx0e, $xx0f);
    $xx10->id = $xx0e;
    $xx12 = new PDFContent($xx11, $xx0f, $xx10, $_REQUEST["language"]);
    $xx13 = $xx12->getContent();
    $xx14 = $xx12->getSettings();
    $xx15 = $xx1e($xx13["header"], ENT_COMPAT, "utf-8");
    $xx16 = $xx1e($xx13["body"], ENT_COMPAT, "utf-8");
    $xx17 = $xx1e($xx13["footer"], ENT_COMPAT, "utf-8");
    if ($xx14["orientation"] == "landscape") {
        $xx18 = $xx14["format"] . "-L";
    } else {
        $xx18 = $xx14["format"];
    }
    $xx19 = new mPDF('', $xx18, '', 'Arial', $xx14["margin_left"], $xx14["margin_right"], 0, 0, $xx14["margin_top"], $xx14["margin_bottom"]);
    $xx19->SetAutoFont();
    @$xx19->SetHTMLHeader($xx15);
    @$xx19->SetHTMLFooter($xx17);
    @$xx19->WriteHTML($xx16);