142 lines
7.1 KiB
PHP
Executable File
142 lines
7.1 KiB
PHP
Executable File
<?php
|
|
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
|
die ( 'Not A Valid Entry Point' );
|
|
|
|
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
|
|
|
|
require_once ('modules/EcmInvoiceOuts/EcmInvoiceOut.php');
|
|
|
|
|
|
require_once ('include/time.php');
|
|
|
|
require_once ('include/json_config.php');
|
|
|
|
//add jquery
|
|
|
|
echo '<script type="text/javascript" src="include/ECM/SearchProductTable.js"></script>';
|
|
|
|
|
|
$json_config = new json_config ();
|
|
|
|
$focus = new EcmInvoiceOut ();
|
|
|
|
if (isset ( $_REQUEST ['record'] )) {
|
|
$focus->retrieve ( $_REQUEST ['record'] );
|
|
$focus->format_all_fields ();
|
|
|
|
$OPT ['status'] = $focus->status;
|
|
}
|
|
|
|
require_once ('include/MVC/View/SugarView.php');
|
|
|
|
require_once ('modules/EcmInvoiceOuts/views/DetailView/view.detail.my.php');
|
|
|
|
//create position list table
|
|
$pl = $focus->getPositionList();
|
|
$kp=false;
|
|
$z=$focus->db->query("select id from ecmnewkpkws where so_id='$focus->id'");
|
|
$dd=$focus->db->fetchByAssoc($z);
|
|
|
|
if($dd['id']==""){
|
|
$kp=true;
|
|
}
|
|
|
|
$edit = new ViewDetailMy ();
|
|
$edit->ss = new Sugar_Smarty ();
|
|
$edit->module = 'EcmInvoiceOuts';
|
|
|
|
//SendMailFromUserAccount($focus->id,'EcmInvoiceOuts',$focus->parent_id);
|
|
$btn = '<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmInvoiceOuts&action=createPDF&to_pdf=1&show_img=\'+$(\'#pdf_images\').val()+\'&show_ean=\'+$(\'#pdf_ean\').val()+\'&show_ean2=\'+$(\'#pdf_ean2\').val()+\'&show_recipient_code=\'+$(\'#pdf_recipient_code\').val()+\'&show_remarks=\'+$(\'#pdf_remarks\').val()+\'&record='.$_REQUEST['record'].'\',\'_blank\');" type="button" value="Pokaż PDF"></div>';
|
|
$edit->ss->assign("CREATE_PDF",$btn);
|
|
|
|
$btn = '<input id="duplicate_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmInvoiceOuts&action=createPDF&to_pdf=1&isDuplicatePDF=1&&record='.$_REQUEST['record'].'\',\'_blank\');" type="button" value="Generuj duplikat"></div>';
|
|
$edit->ss->assign("CREATE_DUPLICATE_PDF",$btn);
|
|
|
|
$btn ='<input title="Generuj Katalog" class="button" onclick="if($(\'#div_cat\').css(\'display\') == \'none\'){$(\'#div_cat\').show(\'slow\'); } else { $(\'#div_cat\').hide(\'slow\'); }" type="button" name="productcat" id="productcat" value="Generuj Katalog">';
|
|
$btn .= '<div id="div_cat" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
|
|
$btn .= 'EAN: <select name="cat_ean" id="cat_ean"><option value="1">1</option><option value="2">2</option><option value="0">Brak</option></select><br /><br />';
|
|
$btn .= '<input name="cat_pdf" id="cat_pdf" title="Show Cat" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmInvoiceOuts&action=createCatalogue&to_pdf=1&show_ean=\'+$(\'#cat_ean\').val()+\'&record='.$_REQUEST['record'].'\',\'_blank\');" type="button" value="Pokaż Katalog"></div>';
|
|
$edit->ss->assign("CATALOGUE",$btn);
|
|
|
|
$btn ='<input title="Generuj XLS" class="button" onclick="if($(\'#div_xls\').css(\'display\') == \'none\'){$(\'#div_xls\').show(\'slow\'); } else { $(\'#div_xls\').hide(\'slow\'); }" type="button" name="productxls" id="productxls" value="Generuj XLS">';
|
|
$btn .= '<div id="div_xls" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
|
|
$btn .= 'EAN: <select name="xls_ean" id="xls_ean"><option value="1">1</option><option value="2">2</option><option value="0">Brak</option></select><br /><br />';
|
|
$btn .= '<input name="cat_xls" id="cat_xls" title="Generuj XLS" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmInvoiceOuts&action=createXLS&to_pdf=1&show_ean=\'+$(\'#xls_ean\').val()+\'&record='.$_REQUEST['record'].'\',\'_blank\');" type="button" value="Pokaż XLS"></div>';
|
|
$edit->ss->assign("CREATE_XLS",$btn);
|
|
$create_cor=false;
|
|
if($focus->type!='correct'){
|
|
$create_cor=true;
|
|
}
|
|
|
|
if($focus->check_mail_addresses()==1){
|
|
$btn='<input name="send_mail" id="send_mail" class="button" type="button" value="'.$mod_strings['LBL_SEND_MAIL'].'" onClick="SendMail(\''.$focus->id.'\',\'EcmInvoiceOuts\',\''.$focus->parent_id.'\');">';
|
|
$edit->ss->assign("SEND_PDF",$btn);
|
|
echo '<div id="sendreturn" style="display:none;"></div>';
|
|
}
|
|
$can_edit = false;
|
|
global $current_user;
|
|
if ($focus->assigned_user_id == $current_user->id || is_admin($current_user))
|
|
$can_edit = true;
|
|
|
|
if($focus->type=='normal'){
|
|
$btne='<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}"
|
|
class="button" onclick="this.form.return_module.value=\'EcmInvoiceOuts\';
|
|
this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\''.$focus->id.'\';
|
|
this.form.action.value=\'EditView\';" type="submit" name="Edit" id="edit_button" value="Edytuj"> ';
|
|
} else {
|
|
$btne='<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}"
|
|
class="button" onclick="window.location=\'index.php?module=EcmInvoiceOuts&return_module=EcmInvoiceOuts&action=EditView&return_action=index&record='.$focus->id.'&correctEdit=true&isDuplicate=false\';" type="button" name="Edit" id="edit_button" value="Edytuj"> ';
|
|
}
|
|
|
|
$edit->ss->assign('editButton',$btne);
|
|
$edit->ss->assign("CAN_EDIT", $can_edit);
|
|
$edit->ss->assign("CREATE_COR",$create_cor);
|
|
$edit->ss->assign("CREATED_BY_NAME", $focus->created_by_name);
|
|
$edit->ss->assign("MODIFIED_BY_NAME", $focus->modified_by_name);
|
|
$edit->ss->assign("CREATE_KP", $kp);
|
|
|
|
$a = new EcmSale();
|
|
$a->retrieve($focus->so_id);
|
|
$the_array ['ZS_NO'] = "<a target='_blank' href='index.php?module=EcmSales&action=DetailView&record=$a->id'>".$a->document_no."</a>";
|
|
$edit->ss->assign("zs_no", $the_array ['ZS_NO']);
|
|
$zap=$focus->db->query("select id,document_no from ecmstockdocouts where id in ('".implode("','",explode("@",$focus->wz_id))."')");
|
|
$array=[];
|
|
while($wz=$focus->db->fetchByAssoc($zap)){
|
|
|
|
$array[]="<a target='_blank' href='index.php?module=EcmStockDocOuts&action=DetailView&record=".$wz['id']."'>".$wz['document_no']."</a>";
|
|
}
|
|
|
|
$edit->ss->assign("wz_no", implode(",",$array));
|
|
//$focus->prepaid = $focus->prepaid;
|
|
//get paid left
|
|
if($focus->type=='correct'){
|
|
$edit->ss->assign('PAID_LEFT', format_number(abs($focus->total_brutto)- ($focus->prepaid + $focus->paid_val)));
|
|
} else {
|
|
$edit->ss->assign('PAID_LEFT', format_number($focus->total_brutto- ($focus->prepaid + $focus->paid_val)));
|
|
}
|
|
|
|
if ($focus->parent_id === '682d24c0-0f28-83c5-a840-64d9bbb03632' || $focus->parent_id === '226a168c-2fef-b92f-0918-6200de91bb31') {
|
|
$edit->ss->assign('EDI', true);
|
|
}
|
|
|
|
$edit->bean = $focus;
|
|
$edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl';
|
|
|
|
$edit->preDisplay ();
|
|
|
|
//check number
|
|
$db = $GLOBALS['db'];
|
|
$res = $db->query("SELECT id FROM ecminvoiceouts WHERE document_no='$focus->document_no' AND type='$focus->type' AND deleted='0'");
|
|
if ($res->num_rows > 1) {
|
|
echo '<h1 style="color: red;">Błąd numeracji, skontaktuj się z administratorem! Nie drukuj/publikuj dokumentu!</h1>';
|
|
}
|
|
|
|
|
|
|
|
echo $edit->display ();
|
|
|
|
require_once ('include/SubPanel/SubPanelTiles.php');
|
|
$subpanel = new SubPanelTiles ( $focus, 'EcmInvoiceOuts' );
|
|
echo $subpanel->display ();
|
|
//loading view
|
|
echo '<link rel="stylesheet" type="text/css" href="modules/EcmInvoiceOuts/javascript/helper.css" media="screen" /><div class="loading_panel"></div>'; |