<?php
/**
* @filename        Endicia.php
* @description     This class is for A.R. ZERIN
* @version         1.0
* @package         MSHShippingLibrary.shippingClasses
* @author          A.R. ZERIN
*
* @link            http://arzerin.com
* @created on      November 2, 2011
* @Dependencies    Endicia
* @license         A.R. ZERIN
***/

class Endicia extends Carrier
{
    private $services;

    /* Test Mode URL */ 
    //private $webServiceURL = 'https://www.envmgr.com/LabelService/EwsLabelService.asmx';

    /* Production Mode URL */
    private $webServiceURL = 'https://LabelServer.Endicia.com/LabelService/EwsLabelService.asmx';

    private $webService = '';
    private $webServicePath = '';
    private $webMethod = '';
    private $param = '';
    private $err_code = '';
    private $err_details = '';
    private $apiresponse = '';
    private $testMode = '0';
    private $isValidAccount = '0';
	private $postageBalance = '0';
	private $deviceID = '';
	private $showReturnAddress = TRUE;
	private $mailClass = '';
	private $productWeight = '0';
	private $stealth = FALSE;
	private $productValue = '';
	private $productDescription = '';
	private $partnerCustomerID = '';
	private $partnerTransactionID = '';
	private $toName = '';
	private $toCompany = '';
	private $toAddress1 = '';
	private $toCity = '';
	private $toState = '';
	private $toPostalCode = '';
	private $toPhone = '';
	private $fromName = '';
	private $fromCompany = '';
	private $returnAddress1 = '';
	private $fromCity = '';
	private $fromState = '';
	private $fromPostalCode = '';
	private $fromZIP4 = '';
	private $fromPhone = '';
	private $errCode = '';
	private $errDetails = '';
	private $labelTestMode = '';
	private $labelSize = '';
	private $newPassword = '';
	private $postageAmount = 0;
	private $imageFormat = 'gif';
	private $imageResolution = '300';
	private $mailpieceshape = 'Parcel';
	private $labeltype = 'Default';
	
