/*  */
function mode_save_detail(path, sval, mode, dform, act, ERI, stype, rpstr, ldiv, mtype, mutp) {
	// 存檔檢查 
	if(!mode_save_check(path, sval, mode, dform, ERI, mutp)) return;
	// 存檔 
	var loary = JSON.parse(return_language_str(path, sval, '', '', ''));
	//if (confirm(((loary['CONFIRM_SUBMIT']) ? loary['CONFIRM_SUBMIT']+'?' : 'CONFIRM_SUBMIT'))) {
	loading_create('Y');
	var djson = (fromid_output_json(dform,'name')).replace(/'/g, "''"),mdir = '',perm = '';
	var url = path+'core/cw5e_engine_detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+
			  '&mode='+mode+'&mutp='+mutp+'&act='+act+'&verlen='+(djson.length).toString();
	if (stype == '1' || stype == '2') {
		var nmary = ['exec','qwe','sor','itms'];
		rpstr = rpstr.split(',');
		for (var i = 0; i < nmary.length; i++) {
			if ((rpstr[i]) && $('#'+rpstr[i]+mtype).length > 0) {
				if (perm != '') perm += '&';
				perm += nmary[i]+'='+EncodeURLutf8($('#'+rpstr[i]+mtype).val());
			}
		}
	}
	$.ajax({
		url: url,
		type: 'POST',
		data: 'htmljson='+EncodeURLutf8(djson),
		beforeSend: function(){
			// 開始前執行 
		},
		success: function(msg){
			// 成功後執行 
			//console.log(msg);
			var ret_msg = JSON.parse(msg);
			if (ret_msg[0].result == 'false') {
				alert(ret_msg[0].message);
				loading_close('');
				return false;
			} else {
				// alert(((loary['DATA_SAVED']) ? loary['DATA_SAVED']+'!' : 'DATA_SAVED'));
				if (ret_msg[0].message) alert(ret_msg[0].message);
				if (ret_msg[0].ERI) {
					switch (mutp) {
						case 'R': mdir = 'manage'; break;
						case 'B':
						default: mdir = 'modules'; break;
					}
					switch (stype) {
						case '1':
							// 頁面刷新 
							$('#WEB_CURR_EDIT').val(0);$('#WEB_FOCS_NAME').val('');
							if (ret_msg[0].rnum) $('#result_num_'+mtype).val(ret_msg[0].rnum);
							post_redirect(ldiv, perm, path+mdir+'/'+mode+'/detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&mutp='+mutp+'&act=view&ERI='+ret_msg[0].ERI);
							break;
						case '2':
							if (ERI.length > 0) {
								// 頁面刷新 20170517 
								$('#WEB_CURR_EDIT').val(0);$('#WEB_FOCS_NAME').val('');
								if (ret_msg[0].rnum) $('#result_num_'+mtype).val(ret_msg[0].rnum);
								post_redirect(ldiv, perm, path+mdir+'/'+mode+'/detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&mutp='+mutp+'&act=view&ERI='+ret_msg[0].ERI);
							} else {
								// 連續新增 20170517 
								$('#WEB_CURR_EDIT').val(1);$('#WEB_FOCS_NAME').val('');
								post_redirect(ldiv, perm, path+mdir+'/'+mode+'/detail.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+'&mutp='+mutp+'&act=add&SERI='+ret_msg[0].ERI);
							}
							break;
						case '0':
						default:
							// 跳轉列表頁 
							$('#WEB_CURR_EDIT').val(0);$('#WEB_FOCS_NAME').val('');
							$('#colapi_search_'+mtype).collapsible('enable');
							eval('if (typeof search_submit_'+mtype+' == "function") search_submit_'+mtype+'();');
							break;
					}
				}
				if (ret_msg[0].rpt) {
					var rpt = ret_msg[0].rpt;
					//open_report_show(rpt.path, rpt.frnm, rpt.proj, rpt.famt, rpt.othr);
					popup_win(path+'core/cw5e_save_print.php?sid='+sval+'&parent='+EncodeURLutf8(path)+'&mode='+mode+
							  '&sqls='+EncodeURLutf8(rpt.sqls)+'&path='+EncodeURLutf8(rpt.path)+
							  '&frnm='+EncodeURLutf8(rpt.frnm)+'&proj='+EncodeURLutf8(rpt.proj)+
							  '&famt='+EncodeURLutf8(rpt.famt)+'&othr='+EncodeURLutf8(rpt.othr),
							  'CS Report System',
							  $(window).width(),
							  $(window).height());
				}
			}
		},
		error: function(msg){
			// 失敗後執行 
			alert(msg);
			console.log(msg);
			loading_close('');
		},
		complete: function(msg){
			// 完成後執行 
			// console.log(msg);
		}
	});
	//}
}