825 lines
29 KiB
PHP
Executable File
825 lines
29 KiB
PHP
Executable File
<?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;
|
|
|
|
}
|
|
|
|
|
|
?>
|