Subversion Repositories SmartDukaan

Rev

Rev 8034 | Rev 8036 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8034 Rev 8035
Line 49... Line 49...
49
import org.slf4j.LoggerFactory;
49
import org.slf4j.LoggerFactory;
50
 
50
 
51
import com.ibm.icu.text.RuleBasedNumberFormat;
51
import com.ibm.icu.text.RuleBasedNumberFormat;
52
 
52
 
53
import com.itextpdf.text.Document;
53
import com.itextpdf.text.Document;
-
 
54
import com.itextpdf.text.DocumentException;
54
import com.itextpdf.text.Element;
55
import com.itextpdf.text.Element;
55
import com.itextpdf.text.Font;
56
import com.itextpdf.text.Font;
56
import com.itextpdf.text.FontFactory;
57
import com.itextpdf.text.FontFactory;
57
import com.itextpdf.text.FontFactoryImp;
58
import com.itextpdf.text.FontFactoryImp;
58
import com.itextpdf.text.Image;
59
import com.itextpdf.text.Image;
Line 213... Line 214...
213
					}
214
					}
214
					document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
215
					document.add(getExtraInfoTable(order, provider, 16, warehouse.getBillingType()));
215
					continue;
216
					continue;
216
				}
217
				}
217
 
218
 
218
				PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, PdfWriter.getInstance(document, baosPDF));
219
				PdfPTable dispatchAdviceTable = getDispatchAdviceTable(order, warehouse, provider, barcodeFontSize, destCode, withBill, shippingLocation, document, baosPDF);
219
				dispatchAdviceTable.setSpacingAfter(10.0f);
220
				dispatchAdviceTable.setSpacingAfter(10.0f);
220
				dispatchAdviceTable.setWidthPercentage(90.0f);
221
				dispatchAdviceTable.setWidthPercentage(90.0f);
221
 
222
 
222
				document.add(dispatchAdviceTable);
223
				document.add(dispatchAdviceTable);
223
				if(withBill){
224
				if(withBill){
Line 254... Line 255...
254
			logger.error("Error while generating Invoice: ", e);
255
			logger.error("Error while generating Invoice: ", e);
255
		}
256
		}
256
		return baosPDF;
257
		return baosPDF;
257
	}
258
	}
258
 
259
 
259
	private PdfPTable getDispatchAdviceTable(Order order, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation, PdfWriter pdfWriter){
260
	private PdfPTable getDispatchAdviceTable(Order order, Warehouse warehouse, Provider provider, float barcodeFontSize, String destCode, boolean withBill, Warehouse shippingLocation, Document doc, ByteArrayOutputStream baos){
260
		Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
261
		Font barCodeFont = getBarCodeFont(provider, barcodeFontSize);
261
 
262
 
262
		PdfPTable table = new PdfPTable(1);
263
		PdfPTable table = new PdfPTable(1);
263
		table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
264
		table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
264
 
265
 
265
		PdfPTable logoTable = new PdfPTable(2);
266
		PdfPTable logoTable = new PdfPTable(2);
266
		addLogoTable(logoTable, order);
267
		addLogoTable(logoTable, order);
267
		
268
		
268
		PdfPCell titleCell = getTitleCell();
269
		PdfPCell titleCell = getTitleCell();
269
		PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false);
270
		PdfPTable customerTable = getCustomerAddressTable(order, destCode, false, helvetica12, false);
270
		PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont, pdfWriter);
271
		PdfPTable providerInfoTable = getProviderTable(order, provider, barCodeFont, doc, baos);
271
 
272
 
272
		PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
273
		PdfPTable dispatchTable = new PdfPTable(new float[]{0.5f, 0.1f, 0.4f});
273
		dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
274
		dispatchTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
274
		dispatchTable.addCell(customerTable);
275
		dispatchTable.addCell(customerTable);
275
		dispatchTable.addCell(new Phrase(" "));
276
		dispatchTable.addCell(new Phrase(" "));
Line 301... Line 302...
301
				Barcode128 code128 = new Barcode128();
302
				Barcode128 code128 = new Barcode128();
302
				code128.setGenerateChecksum(true);
303
				code128.setGenerateChecksum(true);
303
				code128.setCode("*"+fedexCodReturnBarcode+"*"); 
304
				code128.setCode("*"+fedexCodReturnBarcode+"*"); 
304
				chargesTable.addCell(new Phrase("PRIORITY OVERNIGHT ", helvetica8));
305
				chargesTable.addCell(new Phrase("PRIORITY OVERNIGHT ", helvetica8));
305
				chargesTable.addCell(formIdCell);
306
				chargesTable.addCell(formIdCell);
-
 
