<?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/EcmInsideOrders/EcmInsideOrder.php');
require_once ('include/time.php');
require_once ('include/json_config.php');

// add jquery
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css"/>';
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-2.1.0.min.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-ui/ui/jquery-ui.js"></script>';

$json_config = new json_config ();

$focus = new EcmInsideOrder ();

if (isset ( $_REQUEST ['record'] )) {
	$focus->retrieve ( $_REQUEST ['record'] );
	$focus->format_all_fields ();
	$OPT ['status'] = $focus->status;
	$rw_id=$focus->SaveProductionRw($focus->id);
	$pw_id=$focus->SaveProductionPw($focus->id,$rw_id);
}


$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmInsideOrders';
$btn .= '<input name="quote_pdf" id="quote_pdf" title="Show PDF" accessKey="" class="button" onclick="window.open(\'index.php?module=EcmInsideOrders&action=createPDF&to_pdf=1&pdf_type=\'+$(\'#pdf_type\').val()+\'&record=' . $_REQUEST ['record'] . '\',\'_blank\');" type="button" value="Pokaż PDF"></div>';
$edit->ss->assign ( "CREATE_PDF", $btn );
$edit->ss->assign ( "CREATED_BY_NAME", $focus->created_by_name );
$edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name );
$edit->ss->assign ( 'FOCUS', $focus);
$edit->ss->assign ( 'rw_id', $rw_id);
$edit->ss->assign ( 'pw_id', $pw_id);
$edit->ss->assign('POSITION_LIST',$position_list);
$edit->ss->assign ( 'MOD', $mod_strings);
$edit->ss-> display('modules/EcmInsideOrders/tpl/SaveProduction.tpl'); //4


// loading view
//echo '<link rel="stylesheet" type="text/css" href="modules/EcmInsideOrders/javascript/helper.css" media="screen" /><div class="loading_panel"></div>';
?>