    public function Endicia()
    {
        parent::Carrier();
        $this->err_code = '';
        $this->err_details = '';
		$this->errCode = '';
		$this->errDetails = '';
		
		
		/* Test Mode URL */
        //$this->setRequestUrl('https://www.envmgr.com/LabelService/EwsLabelService.asmxl');
        //$this->setWebServiceURL('https://www.envmgr.com/LabelService/EwsLabelService.asmx');
        
        /* Production Mode URL */
        $this->setRequestUrl('https://LabelServer.Endicia.com/LabelService/EwsLabelService.asmx');
        $this->setWebServiceURL('https://LabelServer.Endicia.com/LabelService/EwsLabelService.asmx');
        
        $this->setDefaultUserId('821714');            //Endicia Account Number
        $this->setDefaultCredentialOne('lpwc');           //Endicia Partner ID
        $this->setDefaultCredentialTwo('!PwC2011');    //Endicia PassPhrase
        $this->setCacheTableSuffix('endicia');
		$this->labelTestMode = 'YES';
		$this->labelSize = '4X6';
		$this->imageFormat = 'gif';
		$this->imageResolution = '300';
    }
    public function checkAccount(){
        $this->setWebService('GetAccountStatusXML');
        $this->setWebMethod('accountStatusRequestXML');
        $sxml = $this->getResponse($this->getAccountStatusXML(),'simplexmlobject');
		if($sxml->Status!='0'){
			$this->setErrCode($sxml->Status);
			$this->setErrDetails($sxml->ErrorMessage);
		}

		if($sxml->Status=='0'){ //if($sxml->Status!='1001'){
			$sxml2= $sxml->CertifiedIntermediary;
			$this->postageBalance = $sxml2->PostageBalance;
		}
		if(isset($sxml2->AccountStatus) && $sxml2->AccountStatus=='A'){
			$this->isValidAccount = 1; 
		}elseif( isset($sxml2->AccountStatus) && $sxml2->AccountStatus!='A'){
			$this->isValidAccount = 0;
		}else {
			$this->isValidAccount = 0;
		}	

		if(isset($sxml2->DeviceID) && $sxml2->DeviceID=='FakeDeviceID'){
			$this->testMode=1;	
			$this->deviceID=$sxml2->DeviceID;	
			$this->isValidAccount = 0;
		}elseif(isset($sxml2->DeviceID) && $sxml2->DeviceID!=''){
			$this->testMode=0;	
			$this->deviceID = isset($sxml2->DeviceID) ? $sxml2->DeviceID : '';	
			$this->isValidAccount = 1; 
		}else{
			$this->testMode=0;
			$this->isValidAccount = 0;
		}


		
    }
    public function isValidAccount(){
        if ($this->isValidAccount==1)
        	return TRUE;
        else
        	return FALSE;
    }    
    public function isTestAccount(){
        if ($this->testMode==1)
        	return TRUE;
        else
        	return FALSE;
    }    
    public function getResponse($xml, $response_type = 'text')
    {
		$this->param = array('http' => array(
		     'method' => 'POST',
		     'content' => $this->webMethod.'='.$xml,
		     'header' => 'Content-Type: application/x-www-form-urlencoded'));
		 //$this->setWebServiceURL('https://LabelServer.Endicia.com/LabelService/EwsLabelService.asmx');
		 //die('here'.$this->webServiceURL);
		 $ctx = stream_context_create($this->param);
		 $this->webServicePath = $this->webServiceURL.'/'.$this->webService;
		 $fp = fopen($this->webServicePath, 'rb', false, $ctx);
		
		 if (!$fp) 
		 {
		     $this->err_code = -1;
		     $this->err_details = "Problem with ".$this->webServicePath;
		 }
		 $this->apiresponse = stream_get_contents($fp);
		 
		 if ($this->apiresponse === false) 
		 {
		     $this->err_code = 0;
		     $this->err_details = "Problem reading data from ".$this->webServicePath;
		 }
		 if ($response_type=='simplexmlobject'){
		 	
			 $sxml = @Simplexml_load_string( $this->apiresponse );
		 	 return $sxml;
		 }	
		 return  $this->apiresponse; 	
    }    
    public function calculate()
    {
        $this->logMessage('Validating Information for Endicia');
        $this->validateServiceSelected();
        //$this->validateFromState();
        //$this->validateFromZip();
        //$this->validateFromCountyCode();
        //$this->validateToCity();
        //$this->validateToState();
       // $this->validateToZip();
        //$this->validateToCountyCode();
       // $this->item->validate(array('weight', 'length', 'height', 'width'));
        
		$temp_xml = '<PostageRatesRequest>
						<RequesterID>abcd</RequesterID>
						<CertifiedIntermediary> 
							<AccountID>676520</AccountID>
							<PassPhrase>autoship777</PassPhrase> 
						</CertifiedIntermediary> 
						<MailClass>Domestic</MailClass>
						<WeightOz>9.5</WeightOz>
						<MailpieceShape>Parcel</MailpieceShape>
						<Machinable>True</Machinable>
						<Services DeliveryConfirmation="OFF" SignatureConfirmation="OFF"/>
						<FromPostalCode>94306</FromPostalCode> 
						<ToPostalCode>20260</ToPostalCode>
					</PostageRatesRequest>';
		$temp_xml = 'postageRatesRequestXML='.$temp_xml;
		
        if($this->isValid())
        {
        	
        	$this->setRequestUrl('https://www.envmgr.com/LabelService/EwsLabelService.asmx/CalculatePostageRatesXML');
            $this->setRequestString($this->getXML());
            //$this->setHeader('Content-Type', 'text/xml');
            $this->makeAPICall();
			//echo '<pre>';
			//print_r($this->getXML());
			//echo '</pre>';
			//echo 'Here';
        }else{
			//echo 'Here 2';
		}
		//print_r($this->response);
		//print_r($this->getXML());
        return $this->response;
    }
    protected function getSearchString()
    {
        $this->searchString = $this->getUserId() . ':'
                                . $this->getFromZip() . ':'
                                . $this->item->getQuantity() . ':'
                                . $this->item->getWeightInOunce() . ':'
                                . $this->item->getLengthInCentimeter() . ':'
                                . $this->item->getWidthInCentimeter() . ':'
                                . $this->item->getHeightInCentimeter() . ':'
                                . $this->getWeightUnit() . ':'
                                . $this->getLengthUnit();

        if(in_array($this->getToCountryCode(), array('US', 'CA')))
        {
            $this->searchString .= $this->getToStateCode() . ':'
                                . $this->getToCountryCode() . ':'
                                . $this->getToZip();
        }
        else
        {
            $this->searchString .= $this->getToCountryCode();
        }

        return $this->searchString;    	
    }
    private function getXML()
    {
    	$weight = 0;
    	$tmp_weight = 0;
        
		$weight = ((int) ceil($this->item->getWeightInOunce())) * $this->item->getQuantity();    //converting weight to ounce
				        
        if($this->getFromCountryCode() == $this->getToCountryCode())
		   $mailClass = 'Domestic';
		else
		   $mailClass = 'International';
					       
		$xml = '<PostageRatesRequest>
						<RequesterID>' . $this->getCredentialTwo() . '</RequesterID>
						<CertifiedIntermediary> 
							<AccountID>' . $this->getUserId() . '</AccountID>
							<PassPhrase>' . $this->getCredentialOne() . '</PassPhrase> 
						</CertifiedIntermediary> 
						<MailClass>'.$mailClass.'</MailClass>
						<WeightOz>'.$weight.'</WeightOz>
						<MailpieceShape>Parcel</MailpieceShape>
						<Machinable>True</Machinable>
						<Services DeliveryConfirmation="OFF" SignatureConfirmation="OFF"/>
						<FromPostalCode>' . $this->getFromZip() . '</FromPostalCode> 
						<ToPostalCode>' . $this->getToZip() . '</ToPostalCode>
                        <FromCountryCode>' . $this->getFromCountryCode() . '</FromCountryCode>
                        <ToCountryCode>' . $this->getToCountryCode() . '</ToCountryCode>
		                <ResponseOptions PostagePrice="TRUE"/>
					</PostageRatesRequest>';

		if ($mailClass == 'International')
		{
		$xml = '<PostageRatesRequest>
						<RequesterID>' . $this->getCredentialTwo() . '</RequesterID>
						<CertifiedIntermediary> 
							<AccountID>' . $this->getUserId() . '</AccountID>
							<PassPhrase>' . $this->getCredentialOne() . '</PassPhrase> 
						</CertifiedIntermediary> 
						<MailClass>'.$mailClass.'</MailClass>
						<WeightOz>'.$weight.'</WeightOz>
						<MailpieceShape>Parcel</MailpieceShape>
						<Machinable>True</Machinable>
						<Services DeliveryConfirmation="OFF" SignatureConfirmation="OFF"/>
						<FromPostalCode>' . $this->getFromZip() . '</FromPostalCode> 
						<ToPostalCode>' . $this->getToZip() . '</ToPostalCode>
                        <FromCountryCode>' . $this->getFromCountryCode() . '</FromCountryCode>
		        		<ToCountry>' . $this->getToCountry() . '</ToCountry>
                        <ToCountryCode>' . $this->getToCountryCode() . '</ToCountryCode>
		                <ResponseOptions PostagePrice="TRUE"/>
					</PostageRatesRequest>';
		}			


		$xml = 'postageRatesRequestXML='.$xml;
/*
		 $fp = fopen('myshipdata.txt', 'a+');
		 fwrite($fp, $xml);
		 fclose($fp); 
*/
        return $xml;       
    }
    function getAccountStatusXML()
    {
		$xml = '<AccountStatusRequest>
						<RequesterID>' . $this->getCredentialTwo() . '</RequesterID>
						<RequestID>pwc2011</RequestID>
						<CertifiedIntermediary>
						<AccountID>' . $this->getUserId() . '</AccountID>
						<PassPhrase>' . $this->getCredentialOne() . '</PassPhrase>
						</CertifiedIntermediary>
					</AccountStatusRequest>';
       
        return $xml;
    }
	function setWebMethod($name){
		$this->webMethod=$name;
	}	   
	function setWebService($name){
		$this->webService=$name;
	}	
	private function getServiceName($enum)
    {
        if(empty($this->services))
        {
            $this->services = array(  'First-Class Mail' => 'First-Class Mail',
                                'Priority Mail' => 'Priority Mail',
                                'Express Mail' => 'Express Mail',
                                'Library Mail' => 'Library Mail',
                                'Media Mail' => 'Media Mail',
                                'Parcel Post' => 'Parcel Post');
        }

        if(!empty($this->services[$enum]))
        {
            return $this->services[$enum];
        }

        return '';
    }
	protected function prepareResponse()
    {
         $obj = @simplexml_load_string($this->response->getRawResponse());

         $severity = '';
         if($obj)
            $severity = (string) $obj->HighestSeverity;
           
         if(in_array($severity, array('FAILURE', 'ERROR')))
         {
             $message = '';

             if($obj->Notifications)
             {
                 foreach($obj->Notifications as $notif)
                 {
                     $message .= $notif->Message . ' ';
                 }
             }
             $message = trim($message);

             if(!empty($message))
             {
                 $this->response->setError($message);
             }
         }
         else //WARNING, NOTE, SUCCESS
         {
             if(isset($obj->PostagePrice) && $obj->PostagePrice)
             {
        		$parser = new XMLParser();
        		$result = $parser->xml_parser_string_to_array($this->response->getRawResponse());		
        				
				for($i = 1; $i <= count($result)-4; $i++)
		        {
		        	//echo 'Total amount: '.$result[$i]['TOTALAMOUNT'].' -> Service: '.$result[$i]['postage']['mailservice'].' -> Postage Fee: '.$result[$i]['postage']['TOTALAMOUNT'].' -> Fee: '.$result[$i]['fees']['TOTALAMOUNT'].'<br/>';
		        	if(in_array($result[$i]['postage']['mailservice'], $this->getServices()))
                    {
                   	$this->response->setRate($result[$i]['postage']['mailservice'], $result[$i]['TOTALAMOUNT']);
		        	//$this->response->setRate($result[$i]['postage']['mailservice'].' [Postage Fee:'.$result[$i]['postage']['TOTALAMOUNT'].' + Handling Fee:'.$result[$i]['fees']['TOTALAMOUNT'].']', $result[$i]['TOTALAMOUNT']);
                    }
		        }
		        

                 $rates = $this->response->getRates();
                 if(!empty($rates))
                 {
                     $this->insertResponseToDB();
                 }
             }
         }
    }    
	public function getPostageBalance()
    {
		return $this->postageBalance;
	}
	public function setWebServiceURL($val)
    {
		$this->webServiceURL = $val;
	}	
	public function getWebServiceURL()
    {
		return $this->webServiceURL;
	}
    public function getLabel()
	{
		$labeldata = '';
        $this->setWebService('GetPostageLabelXML');
        $this->setWebMethod('labelRequestXML');
        $sxml = $this->getResponse($this->getLabelXML(),'simplexmlobject');
		if (is_object($sxml))
		{
			return $sxml;
		}else{
			return NULL;
		}
    }	
    function getLabelXML()
    {
    	
		$xml = '<LabelRequest  Test="'.$this->getLabelModeTest().'" LabelSize="' . $this->getLabelSize() . '" LabelType="Default" ImageResolution="203" ImageFormat="' . $this->getImageFormat() . '">
		     <RequesterID>' . $this->getCredentialTwo() . '</RequesterID>
		     <AccountID>' . $this->getUserId() . '</AccountID>
		     <PassPhrase>' . $this->getCredentialOne() . '</PassPhrase>
		     <MailClass>' . $this->getMailClass() . '</MailClass>';
		     
		if($this->getMailPieceShape()!='')
		$xml .='<MailpieceShape>' . $this->getMailPieceShape() . '</MailpieceShape>';
		
		$xml .='<DateAdvance>0</DateAdvance>
		     <WeightOz>' . $this->getProductWeight() . '</WeightOz>
		     <Stealth>' . $this->getStealth() . '</Stealth>
		     <Services InsuredMail="OFF" SignatureConfirmation="OFF" />
		     <Value>' . $this->getProductValue() . '</Value>
		     <PartnerCustomerID>' . $this->getPartnerCustomerID() . '</PartnerCustomerID>
		     <PartnerTransactionID>' . $this->getPartnerTransactionID() . '</PartnerTransactionID>
		     <ToName>' . $this->getToName() . '</ToName>
		     <ToCompany>' . $this->cleanXMLfromData($this->getToCompany()) . '</ToCompany>
		     <ToAddress1>' . $this->getToAddress1() . '</ToAddress1>
		     <ToCity>' . $this->getToCity() . '</ToCity>
		     <ToState>' . $this->getToState() . '</ToState>
		     <ToPostalCode>' . $this->getToPostalCode() . '</ToPostalCode>
		     <FromName>' . $this->getFromName() . '</FromName>
		     <FromCompany>' . $this->getFromCompany() . '</FromCompany>
		     <ReturnAddress1>' . $this->getReturnAddress1() . '</ReturnAddress1>
		     <FromCity>' . $this->getFromCity() . '</FromCity>
		     <FromState>' . $this->getFromState() . '</FromState>
		     <FromPostalCode>' . $this->getFromPostalCode() . '</FromPostalCode>
		     <FromZIP4>' . $this->getFromZIP4() . '</FromZIP4>';
		     
	if (!empty($this->fromPhone))	     
	$xml .=	'<FromPhone>' . $this->getFromPhone() . '</FromPhone>';
	
	$xml .=	'<ShowReturnAddress>' . $this->getShowReturnAddress() . '</ShowReturnAddress>
		     </LabelRequest>';   
		     
		     //echo '<pre>';
			 //print_r($xml);
			 //echo '</pre>';
			 //die(); 
        return $xml;
    }	
	public function setShowReturnAddress($val)
    {
		$this->showReturnAddress = $val;
	}		
	public function setMailClass($val)
    {
		$this->mailClass = $val;
	}	
	public function setProductWeight($val)
    {
		$this->productWeight = $val;
	}		
	public function setStealth($val)
    {
		$this->stealth = $val;
	}	
	public function setProductValue($val)
    {
		$this->productValue = $val;
	}	
	public function setProductDescription($val)
    {
		$this->productDescription = $val;
	}		
	public function setPartnerCustomerID($val)
    {
		$this->partnerCustomerID = $val;
	}		
	public function setPartnerTransactionID($val)
    {
		$this->partnerTransactionID = $val;
	}	
	public function setToName($val)
    {
		$this->toName = $val;
	}	
	public function setToCompany($val)
    {
		$this->toCompany = $val;
	}	
	public function setToAddress1($val)
    {
		$this->toAddress1 = $val;
	}	
	public function setToCity($val)
    {
		$this->toCity = $val;
	}	
	public function setToState($val)
    {
		$this->toState = $val;
	}	
	public function setToPostalCode($val)
    {
		$this->toPostalCode = $val;
	}	
	public function setToPhone($val)
    {
		$this->toPhone = $val;
	}	
	public function setFromName($val)
    {
		$this->fromName = $val;
	}	
	public function setFromCompany($val)
    {
		$this->fromCompany = $val;
	}	
	public function setReturnAddress1($val)
    {
		$this->returnAddress1 = $val;
	}	
	public function setFromCity($val)
    {
		$this->fromCity = $val;
	}	
	public function setFromState($val)
    {
		$this->fromState = $val;
	}	
	public function setFromPostalCode($val)
    {
		$this->fromPostalCode = $val;
	}	
	public function setFromZIP4($val)
    {
		$this->fromZIP4 = $val;
	}	
	public function setFromPhone($val)
    {
		$this->fromPhone = $val;
	}	
	public function getMailClass()
    {
		return $this->mailClass;
	}	
	public function getProductWeight()
    {
		return $this->productWeight;
	}		
	public function getStealth()
    {
		if ($this->stealth==True)
		return 'TRUE';
		else
		return 'FALSE';
	}	
	public function getProductValue()
    {
		return $this->productValue;
	}	
	public function getProductDescription()
    {
		return $this->productDescription;
	}		
	public function getPartnerCustomerID()
    {
		return $this->partnerCustomerID;
	}		
	public function getPartnerTransactionID()
    {
		return $this->partnerTransactionID;
	}	
	public function getToName()
    {
		return $this->toName;
	}	
	public function getToCompany()
    {
		return $this->toCompany;
	}	
	public function getToAddress1()
    {
		return $this->toAddress1;
	}	
	public function getToCity()
    {
		return $this->toCity;
	}	
	public function getToState()
    {
		return $this->toState;
	}	
	public function getToPostalCode()
    {
		return $this->toPostalCode;
	}	
	public function getToPhone()
    {
		return $this->toPhone;
	}	
	public function getFromName()
    {
		return $this->fromName;
	}	
	public function getFromCompany()
    {
		return $this->fromCompany;
	}	
	public function getReturnAddress1()
    {
		return $this->returnAddress1;
	}	
	public function getFromCity()
    {
		return $this->fromCity;
	}	
	public function getFromState()
    {
		return $this->fromState;
	}	
	public function getFromPostalCode()
    {
		return $this->fromPostalCode;
	}	
	public function getFromZIP4()
    {
		return $this->fromZIP4;
	}	
	public function getFromPhone()
    {
		return $this->fromPhone;
	}		
	public function getShowReturnAddress()
    {
		if ($this->showReturnAddress==True)
		return 'TRUE';
		else
		return 'FALSE';
	}		
	public function setErrCode($val)
    {
		$this->errCode = $val;
	}	
	public function setErrDetails($val)
    {
		$this->errDetails = $val;
	}			
	public function getErrCode()
    {
		return $this->errCode;
	}	
	public function getErrDetails()
    {
		return $this->errDetails;
	}
	public function setLabelModeTest($val)
    {
		$this->labelTestMode = $val;
	}				
	public function getLabelModeTest()
    {
		return $this->labelTestMode;
	}
	public function getLabelSize()
    {
		return $this->labelSize;
	}
	public function setLabelSize($val)
    {
		$this->labelSize = $val;
	}    
	public function setNewPassword($val)
    {
		$this->newPassword = $val;
	}		
	public function getNewPassword()
    {
		return $this->newPassword;
	}	
    function getChangePasswordXML()
    {
		$xml = '<ChangePassPhraseRequest>
					<RequesterID>' . $this->getCredentialTwo() . '</RequesterID>
					<RequestID>pwc2011</RequestID>
					<CertifiedIntermediary>
							<AccountID>' . $this->getUserId() . '</AccountID>
							<PassPhrase>' . $this->getCredentialOne() . '</PassPhrase>
					</CertifiedIntermediary>
					<NewPassPhrase>' . $this->getNewPassword() . '</NewPassPhrase>
				</ChangePassPhraseRequest>';
       
        return $xml;
    } 	
	public function changePassword()
	{
        $this->setWebService('ChangePassPhraseXML');
        $this->setWebMethod('changePassPhraseRequestXML');
        $sxml = $this->getResponse($this->getChangePasswordXML(),'simplexmlobject');
		//print_r($sxml);
		//die();
		//if($sxml->Status=='0'){
		if($sxml->Status!='0'){
			$this->setErrCode($sxml->Status);
			$this->setErrDetails($sxml->ErrorMessage);
		}		
		return $sxml;
    }
	public function setPostageAmount($val)
    {
		$this->postageAmount = $val;
	}		
	public function getPostageAmount()
    {
		return $this->postageAmount;
	}    
    function buyPostageXML()
    {
		$xml = '<RecreditRequest>
						<RequesterID>' . $this->getCredentialTwo() . '</RequesterID>
						<RequestID>pwc2011</RequestID>
						<CertifiedIntermediary>
							<AccountID>' . $this->getUserId() . '</AccountID>
							<PassPhrase>' . $this->getCredentialOne() . '</PassPhrase>
						</CertifiedIntermediary>
						<RecreditAmount>' . $this->getPostageAmount() . '</RecreditAmount>
				</RecreditRequest>';
       
        return $xml;
    }	
	public function buyPostage()
	{
        $this->setWebService('BuyPostageXML');
        $this->setWebMethod('recreditRequestXML');
        //print_r($this->buyPostageXML());
        $sxml = $this->getResponse($this->buyPostageXML(),'simplexmlobject');
		//print_r($sxml);
		//die();
		//if($sxml->Status=='0'){
		return $sxml;
    }
	public function setImageFormat($val)
    {
		$this->imageFormat = $val;
	}  
	public function getImageFormat()
    {
		return $this->imageFormat;
	}
	public function setImageResolution($val)
    {
		$this->imageResolution = $val;
	}  
	public function getImageResolution()
    {
		return $this->imageResolution;
	}
	public function cleanXMLfromData($data)
    {
		$nonallowedcharacters = array("<", ">", "'", "\\", "&", "&amp;", "&#039;", "\'", "&quot;", "\"", "&lt;", "&gt;", "\r\n", "\n", "\r");
		$data = str_replace($nonallowedcharacters, "", $data);

		return $data;
	}
	public function setMailPieceShape($val)
    {
		$this->mailpieceshape = $val;
	}
	public function getMailPieceShape()
    {
		return $this->mailpieceshape;
	}	
	public function setLabelType($val)
    {
		$this->labeltype = $val;
	}
	public function getLabelType()
    {
		return $this->labeltype;
	}
	public function resetErr()
    {
		$this->errCode = '';
		$this->errDetails = '';
	}	
		   
}
//End of file Endicia.php