package com.cwbuyer.lib;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import com.cwbuyer.format.PItemData;
import com.pwbuyer.main.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.PorterDuff.Mode;
import android.graphics.Shader.TileMode;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
	
@SuppressWarnings("deprecation")
@SuppressLint({ "DefaultLocale", "HandlerLeak" })
public class MkqrSt extends Activity {

	// Called when the activity is first created. 

	public Bitmap vBitmap = Bitmap.createBitmap( 1200,1600, Bitmap.Config.RGB_565);

	//public Bitmap vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	//原直式設計 XY顛倒
	public Canvas vBitmapCanvas = new Canvas( vBitmap );
	private Gallery mGallery01;
	private ImageView mImage;
	private String [] zipList;
	final String myImportPath =android.os.Environment.getExternalStorageDirectory().getAbsolutePath()+Utilis.getIni(this, "SYS", "YEAR",8);	
	
	String uriAPI=null;
	public ProgressDialog myDialog = null;
	protected static final int REFRESH_DATA = 0x00000001;

	Bitmap rsizebar;
	public Bitmap bm =null;
	Bitmap rsizeBM;
    //private String [] Tradetype;
    private String [] tradeStr;
	Paint mPaintT1;
	Paint mPaintT2;
	Paint mPaintT3;
	Paint mPaintT4;
	Paint mPaintT5;
	Paint mPaintT6;
	Paint mPaintT7;
	Paint mPaintT8;
	Paint mPaintT9;
	DecimalFormat df = new DecimalFormat();
	String style = "#,##0";
	String batchFile="";
    StringBuffer albun_array = new StringBuffer();
    String mKind=null;
    int xMode=0;
    String mBufStr="";
    String [] mBufTitle;
    String mDept="";
    String uMobil="";
    String uAddress="";
	private double allSum=0;//總未結算金額 
	int [] xx={50,210,320,430,520,640,760,865,970,1075,1180,1285,1390,1495,1595,0,0};
    
	int counts=0;
	int half=0;
	int GVlocate=0;
	String ini=null; 	
	String[] titles;
	String title="銷 貨 單";
	
	String mStartDay="";
	String mEndDay="";
	int stdX=-10;
	int stdY=50;
	
	int locX=120;
	int locY=45;
	int locH=45;
	int locYgap=220;
    int max=0; //	累加	 每張A4 最多10筆 這是固定規格
    int mmax=15; //10 -> 15
    int PageT=0;
    int Page=0;
    int TotRec=0;
    double PageTT=0;
    
	String mSerch=null;
	Button mBt1;
	TextView tv1;

	PItemData data = new PItemData(); //##格式化需考量內容增刪

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.mkqrst);
	//取得傳來需要列印的資料(LST檔)
		
//nKind =getIntent().getIntExtra("QHis_kind", PItemKind.TR30); //
		//0
		mSerch=getIntent().getStringExtra("SERCH");
		//1
		mKind=getIntent().getStringExtra("QKIND");
		//2
		xMode=getIntent().getIntExtra("MODE",0);
		//3
		mDept=getIntent().getStringExtra("DEPTNO");
		//4
		mBufStr=getIntent().getStringExtra("BUFSTR");
		//5
		mBufTitle=(getIntent().getStringExtra("BUFTITLE")).split(";");
		//6
		mStartDay=getIntent().getStringExtra("STARTDAY");
		//7
		mEndDay=getIntent().getStringExtra("ENDDAY");
		
		if (mDept.length()>0) //針對日結單的門市別
			if (mDept.equalsIgnoreCase("SOS"))
				mDept=Utilis.getIni(this,"SYS","DEPT",6);  //總倉
		//對帳單專用 才會取值 3.對帳單 4.對帳明細單
		if (xMode==3 || xMode==4 || xMode==5 || xMode==6)	{
			locX=180;
			stdY=100;
			locY=30;
			
		}else if (xMode==7 || xMode==8 || xMode==9){
			locX=120;
			
		}else if (xMode==11 || xMode==12){
			//bundle.putString("Mkqrs" , "STD,"+mKind+",12,"+mDept+","+sPrintA4T.toString()+","+sPrintA4.toString());
			locX=120;
//			mBufStr=arrayW[5];
//			titles=arrayW[4].split(";");
		}else if (xMode==13){
			locX=120;
		}else if (xMode==14){
			locX=120;
		}else if (xMode==1 || xMode==2){
			locX=180;
			stdY=100;
		}

		//String mkcsv=mBufStr.replace(";", ",");
		
//		Toast.makeText(MkqrSt.this,"fromW="+fromW , Toast.LENGTH_LONG).show();
    	titles=Utilis.getIni(this,"USER","COMPANY",9).split("!&!");
	    
		tv1=(TextView)findViewById(R.id.tv113);
		mBt1 =(Button)findViewById(R.id.button113);
		mImage = (ImageView) findViewById(R.id.imageView105);
		mGallery01 = (Gallery) findViewById(R.id.myGallery1);
		
		df.applyPattern(style);
		
		tradeStr=Utilis.getIni(this,"SYS","TRADENAME",9).split("!&!");
		if (mKind.equalsIgnoreCase("10") || mKind.equalsIgnoreCase("11"))
			title="進 貨 單";
		else if (mKind.equalsIgnoreCase("20"))
			title="出 貨 單";
		else if (mKind.equalsIgnoreCase("21"))
			title="轉 貨 單";
		else if (mKind.equalsIgnoreCase("30") || mKind.equalsIgnoreCase("31"))
			title="銷 貨 單";
		else if (mKind.equalsIgnoreCase("40") || mKind.equalsIgnoreCase("41"))
			title="櫃員銷貨單";

		max=0;
		mPaintT1 = new Paint(Paint.DEV_KERN_TEXT_FLAG);
		mPaintT2 = new Paint();
		mPaintT3 = new Paint();
		mPaintT4 = new Paint();
		mPaintT5 = new Paint();
		mPaintT6 = new Paint();
		mPaintT7 = new Paint();
		mPaintT8 = new Paint();
		mPaintT9 = new Paint();
		
		// 設定畫筆顏色及樣式 
		mPaintT1.setStyle(Paint.Style.FILL);  //畫框    		
		mPaintT1.setColor(-16777216);
		mPaintT1.setStrokeWidth(0);
		mPaintT1.setTextSize(24);

 
		mPaintT2.setStyle(Paint.Style.FILL);  //畫框    		
		mPaintT2.setColor(-16777216);
		mPaintT2.setStrokeWidth(0);
		mPaintT2.setTextSize(36);
		
		mPaintT3.setStyle(Paint.Style.FILL);
		mPaintT3.setColor(-16777216);
		mPaintT3.setStrokeWidth(0);
		mPaintT3.setTextSize(22);
		//mPaintT3.setAntiAlias(true);

		mPaintT4.setStyle(Paint.Style.FILL_AND_STROKE);
		mPaintT4.setColor(-16777216);
		mPaintT4.setStrokeWidth(0);
		mPaintT4.setTextSize(18);
		
		mPaintT5.setStyle(Paint.Style.STROKE);
		mPaintT5.setColor(-16777216);
		mPaintT5.setStrokeWidth(0);
		
		if (xMode==4){	
			mPaintT6.setStyle(Paint.Style.FILL);
			mPaintT6.setColor(0XFFCC0000);
			mPaintT6.setStrokeWidth(0);
			mPaintT6.setTextSize(22);
		}else{
			mPaintT6.setStyle(Paint.Style.FILL);
			mPaintT6.setColor(-16777216);
			mPaintT6.setStrokeWidth(0);
			mPaintT6.setTextSize(22);
		}
		
		mPaintT7.setStyle(Paint.Style.FILL);
		mPaintT7.setColor(-16777216);
		mPaintT7.setStrokeWidth(0);
		mPaintT7.setTextSize(20);
		
		mPaintT8.setStyle(Paint.Style.FILL);
		mPaintT8.setColor(0XFFCFCFCF);
		mPaintT8.setStrokeWidth(2.0F);
		mPaintT8.setAntiAlias(true);
		
		mPaintT9.setStyle(Paint.Style.FILL_AND_STROKE);
		mPaintT9.setColor(-16777216);
		mPaintT9.setStrokeWidth(0);
		mPaintT9.setTextSize(22);
		mPaintT9.setFakeBoldText(true);
	
if (xMode==0){ //印出某單據
	printAtrade();
}else if (xMode==1 || xMode==2){ //印出某天的交易明細  雲端版
	printAday(xMode);
}else if (xMode==3 || xMode==4){ //印出某客戶的對帳單  雲端版
	printApay(xMode);
}else if (xMode==5 || xMode==6){ //印出某門市的月報表
//	mSerch=arrayW[6].replace("/", "")+"~"+arrayW[7].replace("/", "");
//	mDept=arrayW[0];
	printAmonth(xMode);
}else if (xMode==7 || xMode==8 || xMode==9){ //印出某客戶的對帳單  雲端版
	printSupperSale(xMode);
}else if (xMode==11 || xMode==12){ //印出 銷售分析
	printSTD(xMode);
}else if (xMode==13){ //盤點清冊
	printPAN(xMode);
}else if (xMode==14){ //盤點清冊
	Pan_Qadff(xMode);
}else if (xMode==15){ //總庫存分析
	printSTD(xMode);
}


//    		mPaintT5.setAntiAlias(true);

		//已在進入程式完成CANVAS 且已存入檔案,後續應為列印或傳送到遠端伺服器的後續處理
		mBt1.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View arg0) {
            	
				 ArrayList<Uri> imageUris = new ArrayList<Uri>();
				 for (int xyz=0;xyz<zipList.length;xyz++)
				 {
					 imageUris.add(Uri.parse("file://"+zipList[xyz])); // Add your image URIs here
				 }
				Intent shareIntent = new Intent();
				shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
				shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
				shareIntent.setType("image/*");
				startActivity(Intent.createChooser(shareIntent, "Share images to..")); 			    
            }
        }); 
  
		mGallery01.setOnItemClickListener(new Gallery.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long ids) {
				// TODO Auto-generated method stub
				Bitmap bm = Utilis.getLimitBitmap(zipList[position], 600,900);
				GVlocate=position;
				
				if (bm!=null){	
//					Bitmap reflactionBitmap;
//					reflactionBitmap = createReflectionBitmap(bm);
					mImage.setImageBitmap(bm);
//					AnimationSet animation = new AnimationSet(true);
//					animation.addAnimation(new AlphaAnimation(0.0F, 1.0F));
//					animation.addAnimation(new TranslateAnimation(30, 0, 10, 0));
//					animation.setDuration(1000);
//					mImage.startAnimation(animation);
				}
				
			}
		});

		mImage.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
		    	Intent send = new Intent(Intent.ACTION_SEND);
		    	send.setType("image/jpeg");
			    String uriText;
			    Uri U=Uri.parse("file://"+zipList[GVlocate]);  //重要的範例
