198 lines
6.4 KiB
PHP
198 lines
6.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
if (!defined('sugarEntry') || !sugarEntry)
|
||
|
|
die('Not A Valid Entry Point');
|
||
|
|
|
||
|
|
//require_once('modules/EcmGroupSales/HeaderMenu.php');
|
||
|
|
|
||
|
|
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
|
||
|
|
|
||
|
|
require_once('modules/EcmReceipts/EcmReceipt.php');
|
||
|
|
require_once('modules/EcmReceipts/Forms.php');
|
||
|
|
require_once('include/time.php');
|
||
|
|
require_once('include/json_config.php');
|
||
|
|
|
||
|
|
$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;
|
||
|
|
|
||
|
|
$focus = new EcmReceipt();
|
||
|
|
|
||
|
|
if (isset($_REQUEST['record'])) {
|
||
|
|
$focus->retrieve($_REQUEST['record']);
|
||
|
|
$focus->format_all_fields();
|
||
|
|
|
||
|
|
if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') {
|
||
|
|
$focus->doNotAccepted();
|
||
|
|
}
|
||
|
|
// echo '<pre>' . var_export($focus->getPositionList(true), true);
|
||
|
|
// exit;
|
||
|
|
$focus->position_list = str_replace('"', '\"', $focus->getPositionList());
|
||
|
|
$t = $focus->calculate($focus->getPositionList(true));
|
||
|
|
|
||
|
|
$to_paid = format_number($t['total']);
|
||
|
|
|
||
|
|
if (!$focus->prepaid) {
|
||
|
|
$focus->prepaid = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!$focus->paid_val) {
|
||
|
|
$focus->paid_val = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
//echo $focus->prepaid.' '.$focus->paid_val;
|
||
|
|
|
||
|
|
$left = format_number($t['total'] - $focus->paid_val - $focus->prepaid);
|
||
|
|
$weight_netto = $t['weight_netto'];
|
||
|
|
|
||
|
|
$OPT['status'] = $focus->status;
|
||
|
|
} else {
|
||
|
|
$OPT['new_number'] = true;
|
||
|
|
|
||
|
|
$datef = $current_user->getPreference('datef');
|
||
|
|
|
||
|
|
if ($datef != '') {
|
||
|
|
$sugar_config['datef'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$focus->register_date = date($datef);
|
||
|
|
$focus->payment_date = date($datef, mktime() + 30 * 24 * 60 * 60);
|
||
|
|
$focus->sell_date = date($datef);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (isset($_REQUEST['send_email']) && $_REQUEST['send_email'] == '1') {
|
||
|
|
$OPT['setTab'] = 'EMAIL';
|
||
|
|
}
|
||
|
|
|
||
|
|
$tmp = $current_user->getPreference('num_grp_sep');
|
||
|
|
|
||
|
|
$tmp = ".";
|
||
|
|
if (!isset($tmp) || $tmp == '' || $tmp == NULL) {
|
||
|
|
$tmp = $sugar_config['default_number_grouping_seperator'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$OPT['sep_1000'] = $tmp;
|
||
|
|
|
||
|
|
$tmp = $current_user->getPreference('dec_sep');
|
||
|
|
|
||
|
|
$tmp = ",";
|
||
|
|
|
||
|
|
if (!isset($tmp) || $tmp == '' || $tmp == NULL) {
|
||
|
|
$tmp = $sugar_config['default_decimal_seperator'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$OPT['dec_sep'] = $tmp;
|
||
|
|
|
||
|
|
$tmp = $current_user->getPreference('default_currency_significant_digits');
|
||
|
|
|
||
|
|
if (!isset($tmp) || $tmp == '' || $tmp == NULL) {
|
||
|
|
$tmp = $sugar_config['default_currency_significant_digits'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$OPT['dec_len'] = $tmp;
|
||
|
|
$OPT['default_unit'] = '1';
|
||
|
|
$OPT['default_vat'] = '19.00';
|
||
|
|
$OPT['default_category'] = '';
|
||
|
|
$OPT['invoice']['type'] = $focus->type;
|
||
|
|
$OPT['to_is_vat_free'] = $focus->to_is_vat_free;
|
||
|
|
|
||
|
|
$cq = $current_user->getPreference('confirm_receipts');
|
||
|
|
|
||
|
|
$OPT['user']['confirm_receipts'] = ((isset($cq) && $cq) ? 1 : 0);
|
||
|
|
|
||
|
|
$json = getJSONobj();
|
||
|
|
|
||
|
|
$qw = 'select name,id,value from ecmvats where deleted = \'0\' order by name';
|
||
|
|
$w = $GLOBALS[db]->query($qw);
|
||
|
|
|
||
|
|
$nvats = mysql_num_rows($w);
|
||
|
|
|
||
|
|
while ($r = $GLOBALS[db]->fetchByAssoc($w)) {
|
||
|
|
$VAT[$r['id']] = array(
|
||
|
|
'id' => $r['id'],
|
||
|
|
'name' => $r['name'],
|
||
|
|
'value' => $r['value']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$show_pdf = $current_user->getPreference('show_pdf_in_div');
|
||
|
|
|
||
|
|
if (!isset($show_pdf)) {
|
||
|
|
require_once('modules/EcmGroupSales/EcmGroupSale.php');
|
||
|
|
|
||
|
|
$cc = EcmGroupSale::loadSettings();
|
||
|
|
$show_pdf = $cc['show_pdf_in_div_global'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$scriptOpt = '
|
||
|
|
<script language="javascript">
|
||
|
|
var SHOW_PDF_IN_DIV =' . $show_pdf . ';
|
||
|
|
var UNIT =' . str_replace('"', '\"', $json->encode($GLOBALS['app_list_strings']['ecmproducts_unit_dom'])) . ';
|
||
|
|
var VAT = ' . str_replace('"', '\"', $json->encode($VAT)) . ';
|
||
|
|
var OPT = ' . str_replace('"', '\"', $json->encode($OPT)) . ';
|
||
|
|
var MOD = ' . str_replace('"', '\"', $json->encode($mod_strings)) . ';
|
||
|
|
var N;
|
||
|
|
</script>';
|
||
|
|
|
||
|
|
echo $scriptOpt;
|
||
|
|
|
||
|
|
require_once('include/MVC/View/SugarView.php');
|
||
|
|
require_once('modules/EcmReceipts/view/DetailView/view.detail.my.php');
|
||
|
|
|
||
|
|
$edit = new ViewDetailMy();
|
||
|
|
|
||
|
|
$edit->ss = new Sugar_Smarty();
|
||
|
|
$edit->module = 'EcmReceipts';
|
||
|
|
$edit->bean = $focus;
|
||
|
|
$edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl';
|
||
|
|
$edit->bean->total = unformat_number($edit->bean->total);
|
||
|
|
|
||
|
|
$edit->preDisplay();
|
||
|
|
|
||
|
|
$arr_template = $focus->getTemplateList();
|
||
|
|
|
||
|
|
if (isset($focus->template_id)) {
|
||
|
|
$edit->ss->assign('DOCUMENT_TEMPLATES_OPTIONS', get_select_options_with_id($arr_template, $focus->template_id));
|
||
|
|
} else {
|
||
|
|
$edit->ss->assign('DOCUMENT_TEMPLATES_OPTIONS', get_select_options_with_id($arr_template, ''));
|
||
|
|
}
|
||
|
|
|
||
|
|
$edit->ss->assign('POSITION_LIST', $focus->position_list);
|
||
|
|
$edit->ss->assign('EMAIL_LINK', $focus->createSendEmailLink());
|
||
|
|
$edit->ss->assign('LEFT', $left);
|
||
|
|
$edit->ss->assign('TO_PAID', $to_paid);
|
||
|
|
$edit->ss->assign('WEIGHT_TOTAL', $weight_netto);
|
||
|
|
$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>Paragon</option><br /><br />';
|
||
|
|
$desc.='<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.location = \'index.php?module=EcmReceipts&action=previewPDF&to_pdf=1&record='.$_REQUEST['record'].'\';" type="button" value="Pokaż PDF">';
|
||
|
|
$edit->ss->assign("CATALOGUE",$desc);
|
||
|
|
|
||
|
|
//$email_link_tab = '<script language="javascript">YAHOO.util.Event.addListener(window, "load", function(){setEMAIL = function(){' . $focus->createSendEmailLink() . '}});</script>';
|
||
|
|
//$edit->ss->assign('EMAIL_LINK_TAB', $email_link_tab);
|
||
|
|
|
||
|
|
$qr = 'select id from ecmstockdoccorrects where ecmreceipt_id = \'' . $focus->id . '\';';
|
||
|
|
$r = $GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query($qr));
|
||
|
|
|
||
|
|
if ($r['id']) {
|
||
|
|
$edit->ss->assign('hasCorrect', $r['id']);
|
||
|
|
}
|
||
|
|
|
||
|
|
$edit->ss->assign('OPT', $OPT);
|
||
|
|
|
||
|
|
echo $edit->display();
|
||
|
|
|
||
|
|
//echo '<div id="subpanels_div">';
|
||
|
|
//require_once('subpanels.php');
|
||
|
|
//echo '</div>';
|