function parseDate(input, format) {
format = format || 'yyyy-mm-dd'; // default format
var parts = input.match(/(\d+)/g),
i = 0, fmt = {};
// extract date-part indexes from the format
format.replace(/(yyyy|dd|mm)/g, function(part) { fmt[part] = i++; });
return new Date(parts[fmt['yyyy']], parts[fmt['mm']]-1, parts[fmt['dd']]);
}
It is my Computer Notes. Using Guide : object-key or object-key-key e.g. Step 1 Blog Search : [mysql-run] and then Step 2 ctrl+F [mysql-run] {bookMark me : Ctrl+D}
2014年7月29日 星期二
2014年7月25日 星期五
generator-onchange onchange-update-table
text
{onchange}
var s160610="tableWrite?"+
"db="+DATABASE+""
+"&table=SALES_ORDER_PO_DESC"
+"&fields=VENDOR_PROMISE_DELIVERY_DATE,VENDOR_PROMISE_DELIVERY_INPUT_BY"
+"&key=recordID&value="+Xdata[thisRowNo]
+"&values='" +this.value +"'," +"'" +USER+"'"
+"&callback=?"
;
$.getJSON(s160610);
{/onchange}
$( '.SALES_ORDER_HEAD_CUSTOMER_NO' ).change();
document.getElementById('SALES_ORDER_HEAD.CUSTOMER_NO').onchange();
{onChange}
_refreshv2('SETTINGS.DESCRIPTION',this.value)
{/onChange}
{onchange}
var s=lookupTable('CODE','SETTINGS.RECORDID',this.value);
if(s=='G'){_refreshv2('PRODUCT.UNSPSC_CODE','N/A');}else{_refreshv2('PRODUCT.UNSPSC_CODE','');}
if(s=='G'){_refreshv2('PRODUCT.ITEM_NO','N/A');}else{_refreshv2('PRODUCT.ITEM_NO','');}
if(s=='C') {_refreshv2('PRODUCT.ISCOMMERCIAL',1);} else {_refreshv2('PRODUCT.ISCOMMERCIAL',0)}
{/onchange}
{onchange}
var s160610="tableWrite?"+
"db="+DATABASE+""
+"&table=SALES_ORDER_PO_DESC"
+"&fields=VENDOR_PROMISE_DELIVERY_DATE,VENDOR_PROMISE_DELIVERY_INPUT_BY"
+"&key=recordID&value="+Xdata[thisRowNo]
+"&values='" +this.value +"'," +"'" +USER+"'"
+"&callback=?"
;
$.getJSON(s160610);
{/onchange}
$( '.SALES_ORDER_HEAD_CUSTOMER_NO' ).change();
document.getElementById('SALES_ORDER_HEAD.CUSTOMER_NO').onchange();
{onChange}
_refreshv2('SETTINGS.DESCRIPTION',this.value)
{/onChange}
{onchange}
var s=lookupTable('CODE','SETTINGS.RECORDID',this.value);
if(s=='G'){_refreshv2('PRODUCT.UNSPSC_CODE','N/A');}else{_refreshv2('PRODUCT.UNSPSC_CODE','');}
if(s=='G'){_refreshv2('PRODUCT.ITEM_NO','N/A');}else{_refreshv2('PRODUCT.ITEM_NO','');}
if(s=='C') {_refreshv2('PRODUCT.ISCOMMERCIAL',1);} else {_refreshv2('PRODUCT.ISCOMMERCIAL',0)}
{/onchange}
2014年7月24日 星期四
generator-checker generator-check
{object}0.66,GRN_HEADER.NO_GRN,check,0,0,GRN :No GRN,,
{/object}
document.getElementById('PRODUCT.ISCOMMERCIAL').checked = (s=='C');
{/object}
document.getElementById('PRODUCT.ISCOMMERCIAL').checked = (s=='C');
2014年7月23日 星期三
java-tab
java tab remove
java enter next line remove
- inputString = inputString.replaceAll("\t", "");
- inputString = inputString.replaceAll("\n", "");
2014年7月22日 星期二
javascript-dtos date to string
function dateCal(pDate, pDay){
var ms = pDate.getTime(); //換成毫秒數
ms =ms+ pDay*24*60*60*1000; //計算相差的毫秒數
return new Date(ms); //返回新的時間對象
}
function dtos(pDate,pFormat){
if (!pFormat) pFormat='yyyy-mm-dd';
yyyy=pDate.getFullYear();
mm=pDate.getMonth()+1;
mm='0'+mm;
mm=right(mm,2);
dd=pDate.getDate();
dd='0'+dd;
dd=right(dd,2);
result='';
if (pFormat=='yyyy-mm-dd'){result=yyyy+'-'+mm+'-'+dd;}
else if (pFormat=='yyyymmdd'){result=yyyy+mm+dd;}
return result;
}
var ms = pDate.getTime(); //換成毫秒數
ms =ms+ pDay*24*60*60*1000; //計算相差的毫秒數
return new Date(ms); //返回新的時間對象
}
function dtos(pDate,pFormat){
if (!pFormat) pFormat='yyyy-mm-dd';
yyyy=pDate.getFullYear();
mm=pDate.getMonth()+1;
mm='0'+mm;
mm=right(mm,2);
dd=pDate.getDate();
dd='0'+dd;
dd=right(dd,2);
result='';
if (pFormat=='yyyy-mm-dd'){result=yyyy+'-'+mm+'-'+dd;}
else if (pFormat=='yyyymmdd'){result=yyyy+mm+dd;}
return result;
}
javascript-right
function dateCal(pDate, pDay){
var ms = pDate.getTime(); //換成毫秒數
ms =ms+ pDay*24*60*60*1000; //計算相差的毫秒數
return new Date(ms); //返回新的時間對象
}
function dtos(pDate,pFormat){
if (!pFormat) pFormat='yyyy-mm-dd';
yyyy=pDate.getFullYear();
mm=pDate.getMonth()+1;
mm='0'+mm;
mm=right(mm,2);
dd=pDate.getDate();
dd='0'+dd;
dd=right(dd,2);
result='';
if (pFormat=='yyyy-mm-dd'){result=yyyy+'-'+mm+'-'+dd;}
else if (pFormat=='yyyymmdd'){result=yyyy+mm+dd;}
return result;
}
javascript-date-calculate
http://msdn.microsoft.com/en-us/library/ie/ee532932(v=vs.94).aspx
{onchange}var d=parseDate(this.value);var today=new Date(); if (d<today){alert('Remind : Purchase plan date is before today.');}{/onchange}
var mydate = new Date('2014-04-03');
console.log(mydate.toDateString());
new Date('2011-04-11')
or
new Date('2011-04-11T11:51:00')
{onchange}var d=parseDate(this.value);var today=new Date(); if (d<today){alert('Remind : Purchase plan date is before today.');}{/onchange}
2014年7月21日 星期一
java-bean servlet
servlet
e.g. PDFCreateAndView.java
CompanyProfile bean = (CompanyProfile) request.getSession().getAttribute("bean");
allDocGenPDF.logoSizeFactor=bean.getLogoSizeFactor();
http://stackoverflow.com/questions/2663079/java-servlet-and-jsp-accessing-the-same-session-bean
The basic semantic tries to find an existing object using id and scope. If the object is not found it will attempt to create the object using the other attributes.
In other words,
<jsp:useBean id="user" scope="session" class="package.name.User"/>
would translate roughly into java as:
package.name.User user = (package.name.User)session.getAttribute("user");
if (user == null){
user = new package.name.User();
session.setAttribute("user", user);
}
2014年7月17日 星期四
mysql2java mysql to java
mysql
table to array
table2array
Connection con = null;
Statement stmt = null;
con = DriverManager.getConnection("jdbc:mysql://localhost/"+db+ "?useUnicode=true&characterEncoding=UTF8",dbID, dbPassword);
stmt = con.createStatement();
String documentLineSqlString="SELECT ITEM, MODEL , DESCRIPTION ,FORMAT(QTY,2),UNIT, FORMAT(PRICE,2), FORMAT(ROUND(PRICE*QTY,2),2) NET FROM SALES_LINE WHERE PARENT_RECORDID="+recordID+";";
String documentLineFormat="S,S,S,D,S,C,C"; // add column 1/5 step
String formats[]=documentLineFormat.split(",");
rs = stmt.executeQuery(documentLineSqlString);
while (rs.next()){
String id=rs.getString(1);
}rs.last(); //go bottom
int rowCount=rs.getRow(); //go recno
dRaws = new String[rowCount][];
String dRaws2[][] = new String[rowCount][];
rs.beforeFirst(); //go top
int iix=0;
while (rs.next()){
dRaws2[iix]=new String[7];
dRaws2[iix][2]=rs.getString(3);
dRaws2[iix][3]=rs.getString(4);
dRaws2[iix][4]=rs.getString(5);
dRaws2[iix][5]=rs.getString(6);
dRaws2[iix][6]=rs.getString(7);
iix++;
}
table to array
table2array
Connection con = null;
Statement stmt = null;
con = DriverManager.getConnection("jdbc:mysql://localhost/"+db+ "?useUnicode=true&characterEncoding=UTF8",dbID, dbPassword);
stmt = con.createStatement();
String documentLineSqlString="SELECT ITEM, MODEL , DESCRIPTION ,FORMAT(QTY,2),UNIT, FORMAT(PRICE,2), FORMAT(ROUND(PRICE*QTY,2),2) NET FROM SALES_LINE WHERE PARENT_RECORDID="+recordID+";";
String documentLineFormat="S,S,S,D,S,C,C"; // add column 1/5 step
String formats[]=documentLineFormat.split(",");
rs = stmt.executeQuery(documentLineSqlString);
while (rs.next()){
String id=rs.getString(1);
}rs.last(); //go bottom
int rowCount=rs.getRow(); //go recno
dRaws = new String[rowCount][];
String dRaws2[][] = new String[rowCount][];
rs.beforeFirst(); //go top
int iix=0;
while (rs.next()){
dRaws2[iix]=new String[7];
dRaws2[iix][2]=rs.getString(3);
dRaws2[iix][3]=rs.getString(4);
dRaws2[iix][4]=rs.getString(5);
dRaws2[iix][5]=rs.getString(6);
dRaws2[iix][6]=rs.getString(7);
iix++;
}
2014年7月16日 星期三
javascript-scroll dom-scroll
window.scrollTo(0,0);
window.location.hash="#top_";
window.location.href="#top_"; //ok
top.scrollTo( 0, 0 );
top.location.hash = 'top_';
document.body.scrollTop = 0;
document.body.scrollLeft = 0;
window.location.hash="#top_";
window.location.href="#top_"; //ok
top.scrollTo( 0, 0 );
top.location.hash = 'top_';
document.body.scrollTop = 0;
document.body.scrollLeft = 0;
2014年7月15日 星期二
generator-date , -date-calculate dateCalculate -default dtoc from date to date
_refreshv2('RECEIPT_HEADER.DATE',_today());
from date to date
{object}
0.30,query.GRN_SN_EXP,date,10,10,From D. Expire: Date ,,
{toolTips}Distributor Expire Date{/toolTips}
{from}
{placeHolder}yyyy-mm-dd{/placeHolder}
{default}empty{/default}
{colspan}3{/colspan}
{/object}
{object}
0.30,query.GRN_SN_EXP{to},date,10,10,To : Date ,,
{default}_today('y5'){/default}
{to}
{dependent}
{/object}
* and it depend on config file.
date layout
{object}
0.12,PURCHASE_HEADER.DATE,date,12,12,Date,,
{default}today{/default}
{default}_today(){/default}
{default}_today('now'){/default} /*last date of last month*/
{default}_today('lol'){/default} /*last date of last month*/
{default}_today('fol'){/default} /*first date of last month*/
{default}_today('fom'){/default} /*first date of this month*/
{default}_today('d5'){/default} /*last 5 date*/
{default}_today('D5'){/default} /*next 5 date*/
{default}_today('y5'){/default} /* next 5 years */
{placeHolder}yyyy-mm-dd{/placeHolder}
{default}empty{/default}
{required}
{string}.substring(2,10){/string}
{inLineStyle}direction:rtl;{/inLineStyle}
format YYYY-MM-DD TO YY-MM-DD
{/object}
date difference
{onchange}
var d1 = new Date(this.value);
var d2 = new Date(userStrVariable0);
if(d2>d1){alert('New DNOte Date '+this.value+'cannot < the Old DNote Date '+userStrVariable0+' !!');this.value='';}
{/onchange}
date difference
{object}
1.361,DNOTE_LINE.EXPIRE_DATE,date:GRID,8%,150,Expire Date,,
{labelInLineStyle}font-style: italic;{/labelInLineStyle}
{tooltip}Maintenance Expire Date{/tooltip}
{onchange}
var sDateFrom=_lookup('DNOTE_LINE.ACTIVE_DATE'+thisRowNo);
var sDateTo=_lookup('DNOTE_LINE.EXPIRE_DATE'+thisRowNo);
var d1=parseDate(sDateFrom);
var d2=parseDate(sDateTo);
alert(DateDiff.inMonths(d1, d2));
/*e.g. DateDiff.inDays(d1, d2),DateDiff.inWeeks(d1, d2),DateDiff.inMonths(d1, d2),DateDiff.inYears(d1, d2)*/
{/onchange}
{/object}
_today()
function _today(){
var _today;
dateValue = new Date()
var M = "" + (dateValue.getMonth()+1);
var MM = "0" + M;
MM = MM.substring(MM.length-2, MM.length);
var D = "" + (dateValue.getDate());
var DD = "0" + D;
DD = DD.substring(DD.length-2, DD.length);
var YYYY = "" + (dateValue.getFullYear());
_today=YYYY+'-'+MM+'-'+DD;
return _today}
e.g.
{default}empty{/default}
{-----------------copy this code--------------------------------}
{refresh}
var s0723=_lookup('SALES_HEADER.INV_DATE');
if (s0723){
var oBeijing =parseDate(s0723);
var s0723a='10';
var oMyDate = dateCal(oBeijing,s0723a);
s0723=dtos(oMyDate,'yyyy-mm-dd');
if(s0723!='1899-12-31'){
_refreshv2('SALES_HEADER.DUE_DATE',s0723);}
}
{/refresh}
{-------------------------------------Lead Time --------------------------------------------------------}
{object}
0.679,SALES_ORDER_HEAD.LEADTIME,int,5,3,Committed Lead Time (Day),,
{numeric}
{alignRight}
{refresh}
var s0723=_lookup('SALES_ORDER_HEAD.ENTRY_DATE');
if (s0723){
/*var oBeijing = new Date(s0723);*/
var oBeijing =parseDate(s0723);
var s0723a=_lookup('SALES_ORDER_HEAD.LEADTIME');
var oMyDate = dateCal(oBeijing,s0723a);
s0723=dtos(oMyDate,'yyyy-mm-dd');
if(s0723!='1899-12-31'){
_refreshv2('SALES_ORDER_HEAD.REQUEST_SHIP_DATE',s0723);}
}
{/refresh}
{enableAutocomplete}
{tooltip}Please Input days. (Calender day){/tooltip}
{/object}
{object}
0.67,SALES_ORDER_HEAD.ENTRY_DATE,date,9,10,Customer Order Rec. Date,,
{submitMust}
{default}{/default}
{tooltip}Customer Order Received Date{/tooltip}
{placeHolder}yyyy-mm-dd{/placeHolder}
{refresh}
var d1 = new Date(_lookup('this..CUSTOMER_PO_DATE'));
var d1add= dateCal(d1,4);
var d2 = new Date(_lookup('this.id'));
if (d2>d1add){$('.SALES_ORDER_HEAD_ENTRY_DATE').css('color', 'red');} else {$('.SALES_ORDER_HEAD_ENTRY_DATE').css('color', 'black');};
{/refresh}
{/object}
{object}
0.67,SALES_ORDER_HEAD.COMMITTED_COMPLETION_DATE,date,10,10,Actual Completion Date,,
{default}empty{/default}
{placeHolder}yyyy-mm-dd{/placeHolder}
{/object}
{default} / / {/default}
{default}{/default} <- default today
from date to date
{object}
0.30,query.GRN_SN_EXP,date,10,10,From D. Expire: Date ,,
{toolTips}Distributor Expire Date{/toolTips}
{from}
{placeHolder}yyyy-mm-dd{/placeHolder}
{default}empty{/default}
{colspan}3{/colspan}
{/object}
{object}
0.30,query.GRN_SN_EXP{to},date,10,10,To : Date ,,
{default}_today('y5'){/default}
{to}
{dependent}
{/object}
* and it depend on config file.
date layout
{object}
0.12,PURCHASE_HEADER.DATE,date,12,12,Date,,
{default}today{/default}
{default}_today(){/default}
{default}_today('now'){/default} /*last date of last month*/
{default}_today('lol'){/default} /*last date of last month*/
{default}_today('fol'){/default} /*first date of last month*/
{default}_today('fom'){/default} /*first date of this month*/
{default}_today('d5'){/default} /*last 5 date*/
{default}_today('D5'){/default} /*next 5 date*/
{default}_today('y5'){/default} /* next 5 years */
{placeHolder}yyyy-mm-dd{/placeHolder}
{default}empty{/default}
{required}
{string}.substring(2,10){/string}
{inLineStyle}direction:rtl;{/inLineStyle}
format YYYY-MM-DD TO YY-MM-DD
{/object}
date difference
{onchange}
var d1 = new Date(this.value);
var d2 = new Date(userStrVariable0);
if(d2>d1){alert('New DNOte Date '+this.value+'cannot < the Old DNote Date '+userStrVariable0+' !!');this.value='';}
{/onchange}
date difference
{object}
1.361,DNOTE_LINE.EXPIRE_DATE,date:GRID,8%,150,Expire Date,,
{labelInLineStyle}font-style: italic;{/labelInLineStyle}
{tooltip}Maintenance Expire Date{/tooltip}
{onchange}
var sDateFrom=_lookup('DNOTE_LINE.ACTIVE_DATE'+thisRowNo);
var sDateTo=_lookup('DNOTE_LINE.EXPIRE_DATE'+thisRowNo);
var d1=parseDate(sDateFrom);
var d2=parseDate(sDateTo);
alert(DateDiff.inMonths(d1, d2));
/*e.g. DateDiff.inDays(d1, d2),DateDiff.inWeeks(d1, d2),DateDiff.inMonths(d1, d2),DateDiff.inYears(d1, d2)*/
{/onchange}
{/object}
_today()
function _today(){
var _today;
dateValue = new Date()
var M = "" + (dateValue.getMonth()+1);
var MM = "0" + M;
MM = MM.substring(MM.length-2, MM.length);
var D = "" + (dateValue.getDate());
var DD = "0" + D;
DD = DD.substring(DD.length-2, DD.length);
var YYYY = "" + (dateValue.getFullYear());
_today=YYYY+'-'+MM+'-'+DD;
return _today}
e.g.
{default}empty{/default}
{-----------------copy this code--------------------------------}
{refresh}
var s0723=_lookup('SALES_HEADER.INV_DATE');
if (s0723){
var oBeijing =parseDate(s0723);
var s0723a='10';
var oMyDate = dateCal(oBeijing,s0723a);
s0723=dtos(oMyDate,'yyyy-mm-dd');
if(s0723!='1899-12-31'){
_refreshv2('SALES_HEADER.DUE_DATE',s0723);}
}
{/refresh}
{-------------------------------------Lead Time --------------------------------------------------------}
{object}
0.679,SALES_ORDER_HEAD.LEADTIME,int,5,3,Committed Lead Time (Day),,
{numeric}
{alignRight}
{refresh}
var s0723=_lookup('SALES_ORDER_HEAD.ENTRY_DATE');
if (s0723){
/*var oBeijing = new Date(s0723);*/
var oBeijing =parseDate(s0723);
var s0723a=_lookup('SALES_ORDER_HEAD.LEADTIME');
var oMyDate = dateCal(oBeijing,s0723a);
s0723=dtos(oMyDate,'yyyy-mm-dd');
if(s0723!='1899-12-31'){
_refreshv2('SALES_ORDER_HEAD.REQUEST_SHIP_DATE',s0723);}
}
{/refresh}
{enableAutocomplete}
{tooltip}Please Input days. (Calender day){/tooltip}
{/object}
{object}
0.67,SALES_ORDER_HEAD.ENTRY_DATE,date,9,10,Customer Order Rec. Date,,
{submitMust}
{default}{/default}
{tooltip}Customer Order Received Date{/tooltip}
{placeHolder}yyyy-mm-dd{/placeHolder}
{refresh}
var d1 = new Date(_lookup('this..CUSTOMER_PO_DATE'));
var d1add= dateCal(d1,4);
var d2 = new Date(_lookup('this.id'));
if (d2>d1add){$('.SALES_ORDER_HEAD_ENTRY_DATE').css('color', 'red');} else {$('.SALES_ORDER_HEAD_ENTRY_DATE').css('color', 'black');};
{/refresh}
{/object}
{object}
0.67,SALES_ORDER_HEAD.COMMITTED_COMPLETION_DATE,date,10,10,Actual Completion Date,,
{default}empty{/default}
{placeHolder}yyyy-mm-dd{/placeHolder}
{/object}
{default} / / {/default}
{default}{/default} <- default today
2014年7月14日 星期一
2014年7月6日 星期日
2014年7月3日 星期四
itext-fonts use windows fonts
Chinese fonts use together
FontFactory
Font font = FontFactory.getFont("/fonts/Sansation_Regular.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK);
BaseFont baseFont = font.getBaseFont();
http://renjin.blogspot.hk/2009/01/using-chinese-fonts-in-itextsharp.html
use windows fonts
http://itext-general.2136553.n4.nabble.com/quot-Arial-Unicode-MS-quot-and-FontFactory-registerDirectories-td2158167.html
BaseFont customfont = BaseFont.createFont("/erp/fonts/CONSOLA.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font consoles = new Font(customfont,11);
Font font = FontFactory.getFont("/fonts/Sansation_Regular.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK);
BaseFont baseFont = font.getBaseFont();
http://www.1728.org/fontlttr.htm
http://renjin.blogspot.hk/2009/01/using-chinese-fonts-in-itextsharp.html
http://tomkuo139.blogspot.hk/2009/08/java-itext-pdf.html
http://wenku.baidu.com/view/1b99f2afd1f34693daef3e79
訂閱:
文章 (Atom)