116 lines
3.8 KiB
PHP
116 lines
3.8 KiB
PHP
<?php
|
|
|
|
error_reporting(E_PARSE | E_WARNING);
|
|
$json = getJSONobj();
|
|
$pll = array();
|
|
$i = 0;
|
|
while (isset($_POST['p_' . $i])) {
|
|
$pll[] = $json->decode(htmlspecialchars_decode($_POST['p_' . $i]));
|
|
$_POST['p_' . $i] = '';
|
|
$i++;
|
|
}
|
|
$_POST = $json->decode(htmlspecialchars_decode($_POST['otherFormData']));
|
|
$_POST['position_list'] = $pll;
|
|
|
|
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '' && $_REQUEST['cache'] != "fromJava") {
|
|
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
|
|
|
|
$focus = new EcmInvoiceOutOld();
|
|
|
|
$method = (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? $_REQUEST['method'] : 'D';
|
|
$i = new EcmInvoiceOutOld();
|
|
$i->retrieve($_REQUEST['record']);
|
|
/*
|
|
//echo $i->createPdfFileName.' null<br>';
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, 'https://192.168.1.130/crm/index.php?action=Authenticate&module=Users&return_module=Users&return_action=Login&user_name=db&user_password=rudemodz&login_theme=Sugar&login_language=en_us');
|
|
//curl_setopt($ch, CURLOPT_POSTFIELDS,'user_name=db&user_password='.$pass.'');
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
|
|
$page = curl_exec($ch);
|
|
|
|
$up='https://192.168.1.130/crm/index.php?module=EcmInvoiceOutOlds&action=prdfg&type=&to_pdf=1&record='.$_REQUEST['record'].'';
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL, $up);
|
|
//echo $i.': '.$row['id'].'<br>';
|
|
$page = curl_exec($ch);
|
|
$date = new DateTime(date('Y-m-d'));
|
|
mkdir('pdfkopie/'.$date->format('Y-m-01'));
|
|
if (!file_exists('pdfkopie/'.$date->format('Y-m-01').'/'.$i->createPdfFileName())) {
|
|
$fp = fopen('pdfkopie/'.$date->format('Y-m-01').'/'.$i->createPdfFileName().'', 'w');
|
|
fwrite($fp, $page);
|
|
}
|
|
*/
|
|
$focus->getPDF($_REQUEST['record'], $method, null, $_REQUEST['preview_type']);
|
|
|
|
|
|
|
|
} else
|
|
|
|
if ($_REQUEST['cache'] == "fromJava" && $_GET['from'] != "EcmInvoiceOutOlds") {
|
|
$_SESSION['PDF_ECMINVOICEOUTOLDS'] = $_POST;
|
|
} else
|
|
|
|
if ($_GET['from'] == "EcmInvoiceOutOlds") {
|
|
require_once("modules/EcmInvoiceOutOlds/EcmInvoiceOutOld.php");
|
|
|
|
$focus = new EcmInvoiceOutOld();
|
|
|
|
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS']['record']) && $_SESSION['PDF_ECMINVOICEOUTOLDS']['record'] != '') {
|
|
|
|
$focus->retrieve($_SESSION['PDF_ECMINVOICEOUTOLDS']['record']);
|
|
}
|
|
|
|
if (!$focus->ACLAccess('Save')) {
|
|
|
|
ACLController::displayNoAccess(true);
|
|
|
|
sugar_cleanup(true);
|
|
}
|
|
|
|
foreach ($focus->column_fields as $field) {
|
|
|
|
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS'][$field])) {
|
|
|
|
$value = $_SESSION['PDF_ECMINVOICEOUTOLDS'][$field];
|
|
|
|
$focus->$field = $value;
|
|
}
|
|
}
|
|
|
|
foreach ($focus->additional_column_fields as $field) {
|
|
|
|
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS'][$field])) {
|
|
|
|
$value = $_SESSION['PDF_ECMINVOICEOUTOLDS'][$field];
|
|
|
|
$focus->$field = $value;
|
|
}
|
|
}
|
|
|
|
if (isset($_SESSION['PDF_ECMINVOICEOUTOLDS']['to_is_vat_free']) && $_SESSION['PDF_ECMINVOICEOUTOLDS']['to_is_vat_free'])
|
|
$focus->to_is_vat_free = 1;
|
|
else
|
|
$focus->to_is_vat_free = 0;
|
|
|
|
$json = getJSONobj();
|
|
|
|
$pl = $_SESSION['PDF_ECMINVOICEOUTOLDS']['position_list'];
|
|
|
|
$focus->position_list = $pl;
|
|
|
|
$focus->document_no = $_SESSION['PDF_ECMINVOICEOUTOLDS']['document_no'];
|
|
|
|
$focus->wz_id = $_SESSION['PDF_ECMINVOICEOUTOLDS']['out_id'];
|
|
|
|
$focus->ecmpaymentcondition_text = EcmInvoiceOutOld::getTranslation('EcmPaymentConditions', $focus->ecmpaymentcondition_id, $focus->ecmlanguage);
|
|
//die();
|
|
$focus->getPDF();
|
|
|
|
}
|