Current File : /home/users/barii/public_html/finansenl.com.pl/wodki/admin/poczta/class.php |
<?php
include "en.php";
class client
{
// -------------------------------------------------------------------------
protected $guid= null;
// -------------------------------------------------------------------------
public function makeTests()
{
echo "<pre>let test begin";
$this->testDodaniaPrzesylki();
$this->testDodaniaPrzesylkiBiznesowej();
$this->testPobraniaNalepki();
echo"</pre>";
}
// -------------------------------------------------------------------------
protected function testDodaniaPrzesylkiBiznesowej()
{
$this->hr();
echo"test przesylkaBiznesowaType<br>";
$E = new ElektronicznyNadawca();
$P = new przesylkaBiznesowaType();
$A = new adresType();
$tmp = new addShipment();
$A->nazwa = "Jan";
$A->nazwa2 = "Nowak";
$A->ulica = "Śliska";
$A->numerDomu = "1";
$A->numerLokalu = "2";
$A->miejscowosc = "Warszawa";
$A->kodPocztowy = "00002";
$P->adres = $A;
$P->gabaryt = gabarytBiznesowaType::XS;
$P->pobranie = new pobranieType();
$P->pobranie->kwotaPobrania = "12345"; //kwota w groszach 123.45 PLN
$P->pobranie->nrb = "12345678901234567890123456"; // nrb
$P->pobranie->sposobPobrania = sposobPobraniaType::RACHUNEK_BANKOWY;
$P->pobranie->tytulem = "FV 123";
$P->masa = 1230;// masa w gramach
$P->wartosc = 52345;// wartość w groszach 523.45 PLN
$P->ostroznie = true;
$this->guid = getGuid();
$P->guid = $this->guid;
$tmp->przesylki[] = $P;
var_dump($E->addShipment($tmp)); // wysłanie zapytania
echo"\n";
echo"\n";
echo"\n";
echo"\n";
echo $E->__getLastRequest();
echo"\n";
echo"\n";
echo"\n";
echo"\n";
}
// -------------------------------------------------------------------------
protected function testDodaniaPrzesylki()
{
$this->hr();
echo"test paczkaPocztowaType<br>";
$E = new ElektronicznyNadawca();
$P = new paczkaPocztowaType();
$A = new adresType();
$tmp = new addShipment();
$A->nazwa = "Jan";
$A->nazwa2 = "Nowak";
$A->ulica = "Śliska";
$A->numerDomu = "1";
$A->numerLokalu = "2";
$A->miejscowosc = "Warszawa";
$A->kodPocztowy = "00002";
$P->adres = $A;
$P->iloscPotwierdzenOdbioru = 1;
$P->kategoria = kategoriaType::EKONOMICZNA;
$P->gabaryt = gabarytType::GABARYT_A;
$P->masa = 1230;// masa w gramach
$this->guid = getGuid();
$P->guid = $this->guid;
$tmp->przesylki[] = $P;
var_dump($E->addShipment($tmp)); // wysłanie zapytania
echo"\n";
echo"\n";
echo"\n";
echo"\n";
echo $E->__getLastRequest();
echo"\n";
echo"\n";
echo"\n";
echo"\n";
}
// -------------------------------------------------------------------------
protected function testPobraniaNalepki()
{
$E = new ElektronicznyNadawca();
$parameters= new getAddresLabelByGuid();
$parameters->guid = array($this->guid);
$retval = $E->getAddresLabelByGuid($parameters);
if(!is_array($retval->content))
{
$retval->content = array($retval->content);
}
foreach ($retval->content as $c) /* @var $c addressLabelContent */
{
$h = fopen("nalepka".$c->nrNadania.".pdf", "w");
fwrite($h, $c->pdfContent);
fclose($h);
}
}
// -------------------------------------------------------------------------
protected function hr()
{
echo "<hr>\n";
flush();
}
// -------------------------------------------------------------------------
}
// -----------------------------------------------------------------------------
function getGuid()
{
mt_srand((double)microtime()*10000);
$charid = strtoupper(md5(uniqid(rand(), true)));
$retval = substr($charid, 0, 32);
return $retval;
}
// -----------------------------------------------------------------------------
ini_set ("max_execution_time","1800");
$c = new client();
$c->makeTests();