Add php files
This commit is contained in:
234
WSDL/1.php
Executable file
234
WSDL/1.php
Executable file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
define("MYSQL_API_HOST", "localhost");
|
||||
define("MYSQL_API_PORT", "80");
|
||||
define("MYSQL_API_USER", "root");
|
||||
define("MYSQL_API_PASSWORD", "sgpmk777");
|
||||
define("MYSQL_API_DATABASE", "crm");
|
||||
define("MYSQL_API_COLLATE", "UTF8");
|
||||
|
||||
|
||||
|
||||
echo "TEST";
|
||||
|
||||
function ecm_add_order_from_shop($user_name, $password, $order, $presta, $user, $a, $b, $c, $d) {
|
||||
|
||||
|
||||
$x = "";
|
||||
$x = "S";
|
||||
$y = "false";
|
||||
|
||||
|
||||
|
||||
if(!empty($order)) {
|
||||
|
||||
$y = "ok";
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$order = unserialize(base64_decode($order));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//return print_r($order);
|
||||
if(!empty($order) && is_array($order)) {
|
||||
|
||||
|
||||
|
||||
if($order['Order-Header']['OrderNumber'] == "ORDERTEST1234")
|
||||
return "IDTEST1234";
|
||||
|
||||
else {
|
||||
require_once("modules/EcmSales/EcmSale.php");
|
||||
$focus=new EcmSale();
|
||||
|
||||
|
||||
$template_id="97700b0d-fbe9-e366-4016-4b260f058a47";
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
|
||||
|
||||
|
||||
$focus->template_id=$template_id;
|
||||
//$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmdocumenttemplates where id='".$template_id."'"));
|
||||
//$query = $db->executeQuery(query("select name from ecmdocumenttemplates where id='".$template_id."'"));
|
||||
|
||||
$row = $db->fetchFirstRow("select name from ecmdocumenttemplates where id='".$template_id."'");
|
||||
$focus->template_name=$row['name'];
|
||||
$focus->setTemplate();
|
||||
$focus->number=$focus->generateNumber();
|
||||
$focus->document_no=$focus->formatNumber();
|
||||
$focus->currency_id="PLN";
|
||||
$focus->ecmlanguage="pl_pl";
|
||||
$focus->status="s10";
|
||||
$focus->type="sales_order";
|
||||
$focus->modified_user_id="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
$focus->created_by="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
|
||||
$pr=$order['Order-Lines'];
|
||||
$x = "ok";
|
||||
include_once("modules/Accounts/Account.php");
|
||||
//$ww=$GLOBALS['db']->query("select count(*) as c from accounts where b2clogin ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$ww=$GLOBALS['db']->query("select count(*) as c from accounts where `id` ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
$row = $db->fetchFirstRow("select count(*) as c from accounts where `id` ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$rr=$GLOBALS['db']->fetchByAssoc($ww);
|
||||
$focus->parent_id="getmir";
|
||||
$focus->description=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Description']);
|
||||
|
||||
|
||||
// if($rr['c']==0){
|
||||
// $account=new Account();
|
||||
$account->ownership="getmir";
|
||||
// $account->name=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Name']);
|
||||
// $account->b2clogin=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Login']);
|
||||
// $account->billing_address_street=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['StreetAndNumber']);
|
||||
// $account->billing_address_postalcode=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['PostalCode']);
|
||||
// $account->billing_address_city=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['CityName']);
|
||||
// $account->shipping_address_street=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['StreetAndNumber']);
|
||||
// $account->shipping_address_postalcode=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['PostalCode']);
|
||||
// $account->shipping_address_city=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['CityName']);
|
||||
// $focus->parent_id=create_guid_2();
|
||||
// $GLOBALS['db']->query("insert into accounts set id='".$focus->parent_id."',name='".$account->name."',billing_address_street='".$account->billing_address_street."',billing_address_postalcode='".$account->billing_address_postalcode."',billing_address_city='".$account->billing_address_city."',shipping_address_street='".$account->shipping_address_street."',shipping_address_postalcode='".$account->shipping_address_postalcode."',shipping_address_city='".$account->shipping_address_city."', b2clogin='".$account->b2clogin."'");
|
||||
// }
|
||||
// else{
|
||||
|
||||
|
||||
//$w=$GLOBALS['db']->query("select id from accounts where b2clogin = '".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$w=$GLOBALS['db']->query("select `id` from `accounts` where `id` = '".$order['Order-Parties']['Buyer']['Login']."' and `deleted`='0'");
|
||||
$row = $db->fetchFirstRow("select `id` from `accounts` where `id` = '".$order['Order-Parties']['Buyer']['Login']."' and `deleted`='0'");
|
||||
//$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
$account=new Account();
|
||||
//update account, maybe sth. change
|
||||
|
||||
// $GLOBALS['db']->query("update accounts set name='".$account->name."',billing_address_street='".$account->billing_address_street."',billing_address_postalcode='".$account->billing_address_postalcode."',billing_address_city='".$account->billing_address_city."'"."',shipping_address_street='".$account->shipping_address_street."',shipping_address_postalcode='".$account->shipping_address_postalcode."',shipping_address_city='".$account->shipping_address_city."'where id='".$r['id']."'");
|
||||
|
||||
// $account->retrieve($r['id']);
|
||||
$focus->parent_id=$row['id'];
|
||||
//}
|
||||
$focus->assigned_user_id="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
$focus->register_date=$order['Order-Header']['OrderDate'];
|
||||
$focus->delivery_date=$order['Order-Header']['ExpectedDeliveryDate'];
|
||||
//$focus->supplier_code=3442;
|
||||
$focus->order_no=$order['Order-Header']['OrderNumber'];
|
||||
$focus->ecmlanguage="pl_pl";
|
||||
$focus->ecmpaymentcondition_id=$order['Order-Parties']['Buyer']['PaymentConditionId'];
|
||||
|
||||
$focus->parent_name=$row["name"];//$account->name;
|
||||
$focus->parent_address_street=$a;//$account->shipping_address_street;
|
||||
$focus->parent_address_city=$b;//$account->shipping_address_city;
|
||||
$focus->parent_address_postalcode=$c;//$account->shipping_address_postalcode;
|
||||
$focus->parent_address_country=$d;//$account->shipping_address_country;
|
||||
|
||||
$ra=array();
|
||||
$total=0;
|
||||
|
||||
|
||||
|
||||
if(count($pr)>0){
|
||||
foreach($pr as $prod){
|
||||
$product_id="";
|
||||
//$w=$GLOBALS['db']->query("select id as ecmproduct_id from ecmproducts where code='".$prod['Line']['Line-Item']['CODE']."' and deleted='0' and code NOT LIKE '%_w' and code NOT LIKE '%_z' and code NOT LIKE '%_W' and code NOT LIKE '%_Z'");
|
||||
//$w=$GLOBALS['db']->query("select `id` as `ecmproduct_id` from `ecmproducts` where `id`='".$prod['Line']['Line-Item']['CODE']."' and `deleted`='0' and `code` NOT LIKE '%_w' and `code` NOT LIKE '%_z' and `code` NOT LIKE '%_W' and `code` NOT LIKE '%_Z'");
|
||||
$row = $db->fetchFirstRow("select `id` as `ecmproduct_id` from `ecmproducts` where `id`='".$prod['Line']['Line-Item']['CODE']."' and `deleted`='0' and `code` NOT LIKE '%_w' and `code` NOT LIKE '%_z' and `code` NOT LIKE '%_W' and `code` NOT LIKE '%_Z'");
|
||||
// $r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
$product_id=$row['ecmproduct_id'];
|
||||
|
||||
$wp=$GLOBALS['db']->query("select * from `ecmproducts` where `id`='".$product_id."'");
|
||||
$rppp=$GLOBALS['db']->fetchByAssoc($wp);
|
||||
$product_code=$rppp['code'];
|
||||
$product_name=$rppp['name'];
|
||||
$vat_id=$rppp['vat_id'];
|
||||
$vat_name=$rppp['vat_name'];
|
||||
$vat_value=$rppp['vat_value'];
|
||||
|
||||
$return_array['id'] = $product_id;
|
||||
$return_array['code'] = $product_code;
|
||||
$return_array['name'] = $product_name;
|
||||
$return_array['quantity'] = $prod['Line']['Line-Item']['OrderedQuantity'];
|
||||
$return_array['price'] = $prod['Line']['Line-Item']['OrderedUnitNetPrice'];
|
||||
$return_array['discount'] = 0;
|
||||
$return_array['total'] = $prod['Line']['Line-Item']['OrderedQuantity']*$prod['Line']['Line-Item']['OrderedUnitNetPrice'];
|
||||
$return_array['unit_id'] = 1;
|
||||
$return_array['unit_name'] = 'szt.';
|
||||
$return_array['vat_id'] = $vat_id;
|
||||
$return_array['vat_name'] = $vat_name;
|
||||
$return_array['vat_value'] = $vat_value;
|
||||
$return_array['currency_id'] = 'PLN';
|
||||
$return_array['recipient_code'] = $prod['Line']['Line-Item']['BuyerItemCode'];
|
||||
$total+=$return_array['quantity']*$return_array['price']*(1+$vat_value/100);
|
||||
$ra[]=$return_array;
|
||||
}
|
||||
}
|
||||
$focus->position_list = $ra;
|
||||
$return_id=$focus->save_from_shop($presta, $user);
|
||||
$GLOBALS['db']->query("update `ecmsales` set `total`='".$total."' where `id`='".$return_id."'");
|
||||
|
||||
|
||||
return $return_id;
|
||||
|
||||
|
||||
//return print_r(mysql_error()."mm", true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch(Exception $e) {}
|
||||
|
||||
}
|
||||
|
||||
return $y;
|
||||
|
||||
|
||||
}
|
||||
|
||||
$order_lines = array();
|
||||
$line= array(
|
||||
'Line' => array(
|
||||
'Line-Item' => array(
|
||||
'LineNumber' => 1,
|
||||
'CODE' => 33,
|
||||
'EAN' => '',
|
||||
'BuyerItemCode' => '',
|
||||
'SupplierItemCode' => '',
|
||||
'ItemDescription' => "produkt",
|
||||
'ItemType' => 'CU',
|
||||
'OrderedQuantity' => "1",
|
||||
'OrderedUnitPacksize' => 1,
|
||||
'UnitOfMeasure' => 'PCE',
|
||||
'OrderedUnitNetPrice' => 99,
|
||||
'PackageNumber' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
$order_lines[] = $line;
|
||||
|
||||
|
||||
$order = array();
|
||||
$order['Order-Summary'] = array(
|
||||
'TotalLines' => 1-1,
|
||||
'TotalOrderedAmount' => "5000",
|
||||
);
|
||||
$order['Order-Lines'] = $order_lines; // ilosc wierszy w zamowieniu
|
||||
|
||||
// echo print_r($order);
|
||||
//exit;
|
||||
|
||||
$order['Order-Parties']['Buyer']['Login'] = "777"; // login uzytkownika
|
||||
$order['Order-Parties']['Buyer']['Description'] = ""; // opis
|
||||
$order['Order-Header']['OrderDate'] = date("Y-m-d");
|
||||
$order['Order-Header']['ExpectedDeliveryDate'] = date("Y-m-d");
|
||||
|
||||
$order['Order-Header']['OrderNumber'] = "brak"; // numer zamowienia
|
||||
$order['Order-Parties']['Buyer']['PaymentConditionId'] = "23d19aa9-d63a-dd99-568c-4dff0bbc7f40"; // 7 dni na zaplate
|
||||
|
||||
$getReference = "HKKMLOPMX";
|
||||
|
||||
$order['Order-Header']['Presta'] = $getReference;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
27
WSDL/inc.error.php
Executable file
27
WSDL/inc.error.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
////
|
||||
// Error handling
|
||||
////
|
||||
|
||||
error_reporting( E_ERROR );
|
||||
function handleError($errno, $errstr,$error_file,$error_line) { throw new Exception("Error [$errno]: $errstr - $error_file:$error_line"); }
|
||||
set_error_handler("handleError");
|
||||
|
||||
error_reporting(0);
|
||||
set_error_handler('myErrorHandler');
|
||||
register_shutdown_function('fatalErrorShutdownHandler');
|
||||
function myErrorHandler($code, $message, $file, $line)
|
||||
{
|
||||
die("Fatal Error: [$code] $message - $file:$line");
|
||||
}
|
||||
|
||||
function fatalErrorShutdownHandler()
|
||||
{
|
||||
$last_error = error_get_last();
|
||||
if ($last_error['type'] === E_ERROR)
|
||||
{
|
||||
// fatal error
|
||||
myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
141
WSDL/inc.functions.php
Executable file
141
WSDL/inc.functions.php
Executable file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
|
||||
function DateTimeToString($dt)
|
||||
{
|
||||
$_dt = new DateTime($dt);
|
||||
return $_dt->format(DateTime::ATOM);
|
||||
}
|
||||
|
||||
function StartTimer()
|
||||
{
|
||||
$time = microtime();$time = explode(' ', $time);$time = $time[1] + $time[0];$start = $time;
|
||||
return $start;
|
||||
}
|
||||
|
||||
function StopTimer($start)
|
||||
{
|
||||
$time = microtime();$time = explode(' ', $time);$time = $time[1] + $time[0];$finish = $time; //$total_time = round(($finish - $start), 4);
|
||||
return round(($finish - $start), 4);
|
||||
}
|
||||
|
||||
function startsWith($haystack, $needle)
|
||||
{
|
||||
return !strncmp($haystack, $needle, strlen($needle));
|
||||
}
|
||||
|
||||
function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
function strrtrim($message, $strip) {
|
||||
// break message apart by strip string
|
||||
$lines = explode($strip, $message);
|
||||
$last = '';
|
||||
// pop off empty strings at the end
|
||||
do {
|
||||
$last = array_pop($lines);
|
||||
} while (empty($last) && (count($lines)));
|
||||
// re-assemble what remains
|
||||
return implode($strip, array_merge($lines, array($last)));
|
||||
}
|
||||
|
||||
|
||||
function full_url()
|
||||
{
|
||||
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
|
||||
$sp = strtolower($_SERVER["SERVER_PROTOCOL"]);
|
||||
$protocol = substr($sp, 0, strpos($sp, "/")) . $s;
|
||||
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
|
||||
return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
function md5_hash_encode($source)
|
||||
{
|
||||
$base_string = md5($source); // kodowanie stringa standardowym MD5()
|
||||
|
||||
// dzielenie stringa na 3 kawałki
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 4,20);
|
||||
$end = substr($base_string, 20, strlen($base_string));
|
||||
|
||||
$base_string = $begin.rand(0,8).$in.rand(0,8).$end; // dodawanie dodatkowego hasha
|
||||
$base_string = strrev($base_string); // odwracanie kolejności znaków w stringu
|
||||
|
||||
return $base_string;
|
||||
}
|
||||
|
||||
function md5_hash_decode($source)
|
||||
{
|
||||
$base_string = strrev($source); // odwracanie kolejności znaków w stringu
|
||||
|
||||
// pobieranie prawidłowych elementów stringa
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 5, 20);
|
||||
$end = substr($base_string, 30, strlen($base_string));
|
||||
|
||||
$base_string = $begin.$in.$end;
|
||||
|
||||
return $base_string;
|
||||
}
|
||||
|
||||
function base64_hash_encode($source, $base = false)
|
||||
{
|
||||
if ($base) $base_string = base64_encode($source); else $base_string = $source;
|
||||
|
||||
if (strlen($source) > 24) {
|
||||
// dzielenie stringa na 3 kawałki
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 4,20);
|
||||
$end = substr($base_string, 24, strlen($base_string));
|
||||
|
||||
$base_string = $begin.rand(0, 8).$in.rand(0, 8).$end; // dodawanie dodatkowego hasha
|
||||
}
|
||||
|
||||
$base_string = strrev($base_string); // odwracanie kolejności znaków w stringu
|
||||
|
||||
for ($i = 0; $i < strlen($base_string); $i++) $base_string[$i] = chr(ord($base_string[$i]) + ($i * 3));
|
||||
|
||||
// zamiana treści na HEX
|
||||
$encode_result = "";
|
||||
foreach(str_split($base_string) as $c) $encode_result .= sprintf("%02X", ord($c));
|
||||
|
||||
return strtolower($encode_result);
|
||||
|
||||
}
|
||||
|
||||
function base64_hash_decode($source, $base = false)
|
||||
{
|
||||
// odwracanie treści z HEX
|
||||
$source_decode = "";
|
||||
foreach(explode("\n", trim(chunk_split(strtoupper($source), 2))) as $h) $source_decode .= chr(hexdec($h));
|
||||
|
||||
for ($i = 0; $i < strlen($source_decode); $i++) $source_decode[$i] = chr(ord($source_decode[$i]) - ($i * 3));
|
||||
|
||||
$base_string = strrev($source_decode); // odwracanie kolejności znaków w stringu
|
||||
|
||||
if (strlen($base_string) > 24) {
|
||||
// pobieranie prawidłowych elementów stringa
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 5, 20);
|
||||
$end = substr($base_string, 26, strlen($base_string));
|
||||
|
||||
$base_string = $begin.$in.$end;
|
||||
}
|
||||
|
||||
if ($base) $base_string = base64_decode($base_string);
|
||||
|
||||
return $base_string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// echo md5('passowrd!!!!787').'<BR>';
|
||||
// echo md5_hash_decode('912e198bd3876d387bd8846228375303036951').'<BR>';
|
||||
?>
|
||||
12
WSDL/inc.mysqli.config.php
Executable file
12
WSDL/inc.mysqli.config.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
define("MYSQL_API_HOST", "localhost");
|
||||
define("MYSQL_API_PORT", "80");
|
||||
define("MYSQL_API_USER", "root");
|
||||
define("MYSQL_API_PASSWORD", "sgpmk777");
|
||||
define("MYSQL_API_DATABASE", "crm");
|
||||
define("MYSQL_API_COLLATE", "UTF8");
|
||||
|
||||
define("sugarEntry", "true");
|
||||
|
||||
?>
|
||||
100
WSDL/inc.mysqli.php
Executable file
100
WSDL/inc.mysqli.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// Wrapper do łatwej obsługi MySQL poprzez mysqli
|
||||
|
||||
|
||||
class Database {
|
||||
|
||||
public $link = NULL;
|
||||
public $errors = array();
|
||||
|
||||
public function __construct($server = '',$user='',$pass='',$port='',$dbname='',$collation='') {
|
||||
|
||||
if(!empty($server)) $this->connect($server, $user, $pass, $port, $dbname, $collation);
|
||||
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
||||
$this->close();
|
||||
|
||||
}
|
||||
|
||||
public function connect($server, $user, $pass, $port, $dbname, $collation) {
|
||||
|
||||
$this->link = mysqli_connect($server, $user, $pass, $dbname, $port) or $errors[] = 'Database Error: '.mysqli_connect_error();
|
||||
$this->link->set_charset($collation);
|
||||
//$this->nonquery("SET NAMES 'utf8';");
|
||||
|
||||
}
|
||||
|
||||
public function close() {
|
||||
|
||||
//$this->link->close();
|
||||
|
||||
}
|
||||
|
||||
public function info() {
|
||||
|
||||
return mysqli_get_host_info($this->link);
|
||||
|
||||
}
|
||||
|
||||
public function es($text) {
|
||||
|
||||
return $this->link->real_escape_string($text);
|
||||
|
||||
}
|
||||
|
||||
function prepareQuery($string, $vars = array()) {
|
||||
|
||||
if(!is_array($vars)) $vars = array_slice(func_get_args(),1);
|
||||
|
||||
foreach($vars as $var) {
|
||||
if(!isset($v)) $v = 0;
|
||||
++$v;
|
||||
$string = str_replace('{'.$v.'}',$this->es($var),$string);
|
||||
}
|
||||
return $string;
|
||||
|
||||
}
|
||||
|
||||
public function query($command) {
|
||||
|
||||
$result = $this->link->query($command);
|
||||
if ($result == NULL) throw new Exception("Query Error: ".$this->link->error." Query:".$command."");
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function nonquery($command) {
|
||||
|
||||
if ($this->link->query($command) == NULL) throw new Exception("NonQuery Error: ".$this->link->error." Query:".$command."");
|
||||
|
||||
}
|
||||
|
||||
public function fetchfirst($command) {
|
||||
|
||||
$result = $this->fetcharray($command);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function fetcharray($command) {
|
||||
|
||||
$query = $this->link->query($command);
|
||||
$result = $query->fetch_array(MYSQLI_BOTH);
|
||||
$query->close();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function LastInsertId() {
|
||||
|
||||
$result = $this->fetchfirst("SELECT LAST_INSERT_ID();");
|
||||
return $result[0];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
7
WSDL/inc.variables.php
Executable file
7
WSDL/inc.variables.php
Executable file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
define("WEBSERVICE_NAME", "WSDL");
|
||||
define("DEBUG", false);
|
||||
define("ROOT_URL", "https://e5.2dev.pl/");
|
||||
|
||||
?>
|
||||
824
WSDL/inc.ws.methods.php
Executable file
824
WSDL/inc.ws.methods.php
Executable file
@@ -0,0 +1,824 @@
|
||||
<?php
|
||||
|
||||
$methodName = "";
|
||||
$db = null;
|
||||
|
||||
// aktualizuje oferte o status
|
||||
// w pole `type` nalezy podac `id_presta` zamowienia z CRM
|
||||
|
||||
function create_guid_2() {
|
||||
$microTime = microtime();
|
||||
list($a_dec, $a_sec) = explode(" ", $microTime);
|
||||
|
||||
$dec_hex = dechex($a_dec* 1000000);
|
||||
$sec_hex = dechex($a_sec);
|
||||
|
||||
ensure_length_2($dec_hex, 5);
|
||||
ensure_length_2($sec_hex, 6);
|
||||
|
||||
$guid = "";
|
||||
$guid .= $dec_hex;
|
||||
$guid .= create_guid_section_2(3);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section_2(4);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section_2(4);
|
||||
$guid .= '-';
|
||||
$guid .= create_guid_section_2(4);
|
||||
$guid .= '-';
|
||||
$guid .= $sec_hex;
|
||||
$guid .= create_guid_section_2(6);
|
||||
|
||||
return $guid;
|
||||
|
||||
}
|
||||
function create_guid_section_2($characters)
|
||||
{
|
||||
$return = "";
|
||||
for($i=0; $i<$characters; $i++)
|
||||
{
|
||||
$return .= dechex(mt_rand(0,15));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function ensure_length_2(&$string, $length)
|
||||
{
|
||||
$strlen = strlen($string);
|
||||
if($strlen < $length)
|
||||
{
|
||||
$string = str_pad($string,$length,"0");
|
||||
}
|
||||
else if($strlen > $length)
|
||||
{
|
||||
$string = substr($string, 0, $length);
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************CATEGORIES*
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcategories',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'id' => array('name'=>'id','type'=>'xsd:string'),
|
||||
'name' => array('name'=>'name', 'type'=>'xsd:string'),
|
||||
'name_en' => array('name'=>'name_en', 'type'=>'xsd:string'),
|
||||
'ilosc' => array('name'=>'ilosc', 'type'=>'xsd:int'),
|
||||
'deleted' => array('name'=>'deleted', 'type'=>'xsd:int'),
|
||||
'description' => array('name'=>'description', 'type'=>'xsd:string')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcategories_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmcategories[]')
|
||||
),
|
||||
'tns:ecmcategories'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_categories',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'pricelist' => 'xsd:string'),
|
||||
array('return'=>'tns:ecmcategories_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_categories($user_name, $password, $pricelist) {
|
||||
|
||||
//$GLOBALS['db']->query("INSERT INTO log VALUES ('!!!!!')");
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
|
||||
$query = $db->executeQuery("SELECT `c`.`id`, `c`.`name`, `c`.`name_en`, `c`.`description`, `c`.`deleted`, (SELECT count(`p`.`id`) FROM `crm`.`ecmproducts` `p` JOIN `crm`.`ecmpricebooks_ecmproducts` `pbp` ON
|
||||
`pbp`.`ecmpricebook_id`='".$pricelist."' AND `pbp`.`ecmproduct_id`=`p`.`id`
|
||||
WHERE `p`.`product_category_id`=`c`.`id`
|
||||
AND `pbp`.`deleted`='0') as `ilosc` FROM `crm`.`ecmproductcategories` `c`");
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"name"=>$r['name'],
|
||||
"name_en"=>$r['name_en'],
|
||||
"ilosc"=>$r['ilosc'],
|
||||
"deleted"=>$r['deleted'],
|
||||
"description"=>$r['description']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* $query = $db->executeQuery("SELECT `c`.`id`, `c`.`name`, `c`.`name_en`, `c`.`description` FROM `ecmproductcategories` `c` where (SELECT count(`p`.`id`) FROM `ecmproducts` `p` JOIN `ecmpricebooks_ecmproducts` `pbp` ON `pbp`.`ecmpricebook_id`='".$pricelist."' AND `pbp`.`ecmproduct_id`=`p`.`id` WHERE `p`.`product_category_id`=`c`.`id` AND `pbp`.`deleted`='0') > 0 AND `c`.`deleted`='0'");
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"name"=>$r['name'],
|
||||
"name_en"=>$r['name_en'],
|
||||
"description"=>$r['description']);
|
||||
}*/
|
||||
|
||||
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***********************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////
|
||||
|
||||
|
||||
|
||||
//
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcategories_a',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'id' => array('name'=>'id','type'=>'xsd:string'),
|
||||
'name' => array('name'=>'name', 'type'=>'xsd:string'),
|
||||
'description' => array('name'=>'description', 'type'=>'xsd:string'),
|
||||
'ecmpricebook_id' => array('name'=>'ecmpricebook_id', 'type'=>'xsd:string'),
|
||||
'billing_address_street' => array('name'=>'billing_address_street', 'type'=>'xsd:string'),
|
||||
'billing_address_postalcode' => array('name'=>'billing_address_postalcode', 'type'=>'xsd:string'),
|
||||
'billing_address_city' => array('name'=>'billing_address_city', 'type'=>'xsd:string'),
|
||||
'phone_office' => array('name'=>'phone_office', 'type'=>'xsd:string')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcategories_a_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmcategories[]')
|
||||
),
|
||||
'tns:ecmcategories_a'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_categories_a',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'pricelist' => 'xsd:string'),
|
||||
array('return'=>'tns:ecmcategories_a_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_categories_a($user_name, $password, $date = "") {
|
||||
|
||||
|
||||
$return_array = array();
|
||||
|
||||
//$w = $GLOBALS['db']->query("SELECT `c`.`id`, `c`.`name`, `c`.`description` FROM `ecmproductcategories` `c` where `c`.`local_transportation`!='0' AND (SELECT count(`p`.`id`) FROM `ecmproducts` `p` JOIN `ecmpricebooks_ecmproducts` `pbp` ON `pbp`.`ecmpricebook_id`='".$pricelist."' AND `pbp`.`ecmproduct_id`=`p`.`id` WHERE `p`.`product_category_id`=`c`.`id` AND `pbp`.`deleted`='0') > 0 AND `c`.`deleted`='0'");
|
||||
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
$query = $db->executeQuery("SELECT `a`.`ecmpricebook_id`, `a`.`shop_user`, `a`.`id`, `a`.`name`, `a`.`deleted`, `a`.`billing_address_street`, `a`.`billing_address_postalcode`, `a`.`billing_address_city`, `a`.`phone_office`, `a`.`vatid`, `a`.`is_vat_free` FROM `accounts` `a` ".($date != "" ? " WHERE `a`.`date_modified`>'".$date."'" : ""));
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"name"=>$r['name'],
|
||||
"description"=>$r['description'],
|
||||
"ecmpricebook_id"=>$r['ecmpricebook_id'],
|
||||
"billing_address_street"=>$r['billing_address_street'],
|
||||
"billing_address_postalcode"=>$r['billing_address_postalcode'],
|
||||
"billing_address_city"=>$r['billing_address_city'],
|
||||
"phone_office"=>$r['phone_office']
|
||||
);
|
||||
}
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
//*******************************PRODUCTS*
|
||||
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmproducts',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'id' => array('name'=>'id','type'=>'xsd:string'),
|
||||
'name' => array('name'=>'name', 'type'=>'xsd:string'),
|
||||
'name_en' => array('name'=>'name_en', 'type'=>'xsd:string'),
|
||||
'description' => array('name'=>'description', 'type'=>'xsd:string'),
|
||||
'description_en' => array('name'=>'description_en', 'type'=>'xsd:string'),
|
||||
'deleted' => array('name'=>'deleted', 'type'=>'xsd:int'),
|
||||
'code' => array('name'=>'code', 'type'=>'xsd:string'),
|
||||
'manufacturer_id' => array('name'=>'manufacturer_id', 'type'=>'xsd:string'),
|
||||
'srp_price' => array('name'=>'srp_price', 'type'=>'xsd:float'),
|
||||
'srp_price_eur' => array('name'=>'srp_price_eur', 'type'=>'xsd:float'),
|
||||
'pl_vat' => array('name'=>'pl_vat', 'type'=>'xsd:float'),
|
||||
'image' => array('name'=>'image', 'type'=>'xsd:string'),
|
||||
'popular' => array('name'=>'popular', 'type'=>'xsd:string'),
|
||||
'stock_value' => array('name'=>'stock_value', 'type'=>'xsd:int')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmproducts_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmproducts[]')
|
||||
),
|
||||
'tns:ecmproducts'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_products2',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'category' => 'xsd:string', 'lang' => 'xsd:int'),
|
||||
array('return'=>'tns:ecmproducts_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_products2($user_name, $password, $category, $lang, $pricebook, $stock = "", $date = "") {
|
||||
|
||||
|
||||
if ($lang == 1) $lang = "pl";
|
||||
if ($lang == 2) $lang = "en";
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
$query = $db->executeQuery("SELECT `stock`.`quantity`, `p`.`id`, `p`.`name`, `l`.`long_description`,
|
||||
`l_en`.`short_description` as `name_en`, `l_en`.`long_description` as `long_description_en`,
|
||||
`pbp`.`deleted`,
|
||||
`p`.`code`, `p`.`manufacturer_id`, `p`.`srp_price`, `p`.`srp_price_eur`,
|
||||
`v`.`value`, `p`.`product_picture`, `pbp`.`popular` FROM `crm`.`ecmproducts` `p`
|
||||
JOIN `crm`.`ecmvats` `v` ON `v`.`id`=`p`.`vat_id` AND `v`.`deleted`='0'
|
||||
JOIN `crm`.`ecmpricebooks_ecmproducts` `pbp` ON `pbp`.`ecmproduct_id`=`p`.`id`
|
||||
AND `pbp`.`product_category_id`='".$category."' JOIN `crm`.`ecmproduct_language` `l`
|
||||
ON `l`.`ecmproduct_id`=`p`.`id` AND `l`.`language`='pl'
|
||||
JOIN `crm`.`ecmproduct_language` `l_en`
|
||||
ON `l_en`.`ecmproduct_id`=`p`.`id` AND `l_en`.`language`='en'
|
||||
|
||||
LEFT JOIN `crm`.`ecmstockstates` `stock` ON `stock`.`stock_id`='".$stock."' and `stock`.`product_id`=`p`.`id`
|
||||
|
||||
".($date != "" ? "WHERE `p`.`date_modified`>'".$date."'" : "")." group by `p`.`id`");
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
|
||||
|
||||
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"name"=>$r['name'],
|
||||
"name_en"=>$r['name_en'],
|
||||
"description"=>$r['long_description'],
|
||||
"description_en"=>$r['long_description_en'],
|
||||
"deleted"=>$r['deleted'],
|
||||
"code"=>$r['code'],
|
||||
"manufacturer_id"=>$r['manufacturer_id'],
|
||||
"srp_price"=>$r['srp_price'],
|
||||
"srp_price_eur"=>$r['srp_price_eur'],
|
||||
"pl_vat"=>$r['value'],
|
||||
"image"=>$r['product_picture'],
|
||||
"popular"=>$r['popular'],
|
||||
"stock_value"=>$r['quantity']
|
||||
);
|
||||
}
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmproducts',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'id' => array('name'=>'id','type'=>'xsd:string'),
|
||||
'name' => array('name'=>'name', 'type'=>'xsd:string'),
|
||||
'name_en' => array('name'=>'name_en', 'type'=>'xsd:string'),
|
||||
'description' => array('name'=>'description', 'type'=>'xsd:string'),
|
||||
'description_en' => array('name'=>'description_en', 'type'=>'xsd:string'),
|
||||
'deleted' => array('name'=>'deleted', 'type'=>'xsd:int'),
|
||||
'code' => array('name'=>'code', 'type'=>'xsd:string'),
|
||||
'manufacturer_id' => array('name'=>'manufacturer_id', 'type'=>'xsd:string'),
|
||||
'srp_price' => array('name'=>'srp_price', 'type'=>'xsd:float'),
|
||||
'srp_price_eur' => array('name'=>'srp_price_eur', 'type'=>'xsd:float'),
|
||||
'pl_vat' => array('name'=>'pl_vat', 'type'=>'xsd:float'),
|
||||
'image' => array('name'=>'image', 'type'=>'xsd:string'),
|
||||
'popular' => array('name'=>'popular', 'type'=>'xsd:string'),
|
||||
'stock_value' => array('name'=>'stock_value', 'type'=>'xsd:int')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmproducts_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmproducts[]')
|
||||
),
|
||||
'tns:ecmproducts'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_products',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'category' => 'xsd:string', 'lang' => 'xsd:int'),
|
||||
array('return'=>'tns:ecmproducts_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_products($user_name, $password, $category, $lang, $pricebook, $stock, $date = "") {
|
||||
|
||||
|
||||
if ($lang == 1) $lang = "pl";
|
||||
if ($lang == 2) $lang = "en";
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
$query = $db->executeQuery("SELECT `stock`.`quantity`, `p`.`id`, `p`.`name`, `l`.`long_description`, `l_en`.`short_description` as `name_en`, `l_en`.`long_description` as `long_description_en`, `pbp`.`deleted`, `p`.`code`, `p`.`manufacturer_id`, `p`.`srp_price`, `p`.`srp_price_eur`, `v`.`value`, `p`.`product_picture`, `pbp`.`popular` FROM `ecmproducts` `p` JOIN `ecmvats` `v` ON `v`.`id`=`p`.`vat_id` AND `v`.`deleted`='0' JOIN `ecmpricebooks_ecmproducts` `pbp` ON `pbp`.`ecmproduct_id`=`p`.`id` AND `pbp`.`ecmpricebook_id`='".$pricebook."' JOIN `ecmproduct_language` `l` ON `l`.`ecmproduct_id`=`p`.`id` AND `l`.`language`='pl' JOIN `ecmproduct_language` `l_en` ON `l_en`.`ecmproduct_id`=`p`.`id` AND `l_en`.`language`='en'
|
||||
LEFT JOIN `ecmstockstates` `stock` ON `stock`.`stock_id`='".$stock."' and `stock`.`product_id`=`p`.`id`
|
||||
WHERE `p`.`product_category_id`='".$category."'".($date != "" ? " AND `p`.`date_modified`>'".$date."'" : "")." group by `p`.`id`");
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
|
||||
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"name"=>$r['name'],
|
||||
"name_en"=>$r['name_en'],
|
||||
"description"=>$r['long_description'],
|
||||
"description_en"=>$r['long_description'],
|
||||
"deleted"=>$r['deleted'],
|
||||
"code"=>$r['code'],
|
||||
"manufacturer_id"=>$r['manufacturer_id'],
|
||||
"srp_price"=>$r['srp_price'],
|
||||
"srp_price_eur"=>$r['srp_price_eur'],
|
||||
"pl_vat"=>$r['value'],
|
||||
"image"=>$r['product_picture'],
|
||||
"popular"=>$r['popular'],
|
||||
"stock_value"=>$r['quantity']
|
||||
);
|
||||
}
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*******************************PRICEBOOK PRODUCTS*
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmpricebook_products',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'ecmproduct_id' => array('name'=>'ecmproduct_id', 'type'=>'xsd:string'),
|
||||
'price' => array('name'=>'price', 'type'=>'xsd:float'),
|
||||
'popular' => array('name'=>'popular', 'type'=>'xsd:int'),
|
||||
'deleted' => array('name'=>'deleted', 'type'=>'xsd:int'),
|
||||
'vat' => array('name'=>'vat', 'type'=>'xsd:int')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmpricebook_products_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmpricebook_products[]')
|
||||
),
|
||||
'tns:ecmpricebook_products'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_pricebook_products',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string'),
|
||||
array('return'=>'tns:ecmpricebook_products_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_pricebook_products($user_name, $password, $pricebook) {
|
||||
|
||||
|
||||
$return_array = array();
|
||||
//$w=$GLOBALS['db']->query("SELECT `ecmproduct_id`, `price`, `popular`, `deleted` FROM `ecmpricebooks_ecmproducts` WHERE `ecmpricebook_id`='".$pricebook."'".($date != "" ? " AND `date_modified`>'".$date."'" : ""));
|
||||
//$w=$GLOBALS['db']->query("SELECT `ecmproduct_id`, `price`, `popular`, `deleted` FROM `ecmpricebooks_ecmproducts` WHERE `ecmpricebook_id`='".$pricebook."'");
|
||||
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
$query = $db->executeQuery("SELECT `pp`.`ecmproduct_id`, `pp`.`price`, `pp`.`popular`, `pp`.`deleted`, `p`.`vat_value` FROM
|
||||
`crm`.`ecmpricebooks_ecmproducts` `pp`
|
||||
JOIN `crm`.`ecmproducts` `p` ON `p`.`id`=`pp`.`ecmproduct_id`
|
||||
WHERE `pp`.`ecmpricebook_id`='".$pricebook."'");
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
|
||||
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"ecmproduct_id"=>$r['ecmproduct_id'],
|
||||
"price"=>$r['price'],
|
||||
"popular"=>$r['popular'],
|
||||
"deleted"=>$r['deleted'],
|
||||
"vat"=>$r['vat_value']
|
||||
);
|
||||
}
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
//*******************************PRICEBOOKS*
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmpricebooks',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'id' => array('name'=>'id', 'type'=>'xsd:string'),
|
||||
'name' => array('name'=>'name', 'type'=>'xsd:string')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmpricebooks_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmpricebooks[]')
|
||||
),
|
||||
'tns:ecmpricebooks'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_pricebooks',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string'),
|
||||
array('return'=>'tns:ecmpricebooks_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_pricebooks($user_name, $password, $pricebook) {
|
||||
|
||||
|
||||
$return_array = array();
|
||||
//$w=$GLOBALS['db']->query("SELECT `id`, `name` FROM `ecmpricebooks` WHERE `id`='".$pricebook."'");
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
$query = $db->executeQuery("SELECT `id`, `name` FROM `ecmpricebooks`");
|
||||
foreach($db->executeReader($query) as $r) {
|
||||
$return_array[]=array("id"=>$r['id'],
|
||||
"name"=>$r['name']
|
||||
);
|
||||
}
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
/**************************************/
|
||||
/* potwierdzenie sprzedazy */
|
||||
|
||||
|
||||
$server->register(
|
||||
'ecm_add_order_from_shop',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'order' => 'xsd:string'),
|
||||
array('return'=>'xsd:string'),
|
||||
$NAMESPACE);
|
||||
|
||||
|
||||
|
||||
function ecm_add_order_from_shop($user_name, $password, $order, $presta, $user, $a, $b, $c, $d) {
|
||||
|
||||
|
||||
$x = "";
|
||||
$x = "S";
|
||||
$y = "false";
|
||||
|
||||
|
||||
|
||||
if(!empty($order)) {
|
||||
|
||||
$y = "ok";
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$order = unserialize(base64_decode($order));
|
||||
|
||||
|
||||
|
||||
//return print_r($order);
|
||||
if(!empty($order) && is_array($order)) {
|
||||
|
||||
|
||||
|
||||
if($order['Order-Header']['OrderNumber'] == "ORDERTEST1234")
|
||||
return "IDTEST1234";
|
||||
|
||||
else {
|
||||
require_once("modules/EcmSales/EcmSale.php");
|
||||
$focus=new EcmSale();
|
||||
|
||||
|
||||
|
||||
$template_id="97700b0d-fbe9-e366-4016-4b260f058a47";
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
|
||||
|
||||
|
||||
$focus->template_id=$template_id;
|
||||
//$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmdocumenttemplates where id='".$template_id."'"));
|
||||
//$query = $db->executeQuery(query("select name from ecmdocumenttemplates where id='".$template_id."'"));
|
||||
|
||||
$row = $db->fetchFirstRow("select name from ecmdocumenttemplates where id='".$template_id."'");
|
||||
$focus->template_name=$row['name'];
|
||||
$focus->setTemplate();
|
||||
$focus->number=$focus->generateNumber();
|
||||
$focus->document_no=$focus->formatNumber();
|
||||
$focus->currency_id="PLN";
|
||||
$focus->ecmlanguage="pl_pl";
|
||||
$focus->status="s10";
|
||||
$focus->type="sales_order";
|
||||
$focus->modified_user_id="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
$focus->created_by="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
|
||||
$pr=$order['Order-Lines'];
|
||||
$x = "ok";
|
||||
include_once("modules/Accounts/Account.php");
|
||||
//$ww=$GLOBALS['db']->query("select count(*) as c from accounts where b2clogin ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$ww=$GLOBALS['db']->query("select count(*) as c from accounts where `id` ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
$row = $db->fetchFirstRow("select count(*) as c from accounts where `id` ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$rr=$GLOBALS['db']->fetchByAssoc($ww);
|
||||
$focus->parent_id="getmir";
|
||||
$focus->description=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Description']);
|
||||
|
||||
|
||||
// if($rr['c']==0){
|
||||
// $account=new Account();
|
||||
$account->ownership="getmir";
|
||||
// $account->name=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Name']);
|
||||
// $account->b2clogin=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Login']);
|
||||
// $account->billing_address_street=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['StreetAndNumber']);
|
||||
// $account->billing_address_postalcode=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['PostalCode']);
|
||||
// $account->billing_address_city=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['CityName']);
|
||||
// $account->shipping_address_street=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['StreetAndNumber']);
|
||||
// $account->shipping_address_postalcode=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['PostalCode']);
|
||||
// $account->shipping_address_city=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['CityName']);
|
||||
// $focus->parent_id=create_guid_2();
|
||||
// $GLOBALS['db']->query("insert into accounts set id='".$focus->parent_id."',name='".$account->name."',billing_address_street='".$account->billing_address_street."',billing_address_postalcode='".$account->billing_address_postalcode."',billing_address_city='".$account->billing_address_city."',shipping_address_street='".$account->shipping_address_street."',shipping_address_postalcode='".$account->shipping_address_postalcode."',shipping_address_city='".$account->shipping_address_city."', b2clogin='".$account->b2clogin."'");
|
||||
// }
|
||||
// else{
|
||||
|
||||
|
||||
//$w=$GLOBALS['db']->query("select id from accounts where b2clogin = '".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$w=$GLOBALS['db']->query("select `id` from `accounts` where `id` = '".$order['Order-Parties']['Buyer']['Login']."' and `deleted`='0'");
|
||||
$row = $db->fetchFirstRow("select `id` from `accounts` where `id` = '".$order['Order-Parties']['Buyer']['Login']."' and `deleted`='0'");
|
||||
//$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
$account=new Account();
|
||||
//update account, maybe sth. change
|
||||
|
||||
// $GLOBALS['db']->query("update accounts set name='".$account->name."',billing_address_street='".$account->billing_address_street."',billing_address_postalcode='".$account->billing_address_postalcode."',billing_address_city='".$account->billing_address_city."'"."',shipping_address_street='".$account->shipping_address_street."',shipping_address_postalcode='".$account->shipping_address_postalcode."',shipping_address_city='".$account->shipping_address_city."'where id='".$r['id']."'");
|
||||
|
||||
// $account->retrieve($r['id']);
|
||||
$focus->parent_id=$row['id'];
|
||||
//}
|
||||
$focus->assigned_user_id="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
$focus->register_date=$order['Order-Header']['OrderDate'];
|
||||
$focus->delivery_date=$order['Order-Header']['ExpectedDeliveryDate'];
|
||||
//$focus->supplier_code=3442;
|
||||
$focus->order_no=$order['Order-Header']['OrderNumber'];
|
||||
$focus->ecmlanguage="pl_pl";
|
||||
$focus->ecmpaymentcondition_id=$order['Order-Parties']['Buyer']['PaymentConditionId'];
|
||||
|
||||
$focus->parent_name=$row["name"];//$account->name;
|
||||
$focus->parent_address_street=$a;//$account->shipping_address_street;
|
||||
$focus->parent_address_city=$b;//$account->shipping_address_city;
|
||||
$focus->parent_address_postalcode=$c;//$account->shipping_address_postalcode;
|
||||
$focus->parent_address_country=$d;//$account->shipping_address_country;
|
||||
|
||||
$ra=array();
|
||||
$total=0;
|
||||
|
||||
|
||||
|
||||
if(count($pr)>0){
|
||||
foreach($pr as $prod){
|
||||
$product_id="";
|
||||
//$w=$GLOBALS['db']->query("select id as ecmproduct_id from ecmproducts where code='".$prod['Line']['Line-Item']['CODE']."' and deleted='0' and code NOT LIKE '%_w' and code NOT LIKE '%_z' and code NOT LIKE '%_W' and code NOT LIKE '%_Z'");
|
||||
//$w=$GLOBALS['db']->query("select `id` as `ecmproduct_id` from `ecmproducts` where `id`='".$prod['Line']['Line-Item']['CODE']."' and `deleted`='0' and `code` NOT LIKE '%_w' and `code` NOT LIKE '%_z' and `code` NOT LIKE '%_W' and `code` NOT LIKE '%_Z'");
|
||||
$row = $db->fetchFirstRow("select `id` as `ecmproduct_id` from `ecmproducts` where `id`='".$prod['Line']['Line-Item']['CODE']."' and `deleted`='0' and `code` NOT LIKE '%_w' and `code` NOT LIKE '%_z' and `code` NOT LIKE '%_W' and `code` NOT LIKE '%_Z'");
|
||||
// $r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
$product_id=$row['ecmproduct_id'];
|
||||
|
||||
$wp=$GLOBALS['db']->query("select * from `ecmproducts` where `id`='".$product_id."'");
|
||||
$rppp=$GLOBALS['db']->fetchByAssoc($wp);
|
||||
$product_code=$rppp['code'];
|
||||
$product_name=$rppp['name'];
|
||||
$vat_id=$rppp['vat_id'];
|
||||
$vat_name=$rppp['vat_name'];
|
||||
$vat_value=$rppp['vat_value'];
|
||||
|
||||
$return_array['id'] = $product_id;
|
||||
$return_array['code'] = $product_code;
|
||||
$return_array['name'] = $product_name;
|
||||
$return_array['quantity'] = $prod['Line']['Line-Item']['OrderedQuantity'];
|
||||
$return_array['price'] = $prod['Line']['Line-Item']['OrderedUnitNetPrice'];
|
||||
$return_array['discount'] = 0;
|
||||
$return_array['total'] = $prod['Line']['Line-Item']['OrderedQuantity']*$prod['Line']['Line-Item']['OrderedUnitNetPrice'];
|
||||
$return_array['unit_id'] = 1;
|
||||
$return_array['unit_name'] = 'szt.';
|
||||
$return_array['vat_id'] = $vat_id;
|
||||
$return_array['vat_name'] = $vat_name;
|
||||
$return_array['vat_value'] = $vat_value;
|
||||
$return_array['currency_id'] = 'PLN';
|
||||
$return_array['recipient_code'] = $prod['Line']['Line-Item']['BuyerItemCode'];
|
||||
$total+=$return_array['quantity']*$return_array['price']*(1+$vat_value/100);
|
||||
$ra[]=$return_array;
|
||||
}
|
||||
}
|
||||
$focus->position_list = $ra;
|
||||
$return_id=$focus->save_from_shop($presta, $user);
|
||||
$GLOBALS['db']->query("update `ecmsales` set `total`='".$total."' where `id`='".$return_id."'");
|
||||
|
||||
|
||||
return $return_id;
|
||||
|
||||
|
||||
//return print_r(mysql_error()."mm", true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch(Exception $e) {}
|
||||
|
||||
}
|
||||
|
||||
return $y;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**************************************/
|
||||
|
||||
|
||||
//*******************************accounts_shop*
|
||||
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcustomer_add',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'status' => array('name'=>'status','type'=>'xsd:string')
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcustomer_add_array',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmcategories[]')
|
||||
),
|
||||
'tns:ecmcustomer_add'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_customer_add',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'pricelist' => 'xsd:string'),
|
||||
array('return'=>'tns:ecmcustomer_add_array'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_customer_add($user_name, $password, $fullname = "", $pricebook = "", $shop_user = "", $email = "", $edit = false, $id = "", $street = "", $company="", $city = "", $code = "", $nip = "", $phone = "") {
|
||||
|
||||
$return_array = array();
|
||||
|
||||
if (!$edit) {
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
$getID = create_guid();
|
||||
$query = $db->executeQuery("INSERT INTO `accounts` SET `id`='".$getID."', `name`='".$fullname."', `date_entered`='".date("Y-m-d H:i:s")."', `date_modified`='".date("Y-m-d H:i:s")."', `ecmpricebook_id`='".$pricebook."', `shop_user`='".$shop_user."', `email`='".$email."'");
|
||||
|
||||
$return_array[]=array("status"=>$getID);
|
||||
|
||||
} else {
|
||||
|
||||
if ($company != "") $fullname = $company;
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
$query = $db->executeQuery("UPDATE `accounts` SET `name`='".$fullname."', `shipping_address_postalcode`='".$code."', `shipping_address_street`='".$street."', `shipping_address_city`='".$city."', `billing_address_postalcode`='".$code."', `billing_address_street`='".$street."', `billing_address_city`='".$city."', `vatid`='".$nip."', `phone_office`='".$phone."', `date_modified`='".date("Y-m-d H:i:s")."' WHERE `id`='".$id."'");
|
||||
|
||||
$return_array[]=array("status"=>'ok');
|
||||
|
||||
}
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcategories2',
|
||||
'complexType',
|
||||
'struct',
|
||||
'all',
|
||||
'',
|
||||
array(
|
||||
'id' => array('name'=>'id','type'=>'xsd:string')
|
||||
// 'name' => array('name'=>'name', 'type'=>'xsd:string'),
|
||||
// 'name_en' => array('name'=>'name_en', 'type'=>'xsd:string'),
|
||||
// 'description' => array('name'=>'description', 'type'=>'xsd:string'),
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType(
|
||||
'ecmcategories_array2',
|
||||
'complexType',
|
||||
'array',
|
||||
'',
|
||||
'SOAP-ENC:Array',
|
||||
array(),
|
||||
array(
|
||||
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ecmcategories2[]')
|
||||
),
|
||||
'tns:ecmcategories2'
|
||||
);
|
||||
$server->register(
|
||||
'ecm_get_categories2',
|
||||
array('user_name'=>'xsd:string', 'password'=>'xsd:string', 'pricelist' => 'xsd:string'),
|
||||
array('return'=>'tns:ecmcategories_array2'),
|
||||
$NAMESPACE);
|
||||
|
||||
function ecm_get_categories2($user_name, $password, $pricelist) {
|
||||
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
$query = $db->executeQuery("SELECT `id` FROM `ecmproducts` LIMIT 10");
|
||||
foreach($db->executeReader($query) as $row) {
|
||||
|
||||
//echo $row[0]."<br>";
|
||||
|
||||
$return_array[]=array("id"=>$row[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
25
WSDL/inc.ws.types.php
Executable file
25
WSDL/inc.ws.types.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
function Register_Types($server) {
|
||||
|
||||
$server->wsdl->addComplexType('UpdateOrder','complexType','struct','sequence','',
|
||||
array (
|
||||
|
||||
'outputInfo' => array('type' => 'tns:OutputInfo')
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType('Aktualizuj','complexType','struct','sequence','',
|
||||
array (
|
||||
|
||||
'data'=>array('name'=>'data','type'=>'xsd:int'),
|
||||
|
||||
'outputInfo' => array('type' => 'tns:OutputInfo')
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
159
WSDL/pdo.db.php
Executable file
159
WSDL/pdo.db.php
Executable file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
class PDODB extends PDO
|
||||
{
|
||||
private $error;
|
||||
private $lastQuery;
|
||||
private $numRows;
|
||||
|
||||
|
||||
public function __construct($dsn, $user="", $passwd="", $timeout=30000)
|
||||
{
|
||||
$options = array(
|
||||
//PDO::ATTR_PERSISTENT => true,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_TIMEOUT => $timeout,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' );
|
||||
|
||||
try
|
||||
{
|
||||
parent::__construct($dsn, $user, $passwd, $options);
|
||||
$this->error = null;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function getLastQuery()
|
||||
{
|
||||
return $this->lastQuery;
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
public function rowCount()
|
||||
{
|
||||
return $this->numRows;
|
||||
}
|
||||
|
||||
|
||||
public function executeQuery($query, $params=array())
|
||||
{
|
||||
try
|
||||
{
|
||||
$_query = $this->prepare($query);
|
||||
$_query->execute($params);
|
||||
$this->numRows = $_query->rowCount();
|
||||
$this->error = null;
|
||||
$this->lastQuery = $_query->queryString;
|
||||
return $_query;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeReader($executed_query)
|
||||
{
|
||||
try
|
||||
{
|
||||
$results = $executed_query->fetchAll(PDO::FETCH_BOTH);
|
||||
$this->error = null;
|
||||
return $results;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchFirstRow($query, $params=array())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
$executed_query = $this->executeQuery($query, $params);
|
||||
$this->lastQuery = $query;
|
||||
|
||||
$results = $executed_query->fetch(PDO::FETCH_BOTH);
|
||||
$this->error = null;
|
||||
return $results;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeNonQuery($query)
|
||||
{
|
||||
try
|
||||
{
|
||||
$_rows = $this->exec($query);
|
||||
$this->error = null;
|
||||
$this->lastQuery = $query;
|
||||
return $_rows;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// nonquery
|
||||
//$query = $db->executeQuery("INSERT INTO pdo_test VALUES (null,now(), :v);",array('v' => 'ABC'.rand().'X'));
|
||||
$query = $db->executeQuery("INSERT INTO pdo_test VALUES (null,now(), ?);",array('ABC'.rand().'X'));
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><br>");
|
||||
print("inserted id: ".$db->lastInsertId()."<hr>");
|
||||
|
||||
// select
|
||||
$query = $db->executeQuery("SELECT * FROM pdo_test WHERE val like :v LIMIT 10;",array('v'=>'%5%'));
|
||||
foreach($db->executeReader($query) as $row)
|
||||
{
|
||||
echo "ROW: ".$row['created']." ".$row['val']."<br>";
|
||||
}
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
|
||||
|
||||
//procedura
|
||||
$query = $db->executeQuery("CALL `pdo_test_proc`();");
|
||||
foreach($db->executeReader($query) as $row)
|
||||
{
|
||||
echo "ROW: ".$row['result']."<br>";
|
||||
}
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
|
||||
//procedura drugi raz
|
||||
$firstRow = $db->fetchFirstRow("CALL `pdo_test_proc`();");
|
||||
echo "ROW: ".$firstRow['result']."<br>";
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
|
||||
|
||||
//prosty select
|
||||
$firstRow = $db->fetchFirstRow("SELECT count(*) FROM `pdo_test`;");
|
||||
echo "ROW: ".$firstRow[0]."<br>";
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
*
|
||||
* */
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user