Files
crm.twinpol.com/modules/EcmPrepaymentInvoices2/DetailView.php
2025-05-12 15:44:39 +00:00

89 lines
3.4 KiB
PHP
Executable File

<?
error_reporting(LC_ALL);
ini_set('display_errors', '1');
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
require_once('modules/EcmPrepaymentInvoices/EcmPrepaymentInvoice.php');
//require_once('modules/EcmPrepaymentInvoices/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmPrepaymentInvoice();
if(isset($_REQUEST['record']))$focus->retrieve($_REQUEST['record']);
$file = 'modules/EcmGroupSales/EcmGroupSale.php';
if(file_exists($file)) {
$cc = array();
require_once($file);
$cc = EcmGroupSale::loadSettings();
}
$OPT = array();
$OPT['row_item_height'] = $cc['row_item_height'];
$OPT['row_item_height_selected'] = $cc['row_item_height_selected'];
$OPT['rows_on_item_list'] = $cc['rows_on_item_list'];
$OPT['position_table_height'] = $OPT['row_item_height']*$OPT['rows_on_item_list']+40+$OPT['rows_on_item_list']*4;
$OPT['quick_product_item_adding'] = $cc['quick_product_item_adding'];
global $app_list_strings;
$focus->position_list = str_replace('&quot;','\"',$focus->getPositionListDetailView());
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmPrepaymentInvoices/views/DetailView/view.detail.php');
$detail = new EcmPrepaymentInvoicesViewDetail();
$detail->ss = new Sugar_Smarty();
$detail->module = 'EcmPrepaymentInvoices';
$detail->bean = $focus;
$detail->tplFile = 'include/DetailView/DetailView.tpl';
$detail->ss->assign("POSITION_LIST", $focus->position_list);
//get other prepaymentinvoices info
$res = $GLOBALS['db']->query("SELECT id, document_no, inv_value FROM ecmprepaymentinvoices WHERE ecmsale_id='".$focus->ecmsale_id."'");
$total = 0;
$other_inv = '';
while ($row = $GLOBALS['db']->fetchByAssoc($res)) {
if ($row['id']==$focus->id) continue;
$other_inv.='<a href="index.php?module=EcmPrepaymentInvoices&action=DetailView&record='.$row['id'].'">'.$row['document_no'].'</a> ';
$total+=$row['inv_value'];
}
$detail->ss->assign('other_ecmprepaymentinvoices',$other_inv);
$detail->ss->assign('other_ecmprepayment_invoices_sum',$total);
$desc.='<input title="Generuj PDF" class="button" onclick="if(document.getElementById(\'div_desc\').style.display==\'none\')document.getElementById(\'div_desc\').style.display=\'block\';else document.getElementById(\'div_desc\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Generuj PDF">';
$desc .= '<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$desc .= 'Typ: <select name="preview_type" id="preview_type"><option value>Faktura zaliczkowa</option><br /><br />';
$desc.='<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmPrepaymentInvoices&action=previewPDF&to_pdf=1&record='.$_REQUEST['record'].'\';" type="button" value="Pokaż PDF">';
$detail->ss->assign("CATALOGUE",$desc);
$scriptOpt = '<script language="javascript">
var OPT = '.str_replace('&quot;','\"',$json->encode($OPT)).';
var MOD = '.str_replace('&quot;','\"',$json->encode($mod_strings)).';
var N;
</script>';
echo $scriptOpt;
$detail->preDisplay();
echo $detail->display();
?>