DHL-PHP-SDK  v0.4
A wrapper for the DHL-XML-API Version 2
ExportDocument.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Petschko\DHL;
4 
16 use Exception;
17 use stdClass;
18 
28  const EXPORT_TYPE_OTHER = 'OTHER';
29  const EXPORT_TYPE_PRESENT = 'PRESENT';
30  const EXPORT_TYPE_COMMERCIAL_SAMPLE = 'COMMERCIAL_SAMPLE';
31  const EXPORT_TYPE_DOCUMENT = 'DOCUMENT';
32  const EXPORT_TYPE_RETURN_OF_GOODS = 'RETURN_OF_GOODS';
33 
37  const TERMS_OF_TRADE_DDP = 'DDP';
38  const TERMS_OF_TRADE_DXV = 'DXV';
39  const TERMS_OF_TRADE_DDU = 'DDU';
40  const TERMS_OF_TRADE_DDX = 'DDX';
41 
51  private $invoiceNumber = null;
52 
68  private $exportType;
69 
79  private $exportTypeDescription = null;
80 
97  private $termsOfTrade = null;
98 
108  private $placeOfCommittal;
109 
117  private $additionalFee;
118 
129  private $permitNumber = null;
130 
141  private $attestationNumber = null;
142 
150  private $withElectronicExportNotification = null;
151 
159  private $exportDocPosition = null;
160 
164  public function __destruct() {
165  unset($this->invoiceNumber);
166  unset($this->exportType);
167  unset($this->exportTypeDescription);
168  unset($this->termsOfTrade);
169  unset($this->placeOfCommittal);
170  unset($this->additionalFee);
171  unset($this->permitNumber);
172  unset($this->attestationNumber);
173  unset($this->withElectronicExportNotification);
174  unset($this->exportDocPosition);
175  }
176 
182  public function getInvoiceNumber() {
183  return $this->invoiceNumber;
184  }
185 
191  public function setInvoiceNumber($invoiceNumber) {
192  $this->invoiceNumber = $invoiceNumber;
193  }
194 
200  public function getExportType() {
201  return $this->exportType;
202  }
203 
209  public function setExportType($exportType) {
210  $this->exportType = $exportType;
211  }
212 
218  public function getExportTypeDescription() {
219  return $this->exportTypeDescription;
220  }
221 
227  public function setExportTypeDescription($exportTypeDescription) {
228  $this->exportTypeDescription = $exportTypeDescription;
229  }
230 
236  public function getTermsOfTrade() {
237  return $this->termsOfTrade;
238  }
239 
245  public function setTermsOfTrade($termsOfTrade) {
246  $this->termsOfTrade = $termsOfTrade;
247  }
248 
254  public function getPlaceOfCommittal() {
255  return $this->placeOfCommittal;
256  }
257 
263  public function setPlaceOfCommittal($placeOfCommittal) {
264  $this->placeOfCommittal = $placeOfCommittal;
265  }
266 
272  public function getAdditionalFee() {
273  return $this->additionalFee;
274  }
275 
281  public function setAdditionalFee($additionalFee) {
282  $this->additionalFee = $additionalFee;
283  }
284 
290  public function getPermitNumber() {
291  return $this->permitNumber;
292  }
293 
299  public function setPermitNumber($permitNumber) {
300  $this->permitNumber = $permitNumber;
301  }
302 
308  public function getAttestationNumber() {
309  return $this->attestationNumber;
310  }
311 
317  public function setAttestationNumber($attestationNumber) {
318  $this->attestationNumber = $attestationNumber;
319  }
320 
327  return $this->withElectronicExportNotification;
328  }
329 
335  public function setWithElectronicExportNotification($withElectronicExportNotification) {
336  $this->withElectronicExportNotification = $withElectronicExportNotification;
337  }
338 
344  public function getExportDocPosition() {
345  return $this->exportDocPosition;
346  }
347 
353  public function setExportDocPosition($exportDocPosition) {
354  $this->exportDocPosition = $exportDocPosition;
355  }
356 
366  public function addExportDocPosition($exportDocPosition) {
367  if($this->getExportDocPosition() === null)
368  $this->setExportDocPosition($exportDocPosition);
369  else if(is_array($this->getExportDocPosition()))
370  $this->exportDocPosition[] = $exportDocPosition;
371  else {
372  // Convert the first existing entry to an array
373  $this->setExportDocPosition(array($this->getExportDocPosition(), $exportDocPosition));
374  }
375  }
376 
384  public function getExportDocumentClass_v1() {
385  trigger_error('[DHL-PHP-SDK]: Version 1 Methods are deprecated and will removed soon (Called method ' . __METHOD__ . ')!', E_USER_DEPRECATED);
386  trigger_error('[DHL-PHP-SDK]: Called Version 1 Method: ' . __METHOD__ . ' is incomplete (does nothing)!', E_USER_WARNING);
387 
388  $class = new StdClass;
389 
390  return $class;
391  }
392 
399  public function getExportDocumentClass_v2() {
400  $class = new StdClass;
401 
402  // Standard-Export-Stuff
403  if($this->getInvoiceNumber() !== null)
404  $class->invoiceNumber = $this->getInvoiceNumber();
405 
406  $class->exportType = $this->getExportType();
407 
408  if($this->getExportTypeDescription() !== null)
409  $class->exportTypeDescription = $this->getExportTypeDescription();
410  else if($this->getExportType() === self::EXPORT_TYPE_OTHER)
411  throw new Exception('ExportTypeDescription must filled out if Export-Type is OTHER! - ' .
412  'Export-Class will not generated now');
413 
414  if($this->getTermsOfTrade() !== null)
415  $class->termsOfTrade = $this->getTermsOfTrade();
416 
417  $class->placeOfCommital = $this->getPlaceOfCommittal();
418  $class->additionalFee = $this->getAdditionalFee();
419 
420  if($this->getPermitNumber() !== null)
421  $class->permitNumber = $this->getPermitNumber();
422 
423  if($this->getAttestationNumber() !== null)
424  $class->attestationNumber = $this->getAttestationNumber();
425 
426  // Add rest (Elements)
427  if($this->getWithElectronicExportNotification() !== null) {
428  $class->WithElectronicExportNtfctn = new StdClass;
429  $class->WithElectronicExportNtfctn->active = (int) $this->getWithElectronicExportNotification();
430  }
431 
432  // Check if child-class is being used
433  if($this->getExportDocPosition() !== null) {
434  // Handle non-arrays... (Backward compatibility)
435  if(! is_array($this->getExportDocPosition()))
436  $class->ExportDocPosition = $this->getExportDocPosition()->getExportDocPositionClass_v2();
437  else {
438  $pos = $this->getExportDocPosition();
439  foreach($pos as $key => &$exportDoc)
440  $class->ExportDocPosition[$key] = $exportDoc->getExportDocPositionClass_v2();
441  }
442  }
443 
444  return $class;
445  }
446 }
setPlaceOfCommittal($placeOfCommittal)
setExportTypeDescription($exportTypeDescription)
setAdditionalFee($additionalFee)
setWithElectronicExportNotification($withElectronicExportNotification)
setAttestationNumber($attestationNumber)
setInvoiceNumber($invoiceNumber)
addExportDocPosition($exportDocPosition)
setExportDocPosition($exportDocPosition)