Files
2025-05-12 15:44:39 +00:00

101 lines
4.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/EcmAgreements/EcmAgreement.php');
require_once ('include/time.php');
require_once ('include/json_config.php');
//add jquery
$json_config = new json_config ();
$focus = new EcmAgreement ();
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/EcmAgreements/views/DetailView/view.detail.my.php');
//create position list table
$pl = $focus->getPositionList();
global $db;
$edit = new ViewDetailMy ();
$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmAgreements';
//add pdf buttons
/*
$btn = '<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmAgreements&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="Harmonogram">';
$edit->ss->assign("CREATE_PDF",$btn);
*/
$get_saved_templates_query = "SELECT value0 AS template_name FROM operating_values WHERE name='AgreementTemplates' AND module_name='EcmAgreements' AND id='" . $focus->pdf_template . "'order by value0";
$get_saved_templates_result = $db->query($get_saved_templates_query);
$get_saved_templates_array = array();
$row = $db->fetchByAssoc($get_saved_templates_result);
$edit->ss->assign('TEMPLATES', $row['template_name']);
/*
$btn = '<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmAgreements&action=drawAgreement&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="Umowa">';
$edit->ss->assign("CREATE_PDF2",$btn);*/
$btnpdf = '<input name="quote_pdf" id="quote_pdf" title="Utwórz PDF z szablonu" class="button" onclick="window.open(\'index.php?module=EcmAgreements&action=createPDF&to_pdf=1&generateFromTeplate=1&record='.$_REQUEST['record'].'\',\'_blank\');" type="button" value="PDF z szablonu">';
$edit->ss->assign("CREATE_PDF_FROM_TEMPLATE",$btnpdf);
unset($btnpdf);
$create_cor=false;
if($focus->type!='correct'){
$create_cor=true;
}
$qq = "SELECT * from ecmagreements_aditional_fields_pdf WHERE ecmagreements_id='" . $focus->id ."'";
$rr = $focus->db->query($qq);
$additiona_field = '';
while($row = $focus->db->fetchByAssoc($rr)){
$additiona_field .= $row['field_name'] . " " . $row['filed_value'] ."<br>";
}
$edit->ss->assign("additiona_field",$additiona_field);
$can_edit = false;
global $current_user;
if ($focus->assigned_user_id == $current_user->id || is_admin($current_user))
$can_edit = true;
$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->bean = $focus;
$edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl';
$edit->preDisplay ();
//check number
$db = $GLOBALS['db'];
$res = $db->query("SELECT id FROM ecmagreements WHERE document_no='$focus->document_no'");
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, 'EcmAgreements' );
echo $subpanel->display ();
//loading view
echo '<link rel="stylesheet" type="text/css" href="modules/EcmAgreements/javascript/helper.css" media="screen" /><div class="loading_panel"></div>';
?>