307
				
-
 
308
				doc.open();
-
 
309
				try {
-
 
310
					baos = new ByteArrayOutputStream();
306
				chargesTable.addCell(code128.createImageWithBarcode(pdfWriter.getDirectContent(), null, null));
311
					chargesTable.addCell(code128.createImageWithBarcode(PdfWriter.getInstance(doc, baos).getDirectContent(), null, null));
-
 
312
				} catch (Exception e) {
-
 
313
					logger.error("Error while adding COD return barcode for FedEx: ", e);
-
 
314
				}
-
 
315
				
307
			}
316
			}
308
			//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
317
			//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
309
		} else {
318
		} else {
310
			chargesTable.addCell(new Phrase("Do not pay any extra charges to the Courier."));  
319
			chargesTable.addCell(new Phrase("Do not pay any extra charges to the Courier."));  
311
		}
320
		}
Line 370... Line 379...
370
		titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
379
		titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
371
		titleCell.setBorder(Rectangle.NO_BORDER);
380
		titleCell.setBorder(Rectangle.NO_BORDER);
372
		return titleCell;
381
		return titleCell;
373
	}
382
	}
374
 
383
 
375
	private PdfPTable getProviderTable(Order order, Provider provider, Font barCodeFont, PdfWriter pdfWriter) {
384
	private PdfPTable getProviderTable(Order order, Provider provider, Font barCodeFont, Document doc, ByteArrayOutputStream baos) {
376
		PdfPTable providerInfoTable = new PdfPTable(1);
385
		PdfPTable providerInfoTable = new PdfPTable(1);
377
		providerInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
386
		providerInfoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
378
		if(order.isLogisticsCod()){
387
		if(order.isLogisticsCod()){
379
			PdfPCell deliveryTypeCell = new PdfPCell(new Phrase("COD   ", helvetica28));
388
			PdfPCell deliveryTypeCell = new PdfPCell(new Phrase("COD   ", helvetica28));
380
			deliveryTypeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
389
			deliveryTypeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
381
			deliveryTypeCell.setBorder(Rectangle.NO_BORDER);
390
			deliveryTypeCell.setBorder(Rectangle.NO_BORDER);
382
			providerInfoTable.addCell(deliveryTypeCell);
391
			providerInfoTable.addCell(deliveryTypeCell);
383
		}
392
		}
384
		
393
		
-
 
394
		
385
		PdfPCell providerNameCell = new PdfPCell(new Phrase(provider.getName(), helveticaBold12));
395
		PdfPCell providerNameCell = new PdfPCell(new Phrase(provider.getName(), helveticaBold12));
386
		providerNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
396
		providerNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
387
		providerNameCell.setBorder(Rectangle.NO_BORDER);
397
		providerNameCell.setBorder(Rectangle.NO_BORDER);
388
		PdfPCell formIdCell= null;
398
		PdfPCell formIdCell= null;
389
		if(order.getLogistics_provider_id()==7L){
399
		if(order.getLogistics_provider_id()==7L){
Line 423... Line 433...
423
			providerInfoTable.addCell(formIdCell);
433
			providerInfoTable.addCell(formIdCell);
424
		}
434
		}
425
		//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
435
		//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
426
		providerInfoTable.addCell(awbNumberCell);
436
		providerInfoTable.addCell(awbNumberCell);
427
		if(order.getLogistics_provider_id()==7L && fedexPackageBarcode!=null ){
437
		if(order.getLogistics_provider_id()==7L && fedexPackageBarcode!=null ){
-
 
438
			doc.open();
428
			Barcode128 code128 = new Barcode128();
439
			Barcode128 code128 = new Barcode128();
429
			code128.setGenerateChecksum(true);
440
			code128.setGenerateChecksum(true);
430
			code128.setCode("*"+fedexPackageBarcode+"*"); 
441
			code128.setCode("*"+fedexPackageBarcode+"*"); 
-
 
442
			try {
-
 
443
				baos = new ByteArrayOutputStream();
431
			providerInfoTable.addCell(code128.createImageWithBarcode(pdfWriter.getDirectContent(), null, null));
444
				providerInfoTable.addCell(code128.createImageWithBarcode(PdfWriter.getInstance(doc, baos).getDirectContent(), null, null));
-
 
445
			} catch (Exception e) {
-
 
446
				logger.error("Error while adding barcode for FedEx: ", e);
-
 
447
			}
432
		}
448
		}
433
		
449
		
434
		Warehouse warehouse = null;
450
		Warehouse warehouse = null;
435
		try{
451
		try{
436
    		InventoryClient isc = new InventoryClient();
452
    		InventoryClient isc = new InventoryClient();