//			    uriText = "https://www.google.com/cloudprint/addpublicprinter.html?printerid=bfcafa8e-0ab8-1a5c-8533-55da3b447c7c&key=1525231132";
			    uriText = "https://www.google.com/cloudprint/addpublicprinter.html?printerid=ad8f5166-1d68-ada1-5d7f-2ce01589f18e&key=c19901109";
			    send.putExtra(Intent.ACTION_SENDTO,uriText);
			    send.putExtra(Intent.EXTRA_STREAM,U);
			    startActivity(Intent.createChooser(send, uriText));
			    finish();
			}
		});
		
	} //主程式結束
	
	public void saved(int xMod) {
		
	if (xMod==0){	
		
		//if (max>=10){
		//if (max>=10 || (max>7 && max <10)){
			//vBitmapCanvas.drawRect(stdX+90, stdY+189, stdX+380, stdY+290+(8)*locH, mPaintT5);
			//vBitmapCanvas.drawRect(stdX+700, stdY+189, stdX+770, stdY+290+(8)*locH, mPaintT5);
			//vBitmapCanvas.drawRect(stdX+900, stdY+189, stdX+900, stdY+290+(8)*locH, mPaintT5);
			//vBitmapCanvas.drawRect(stdX+90, stdY+189, stdX+1050, stdY+290+(8)*locH, mPaintT5);

			//vBitmapCanvas.drawRect(stdX+90, stdY+270+(10)*locH, stdX+380, stdY+296+(max-1)*locH, mPaintT5);
			//vBitmapCanvas.drawRect(stdX+700, stdY+270+(10)*locH, stdX+770, stdY+296+(max-1)*locH, mPaintT5);
			//vBitmapCanvas.drawRect(stdX+90, stdY+270+(10)*locH, stdX+1050, stdY+296+(max-1)*locH, mPaintT5);
			
			vBitmapCanvas.drawRect(stdX+90, stdY+189, stdX+380, stdY+296+(max-2)*locH, mPaintT5);
			vBitmapCanvas.drawRect(stdX+700, stdY+189, stdX+770, stdY+296+(max-2)*locH, mPaintT5);
			vBitmapCanvas.drawRect(stdX+883, stdY+189, stdX+883, stdY+296+(max-2)*locH, mPaintT5);
			vBitmapCanvas.drawRect(stdX+90, stdY+189, stdX+1050, stdY+296+(max-2)*locH, mPaintT5);
		
			half=stdY+ locYgap+(max+1)*locH;
		
		vBitmapCanvas.drawRect(stdX+90, half, stdX+1050, half+80, mPaintT5);
		vBitmapCanvas.drawRect(stdX+90, half+40, stdX+1050, half+40, mPaintT5);
		//vBitmapCanvas.drawRect(stdX+883, half+80, stdX+1050, half+80, mPaintT5);
		vBitmapCanvas.drawText("備註:"+data.mhPs,stdX+100 ,half+30 , mPaintT4);
		//vBitmapCanvas.drawText("折扣:",stdX+900 ,half+70 , mPaintT1);
		//vBitmapCanvas.drawText(df.format(data.dBsum-data.dTuresum),stdX+1114-getN(df.format(data.dBsum-data.dTuresum)) ,half+70 , mPaintT1);
		vBitmapCanvas.drawText("總計 :",stdX+900 ,half+70 , mPaintT1);
		vBitmapCanvas.drawText(df.format(data.dBsum),stdX+1040-getN(df.format(data.dBsum)) ,half+70 , mPaintT1);
		vBitmapCanvas.drawRect(stdX+883, half, stdX+883, half+80, mPaintT5);


		vBitmapCanvas.drawText("建檔人員 :"+data.mEmpid+"/"+data.mEmpname,stdX+550 ,half+30 , mPaintT4);
		vBitmapCanvas.drawText("負責業務 :",stdX+100 ,half+70 , mPaintT4);
		vBitmapCanvas.drawText("出貨人員 :",stdX+350 ,half+70 , mPaintT4);
		vBitmapCanvas.drawText("客戶簽收 :",stdX+600 ,half+70 , mPaintT4);
		
	}else if(xMod==3 || xMod==4){
		vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max)*locY, mPaintT5);
		
	}else if(xMod==7 || xMod==8 || xMod==9){
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-50+(max)*locY+6, stdX+1133, stdY+locX-50+(max)*locY+6, mPaintT5);
	}

		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		final String filepath=android.os.Environment.getExternalStorageDirectory().getAbsolutePath()+Utilis.getIni(this, "SYS", "YEAR",6);
		File myAlbunPath= new File(filepath);
		if (!myAlbunPath.exists()){myAlbunPath.mkdirs(); }
						
		String edpic=null;
		edpic = filepath+File.separator+"mkqrst_"+ (100+counts)+".png";
		albun_array.append(edpic+",");

		counts=counts+1;
		PageTT=0;
		int swidth = vBitmap.getWidth();
		int shgh = vBitmap.getHeight();
		
		Matrix scaleMatrix = new Matrix();
		scaleMatrix.postScale(1,1);
 		 rsizebar =Bitmap.createBitmap(vBitmap, 0, 0, swidth, shgh, scaleMatrix, true);
 		rsizebar.compress(Bitmap.CompressFormat.PNG, 100, stream);// (0 - 100)压缩文件

        FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(edpic);
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
//			Toast.makeText(Mkqr.this, edpic + "開檔失敗!!", Toast.LENGTH_LONG).show();
			e.printStackTrace();
		}
		
    try {
    	rsizebar.compress(CompressFormat.PNG, 100, fos);
				fos.close();
//				Toast.makeText(Mkqr.this, "saved"+edpic, Toast.LENGTH_LONG).show();				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				Toast.makeText(MkqrSt.this, edpic + "存檔失敗!!", Toast.LENGTH_LONG).show();					
			}
	
	
	}

	public static void toZipF(Context context,String[] files, String destZip) {
		try {
			int BUFFER = 2048;
			BufferedInputStream origin = null;
			FileOutputStream dest = new FileOutputStream(destZip);
			ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
			byte data[] = new byte[BUFFER];
			for (int i = 0; i < files.length; i++) {
				Log.v("Compress", "Adding: " + files[i]);
				FileInputStream fi = new FileInputStream(files[i]);
				origin = new BufferedInputStream(fi, BUFFER);
				ZipEntry entry = new ZipEntry(files[i].substring(files[i].indexOf(Utilis.getIni(context, "SYS","YEAR", 6))+Utilis.getIni(context, "SYS","YEAR", 6).length()+1));
				
				out.putNextEntry(entry);
				int count;
				while ((count = origin.read(data, 0, BUFFER)) != -1) {
					out.write(data, 0, count);
				}
				origin.close();
			}
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private List<String> ChkPic() {
		/* 設定目前所在路徑 */
		List<String> it = new ArrayList<String>();
		/* 將所有檔案加入ArrayList中 */
		for (int i = 0; i < counts; i++) {
			if (getImageFile(zipList[i]))
				it.add(zipList[i]);
			else {it.add(android.os.Environment.getExternalStorageDirectory().getAbsolutePath()+"/cwbuyer/para/img_additem.png");}
		}
		return it;
	}

	private boolean getImageFile(String fName) {
		boolean re;

		/* 取得副檔名 */
		String end = fName
				.substring(fName.lastIndexOf(".") + 1, fName.length())
				.toLowerCase();

		/* 依附檔名的類型決定MimeType */
		if (end.equals("jpg") || end.equals("gif") || end.equals("png")
				|| end.equals("jpeg") || end.equals("bmp")) {
			re = true;
		} else {
			re = false;
		}
		return re;
	}

	public static Bitmap createReflectionBitmap(Bitmap src) {
		// 原始圖片與反射圖片的邊界
		int margin = 4;
		int width = src.getWidth();
		int height = src.getHeight();

		// 用來做上下顛倒的Matrix
		Matrix matrix = new Matrix();
		matrix.preScale(1.0f, -1.2f);

		// 以原始圖片下半部顛倒過來產生Bitmap
		Bitmap reflection;
		reflection = Bitmap.createBitmap(src, 0, height / 2, width, height / 2,
				matrix, true);
		// 產生原始圖片與反射圖片合體後的結果圖片Bitmap
		// 這時還是空的
		Bitmap result;
		result = Bitmap.createBitmap(width, height + height / 5,
				Config.ARGB_8888);
		// 使用畫布
		Canvas canvas;
		canvas = new Canvas(result);
		// 將原始圖片寫到結果圖片畫布上
		canvas.drawBitmap(src, 0, 0, null);
		// 將反射圖片寫到結果圖片畫布上
		canvas.drawBitmap(reflection, 0, height + margin, null);

		// 到這裡已經與反射圖片合體完成了
		// 接下來要做淡化處理
		Paint paint = new Paint();
		// 使用LinearGradient這個直線方向的漸層
		LinearGradient shader;
		// 製作漸入透明的漸層
		// 0x90ffffff(稍微透明) -> 0x00FFFFFF(完全透明)
		shader = new LinearGradient(0, height, 0, result.getHeight() + margin,
				0x80ffffff, 0x00ffffff, TileMode.CLAMP);
		// 因為繼承Shader類別，所以使用setShader設定給Paint。
		paint.setShader(shader);
		// 指定顏色轉換模式
		paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
		// 描繪漸層
		canvas.drawRect(0, height, width, result.getHeight(), paint);

		return result;
	}

	public class ImageAdapter extends BaseAdapter {
		/* 宣告變數 */
		int mGalleryItemBackground;
		private Context mContext;
		private List<String> lis;

		/* ImageAdapter的建構子 */
		public ImageAdapter(Context c, List<String> li) {
			mContext = c;
			lis = li;
			/*
			 * 使用在res/values/attrs.xml中的<declare-styleable>定義 的Gallery屬性.
			 */
			TypedArray a = obtainStyledAttributes(R.styleable.Gallery);
			/* 取得Gallery屬性的Index id */
			mGalleryItemBackground = a.getResourceId(
					R.styleable.Gallery_android_galleryItemBackground, 0);
			/* 讓物件的styleable屬性能夠反覆使用 */
			a.recycle();
		}

		/* 一定要覆寫的方法getCount,傳回圖片數目 */
		public int getCount() {
			return lis.size();
		}

		/* 一定要覆寫的方法getItem,傳回position */
		public Object getItem(int position) {
			return position;
		}

		/* 一定要覆寫的方法getItemId,傳回position */
		public long getItemId(int position) {
			return position;
		}

		/* 一定要覆寫的方法getView,傳回一View物件 */
		public View getView(int position, View convertView, ViewGroup parent) {
			/* 產生ImageView物件 */
			ImageView i = new ImageView(mContext);
			/* 設定圖片給imageView物件 */
//			Bitmap bm = BitmapFactory.decodeFile(lis.get(position).toString());
				Bitmap bm = Utilis.getLimitBitmap(lis.get(position).toString(), 80, 80);
				i.setImageBitmap(bm);

			/* 重新設定圖片的寬高 */
			i.setScaleType(ImageView.ScaleType.FIT_XY);
			/* 重新設定Layout的寬高 */
				i.setLayoutParams(new Gallery.LayoutParams(150, 100));				
			/* 設定Gallery背景圖 */
			i.setBackgroundResource(mGalleryItemBackground);
			/* 傳回imageView物件 */
			return i;
		}
	}
	

	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
//		db.close();
	}
//T1字型 靠右	運算
private int getN(String Tst){
int lenn=0;
if (Tst.length()<=3) lenn= (Tst.length()-1)*16+4;
//else if (Tst.length()<=7) lenn= (Tst.length()-1)*16;
else lenn=(Tst.length()-2)*16+8;

return lenn;	
}

private int getNT3(String Tst){
int lenn=0;
if (Tst.length()<=3) lenn= (Tst.length()-1)*13+3;
//else if (Tst.length()<=7) lenn= (Tst.length()-1)*13;
else lenn=(Tst.length()-2)*13+6;

return lenn;	
}

//T4字型 靠右運算
private int getNT4(String Tst){
int lenn=0;
if (Tst.length()<=3) lenn= (Tst.length()-1)*11+3;
//else if (Tst.length()<=7) lenn= (Tst.length()-1)*11;
else lenn=(Tst.length()-2)*11+4;

return lenn;	
}

//T7字型 靠右運算
private int getNT7(String Tst){
int lenn=0;
if (Tst.length()<=3) lenn= (Tst.length()-1)*12+3;
//else if (Tst.length()<=7) lenn= (Tst.length()-1)*12;
else lenn=(Tst.length()-2)*12+6;

return lenn;	
}

private void printAtrade(){//New
	//單據的內容
	//mmax=22;
	mmax=38;
	
	data=DBUtil.PItem.getData(this, mSerch, mKind,true);
	locH=25;
	//@@@單子的種類 如 主貨GOODSNO 明細GOODSNOS
	//如果要 進行 公版 開發
	//金額 還要 123,456,00.0
	//點陣印表機
	vBitmap = Bitmap.createBitmap( 1150,1500, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	
	StringBuffer mBuf = new StringBuffer();
	SQLiteDatabase db = Utilis.getDB(this);
	
	mBuf.append("select GOODSNO,GOODSNAME,sum(UNIT"+mKind.substring(0,1)+"0),UNITPRICE,sum(SUBPRICE),P"+data.nTrade+",PS");
	mBuf.append(" from qitems where FORMNO= '"+mSerch+"' and QKIND LIKE '"+mKind.substring(0,1)+"%' group by GOODSNO,GOODSNAME,UNITPRICE,PS order by CREATEDATETIME,HANDNO ");

	Cursor cs=db.rawQuery(mBuf.toString(), null);
	if (cs.getCount()>0){
		//無條件進入法
		PageT=Math.round((cs.getCount()-1)/mmax+1);
		TotRec=cs.getCount();
		mBuf.delete(0, mBuf.toString().length());
		if (mKind.equalsIgnoreCase("10"))
			mBuf.append("select MOBIL,ADDRESS from qfact where FACTNO='"+data.mUser+"' and TR LIKE '"+mKind.substring(0,1)+"%'");
		else	
			mBuf.append("select MOBIL,ADDRESS from qcust where CUSTNO='"+data.mUser+"' and TR LIKE '"+mKind.substring(0,1)+"%'");
		
		Cursor ccs=db.rawQuery(mBuf.toString(), null);
		if (ccs.getCount()>0){
			ccs.moveToFirst();
			uMobil=ccs.getString(0);
			uAddress=ccs.getString(1);
		}
		ccs.close();
		
			half=stdY+220+(cs.getCount()+1)*locH;
		
		makeTitle(xMode);
    		cs.moveToFirst();
    		for (int xxx=0;xxx<cs.getCount();xxx++){
    			//如果全筆數<6 或 最後一頁<6 則以中一刀方式,並將頁尾接到中一刀裡面
    			vBitmapCanvas.drawText(cs.getString(0),stdX+100 ,stdY+locYgap+(max+1)*locH , mPaintT7);
    			
    			vBitmapCanvas.drawText(cs.getString(1),stdX+385 ,stdY+locYgap+(max+1)*locH , mPaintT3);
    			vBitmapCanvas.drawText(cs.getString(2),stdX+760-(cs.getString(2).length()*16) ,stdY+locYgap+(max+1)*locH , mPaintT3);
    			vBitmapCanvas.drawText(df.format(cs.getDouble(3)),stdX+870-getNT3(df.format(cs.getDouble(3))) ,stdY+locYgap+(max+1)*locH , mPaintT3);
    			vBitmapCanvas.drawText(df.format(cs.getDouble(4)),stdX+1030-getNT3(df.format(cs.getDouble(4))) ,stdY+locYgap+(max+1)*locH , mPaintT3);
    			PageTT=PageTT+cs.getDouble(4); //分頁小計
				max++; 
				half=stdY+locYgap+(max+1)*locH;
				/*
				if (max==10){
					max+=1;
				} else if ((max==8 && (TotRec % mmax)<10) && ((counts+1)==PageT)){
					max=11;
				}
				*/
				if (max%mmax==0){
					saved(xMode);
		    		makeTitle(xMode);
					max=0;
				}
				cs.moveToNext();
    		}
    		if (max!=0) saved(xMode);
		cs.close();
		makePic();
	}else{ //沒有單子的內容
		finish();
	}
	db.close();
	
}

private void printAday(int xMode){
//欣維(公司)				銷貨明細日結單   日期:2015-06-17  印製時間:2015-06-17 21:25:00   
//單       號  會員編號 會員名稱 交易人員 原價金額 交易金額 折扣金  尾數折讓 現金收入 票刷金額 匯款金額 
//	交易方式 預購現金 預購刷卡 代運
	//@@@ 是否思考也可以輸出為 excel _CSV
	vBitmap = Bitmap.createBitmap( 1650,1200, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	mmax=20;
	//int [] xx={500,640,780,920,1060,1200,1340,1480};
	 xx[0]=610;xx[1]=750;xx[2]=840;xx[3]=940;xx[4]=1080;xx[5]=1260;xx[6]=1390;xx[7]=1520;xx[8]=1650;
	StringBuffer mBuf = new StringBuffer();
	if(mSerch != null && mSerch.length() > 0){
		mSerch = mSerch.replace("/", "-");
		
		
		String SQL_ALLSUM="";
		SQL_ALLSUM="select round(sum(BSUM)-(sum(CASH)+sum(CARD)+sum(ORDCASH)+sum(ORDCARD)+sum(ATM))) from qhead where QKIND='"+mKind+"' ";
		int ORS=Utilis.toInt(Utilis.getIni(MkqrSt.this, "SYS","DEPT_SEND", 6));
		if (ORS!=2) //含預購帳 
			SQL_ALLSUM+= " and (ISCONFIRM='Y' or (ISCHECK='Y' and ISCONFIRM='N'))";
		else
			SQL_ALLSUM+= " and ISCONFIRM='Y' and ISCHECK='N'";
		
		if (mDept.length()>0) SQL_ALLSUM+=" and DEPTNO='"+mDept+"'";
		
		String SQL_TODAY_TOTAL="";
		SQL_TODAY_TOTAL="select round(sum(TURESUM)),round(sum(BSUM)),round(sum(BSUM-TURESUM-TRCASH)),round(sum(DISMONEY)),sum(CASH),sum(CARD),sum(ATM),sum(TRCASH),sum(ATOT),sum(ORDCASH),sum(ORDCARD)"; 
		SQL_TODAY_TOTAL+=" from qhead where (((FORMDATE= '"+mSerch+"' or FINEDATE = '"+mSerch+"') and ISCONFIRM='Y' ) or (ORDDATE= '"+mSerch+"' and ISCHECK='Y' )) and QKIND ='"+mKind+"'";  
			if (mDept.length()>0) SQL_TODAY_TOTAL+=" and DEPTNO='"+mDept+"'";
		
		String SQL_TODAY_PART="";
		SQL_TODAY_PART="select PS1,round(sum(BSUM))"; 
		SQL_TODAY_PART+=" from qhead where (((FORMDATE= '"+mSerch+"' or FINEDATE = '"+mSerch+"') and ISCONFIRM='Y' ) or (ORDDATE= '"+mSerch+"' and ISCHECK='Y' )) and QKIND ='"+mKind+"'";  
				if (mDept.length()>0) SQL_TODAY_PART+=" and DEPTNO='"+mDept+"'";
				SQL_TODAY_PART+=" group by PS1";
		
		String SQL_TODAY="";
		mBuf.delete(0, mBuf.toString().length());
		mBuf.append("select FORMNO,USER,USERNAME,EMPNAME,TURESUM,BSUM,BSUM-TURESUM-TRCASH,DISMONEY,CASH,CARD,ATM,TRCASH,PS1,HANDNO,TRADETYPE,ORDCASH,ORDCARD");
		mBuf.append(" from qhead where  (((FORMDATE= '"+mSerch+"' or FINEDATE = '"+mSerch+"') and ISCONFIRM='Y' ) or (ORDDATE= '"+mSerch+"' and ISCHECK='Y' ))");
		if (mDept.length()>0) mBuf.append(" and DEPTNO='"+mDept+"'");
		mBuf.append(" and QKIND ='"+mKind+"' order by FORMNO,CREATEDATETIME");
		SQL_TODAY=mBuf.toString();

		String SQL_TODAY_QITEMS="select GOODSNOS,GOODSNAME,UNIT"+mKind.substring(0,1)+"0,UNITPRICE,DISCOUNT,SUBPRICE from qitems where FORMNO ='mFORMNO' order by CREATEDATETIME desc";
		if (xMode!=2) SQL_TODAY_QITEMS="WITHOUT";
		
		
	//雲端版
	if  (Utilis.haveInternet(MkqrSt.this) && Utilis.toInt(Utilis.getIni(MkqrSt.this, "SYS", "IMPORT", 3))==1 && !Utilis.getIni(this,"SYS","DEPT_SEND",4).equalsIgnoreCase("0")){
	//if  (Utilis.haveInternet(MkqrSt.this) && Utilis.toInt(Utilis.getIni(MkqrSt.this, "SYS", "IMPORT", 3))==1 && Utilis.getIni(this,"SYS","DEPT_SEND",4).equalsIgnoreCase("0")){
		StringBuffer bfstr = new StringBuffer();
		StringBuffer bfstrF = new StringBuffer();
		
			bfstr.append(Utilis.getIni(MkqrSt.this, "SYS", "IMPORT", 2)).append(";");
			bfstrF.append("UID").append(";");
			bfstr.append(SQL_ALLSUM).append(";");
			bfstrF.append("SQL_ALLSUM").append(";");
			bfstr.append(SQL_TODAY_TOTAL).append(";");
			bfstrF.append("SQL_TODAY_TOTAL").append(";"); 
			bfstr.append(SQL_TODAY_PART).append(";");
			bfstrF.append("SQL_TODAY_PART").append(";"); 
			bfstr.append(SQL_TODAY_QITEMS).append(";");
			bfstrF.append("SQL_TODAY_QITEMS").append(";"); 
			bfstr.append(""+SQL_TODAY);
			bfstrF.append("SQL_TODAY");  //單別
			
			final String []fields=bfstr.toString().split(";");
			final String []fieldFs=bfstrF.toString().split(";");

				uriAPI="http://"+Utilis.getIni(MkqrSt.this, "SYS", "IMPORT", 1)+File.separator+Utilis.getIni(MkqrSt.this, "SYS", "IMPORT", 2)+File.separator+"qrep_today.php";
				HttpPost httpRequest = new HttpPost(uriAPI);
				// Post運作傳送變數必須用NameValuePair[]陣列儲存
				Log.i("DOWNLOAD_2", "呼叫執行緒PHP___到此一遊"+uriAPI);

				List<NameValuePair> params = new ArrayList<NameValuePair>();
				for(int x=0;x<fields.length;x++){
					params.add(new BasicNameValuePair(fieldFs[x], fields[x]));
				}
				try {
					// 發出HTTP request(請求) 
					httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
					// 取得HTTP response(回傳) 
					HttpResponse httpResponse = new DefaultHttpClient()
							.execute(httpRequest);
					// 若狀態碼為200 ok 
					if (httpResponse.getStatusLine().getStatusCode() == 200)
					{
						// 取出回應字串
						String strResult = EntityUtils.toString(httpResponse	.getEntity());
						mHandlerQDR_TODAY.obtainMessage(REFRESH_DATA, strResult).sendToTarget();
						
					}
				} catch (Exception e)
				{
					e.printStackTrace();
				}


	}else{
		SQLiteDatabase db = Utilis.getDB(this);
		//當前未收款 allSum
		Cursor allcs=db.rawQuery(SQL_ALLSUM, null);
		allcs.moveToFirst();
		allSum=allcs.getDouble(0);
		allcs.close();
		
		//vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
		makeTitle(xMode);
				Cursor csS=db.rawQuery(SQL_TODAY_TOTAL, null);
				if (csS.getCount()>0){
					csS.moveToFirst();
					for (int y=0;y<=7;y++)	vBitmapCanvas.drawText(""+df.format(csS.getDouble(y)),stdX+xx[y]+60-getNT4(""+df.format(csS.getDouble(y))) ,stdY+locX-60 , mPaintT7);
	    			vBitmapCanvas.drawText(csS.getInt(8)+"(件)",stdX+150 ,stdY+locX-60 , mPaintT7);
				}
				csS.close();
				
		//考慮雲端版的搜尋方式
		Cursor cs=db.rawQuery(SQL_TODAY, null);
		if (cs.getCount()>0){
			//無條件進入法
			PageT=Math.round((cs.getCount()-1)/mmax+1);
			//"單       號  會員               交易人員 原價金額 交易金額 折扣金  尾數折讓 現金收入 票刷金額 匯款金額 交易方式 預購現金 預購刷卡 代運 "
			//50,120
			while (cs.moveToNext()){
    			vBitmapCanvas.drawText(""+cs.getString(0),stdX+50 ,stdY+locX+(max)*locY , mPaintT7);
    			vBitmapCanvas.drawText(""+cs.getString(1)+"/"+cs.getString(2),stdX+230 ,stdY+locX+(max)*locY , mPaintT7);
    			vBitmapCanvas.drawText(""+cs.getString(3),stdX+460 ,stdY+locX+(max)*locY , mPaintT7);
    			
    			 for (int y=0;y<=7;y++) vBitmapCanvas.drawText(""+df.format(cs.getDouble(y+4)),stdX+xx[y]+60-getNT7(df.format(cs.getDouble(y+4))) ,stdY+locX+(max)*locY , mPaintT7);
    			
    			vBitmapCanvas.drawText(""+cs.getString(12),stdX+50 ,stdY+locX+20+(max)*locY , mPaintT7);
    			vBitmapCanvas.drawText(""+cs.getString(13),stdX+160 ,stdY+locX+20+(max)*locY , mPaintT7);
    			vBitmapCanvas.drawText(""+tradeStr[cs.getInt(14)],stdX+230 ,stdY+locX+20+(max)*locY , mPaintT7);
    			
    			vBitmapCanvas.drawRect(stdX+45, stdY+locX+(max-1)*locY+24, stdX+1600, stdY+locX+(max)*locY+24, mPaintT5);
    			
				
    			if (xMode==2){
    				String SQL_QITEMS=SQL_TODAY_QITEMS.replace("mFORMNO", cs.getString(0));
    				Cursor csi=db.rawQuery(SQL_QITEMS, null);
    				if (csi.getCount()>0){
    	    			//商品明細的台頭
    	    			vBitmapCanvas.drawText("貨 號 & 品 名",stdX+400 ,stdY+locX+20+(max)*locY , mPaintT7);
    	    			vBitmapCanvas.drawText("件 數",stdX+xx[0]+20 ,stdY+locX+20+(max)*locY , mPaintT7);
    	    			vBitmapCanvas.drawText("單 價",stdX+xx[1]+20 ,stdY+locX+20+(max)*locY , mPaintT7);
    	    			vBitmapCanvas.drawText("折 數",stdX+xx[2]+20 ,stdY+locX+20+(max)*locY , mPaintT7);
    	    			vBitmapCanvas.drawText("小 計",stdX+xx[3]+20 ,stdY+locX+20+(max)*locY , mPaintT7);

		    			max++;
						if (max%mmax==0){
							saved(xMode);
				    		makeTitle(xMode);
							max=0;
						}
    					
    					while (csi.moveToNext()){
    		    			vBitmapCanvas.drawText(""+csi.getString(0),stdX+170 ,stdY+locX+(max)*locY , mPaintT7);
    		    			vBitmapCanvas.drawText(""+csi.getString(1),stdX+400 ,stdY+locX+(max)*locY , mPaintT7);
    		    			for (int y=0;y<=3;y++) vBitmapCanvas.drawText(""+df.format(csi.getDouble(y+2)),stdX+xx[y]+60-getNT7(df.format(csi.getDouble(y+2))) ,stdY+locX+(max)*locY , mPaintT7);
    					
    		    			max++;
    						if (max%mmax==0){
    							saved(xMode);
    				    		makeTitle(xMode);
    							max=0;
    						}
    					}    					
    				} else max++; 
    			}else{
        			max++;
    				if (max%mmax==0){
    					saved(xMode);
    		    		makeTitle(xMode);
    					max=0;
    				}
    			}
			}
   		if (max!=0) saved(xMode);
		}
		cs.close();
		db.close();
		makePic();
	}		
	}else{
		finish();
	}
}

private void printApay(int xMode){
	vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	makeTitle(xMode);
	mmax=40;
	locY=30;
	//int [] xx={180,50,550,400,700,850,1000};
	xx[0]=180;xx[1]=50;xx[2]=550;xx[3]=400;xx[4]=700;xx[5]=850;xx[6]=1000;
	int [] xi={180,50,400,550,700,850};
	int [] it={150,320,840,920,1020,1120};
	
	//日期                單       號			商品編號-品名												           件數				單價				小計			折扣
	//2015-06-01  AA135000012	應收 13920		現金:13920 	收票:13920		匯款:13920		代運:12920       				 
	//                        							OBEY_3615-OBEYshirt 品名										1 		       1280				1280		(90)
		if (mBufStr.indexOf("HHHH\r\n")>2){
			String LineH [] = mBufStr.substring(0, mBufStr.length()-6).split(";HHHH\r\n");
			
			for (int yy=0;yy<LineH.length;yy++){
				
				String LinesH[] =LineH[yy].substring(0, LineH[yy].length()-6).split(";SSSS\r\n");
				
					String Linea [] = LinesH[0].split(";");
					//取得QHEAD
					if (mKind.equalsIgnoreCase("10")){
						if (xMode==4){
			    			vBitmapCanvas.drawRect(stdX+47, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max+1)*locY, mPaintT8);
			    			vBitmapCanvas.drawText(""+Linea[0],stdX+xi[0] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText(""+Linea[1],stdX+xi[1] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("應付 : "+new BigDecimal(Linea[2]).toString(),stdX+xi[2] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText(""+Linea[3]+" (件)",stdX+xi[3] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("共 : "+Linea[4]+" 款",stdX+xi[4] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
						}else{
			    			vBitmapCanvas.drawText(""+Linea[0],stdX+xi[0] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText(""+Linea[1],stdX+xi[1] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText("應付 : "+new BigDecimal(Linea[2]).toString(),stdX+xi[2] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText(""+Linea[3]+" (件)",stdX+xi[3] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText("共 : "+Linea[4]+" 款",stdX+xi[4] ,stdY+locX+(max+1)*locY , mPaintT6);
						}
						
					}else if (mKind.equalsIgnoreCase("30") || mKind.equalsIgnoreCase("31") || mKind.equalsIgnoreCase("11")){
						if (xMode==4){
			    			vBitmapCanvas.drawRect(stdX+47, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max+1)*locY, mPaintT8);
			    			vBitmapCanvas.drawText(""+Linea[0],stdX+xx[0] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText(""+Linea[1],stdX+xx[1] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText(""+Linea[2]+" (件)",stdX+xx[2] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("應收 : "+new BigDecimal(Utilis.toDouble(Linea[8])).toString(),stdX+xx[3] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("現 : "+new BigDecimal(Utilis.toDouble(Linea[4])).toString(),stdX+xx[4] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("票 : "+new BigDecimal(Utilis.toDouble(Linea[5])).toString(),stdX+xx[5] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("代運 : "+Linea[6],stdX+xx[6] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
						}else{
			    			vBitmapCanvas.drawText(""+Linea[0],stdX+xx[0] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText(""+Linea[1],stdX+xx[1] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText(""+Linea[2]+" (件)",stdX+xx[2] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText("應收 : "+new BigDecimal(Utilis.toDouble(Linea[8])).toString(),stdX+xx[3] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText("現 : "+new BigDecimal(Utilis.toDouble(Linea[4])).toString(),stdX+xx[4] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText("票 : "+new BigDecimal(Utilis.toDouble(Linea[5])).toString(),stdX+xx[5] ,stdY+locX+(max+1)*locY , mPaintT6);
			    			vBitmapCanvas.drawText("代運 : "+Linea[6],stdX+xx[6] ,stdY+locX+(max+1)*locY , mPaintT6);
						}
					}else{//20.21
					//0FORMNO,1FORMDATE,2HANDNO,3BSUM,4CASH,5CARD,6ORDCASH,7ORDCARD,8ASUM,9DISMONEY,10ATM,11TRCASH,12USER,13DEPTNO
						if (xMode==4) vBitmapCanvas.drawRect(stdX+47, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max+1)*locY, mPaintT8);
			    			vBitmapCanvas.drawText(""+Linea[0],stdX+xx[0] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText(""+Linea[1],stdX+xx[1] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			if(Linea[12].equalsIgnoreCase(mSerch)){
				    			vBitmapCanvas.drawText(""+Linea[2]+" (件)",stdX+xx[2] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    				vBitmapCanvas.drawText("金額 : "+new BigDecimal(Utilis.toDouble(Linea[8])).toString(),stdX+xx[3] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			}else{
				    			vBitmapCanvas.drawText(""+Linea[2].replace("+", "-")+" (件)",stdX+xx[2] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    				vBitmapCanvas.drawText("(轉"+Linea[12]+") -"+Linea[8],stdX+xx[3] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			}	
			    			vBitmapCanvas.drawText("現 : "+new BigDecimal(Utilis.toDouble(Linea[4])).toString(),stdX+xx[4] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("票 : "+new BigDecimal(Utilis.toDouble(Linea[5])).toString(),stdX+xx[5] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
			    			vBitmapCanvas.drawText("代運 : "+new BigDecimal(Utilis.toDouble(Linea[6])).toString(),stdX+xx[6] ,stdY+locX+(max+1)*locY+2 , mPaintT9);
						
					}						
	    			vBitmapCanvas.drawRect(stdX+1133, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max+1)*locY, mPaintT5);
	    			vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max)*locY, stdX+45, stdY+locX+10+(max+1)*locY, mPaintT5);
	    			vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max)*locY, mPaintT5);
	    			max++;
						if (max%mmax==0){
							saved(xMode);
				    		makeTitle(xMode);
							max=0;
						}
	    			if (xMode==4){
						for (int xy=1;xy<LinesH.length;xy++){
							String Lines[] =LinesH [xy].split(";");
							//取得QITEMS 不分單別
			    			//vBitmapCanvas.drawText(df.format(cs.getDouble(3)),stdX+870-getNT3(df.format(cs.getDouble(3))) ,stdY+203+(max+1)*locH , mPaintT3);
							
							vBitmapCanvas.drawText(""+Lines[0],stdX+it[0] ,stdY+locX+(max+1)*locY , mPaintT3);
							vBitmapCanvas.drawText(""+Lines[1],stdX+it[1] ,stdY+locX+(max+1)*locY , mPaintT3);
							if (mKind.equalsIgnoreCase("20") || mKind.equalsIgnoreCase("21")){
								vBitmapCanvas.drawText(Lines[2],stdX+it[2]-80 ,stdY+locX+(max+1)*locY , mPaintT3);
							}else{
								vBitmapCanvas.drawText(new BigDecimal(Utilis.toDouble(Lines[2])).toString(),stdX+it[2]-getNT3(new BigDecimal(Utilis.toDouble(Lines[2])).toString()) ,stdY+locX+(max+1)*locY , mPaintT3);								
							}
							vBitmapCanvas.drawText(new BigDecimal(Utilis.toDouble(Lines[3])).toString(),stdX+it[3]-getNT3(new BigDecimal(Utilis.toDouble(Lines[3])).toString()) ,stdY+locX+(max+1)*locY , mPaintT3);
							vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Lines[4])),stdX+it[4]-getNT3(new BigDecimal(Utilis.toDouble(Lines[4])).toString()) ,stdY+locX+(max+1)*locY , mPaintT3);
			    			vBitmapCanvas.drawRect(stdX+1133, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max+1)*locY, mPaintT5);
			    			vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max)*locY, stdX+45, stdY+locX+10+(max+1)*locY, mPaintT5);
							if ((xy % 5==0) && xy!=LinesH.length-1 ){
								vBitmapCanvas.drawRect(stdX+47, stdY+locX+10+(max+1)*locY-5, stdX+1133, stdY+locX+10+(max+1)*locY-3, mPaintT8);
							}
							max++;
							if (max%mmax==0){
								saved(xMode);
					    		makeTitle(xMode);
								max=0;
							}
						}
					}else{
		    			vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max)*locY, stdX+1133, stdY+locX+10+(max)*locY, mPaintT5);
						if (max%mmax==0){
							saved(xMode);
				    		makeTitle(xMode);
							max=0;
						}
					}
				}
	   		if (max!=0) saved(xMode);
			makePic();
		}
	}

private void printSupperSale(int xMode){
	vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	if (xMode==7){
		xx[0]=50;xx[1]=250;xx[2]=530;xx[3]=850;xx[4]=900;xx[5]=990;xx[6]=1080;
	}else if (xMode==8){
		xx[0]=50;xx[1]=200;xx[2]=430;xx[3]=590;xx[4]=840;xx[5]=990;
	}else if (xMode==9){
		xx[0]=50;xx[1]=200;xx[2]=430;xx[3]=650;xx[4]=890;
	}
	makeTitle(xMode);
	mmax=45;
	locY=30;
	//供應商/名稱            商品編號(色)/名稱(成本)                  尚存(件) 總進:本進   總銷:本銷   銷售率       
	
			String LineH [] = mBufStr.substring(0, mBufStr.length()-6).split(";SSSS\r\n");
			
			for (int yy=1;yy<LineH.length;yy++){
					String Lines [] = LineH[yy].split(";");

	    			if ((max % 2)!=0) vBitmapCanvas.drawRect(stdX+47, stdY+locX-40+(max)*locY, stdX+1133, stdY+locX-40+(max+1)*locY, mPaintT8);
							vBitmapCanvas.drawText(""+Lines[0],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[1],stdX+xx[1] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[2],stdX+xx[2] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[3],stdX+xx[3] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[4],stdX+xx[4] ,stdY+locX-50+(max+1)*locY , mPaintT7);
						if (xMode<9)	vBitmapCanvas.drawText(""+Lines[5],stdX+xx[5] ,stdY+locX-50+(max+1)*locY , mPaintT7);
						if (xMode==7)	vBitmapCanvas.drawText(""+Lines[6],stdX+xx[6] ,stdY+locX-50+(max+1)*locY , mPaintT7);
			    			vBitmapCanvas.drawRect(stdX+1133, stdY+locX-50+(max)*locY, stdX+1133, stdY+locX-50+(max+1)*locY+6, mPaintT5);
			    			vBitmapCanvas.drawRect(stdX+45, stdY+locX-50+(max)*locY, stdX+45, stdY+locX-50+(max+1)*locY+6, mPaintT5);
							max++;
							if (max%mmax==0){
								saved(xMode);
					    		makeTitle(xMode);
								max=0;
							}
			}
	   		if (max!=0) saved(xMode);
			makePic();
	}

private void printSTD(int xMode){
	vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	//xx[0]=50;xx[1]=250;xx[2]=530;xx[3]=850;xx[4]=900;xx[5]=990;xx[6]=1080;
	xx[0]=50;xx[1]=250;xx[2]=480;xx[3]=620;xx[4]=800;xx[5]=970;xx[6]=1080;
	makeTitle(xMode);
	mmax=45;
	locY=30;
	//供應商/名稱            商品編號(色)/名稱(成本)                  尚存(件) 總進:本進   總銷:本銷   銷售率       
	
	if (mBufStr.indexOf("HHHH\r\n")>2){
		String LineH [] = mBufStr.substring(0, mBufStr.length()-6).split(";HHHH\r\n");

		
		for (int yy=0;yy<LineH.length;yy++){
			
			String LinesH[] =LineH[yy].substring(0, LineH[yy].length()-6).split(";SSSS\r\n");
			
			for (int zz=0;zz<LinesH.length;zz++){
					String Lines [] = LinesH[zz].split(";");
	    			if ((max % 2)!=0 || xMode==15) vBitmapCanvas.drawRect(stdX+47, stdY+locX-40+(max)*locY, stdX+1133, stdY+locX-40+(max+1)*locY, mPaintT8);
							vBitmapCanvas.drawText(""+Lines[0],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[1],stdX+xx[1] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[2],stdX+xx[2] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[3],stdX+xx[3] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[4],stdX+xx[4] ,stdY+locX-50+(max+1)*locY , mPaintT7);
							vBitmapCanvas.drawText(""+Lines[5],stdX+xx[5] ,stdY+locX-50+(max+1)*locY , mPaintT7);
			    			vBitmapCanvas.drawRect(stdX+1133, stdY+locX-50+(max)*locY, stdX+1133, stdY+locX-50+(max+1)*locY+6, mPaintT5);
			    			vBitmapCanvas.drawRect(stdX+45, stdY+locX-50+(max)*locY, stdX+45, stdY+locX-50+(max+1)*locY+6, mPaintT5);
							max++;
							
							if (max%mmax==0){
								saved(xMode);
					    		makeTitle(xMode);
								max=0;
							}
			}
			}
	   		if (max!=0) saved(xMode);
			makePic();
		}
	}

private void printPAN(int xMode){
	vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	//貨品編號   存 盤存  單  價 % 貨品編號   存 盤存  單  價 %
	int rightS=550;
	xx[0]=50;xx[1]=300;xx[2]=360;xx[3]=430;xx[4]=520;
	xx[5]=xx[0]+rightS;xx[6]=xx[1]+rightS;xx[7]=xx[2]+rightS;;xx[8]=xx[3]+rightS;xx[9]=xx[4]+rightS;
	max=0;
	makeTitle(xMode);
	mmax=51;
	locY=30;
	
	if (mBufStr.indexOf("\r\n")>2){
		String LineH [] = mBufStr.split("\r\n");
		for (int zz=0;zz<LineH.length;zz++){
			String Lines [] = LineH[zz].split(";");
			if ((zz+1) % 2 != 0)rightS=0; else rightS=550; 
			if ((zz+2)%10==0 && zz>0) vBitmapCanvas.drawRect(stdX+47, stdY+locX-40+(max)*locY, stdX+1133, stdY+locX-10+(max)*locY, mPaintT8);
			vBitmapCanvas.drawText(""+Lines[0],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT7);
			vBitmapCanvas.drawText(""+Lines[1],stdX+xx[1]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT7);
			vBitmapCanvas.drawText("[____]",stdX+xx[2]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT7);
			vBitmapCanvas.drawText(""+Lines[2],stdX+xx[3]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT7);
			vBitmapCanvas.drawText(""+Lines[3],stdX+xx[4]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT7);
				
			if ((zz+1)%2==0) max++;
			if ((max+1)%mmax==0){
				saved(xMode);
	    		makeTitle(xMode);
				max=0;
			}
		}
		
		if ((max+1)>30){saved(xMode);makeTitle(xMode);max=0;}
		rightS=550;max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("上期存貨量: "+mBufTitle[0],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("上期存貨小計: "+mBufTitle[1],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期進出量: "+mBufTitle[2],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("本期進出小計: "+mBufTitle[3],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期已銷量: "+mBufTitle[4],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("本期已銷小計: "+mBufTitle[5],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期應盤量: "+mBufTitle[6],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("本期應盤小計: "+mBufTitle[7],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("現場盤退量: ",stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("現場盤退小計: ",stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期收負量: ",stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("本期收負小計: ",stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("實際盤存量: ",stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("實際盤存小計: ",stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期盤銷量: ",stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("本期盤銷小計: ",stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期共銷量: ",stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("本期應收合計: ",stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
		
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("經理:",stdX+xx[0] ,stdY+locX-8+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("會計:",stdX+xx[2] ,stdY+locX-8+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("業務:",stdX+xx[0]+rightS ,stdY+locX-8+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("客戶:",stdX+xx[2]+rightS ,stdY+locX-8+(max+1)*locY , mPaintT1);
		
   		if (max!=0) saved(xMode);
   		
		makePic();
			
	}
}

private void Pan_Qadff(int xMode){
	vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	int sumTdef=0;
	int sumT30=0;
	int sumU30=0;
	int rightS=580;
	//日期                                 單號                      件數 進貨金 退貨金
	xx[0]=50;xx[1]=200;xx[2]=360;xx[3]=480;//xx[4]=600;
	//xx[0]=50;xx[1]=200;xx[2]=360;xx[3]=430;//xx[4]=600;
	//日期 			單號		 件數                         小計                 [補價]
	xx[5]=50;xx[6]=170;xx[7]=290;xx[8]=350;xx[9]=440;
	//貨品編號  件數  單價  % 小計 補價小計 [原價]   
	xx[10]=520;xx[11]=700;xx[12]=750;xx[13]=820;xx[14]=870;xx[15]=970;xx[16]=1060;
	max=0;
	makeTitle(xMode);
	mmax=51;
	locY=30;
	//門市出貨明細
	if (mBufStr.indexOf("panok;")>0){
		String LineAll [] = mBufStr.split(";SETPAGE\r\n");
		String LineH20 []=LineAll[2].split(";HH20\r\n");
		//HEAD20 門市出貨清單
		if (mBufStr.indexOf(";HH20\r\n")>0){
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-83, stdX+1180, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("進出日期",stdX+xx[0] ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("單號",stdX+xx[1] ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("件數",stdX+xx[2] ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("實收金額",stdX+xx[3] ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("進出日期",stdX+xx[0]+rightS ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("單號",stdX+xx[1]+rightS ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("件數",stdX+xx[2]+rightS ,stdY+locX-58 , mPaintT1);
			vBitmapCanvas.drawText("實收金額",stdX+xx[3]+rightS ,stdY+locX-58 , mPaintT1);
			for (int zz=0;zz<LineH20.length;zz++){
				String Lines [] = LineH20[zz].split(";");
				if ((zz+1) % 2 != 0)rightS=0; else rightS=580; 
				if ((zz+2)%10==0 && zz>0) vBitmapCanvas.drawRect(stdX+47, stdY+locX-40+(max)*locY, stdX+1180, stdY+locX-10+(max)*locY, mPaintT8);
				vBitmapCanvas.drawText(""+Lines[0],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
				vBitmapCanvas.drawText(""+Lines[1],stdX+xx[1]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
				vBitmapCanvas.drawText(""+Lines[2],stdX+xx[2]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
//				if (!Lines[3].equalsIgnoreCase(Lines[4]))
//					vBitmapCanvas.drawText(""+Lines[3]+"("+Lines[4]+")",stdX+xx[3]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
//				else
					vBitmapCanvas.drawText(""+Lines[3],stdX+xx[3]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
					
				if ((zz+1)%2==0) max++;
				if ((max+1)%mmax==0){
					saved(xMode);
		    		makeTitle(xMode);
					vBitmapCanvas.drawRect(stdX+47, stdY+locX-35+(max)*locY, stdX+1180, stdY+locX-10+(max)*locY, mPaintT5);
					vBitmapCanvas.drawText("進出日期",stdX+xx[0] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("單號",stdX+xx[1] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("件數",stdX+xx[2] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("實收金額",stdX+xx[3] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("進出日期",stdX+xx[0]+rightS ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("單號",stdX+xx[1]+rightS ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("件數",stdX+xx[2]+rightS ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("實收金額",stdX+xx[3]+rightS ,stdY+locX-58 , mPaintT1);
					max=0;
				}
			}
		}else{//是否顯示 沒有帳單
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1180, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("本期沒有專櫃出貨單",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			max++;max++;
		}
		max++;max++;
		if (max+1>40){
			saved(xMode);
    		makeTitle(xMode);
			max=0;
		}
	if 	(mBufStr.indexOf(";HH30\r\n")>0){ 
		String LineH30 []=LineAll[3].split(";HH30\r\n");
		//HEAD30 門市銷貨清單
		
		if (LineH30.length>0){
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-35+(max-1)*locY, stdX+1180, stdY+locX-5+(max-1)*locY, mPaintT5);
			vBitmapCanvas.drawText("銷貨日期",stdX+xx[5] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("單號",stdX+xx[6] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("件數",stdX+xx[7] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("小計",stdX+xx[8] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("[補價]",stdX+xx[9] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("貨號",stdX+xx[10] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("件數",stdX+xx[11] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("單價",stdX+xx[12] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("%",stdX+xx[13] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("小計",stdX+xx[14] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("補價",stdX+xx[15] ,stdY+locX-40+(max)*locY , mPaintT1);
			vBitmapCanvas.drawText("[原價]",stdX+xx[16] ,stdY+locX-40+(max)*locY , mPaintT1);
			max++;
				if ((max+1)%mmax==0){
					saved(xMode);
		    		makeTitle(xMode);
				}			
			for (int zz=0;zz<LineH30.length;zz++){
				String Lines [] = LineH30[zz].split(";II30\r\n");
				String LineH30T[]=Lines[Lines.length-1].split(";");
				vBitmapCanvas.drawRect(stdX+47, stdY+locX-40+(max)*locY, stdX+1180, stdY+locX-13+(max)*locY, mPaintT8);
				vBitmapCanvas.drawText(""+LineH30T[0],stdX+xx[5] ,stdY+locX-50+(max+1)*locY , mPaintT7);
				vBitmapCanvas.drawText(""+LineH30T[1],stdX+xx[6] ,stdY+locX-50+(max+1)*locY , mPaintT7);
				vBitmapCanvas.drawText(""+LineH30T[2],stdX+xx[7] ,stdY+locX-50+(max+1)*locY , mPaintT7);
				vBitmapCanvas.drawText(""+LineH30T[3],stdX+xx[8] ,stdY+locX-50+(max+1)*locY , mPaintT7);
				vBitmapCanvas.drawText("["+LineH30T[4]+"]",stdX+xx[9] ,stdY+locX-50+(max+1)*locY , mPaintT7);
				sumTdef+=Utilis.toInt(LineH30T[4]);	//補價累計
				sumT30+=Utilis.toInt(LineH30T[3]);	//實銷累計
				if ((max+1)%mmax==0){
					saved(xMode);
		    		makeTitle(xMode);
					vBitmapCanvas.drawRect(stdX+45, stdY+locX-83, stdX+1180, stdY+locX-50, mPaintT5);
					vBitmapCanvas.drawText("銷貨日期",stdX+xx[5] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("單號",stdX+xx[6] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("件數",stdX+xx[7] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("小計",stdX+xx[8] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("[補價]",stdX+xx[9] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("貨號",stdX+xx[10] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("件數",stdX+xx[11] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("單價",stdX+xx[12] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("%",stdX+xx[13] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("小計",stdX+xx[14] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("補價",stdX+xx[15] ,stdY+locX-58 , mPaintT1);
					vBitmapCanvas.drawText("[原價]",stdX+xx[16] ,stdY+locX-58 , mPaintT1);
					max=0;
				}
				
				for (int yy=0;yy<Lines.length-1;yy++){
					String LineI []=Lines[yy].split(";");
					//貨號 件數 單價 折 小計 補價 [原價]
					if (LineI[3].indexOf("100")>=0){
						LineI[3]=""; 
					}else{
						LineI[5]="";
						LineI[6]="";
					}
					vBitmapCanvas.drawText(""+LineI[0],stdX+xx[10] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					vBitmapCanvas.drawText(""+LineI[1],stdX+xx[11] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					vBitmapCanvas.drawText(""+LineI[2],stdX+xx[12] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					vBitmapCanvas.drawText(""+LineI[3],stdX+xx[13] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					vBitmapCanvas.drawText(""+LineI[4],stdX+xx[14] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					vBitmapCanvas.drawText(""+LineI[5],stdX+xx[15] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					vBitmapCanvas.drawText("["+LineI[6]+"]",stdX+xx[16] ,stdY+locX-50+(max+1)*locY , mPaintT7);
					sumU30+=Utilis.toInt(LineI[1]);	//實銷累計

					max++;
					if ((max+1)%mmax==0){
						saved(xMode);
			    		makeTitle(xMode);
						vBitmapCanvas.drawRect(stdX+45, stdY+locX-83, stdX+1180, stdY+locX-50, mPaintT5);
						vBitmapCanvas.drawText("銷貨日期",stdX+xx[5] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("單號",stdX+xx[6] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("件數",stdX+xx[7] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("小計",stdX+xx[8] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("[補價]",stdX+xx[9] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("貨號",stdX+xx[10] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("件數",stdX+xx[11] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("單價",stdX+xx[12] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("%",stdX+xx[13] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("小計",stdX+xx[14] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("補價",stdX+xx[15] ,stdY+locX-58 , mPaintT1);
						vBitmapCanvas.drawText("[原價]",stdX+xx[16] ,stdY+locX-58 , mPaintT1);
						max=0;
					}
				}
			}
		}else{//是否顯示 沒有帳單
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1180, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("本期沒有銷貨明細單",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			max++;max++;
		}
	}
		
		//LineT 欄位明細
		String LineT []=LineAll[1].split(";");
		
		if ((max+1)>36){saved(xMode);makeTitle(xMode);max=0;}
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-85+(max+1)*locY, stdX+1180, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("上期存貨量: "+LineT[2],stdX+xx[2]+200 ,stdY+locX-50+(max+1)*locY , mPaintT2);
		vBitmapCanvas.drawText("上期存貨小計:"+LineT[3],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT2);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-85+(max+1)*locY, stdX+1180, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期進出量: "+LineT[4],stdX+xx[2]+200 ,stdY+locX-50+(max+1)*locY , mPaintT2);
		vBitmapCanvas.drawText("本期進出小計:"+LineT[5],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT2);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-85+(max+1)*locY, stdX+1180, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期盤存量: "+LineT[10],stdX+xx[2]+200 ,stdY+locX-50+(max+1)*locY , mPaintT2);
		vBitmapCanvas.drawText("本期盤存小計:"+LineT[11],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT2);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-85+(max+1)*locY, stdX+1180, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期銷件數: "+sumU30,stdX+xx[2]+200 ,stdY+locX-50+(max+1)*locY , mPaintT2);
		vBitmapCanvas.drawText("本期銷貨小計:"+(sumTdef+sumT30),stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT2);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-85+(max+1)*locY, stdX+1180, stdY+locX-42+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("本期補價: "+sumTdef,stdX+xx[2]+200 ,stdY+locX-50+(max+1)*locY , mPaintT2);
		vBitmapCanvas.drawText("本期應收小計:"+sumT30,stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT2);
		max++;max++;
		vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1180, stdY+locX+(max+1)*locY, mPaintT5);
		vBitmapCanvas.drawText("經理:",stdX+xx[0] ,stdY+locX-8+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("會計:",stdX+xx[2] ,stdY+locX-8+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("業務:",stdX+xx[0]+550 ,stdY+locX-8+(max+1)*locY , mPaintT1);
		vBitmapCanvas.drawText("客戶:",stdX+xx[2]+550 ,stdY+locX-8+(max+1)*locY , mPaintT1);
		
   		if (max!=0) saved(xMode);
   		
		makePic();
	}
}

@SuppressLint("HandlerLeak")
private void printAmonth(int xMode){
	mmax=31;
	locY=30;
	vBitmap = Bitmap.createBitmap( 1650,1200, Bitmap.Config.RGB_565);
	vBitmapCanvas = new Canvas( vBitmap );
	//vBitmap = Bitmap.createBitmap( 1200,1650, Bitmap.Config.RGB_565);
	//vBitmapCanvas = new Canvas( vBitmap );
    int [] xx={50,210,320,430,520,640,760,865,970,1075,1180,1285,1390,1495,1595,0,0};
	double [] Tot=new double [15];
	makeTitle(xMode);
	
	//傳回的資料 結構 ;SSSS\r\n 01-31(13) ;HHHH\r\n 01-31(3)
	//vBitmapCanvas.drawText(""+df.format(csT.getDouble(1)),stdX+xx[y]+60-getNT4(""+df.format(csT.getDouble(1))) ,stdY+locX-90 , mPaintT4);
	
	String LineH [] = mBufStr.split(";HHHH\r\n");
				
				String LinesH[] =LineH[0].substring(0, LineH[0].length()-6).split(";SSSS\r\n");
				//後面放棄PS1 改為 CASH CARD ATM TRCASH ORDCASH ORDCARD
				//0                ,1            ,2      ,3        ,4       ,5       ,6              ,7               ,8     ,9        ,10         ,11           ,12             ,13              ,14 
				//FORMDATE,DEPTNO,ATOT,BSUM,CASH,CARD,ORDCASH,ORDCARD,ATM,ASUM,TRCASH,FORMNO,TRUESUM,DISMONEY,MINTO
				
			for (int yy=0;yy<LinesH.length;yy++){
				
    			if ((yy % 2)!=0) vBitmapCanvas.drawRect(stdX+47, stdY+locX+10+(max-2)*locY, stdX+1600, stdY+locX+10+(max-1)*locY, mPaintT8);
				String Linea [] = LinesH[yy].split(";");
					//日期0
	    			vBitmapCanvas.drawText(""+Linea[0],stdX+xx[0] ,stdY+locX+(max-1)*locY , mPaintT4);
	    			//總件數2總單數11
	    			vBitmapCanvas.drawText(Linea[11]+"/"+Linea[2]+"件",stdX+xx[1]-50 ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[1]+=Utilis.toDouble(Linea[11]);
	    			Tot[0]+=Utilis.toDouble(Linea[2]);
	    			//總原價12
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[12])),stdX+xx[2]-getNT4(""+df.format(Utilis.toDouble(Linea[12]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[2]+=Utilis.toDouble(Linea[12]);
	    			//總折扣=3-12
	    			vBitmapCanvas.drawText(""+df.format((Utilis.toDouble(Linea[3])-Utilis.toDouble(Linea[12]))),stdX+xx[3]-getNT4(""+df.format((Utilis.toDouble(Linea[3])-Utilis.toDouble(Linea[12])))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[3]+=Utilis.toDouble(Linea[3])-Utilis.toDouble(Linea[12]);
	    			//總尾數折讓13
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[13])),stdX+xx[4]-getNT4(""+df.format(Utilis.toDouble(Linea[13]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[4]+=Utilis.toDouble(Linea[13]);
	    			//銷售金額3
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[3])+Utilis.toDouble(Linea[13])),stdX+xx[5]-getNT4(""+df.format(Utilis.toDouble(Linea[3])+Utilis.toDouble(Linea[13]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[5]+=(Utilis.toDouble(Linea[3])+Utilis.toDouble(Linea[13]));
	    			//實收金額 (CASH +CARD +ORDCASH +ORDCARD+ATM)
	    			vBitmapCanvas.drawText(""+df.format((Utilis.toDouble(Linea[4])+Utilis.toDouble(Linea[5])+Utilis.toDouble(Linea[6])+Utilis.toDouble(Linea[7])+Utilis.toDouble(Linea[8]))),stdX+xx[6]-getNT4(""+df.format((Utilis.toDouble(Linea[4])+Utilis.toDouble(Linea[5])+Utilis.toDouble(Linea[6])+Utilis.toDouble(Linea[7])+Utilis.toDouble(Linea[8])))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[6]+=Utilis.toDouble(Linea[4])+Utilis.toDouble(Linea[5])+Utilis.toDouble(Linea[6])+Utilis.toDouble(Linea[7])+Utilis.toDouble(Linea[8]);
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[4])),stdX+xx[7]-getNT4(""+df.format(Utilis.toDouble(Linea[4]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[7]+=(Utilis.toDouble(Linea[4]));//CASH
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[5])),stdX+xx[8]-getNT4(""+df.format(Utilis.toDouble(Linea[5]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[8]+=(Utilis.toDouble(Linea[5]));//CARD
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[8])),stdX+xx[9]-getNT4(""+df.format(Utilis.toDouble(Linea[8]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[9]+=(Utilis.toDouble(Linea[8]));//ATM
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[10])),stdX+xx[10]-getNT4(""+df.format(Utilis.toDouble(Linea[10]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[10]+=(Utilis.toDouble(Linea[10]));//TRCASH
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[6])),stdX+xx[11]-getNT4(""+df.format(Utilis.toDouble(Linea[6]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[11]+=(Utilis.toDouble(Linea[6]));//ORDCASH
	    			vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Linea[7])),stdX+xx[12]-getNT4(""+df.format(Utilis.toDouble(Linea[7]))) ,stdY+locX+(max-1)*locY , mPaintT4);
	    			Tot[12]+=(Utilis.toDouble(Linea[7]));//ORDCARD
	    			
	    			
	    			//七種PS1的 金額 以indexof取得 Tradetype[0-6]
/*	    			
    				int chk=0;
	    			for (int xy=0;xy<8;xy++){
	    				String ask=Linea[0]+";"+Tradetype[xy];
	    				for (int jj=0;jj<LinesPs1.length;jj++){
		    				if (LinesPs1[jj].indexOf(ask)>=0){
		    					String ans[]=LinesPs1[jj].split(";");
		    	    			vBitmapCanvas.drawText(""+df.format(Utilis.toInt(ans[2])),stdX+xx[7+xy]-getNT4(""+df.format(Utilis.toInt(ans[2]))) ,stdY+locX+(max-1)*locY , mPaintT4);
		    	    			Tot[7+xy]+=Utilis.toInt(ans[2]);
		    	    			chk=1;
		    				}	    					
	    				}
    				}
    				if (chk==0){
    					int Tott=0;
	    				for (int jj=0;jj<LinesPs1.length;jj++){
		    				if (LinesPs1[jj].indexOf(Linea[0])>=0){
		    					String ans[]=LinesPs1[jj].split(";");
		    					Tott+=Utilis.toInt(ans[2]);
		    					Tot[14]+=Utilis.toInt(ans[2]);
		    				}	    					
	    				}
    	    			vBitmapCanvas.drawText(""+df.format(Tott),stdX+xx[14]-getNT4(""+df.format(Tott)) ,stdY+locX+(max-1)*locY , mPaintT4);
    				}
*/    				
	    			vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max-2)*locY, stdX+1600, stdY+locX+10+(max-1)*locY, mPaintT5);
    				
	    			//vBitmapCanvas.drawRect(stdX+1133, stdY+locX+10+(max-2)*locY, stdX+1133, stdY+locX+10+(max-1)*locY, mPaintT5);
	    			//vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max-2)*locY, stdX+45, stdY+locX+10+(max-1)*locY, mPaintT5);
	    			//vBitmapCanvas.drawRect(stdX+45, stdY+locX+10+(max-1)*locY, stdX+1133, stdY+locX+10+(max-1)*locY, mPaintT5);
	    			max++;
	    			
					if (max%mmax==0){
		    			vBitmapCanvas.drawText(""+Tot[1]+"/"+Tot[0]+"件",stdX+xx[1]-90 ,stdY+locX-100 , mPaintT4);
						for (int xy=2;xy<=14;xy++)
			    			vBitmapCanvas.drawText(""+df.format(Tot[xy]),stdX+xx[xy]-getNT4(""+df.format(Tot[xy])) ,stdY+locX-100 , mPaintT4);
							
						saved(xMode);
			    		makeTitle(xMode);
						max=0;
					}
			}
	   		if (max!=0){
    			vBitmapCanvas.drawText(""+Tot[1]+"/"+Tot[0]+"件",stdX+xx[1]-90 ,stdY+locX-100 , mPaintT4);
				for (int xy=2;xy<=14;xy++)
	    			vBitmapCanvas.drawText(""+df.format(Tot[xy]),stdX+xx[xy]-getNT4(""+df.format(Tot[xy])) ,stdY+locX-100 , mPaintT4);
	   			saved(xMode);
	   		}
			makePic();
	}

Handler mHandlerQDR_TODAY= new Handler()
{
	@Override
	public  void handleMessage(Message msg)
	{
		//傳回的//upup_1-30_系統時間
		
		String Hresult=null;
		switch (msg.what)
		{
		// 顯示網路上抓取的資料
		case REFRESH_DATA:
			if (msg.obj instanceof String) 
				Hresult = (String) msg.obj;
			if (Hresult != null ){
				Log.i("DOWNLOAD_6_mHandlerQC===", ""+Hresult);						
 
					if (Hresult.indexOf("HHHH\r\n")>2){
						Hresult=	Hresult.substring(Hresult.indexOf("repto;")+6);
						//2Part
						String LineH [] = Hresult.substring(0, Hresult.length()-6).split(";HHHH\r\n");
						//Part 1 2
						String LinesH[] =LineH[0].substring(0, LineH[0].length()-6).split(";SSSS\r\n");
						//First_line
						String Lines[] =LinesH[0].split(";");
						//PArt1
						allSum=Utilis.toDouble(Lines[0]);
						vBitmap = Bitmap.createBitmap( 1650,1200, Bitmap.Config.RGB_565);
						vBitmapCanvas = new Canvas( vBitmap );
					
						makeTitle(xMode);
						//Part2
						for (int y=0;y<=7;y++)	vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Lines[y+1])),stdX+xx[y]+60-getNT7(""+df.format(Utilis.toDouble(Lines[y+1]))) ,stdY+locX-60 , mPaintT7);
		    			vBitmapCanvas.drawText(Utilis.toInt(Lines[9])+"(件)",stdX+150 ,stdY+locX-60 , mPaintT7);

		    			//Part4
						String LinesItem[] =LineH[1].substring(0, LineH[1].length()-6).split(";SSSS\r\n");
		    			for (int z=0;z< LinesItem.length;z++){
		    				String Lineiii[]=LinesItem[z].substring(0, LinesItem[z].length()-6).split(";IIII\r\n");
		    				String Lineii[]=Lineiii[0].split(";");

		        			vBitmapCanvas.drawText(""+Lineii[0],stdX+50 ,stdY+locX+(max)*locY , mPaintT7);
		        			vBitmapCanvas.drawText(""+Lineii[1]+"/"+Lineii[2],stdX+230 ,stdY+locX+(max)*locY , mPaintT7);
		        			vBitmapCanvas.drawText(""+Lineii[3],stdX+460 ,stdY+locX+(max)*locY , mPaintT7);
		        			
		        			 for (int y=0;y<=7;y++) vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Lineii[y+4])),stdX+xx[y]+60-getNT7(df.format(Utilis.toDouble(Lineii[y+4]))) ,stdY+locX+(max)*locY , mPaintT7);
		        			
		        			vBitmapCanvas.drawText(""+Lineii[12],stdX+50 ,stdY+locX+20+(max)*locY , mPaintT7);
		        			vBitmapCanvas.drawText(""+Lineii[13],stdX+160 ,stdY+locX+20+(max)*locY , mPaintT7);
		        			vBitmapCanvas.drawText(""+tradeStr[Utilis.toInt(Lineii[14])],stdX+300 ,stdY+locX+20+(max)*locY , mPaintT7);
		        			
		        			vBitmapCanvas.drawRect(stdX+45, stdY+locX+24+(max-1)*locY, stdX+1600, stdY+locX+24+(max)*locY, mPaintT5);
		        			

			     			if (xMode==2){
				    			max++;
								if (max%mmax==0){
									saved(xMode);
						    		makeTitle(xMode);
									max=0;
								}
				    			for (int y=1;y< Lineiii.length;y++){
				    				String Lineiis[]=Lineiii[y].split(";");
			    					
			    		    			vBitmapCanvas.drawText(""+Lineiis[0],stdX+170 ,stdY+locX+(max)*locY , mPaintT7);
			    		    			vBitmapCanvas.drawText(""+Lineiis[1],stdX+400 ,stdY+locX+(max)*locY , mPaintT7);
			    		    			for (int i=0;i<=3;i++) vBitmapCanvas.drawText(""+df.format(Utilis.toDouble(Lineiis[i+2])),stdX+xx[i]+60-getNT7(df.format(Utilis.toDouble(Lineiis[i+2]))) ,stdY+locX+(max)*locY , mPaintT7);
			    					
			    		    			max++;
			    						if (max%mmax==0){
			    							saved(xMode);
			    				    		makeTitle(xMode);
			    							max=0;
			    						}
			    				}
			    			}else{
			        			max++;
			    				if (max%mmax==0){
			    					saved(xMode);
			    		    		makeTitle(xMode);
			    					max=0;
			    				}
			    			}
		    			}
		    	   		if (max!=0) saved(xMode);
		    			makePic();
				}
			}
		}
	}
};

private void makePic(){
	if (albun_array.toString() !=null && albun_array.toString().length()>0) {    						
	    zipList= (albun_array.toString().substring(0,albun_array.toString().length()-1)).split(",");
	    toZipF(MkqrSt.this,zipList, android.os.Environment.getExternalStorageDirectory().getAbsolutePath()+Utilis.getIni(MkqrSt.this, "SYS","YEAR", 8)+File.separator+"cwbuyer_albun_"+mSerch+".zip");
	    
		mGallery01.setAdapter(new ImageAdapter(MkqrSt.this, ChkPic()));		

		Bitmap bm = Utilis.getLimitBitmap(zipList[0], 600,900);
		
		if (bm!=null){	
			mImage.setImageBitmap(bm);
		}
}		

}


	private void makeTitle(int xMod){
		
		if (xMod==0){
				vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
				//印製台頭
				vBitmapCanvas.drawRect(stdX+90, stdY+113, stdX+1050, stdY+188, mPaintT5);
				vBitmapCanvas.drawRect(stdX+450, stdY+115, stdX+450, stdY+188, mPaintT5);
				//最大框
				//vBitmapCanvas.drawRect(stdX+90, stdY+275, stdX+1130, stdY+1350, mPaintT5);
				
				vBitmapCanvas.drawText("公司名稱 :"+titles[0],stdX+100 ,stdY+50 , mPaintT1);
				vBitmapCanvas.drawText("地址 :"+titles[2],stdX+100 ,stdY+75 , mPaintT4);
				vBitmapCanvas.drawText("電話 :"+titles[3],stdX+100 ,stdY+100 , mPaintT4);
				 vBitmapCanvas.drawText(title,stdX+550 ,stdY+100 , mPaintT1);
				 vBitmapCanvas.drawText("頁數/總頁數 :"+(counts+1)+"/"+PageT ,stdX+850 ,stdY+80 , mPaintT4);
				 vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+850 ,stdY+100 , mPaintT4);
				vBitmapCanvas.drawText("印單日期 :"+data.mFormdate,stdX+100 ,stdY+135 , mPaintT3);
				vBitmapCanvas.drawText("客戶編號 :"+data.mUser,stdX+100 ,stdY+158 , mPaintT3);
				vBitmapCanvas.drawText("本單件數 :"+data.mHandno,stdX+100 ,stdY+180 , mPaintT3);
				//
				vBitmapCanvas.drawText("聯絡電話 :"+uMobil,stdX+810 ,stdY+135 , mPaintT3);
	
				vBitmapCanvas.drawText("送貨單號 :"+data.mFno,stdX+460 ,stdY+135 , mPaintT3);
				vBitmapCanvas.drawText("客戶寶號 :"+data.mUsername,stdX+460 ,stdY+158 , mPaintT3);
				//
				vBitmapCanvas.drawText("送貨地址 :"+uAddress,stdX+460 ,stdY+180 , mPaintT3);
				
				vBitmapCanvas.drawText("產品編號",stdX+100 ,stdY+211 , mPaintT3);
				vBitmapCanvas.drawText("產品名稱",stdX+385 ,stdY+211 , mPaintT3);
				vBitmapCanvas.drawText("數量",stdX+713 ,stdY+211 , mPaintT3);
				vBitmapCanvas.drawText("單價",stdX+833 ,stdY+211 , mPaintT3);
				vBitmapCanvas.drawText("小計",stdX+996 ,stdY+211 , mPaintT3);
				//橫線
				vBitmapCanvas.drawRect(stdX+90, stdY+188, stdX+1050, stdY+215, mPaintT5);
				//最下框
		}else if (xMod==1 || xMod==2){
			//日結單的抬頭 2含括商品明細
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawRect(stdX+47, stdY+locX-160, stdX+1600, stdY+locX-80, mPaintT8);			
			vBitmapCanvas.drawText(""+titles[0]+"   "+title+" 交易明細表  交易日期 "+mSerch+"",stdX+100 ,stdY+locX-180 , mPaintT1);
			 vBitmapCanvas.drawText("頁數/總頁數 :"+(counts+1)+"/"+PageT ,stdX+1250 ,stdY+locX-185 , mPaintT7);
			 vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+1250 ,stdY+locX-165 , mPaintT7);
			vBitmapCanvas.drawText("本期合計: ",stdX+50 ,stdY+locX-60 , mPaintT7);		
			vBitmapCanvas.drawText("總未收金額 : "+df.format(allSum),stdX+230 ,stdY+locX-60 , mPaintT7);
			
			vBitmapCanvas.drawText("單       號                     會員編號 會員名稱             交易人員",stdX+50 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("原價金額",stdX+xx[0]-16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("交易金額",stdX+xx[1]-16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("折扣金",stdX+xx[2]+16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("尾數折讓",stdX+xx[3]-16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("現金收入",stdX+xx[4]-16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("票刷金額",stdX+xx[5]-16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("匯款金額",stdX+xx[6]-16 ,stdY+locX-30 , mPaintT7);
			vBitmapCanvas.drawText("代墊運費",stdX+xx[7]-16 ,stdY+locX-30 , mPaintT7);
			
			//vBitmapCanvas.drawText("分類帳目",stdX+100 ,stdY+locX-120 , mPaintT7);
			//vBitmapCanvas.drawText("各項合計",stdX+100 ,stdY+locX-90 , mPaintT7);
			//for (int y=0;y<8;y++)	vBitmapCanvas.drawText(""+Tradetype[y]+"    ".substring(0,4),stdX+xx[y]+64-Tradetype[y].length()*20 ,stdY+locX-120 , mPaintT7);
			
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-50, stdX+1600, stdY+locX-80, mPaintT5);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-160, stdX+1600, stdY+locX-23, mPaintT5);
		}else if (xMod==3 || xMod==4){
			//對帳單的抬頭
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(""+titles[0]+"  "+title+" 對帳單 範圍 : "+mStartDay+"~"+mEndDay,stdX+100 ,stdY+locX-150 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+1250 ,stdY+locX-145 , mPaintT4);
			if (xMode==4){
				vBitmapCanvas.drawRect(stdX+45, stdY+locX-50, stdX+1133, stdY+locX-22, mPaintT8);
				vBitmapCanvas.drawText("交易日期",stdX+50 ,stdY+locX-28 , mPaintT9);
				vBitmapCanvas.drawText("單 號",stdX+180 ,stdY+locX-28 , mPaintT9);
				vBitmapCanvas.drawText("總件數",stdX+550 ,stdY+locX-28 , mPaintT9);
				vBitmapCanvas.drawText("商品編號",stdX+150 ,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("品名",stdX+320 ,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("件數",stdX+800 ,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("單價",stdX+880 ,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("小計",stdX+975,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("折扣",stdX+1080 ,stdY+locX , mPaintT3);
			}else{
				vBitmapCanvas.drawText("交易日期",stdX+50 ,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("單 號",stdX+180 ,stdY+locX , mPaintT3);
				vBitmapCanvas.drawText("總件數",stdX+550 ,stdY+locX , mPaintT3);
			}
			//mBufTitle
			//廠商
			if (mKind.equalsIgnoreCase("10")){
				if (xMode==4){
					vBitmapCanvas.drawText("本單應付",stdX+400 ,stdY+locX -28, mPaintT9);
					vBitmapCanvas.drawText("計款數",stdX+700 ,stdY+locX-28 , mPaintT9);
				}else{
					vBitmapCanvas.drawText("本單應付",stdX+400 ,stdY+locX, mPaintT3);
					vBitmapCanvas.drawText("計款數",stdX+700 ,stdY+locX , mPaintT3);
				}	
				vBitmapCanvas.drawText("廠商 : "+mBufTitle[0],stdX+70 ,stdY+locX-95 , mPaintT1);
		 		vBitmapCanvas.drawText("日期範圍 : "+mStartDay+"~"+mEndDay,stdX+400 ,stdY+locX-95 , mPaintT1);
			
				 vBitmapCanvas.drawText("本期"+mBufTitle[5],stdX+70 ,stdY+locX-60 , mPaintT1);
				 vBitmapCanvas.drawText("本期"+mBufTitle[2],stdX+400 ,stdY+locX-60 , mPaintT1);
				 vBitmapCanvas.drawText("本期"+mBufTitle[3],stdX+800 ,stdY+locX-60 , mPaintT1);
			}else{
				if (xMode==4){
					if (mKind.equalsIgnoreCase("20") || mKind.equalsIgnoreCase("21")){
						vBitmapCanvas.drawText("本單應付",stdX+400 ,stdY+locX -28, mPaintT9);
						vBitmapCanvas.drawText("已付現",stdX+700 ,stdY+locX-28 , mPaintT9);
						vBitmapCanvas.drawText("已付票",stdX+850,stdY+locX-28 , mPaintT9);
						vBitmapCanvas.drawText("已代運",stdX+1000 ,stdY+locX-28 , mPaintT9);
					}else{
					vBitmapCanvas.drawText("本單應收",stdX+400 ,stdY+locX -28, mPaintT9);
					vBitmapCanvas.drawText("已收現",stdX+700 ,stdY+locX-28 , mPaintT9);
					vBitmapCanvas.drawText("已收票",stdX+850,stdY+locX-28 , mPaintT9);
					vBitmapCanvas.drawText("已代運",stdX+1000 ,stdY+locX-28 , mPaintT9);
					}
				}else{
					vBitmapCanvas.drawText("本單應收",stdX+400 ,stdY+locX , mPaintT3);
					vBitmapCanvas.drawText("已收現",stdX+700 ,stdY+locX , mPaintT3);
					vBitmapCanvas.drawText("已收票",stdX+850,stdY+locX , mPaintT3);
					vBitmapCanvas.drawText("已代運",stdX+1000 ,stdY+locX , mPaintT3);
				}
				if (mKind.equalsIgnoreCase("30") || mKind.equalsIgnoreCase("31"))
					vBitmapCanvas.drawText("客戶 : "+mBufTitle[0],stdX+70 ,stdY+locX-95 , mPaintT1);
				else if (mKind.equalsIgnoreCase("40") || mKind.equalsIgnoreCase("41"))
					vBitmapCanvas.drawText("櫃員 : "+mBufTitle[0],stdX+70 ,stdY+locX-95 , mPaintT1);
				else
				vBitmapCanvas.drawText("門市 : "+mBufTitle[0],stdX+70 ,stdY+locX-95 , mPaintT1);
				
				 vBitmapCanvas.drawText("本期"+mBufTitle[2],stdX+500 ,stdY+locX-95 , mPaintT1);
				 vBitmapCanvas.drawText(""+mBufTitle[1],stdX+900 ,stdY+locX-95 , mPaintT1);
			
				 vBitmapCanvas.drawText("本期"+mBufTitle[3],stdX+70 ,stdY+locX-60 , mPaintT1);
				 vBitmapCanvas.drawText("本期"+mBufTitle[4],stdX+500 ,stdY+locX-60 , mPaintT1);
				 vBitmapCanvas.drawText("合計"+mBufTitle[5],stdX+900 ,stdY+locX-60 , mPaintT1);
				
			}
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-140, stdX+1133, stdY+locX+10, mPaintT5);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-50, stdX+1133, stdY+locX-50, mPaintT5);
			
		}else if (xMod==5 || xMod==6){ //月報表
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			//vBitmapCanvas.drawText(""+titles[0]+"   "+title+"   日期範圍 "+mSerch+"  門市 : "+mDept.substring(0,mDept.indexOf(";")),stdX+100 ,stdY+locX-180 , mPaintT1);
			vBitmapCanvas.drawText(titles[0]+" 門市 :"+mDept+" 門市業績表   "+mStartDay+"~"+mEndDay,stdX+100 ,stdY+locX-180 , mPaintT1);
			 vBitmapCanvas.drawText("頁數/總頁數 :"+(counts+1)+"/"+PageT ,stdX+1250 ,stdY+locX-185 , mPaintT4);
			 vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+1250 ,stdY+locX-165 , mPaintT4);
	//		vBitmapCanvas.drawText("日      期     總單數       總原價           折扣      尾數     銷售金額    實收金額",stdX+50 ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("日      期",stdX+xx[0] ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("總單(件)數",stdX+xx[1]-60 ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("總原價",stdX+xx[2]-50 ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("折扣",stdX+xx[3]-30 ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("尾數",stdX+xx[4]-30 ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("銷售金額",stdX+xx[5]-68 ,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("實收金額",stdX+xx[6] -68,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("現金",stdX+xx[7] -30,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("票刷",stdX+xx[8] -30,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("匯款",stdX+xx[9] -30,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("代墊",stdX+xx[10] -30,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("訂金現金",stdX+xx[11] -68,stdY+locX-60 , mPaintT4);
				vBitmapCanvas.drawText("應金刷卡",stdX+xx[12] -68,stdY+locX-60 , mPaintT4);
				//for (int y=0;y<8;y++)	vBitmapCanvas.drawText(""+Tradetype[y]+"       ".substring(0,7),stdX+xx[7+y]-Tradetype[y].length()*16 ,stdY+locX-60 , mPaintT4);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-160, stdX+1600, stdY+locX-20, mPaintT5);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1600, stdY+locX-80, mPaintT5);
			
			vBitmapCanvas.drawText("合      計",stdX+50 ,stdY+locX-100 , mPaintT4);
		}else if (xMod==7){  //廠商追加分析
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(""+titles[0]+mKind,stdX+100 ,stdY+locX-100 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+980 ,stdY+locX-100 , mPaintT4);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1133, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("廠商資料",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("商品編號",stdX+xx[1] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("商品描述",stdX+xx[2] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("尚存",stdX+xx[3] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("總/本進",stdX+xx[4] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("總/本銷",stdX+xx[5] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("銷率",stdX+xx[6] ,stdY+locX-58 , mPaintT3);
		}else if (xMod==8){  //新品暢銷排行
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(""+titles[0]+mKind,stdX+100 ,stdY+locX-100 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+980 ,stdY+locX-100 , mPaintT4);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1133, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("商品編號",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("商品描述",stdX+xx[1] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("規格",stdX+xx[2] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("總進/存貨",stdX+xx[3] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("總銷/毛利",stdX+xx[4] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("毛利/毛率",stdX+xx[5] ,stdY+locX-58 , mPaintT3);
		}else if (xMod==9){  //暢銷排行
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(""+titles[0]+mKind,stdX+100 ,stdY+locX-100 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+980 ,stdY+locX-100 , mPaintT4);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1133, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("商品編號",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("商品描述",stdX+xx[1] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("總進/存貨",stdX+xx[2] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("總銷/毛利",stdX+xx[3] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("本銷/毛利",stdX+xx[4] ,stdY+locX-58 , mPaintT3);

		}else if (xMod==11 || xMod==12){  //只印 表頭(標準型) QRep_03
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(""+titles[0]+" "+mSerch,stdX+100 ,stdY+locX-100 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+980 ,stdY+locX-100 , mPaintT4);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1133, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText(mStartDay+"/貨號",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("名稱/品名",stdX+xx[1] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("件數小計",stdX+xx[2] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("金額小計",stdX+xx[3] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("成本小計",stdX+xx[4] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("毛利分析",stdX+xx[5] ,stdY+locX-58 , mPaintT3);
			
		}else if (xMod==13){  //盤點清冊
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(mSerch,stdX+300 ,stdY+locX-130 , mPaintT2);
			vBitmapCanvas.drawText(mKind,stdX+100 ,stdY+locX-95 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+980 ,stdY+locX-100 , mPaintT4);
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-80, stdX+1133, stdY+locX-50, mPaintT5);
			vBitmapCanvas.drawText("貨品編號",stdX+xx[0] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("存",stdX+xx[1] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("盤存",stdX+xx[2] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("單  價",stdX+xx[3] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("%",stdX+xx[4] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("貨品編號",stdX+xx[5] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("存",stdX+xx[6] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("盤存",stdX+xx[7] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("單  價",stdX+xx[8] ,stdY+locX-58 , mPaintT3);
			vBitmapCanvas.drawText("%",stdX+xx[9] ,stdY+locX-58 , mPaintT3);
			
		}else if (xMod==14){  //盤點對帳請款單
			//xx[0-4] 日期 單號 件數 進貨金 退貨金  
			vBitmapCanvas.drawColor(getResources().getColor(R.drawable.white));
			vBitmapCanvas.drawText(mSerch,stdX+300 ,stdY+locX-130 , mPaintT2);
			vBitmapCanvas.drawText(mKind,stdX+100 ,stdY+locX-95 , mPaintT1);
			vBitmapCanvas.drawText("製單 :"+DateUtil.getFormatDate(),stdX+980 ,stdY+locX-100 , mPaintT4);
			
		}else if (xMod==15){  //總庫存分析
			int rightS=550;
			//vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
			vBitmapCanvas.drawText(mBufTitle[0],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
			vBitmapCanvas.drawText(mBufTitle[1],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
			max++;		
			vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
			max++;		
			vBitmapCanvas.drawText(mBufTitle[2],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
			vBitmapCanvas.drawText(mBufTitle[3],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
//			vBitmapCanvas.drawRect(stdX+45, stdY+locX-72+(max+1)*locY, stdX+1133, stdY+locX-42+(max+1)*locY, mPaintT5);
//			vBitmapCanvas.drawText(mBufTitle[4],stdX+xx[0] ,stdY+locX-50+(max+1)*locY , mPaintT1);
//			vBitmapCanvas.drawText(mBufTitle[5],stdX+xx[0]+rightS ,stdY+locX-50+(max+1)*locY , mPaintT1);
			max++;		
			max++;		
			max++;		
			max++;		
		}
	}		
}


	