3
define( '_VALID_MOS', 1);
6
include("xmlrpcs.inc");
8
require_once( 'configuration.php' );
9
require_once( 'includes/joomla.php' );
10
require_once( 'administrator/components/com_virtuemart/virtuemart.cfg.php' );
12
$con = mysql_pconnect($mosConfig_host, $mosConfig_user,$mosConfig_password );
13
mysql_select_db($mosConfig_db);
16
function get_taxes() {
17
global $mosConfig_dbprefix;
20
$result=mysql_query("select tax_rate_id, tax_rate*100 from ".$mosConfig_dbprefix."vm_tax_rate;");
21
if ($result) while ($row=mysql_fetch_row($result)) {
22
$taxes[]=new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval("Tax ".$row[1]."%", "string")), "array");
24
return new xmlrpcresp( new xmlrpcval($taxes, "array"));
27
function delete_products() {
28
global $mosConfig_dbprefix;
30
mysql_query("truncate table ".$mosConfig_dbprefix."vm_product_attribute;");
31
mysql_query("truncate table ".$mosConfig_dbprefix."vm_product_price;");
32
mysql_query("truncate table ".$mosConfig_dbprefix."vm_product_tax;");
33
mysql_query("truncate table ".$mosConfig_dbprefix."vm_product_category_xref;");
34
mysql_query("delete from ".$mosConfig_dbprefix."jf_content where reference_table='vm_product' and reference_field in ('product_s_desc','product_desc') ;");
35
$result=mysql_query("truncate table ".$mosConfig_dbprefix."vm_product;");
36
//$result=mysql_query("update ".$mosConfig_dbprefix."vm_product set `product_publish` = 'N';");
37
//$result=mysql_query("update ".$mosConfig_dbprefix."vm_product set ".
38
// "product_publish='N' ".
41
return new xmlrpcresp( new xmlrpcval($result, "int"));
44
function unlink_products($product_id) {
45
global $mosConfig_dbprefix;
46
//self.debug("Products Ids for Unlink: ".implode(",",$product_ids));
47
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_publish='N' where product_id in (".implode(",",$product_id).");");
48
return new xmlrpcresp(new xmlrpcval(1,"int"));
51
function delete_product_categories() {
52
global $mosConfig_dbprefix;
54
mysql_query("truncate table ".$mosConfig_dbprefix."vm_category_xref;");
55
$result = mysql_query("truncate table ".$mosConfig_dbprefix."vm_category;");
58
return new xmlrpcresp(new xmlrpcval($result, "int"));
61
function get_languages() {
64
$languages[] = new xmlrpcval(array(new xmlrpcval(1, "int"), new xmlrpcval("Unique", "string")), "array");
66
return new xmlrpcresp( new xmlrpcval($languages, "array"));
69
function get_categories() {
70
global $mosConfig_dbprefix;
73
$result=mysql_query("select category_id, category_name from ".$mosConfig_dbprefix."vm_category;");
75
if ($result) while ($row=mysql_fetch_row($result)) {
77
$row1 = urlencode($row[1]);
78
$categories[] = new xmlrpcval(array(new xmlrpcval($row[0], "int"), new xmlrpcval(parent_category($row0, $row1), "string")), "array");
81
return new xmlrpcresp( new xmlrpcval($categories, "array"));
84
function parent_category($id, $name) {
85
global $mosConfig_dbprefix;
86
$result=mysql_query("select category_parent_id from ".$mosConfig_dbprefix."vm_category_xref where category_child_id=".$id.";");
87
if ($result && $row=mysql_fetch_row($result)) {
91
$resultb=mysql_query("select category_name from ".$mosConfig_dbprefix."vm_category where category_id=".$row[0].";");
92
if ($resultb && $rowb=mysql_fetch_row($resultb)) {
93
$name=parent_category($row[0], $rowb[0] . " \\ ". $name);
101
function set_product_stock($tiny_product) {
102
global $mosConfig_dbprefix;
103
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_in_stock=".$tiny_product['quantity']." where
104
product_id=".$tiny_product['esale_joomla_id'].";");
105
//mysql_query("update products set products_status=".(($tiny_product['quantity']>0)?1:0)." where
106
//products_id=".$tiny_product['esale_joomla_id'].";");
107
return new xmlrpcresp(new xmlrpcval(1,"int"));
111
$fp = fopen("/tmp/debug.xmlrpc2.txt","a");
112
fwrite($fp, $s."\n");
116
function _update_category_name_by_lang($lang_id, $lang_str, $osc_id, $tiny_category) {
118
global $mosConfig_dbprefix;
120
$original_name = ($tiny_category['name']);
121
$name_value = ($tiny_category['name:' . $lang_str]);
123
if($name_value == '' and $original_name != '') {
124
$name_value = $original_name;
125
} elseif ($original_name == '' and $name_value != '') {
126
$original_name = $name_value;
129
if($original_name != '') {
130
$name_value = str_replace('"', '\"', $name_value);
131
$result = mysql_query("select id from ".$mosConfig_dbprefix."jf_content where reference_id=".$osc_id." and reference_table='vm_category' and reference_field='category_name';");
134
if ($result && $row=mysql_fetch_row($result)) {
135
$res = mysql_query("update ".$mosConfig_dbprefix."jf_content set reference_id=".$osc_id." ,language_id='".$lang_id."',published=1,value=\"".$name_value."\",modified='".date( "Y-m-d H:i:s" )."',original_value='".md5($original_name)."' where id=".$row[0].";");
137
$res = mysql_query("insert into ".$mosConfig_dbprefix."jf_content(language_id,reference_id,reference_table,reference_field,value,original_value,modified_by,modified,published) values (".$lang_id.",".$osc_id.",'vm_category','category_name',\"".$name_value."\",'".md5($original_name)."',70,'".date( "Y-m-d H:i:s" )."',1);");
142
function set_category($tiny_category){
143
global $mosConfig_dbprefix;
145
if($tiny_category['esale_joomla_id'] != 0) {
146
$result = mysql_query("update ".$mosConfig_dbprefix."vm_category set ".
147
"category_name='". ($tiny_category['name'])."', ".
148
"category_description='". ($tiny_category['name'])."'".
149
"where category_id=".$tiny_category['esale_joomla_id'].";");
150
$osc_id = $tiny_category['esale_joomla_id'];
153
mysql_query("insert into ".$mosConfig_dbprefix."vm_category (category_name,category_description,category_publish,vendor_id) values (\"". ($tiny_category['name'])."\",\"". ($tiny_category['name'])."\",\"Y\",'1');");
154
$category_child_id = mysql_insert_id();
155
mysql_query("update ".$mosConfig_dbprefix."vm_category set list_order=".$category_child_id." where category_id=".$category_child_id.";");
156
$category_parent_id=$tiny_category['parent_id'];
157
mysql_query("insert into ".$mosConfig_dbprefix."vm_category_xref (category_parent_id,category_child_id) values (".$category_parent_id.",".$category_child_id.");");
158
$osc_id = $category_child_id;
161
$result = mysql_query("select id from ".$mosConfig_dbprefix."languages where iso='fr';");
163
if ($result && $row=mysql_fetch_row($result)) {
168
// Retrieve FRENCH language:
169
$res = mysql_query("select id from ".$mosConfig_dbprefix."languages where iso='fr';");
171
$lang_fr_str = 'fr_FR';
172
if ($res && $row=mysql_fetch_row($res)) {
173
$lang_fr_id = $row[0];
176
// Retrieve ENGLISH language:
177
$res = mysql_query("select id from ".$mosConfig_dbprefix."languages where iso='en';");
179
$lang_en_str = 'en_US';
180
if ($res && $row=mysql_fetch_row($res)) {
181
$lang_en_id = $row[0];
184
_update_category_name_by_lang($lang_fr_id, $lang_fr_str, $osc_id, $tiny_category);
185
_update_category_name_by_lang($lang_en_id, $lang_en_str, $osc_id, $tiny_category);
187
return new xmlrpcresp(new xmlrpcval($osc_id, "int"));
190
function set_tax($tiny_tax){
191
global $mosConfig_dbprefix;
195
if ($tiny_tax['type'] == 'percent')
196
$type = 'percentage';
198
if ($tiny_tax['country']) {
199
$result = mysql_query("select country_3_code from ".$mosConfig_dbprefix."vm_country where country_name='".$tiny_tax['country']."';");
200
if ($result && $row=mysql_fetch_row($result)) {
201
$country_id = $row[0];
205
if($tiny_tax['esale_joomla_id'] != 0) {
206
$result=mysql_query("update ".$mosConfig_dbprefix."vm_tax_rate set ".
207
"tax_name='".$tiny_tax['name']."', ".
208
"tax_type='".$type."', ".
209
"tax_rate=".$tiny_tax['rate'].", ".
210
"inc_base_price=".$tiny_tax['include_base_amount'].", ".
211
"tax_country='".$country_id."', ".
212
"tax_state='".$state_id."', ".
213
"priority=".$tiny_tax['sequence'].
214
" where tax_rate_id=".$tiny_tax['esale_joomla_id'].";");
216
$osc_id=$tiny_tax['esale_joomla_id'];
218
mysql_query("insert into ".$mosConfig_dbprefix."vm_tax_rate (tax_name,tax_type,tax_rate,inc_base_price,priority,tax_country,tax_state,vendor_id) values (\"".$tiny_tax['name']."\",\"".$type."\",".$tiny_tax['rate'].",".$tiny_tax['include_base_amount'].",".$tiny_tax['sequence'].",'".$country_id."','".$state_id."','1');");
219
$osc_id = mysql_insert_id();
222
return new xmlrpcresp(new xmlrpcval($osc_id, "int"));
225
function _update_product_name_by_lang($lang_id, $lang_str, $osc_id, $tiny_product) {
227
global $mosConfig_dbprefix;
229
$original_name = ($tiny_product['name']);
230
$name_value = ($tiny_product['name:' . $lang_str]);
232
if($name_value=='' and $original_name!='') {
233
$name_value = $original_name;
234
} elseif ($original_name=='' and $name_value!='') {
235
$original_name = $name_value;
238
if($original_name != '') {
239
$name_value = str_replace('"', '\"', $name_value);
240
$result = mysql_query("select id from ".$mosConfig_dbprefix."jf_content where reference_id=".$osc_id." and reference_table='vm_product' and reference_field='product_name' and language_id = ".$lang_id.";");
243
if ($result && $row=mysql_fetch_row($result)) {
244
$res = mysql_query("update ".$mosConfig_dbprefix."jf_content set reference_id=".$osc_id." ,language_id='".$lang_id."',published=1,value=\"".$name_value."\",modified='".date( "Y-m-d H:i:s" )."',original_value='".md5($original_name)."' where id=".$row[0].";");
245
//self.debug("update ".$mosConfig_dbprefix."jf_content set reference_id=".$osc_id." ,language_id='".$lang_id."',published=1,value=\"".$name_value."\",modified='".date( "Y-m-d H:i:s" )."',original_value='".md5($original_name)."' where id=".$row[0].";");
246
//self.debug("res_update: " . $res);
248
$res = mysql_query("insert into ".$mosConfig_dbprefix."jf_content(language_id,reference_id,reference_table,reference_field,value,original_value,modified_by,modified,published) values (".$lang_id.",".$osc_id.",'vm_product','product_name',\"".$name_value."\",'".md5($original_name)."',70,'".date( "Y-m-d H:i:s" )."',1);");
249
//self.debug("insert into ".$mosConfig_dbprefix."jf_content(language_id,reference_id,reference_table,reference_field,value,original_value,modified_by,modified,published) values (".$lang_id.",".$osc_id.",'vm_product','product_name',\"".$name_value."\",'".md5($original_name)."',70,'".date( "Y-m-d H:i:s" )."',1);");
250
//self.debug("res_insert: " . $res);
255
function _update_product_long_desc_by_lang($lang_id, $lang_str, $osc_id, $tiny_product) {
257
global $mosConfig_dbprefix;
259
$original_name = ($tiny_product['description']);
260
$desc_value = ($tiny_product['description:' . $lang_str]);
262
if ($desc_value=='' and $original_name!='') {
263
$desc_value = $original_name;
264
} elseif ($original_name=='' and $desc_value!='') {
265
$original_name = $desc_value;
268
if ($original_name!='') {
269
$desc_value = str_replace('"', '\"', $desc_value);
270
$result = mysql_query("select id from ".$mosConfig_dbprefix."jf_content where reference_id=".$osc_id." and reference_table='vm_product' and reference_field='product_desc' and language_id = ".$lang_id.";");
273
if ($result && $row=mysql_fetch_row($result)) {
274
$res = mysql_query("update ".$mosConfig_dbprefix."jf_content set reference_id=".$osc_id." ,language_id='".$lang_id."',published=1,value=\"".$desc_value."\",modified='".date( "Y-m-d H:i:s" )."',original_value='".md5($original_name)."' where id=".$row[0].";");
276
$res = mysql_query("insert into ".$mosConfig_dbprefix."jf_content(language_id,reference_id,reference_table,reference_field,value,original_value,modified_by,modified,published) values (".$lang_id.",".$osc_id.",'vm_product','product_desc',\"".$desc_value."\",'".md5($original_name)."',70,'".date( "Y-m-d H:i:s" )."',1);");
281
function _update_product_short_desc_by_lang($lang_id, $lang_str, $osc_id, $tiny_product) {
283
global $mosConfig_dbprefix;
285
$original_name = ($tiny_product['short_description']);
286
$desc_value = ($tiny_product['short_description:' . $lang_str]);
288
if($desc_value=='' and $original_name!=''){
289
$desc_value = $original_name;
290
} elseif ($original_name=='' and $desc_value!='') {
291
$original_name = $desc_value;
294
if ($original_name!='') {
295
$desc_value = str_replace('"','\"',$desc_value);
296
$result = mysql_query("select id from ".$mosConfig_dbprefix."jf_content where reference_id=".$osc_id." and reference_table='vm_product' and reference_field='product_s_desc' and language_id = ".$lang_id.";");
298
if ($result && $row=mysql_fetch_row($result)) {
299
$temp = mysql_query("update ".$mosConfig_dbprefix."jf_content set reference_id=".$osc_id.",language_id='".$lang_id."',published=1,value=\"".$desc_value."\",modified='".date( "Y-m-d H:i:s" )."',original_value='".md5($original_name)."' where id=".$row[0].";");
301
$temp = mysql_query("insert into ".$mosConfig_dbprefix."jf_content(language_id,reference_id,reference_table,reference_field,value,original_value,modified_by,modified,published) values (".$lang_id.",".$osc_id.",'vm_product','product_s_desc',\"".$desc_value."\",'".md5($original_name)."',70,'".date( "Y-m-d H:i:s" )."',1);");
306
function set_product($tiny_product){
309
global $mosConfig_dbprefix;
314
$result = mysql_query("select vendor_id, vendor_currency from ".$mosConfig_dbprefix."vm_vendor;");
315
if ($result && $row=mysql_fetch_row($result)) {
316
$prod['vendor_id']=$row[0];
317
$prod['vendor_currency']=$row[1];
319
$result=mysql_query("select shopper_group_id from ".$mosConfig_dbprefix."vm_shopper_group where vendor_id=".$vendor_id." and shopper_group_name='-default-';");
320
if ($result && $row=mysql_fetch_row($result))
321
$prod['shopper_group']=$row[0];
322
if ( $tiny_product['esale_joomla_id']) {
323
$result = mysql_query("select count(*) from ".$mosConfig_dbprefix."vm_product where product_id=". $tiny_product['esale_joomla_id']);
324
$row = mysql_fetch_row($result);
326
$tiny_product['esale_joomla_id'] = 0;
329
if (! $tiny_product['esale_joomla_id']) {
330
$res = mysql_query("select shopper_group_id,vendor_id from ".$mosConfig_dbprefix."vm_shopper_group where `default` = 1");
331
$shoperid = mysql_fetch_array($res);
332
$shopper_group = $shoperid['shopper_group_id'];
333
$vendorid = $shoperid['vendor_id'];
335
$res = mysql_query("select vendor_currency from ".$mosConfig_dbprefix."vm_vendor where vendor_id = ".$vendorid);
336
$vcurrency = mysql_fetch_array($res);
337
$vendor_currency = $vcurrency['vendor_currency'];
339
mysql_query("insert into ".$mosConfig_dbprefix."vm_product () values ()");
340
$osc_id = mysql_insert_id();
341
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_price (product_id, product_price, product_currency, product_price_vdate, product_price_edate, shopper_group_id) values (".$osc_id.", ".$tiny_product['price'].", '".$vendor_currency."', 0, 0, ".$shopper_group.");");
342
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_category_xref (product_id, category_id) values (".$osc_id.", ".$tiny_product['category_id'].");");
344
foreach ($tiny_product['tax_rate_id'] as $taxes=>$values) {
345
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_tax (product_id, tax_rate_id) values (".$osc_id.", ".$values["id"].");");
348
$osc_id = $tiny_product['esale_joomla_id'];
351
$query = "update ".$mosConfig_dbprefix."vm_product set ".
352
"product_in_stock=".$tiny_product['quantity'].",".
353
"product_weight=".$tiny_product['weight'].",".
354
"product_sku='".mysql_escape_string($tiny_product['model'])."',".
355
"product_name='".mysql_escape_string( ($tiny_product['name']))."',".
356
"vendor_id='".$prod['vendor_id']."',".
357
"product_desc='".mysql_escape_string( ($tiny_product['description']))."', ".
358
"product_unit='".mysql_escape_string( ($tiny_product['product_unit']))."', ".
359
"product_publish='Y',".
360
"product_packaging=".$tiny_product['product_packaging_qty'].",".
361
"product_packaging_type='".$tiny_product['product_packaging_type']."',".
362
"product_s_desc='".mysql_escape_string( (substr($tiny_product['short_description'],0,200)))."' ".
363
"where product_id=".$osc_id.";";
365
$res = mysql_query($query);
370
// Replace or delete old values
372
mysql_query("update ".$mosConfig_dbprefix."vm_product_price set product_price='".$tiny_product['price']."' where product_id=".$osc_id.";");
374
mysql_query("update ".$mosConfig_dbprefix."vm_product_category_xref set category_id='".$tiny_product['category_id']."' where product_id=".$osc_id.";");
375
mysql_query("delete from ".$mosConfig_dbprefix."vm_product_tax where product_id=".$osc_id.";");
376
foreach ($tiny_product['tax_rate_id'] as $taxes=>$values) {
377
mysql_query("insert into ".$mosConfig_dbprefix."vm_product_tax (product_id, tax_rate_id) values (".$osc_id.", ".$values["id"].");");
380
// Retrieve FRENCH language:
381
$res = mysql_query("select id from ".$mosConfig_dbprefix."languages where iso='fr';");
383
$lang_fr_str = 'fr_FR';
384
if ($res && $row=mysql_fetch_row($res)) {
385
$lang_fr_id = $row[0];
388
// Retrieve ENGLISH language:
389
$res = mysql_query("select id from ".$mosConfig_dbprefix."languages where iso='en';");
391
$lang_en_str = 'en_US';
392
if ($res && $row=mysql_fetch_row($res)) {
393
$lang_en_id = $row[0];
397
_update_product_name_by_lang($lang_fr_id, $lang_fr_str, $osc_id, $tiny_product);
398
_update_product_name_by_lang($lang_en_id, $lang_en_str, $osc_id, $tiny_product);
400
// Product long description:
401
_update_product_long_desc_by_lang($lang_fr_id, $lang_fr_str, $osc_id, $tiny_product);
402
_update_product_long_desc_by_lang($lang_en_id, $lang_en_str, $osc_id, $tiny_product);
404
// Product short description:
405
_update_product_short_desc_by_lang($lang_fr_id, $lang_fr_str, $osc_id, $tiny_product);
406
_update_product_short_desc_by_lang($lang_en_id, $lang_en_str, $osc_id, $tiny_product);
408
if ($tiny_product['haspic']==1) {
409
$filename = tempnam('components/com_virtuemart/shop_image/product/', 'tiny_');
410
$extension = strrchr($tiny_product['code'].'.jpg','.');
411
$filename.=$extension;
412
//$filename='components/com_virtuemart/shop_image/product/tiny_'.$tiny_product['code'].'.jpg';
413
$hd = fopen($filename, "w");
414
fwrite($hd, base64_decode($tiny_product['picture']));
416
$short = strrchr($filename,'/');
417
$short = substr($short, 1, strlen($short));
418
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_full_image='".$short."' where product_id=".$osc_id.";");
419
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_thumb_image='".$short."' where product_id=".$osc_id.";");
420
unlink(substr($filename,0,strlen($filename)-4));
421
/*$newxsize = PSHOP_IMG_WIDTH;
425
$newysize = PSHOP_IMG_HEIGHT;
429
$extension=strtolower($extension);
430
if (in_array($extension, array('.jpeg', '.jpe', '.jpg', '.gif', '.png'))) {
431
if (in_array($extension, array('.jpeg', '.jpe', '.jpg'))) {
434
$thumb=tempnam('components/com_virtuemart/shop_image/product/', 'tiny_').$extension;
435
$load='imagecreatefrom'.substr($extension,1,strlen($extension)-1);
436
$save='image'.substr($extension,1,strlen($extension)-1);
437
$tmp_img=$load($filename);
438
$imgsize = getimagesize($filename);
439
if ($imgsize[0] > $newxsize || $imgsize[1] > $newysize) {
440
if ($imgsize[0]*$newysize > $imgsize[1]*$newxsize) {
441
$ratio=$imgsize[0]/$newxsize;
443
$ratio=$imgsize[1]/$newysize;
448
$tn=imagecreatetruecolor (floor($imgsize[0]/$ratio),floor($imgsize[1]/$ratio));
449
imagecopyresized($tn,$tmp_img,0,0,0,0,floor($imgsize[0]/$ratio),floor($imgsize[1]/$ratio),$imgsize[0],$imgsize[1]);
450
$short=strrchr($thumb,'/');
451
$short=substr($short,1,strlen($short));
453
mysql_query("update ".$mosConfig_dbprefix."vm_product set product_thumb_image='".$short."' where product_id=".$osc_id.";");
458
if ($rpc_error > 0) {
459
$rpc_msg = "Error in sync script";
462
$resp = new xmlrpcresp(new xmlrpcval($osc_id, "int"), $rpc_error, $rpc_msg);
463
//$resp = new xmlrpcresp(new xmlrpcval($osc_id, "int"));
467
function get_saleorders($last_so) {
468
global $mosConfig_dbprefix;
471
/*$result=mysql_query(
473
o.`order_id`, c.`last_name`, c.`address_1`, c.`city`, c.`zip`, c.`state`,
474
c.`country`, c.`phone_1`, c.`user_email`, d.`last_name` , d.`address_1` ,
475
d.`city`, d.`zip`, d.`state`, d.`country`, o.`cdate`,
476
c.title, c.first_name, d.title, d.first_name,
477
d.user_id, c.user_id, o.customer_note
479
$mosConfig_dbprefix."vm_orders as o,".
480
$mosConfig_dbprefix."vm_user_info as c, ".
481
$mosConfig_dbprefix."vm_user_info as d
483
o.order_id>".$last_so." and
484
o.user_id=c.user_id and
485
(c.address_type_name is NULL or c.address_type_name='-default-') and
486
o.user_info_id=d.user_info_id;
491
o.`order_id`, c.`last_name`, c.`address_1`, c.`city`, c.`zip`, c.`state`,
492
cn.`country_2_code` as `country`, c.`phone_1`, c.`user_email`, d.`last_name` , d.`address_1` ,
493
d.`city`, d.`zip`, d.`state`, d.`country`, o.`cdate`,
494
c.title, c.first_name, d.title, d.first_name,
495
d.user_id, c.user_id, o.customer_note,
496
o.order_discount,o.order_shipping,o.order_shipping_tax FROM ".
497
$mosConfig_dbprefix."vm_orders as o,".
498
$mosConfig_dbprefix."vm_user_info as c, ".
499
$mosConfig_dbprefix."vm_country as cn, ".
500
$mosConfig_dbprefix."vm_user_info as d
502
o.order_id>".$last_so." and
503
o.user_id=c.user_id and
504
(c.address_type_name is NULL or c.address_type_name='-default-') and
505
( cn.country_3_code = c.country) and
506
o.user_info_id=d.user_info_id;
509
if ($result) while ($row=mysql_fetch_row($result)) {
510
$orderlines = array();
511
$resultb = mysql_query("select product_id, product_quantity, product_item_price from ".$mosConfig_dbprefix."vm_order_item where order_id=".$row[0].";");
512
if ($resultb) while ($rowb=mysql_fetch_row($resultb)) {
513
$orderlines[] = new xmlrpcval( array(
514
"product_id" => new xmlrpcval($rowb[0], "int"),
515
"product_qty" => new xmlrpcval($rowb[1], "int"),
516
"price" => new xmlrpcval($rowb[2], "string")
521
$shipping_fee = $row[24];
522
if ($shipping_fee!=0){
523
$orderlines[] = new xmlrpcval( array(
524
"product_is_shipping" => new xmlrpcval(True, "boolean"),
525
"product_name" => new xmlrpcval("Shipping fees", "string"),
526
"product_qty" => new xmlrpcval(0, "int"),
527
"price" => new xmlrpcval($shipping_fee, "string")
530
$other_fee = (-1 * $fee);
531
if ($other_fee != 0){
532
$orderlines[] = new xmlrpcval( array(
533
"product_name" => new xmlrpcval("Other fees", "string"),
534
"product_qty" => new xmlrpcval(0, "int"),
535
"price" => new xmlrpcval($other_fee, "string")
538
//$orderlines[]=new xmlrpcval( array(
539
// "product_name" => new xmlrpcval("Shipping tax", "string"),
540
// "product_qty" => new xmlrpcval(0, "int"),
541
// "price" => new xmlrpcval($row[25], "string")
544
$saleorders[] = new xmlrpcval( array(
545
"id" => new xmlrpcval( $row[0], "int"),
546
"note" => new xmlrpcval( $row[22], "string"),
547
"lines" => new xmlrpcval( $orderlines, "array"),
548
"address" => new xmlrpcval( array(
549
"name" => new xmlrpcval($row[16]." ".$row[1]." ".$row[17], "string"),
550
"address" => new xmlrpcval($row[2], "string"),
551
"city" => new xmlrpcval(urlencode($row[3]), "string"),
552
"zip" => new xmlrpcval($row[4], "string"),
553
"state" => new xmlrpcval($row[5], "string"),
554
"country" => new xmlrpcval($row[6], "string"),
555
"phone" => new xmlrpcval($row[7], "string"),
556
"email" => new xmlrpcval($row[8], "string"),
557
"esale_id" => new xmlrpcval($row[20], "string")
559
"delivery" => new xmlrpcval( array(
560
"name" => new xmlrpcval($row[18]." ".$row[9]." ".$row[19], "string"),
561
"address" => new xmlrpcval($row[10], "string"),
562
"city" => new xmlrpcval(urlencode($row[11]), "string"),
563
"zip" => new xmlrpcval($row[12], "string"),
564
"state" => new xmlrpcval($row[13], "string"),
565
"country" => new xmlrpcval($row[14], "string"),
566
"email" => new xmlrpcval($row[8], "string"),
567
"esale_id" => new xmlrpcval($row[21], "string")
569
"billing" =>new xmlrpcval( array(
570
"name" => new xmlrpcval($row[16]." ".$row[1]." ".$row[17], "string"),
571
"address" => new xmlrpcval($row[2], "string"),
572
"city" => new xmlrpcval(urlencode($row[3]), "string"),
573
"zip" => new xmlrpcval($row[4], "string"),
574
"state" => new xmlrpcval($row[5], "string"),
575
"country" => new xmlrpcval($row[6], "string"),
576
"email" => new xmlrpcval($row[8], "string"),
577
"esale_id" => new xmlrpcval($row[20], "string")
579
"date" => new xmlrpcval( date('YmdHis',$row[15]), "date")
583
$resp = new xmlrpcresp(new xmlrpcval($saleorders, "array"));
588
function process_order($order_id) {
589
global $mosConfig_dbprefix;
590
mysql_query("update ".$mosConfig_dbprefix."vm_orders set order_status='C' where order_id=".$order_id.";");
591
mysql_query("update ".$mosConfig_dbprefix."vm_order_item set oerder_status='C' where order_id=".$order_id.";");
592
return new xmlrpcresp(new xmlrpcval(0, "int"));
595
function close_order($order_id) {
596
global $mosConfig_dbprefix;
597
mysql_query("update ".$mosConfig_dbprefix."vm_orders set order_status='S' where order_id=".$order_id.";");
598
mysql_query("update ".$mosConfig_dbprefix."vm_order_item set oerder_status='S' where order_id=".$order_id.";");
599
return new xmlrpcresp(new xmlrpcval(0, "int"));
602
$server = new xmlrpc_server( array(
603
"get_taxes" => array(
604
"function" => "get_taxes",
605
"signature" => array(array($xmlrpcArray))
607
"get_languages" => array(
608
"function" => "get_languages",
609
"signature" => array(array($xmlrpcArray))
611
"get_categories" => array(
612
"function" => "get_categories",
613
"signature" => array(array($xmlrpcArray))
615
"get_saleorders" => array(
616
"function" => "get_saleorders",
617
"signature" => array(array($xmlrpcArray, $xmlrpcInt))
619
"set_product" => array(
620
"function" => "set_product",
621
"signature" => array(array($xmlrpcInt, $xmlrpcStruct))
623
"set_category" => array(
624
"function" => "set_category",
625
"signature" => array(array($xmlrpcInt, $xmlrpcStruct))
628
"function" => "set_tax",
629
"signature" => array(array($xmlrpcInt, $xmlrpcStruct))
632
"set_product_stock" => array(
633
"function" => "set_product_stock",
634
"signature" => array(array($xmlrpcInt, $xmlrpcStruct))
636
"process_order" => array(
637
"function" => "process_order",
638
"signature" => array(array($xmlrpcInt, $xmlrpcInt))
640
"delete_products" => array(
641
"function" => "delete_products",
642
"signature" => array(array($xmlrpcArray))
644
"delete_product_categories" => array(
645
"function" => "delete_product_categories",
646
"signature" => array(array($xmlrpcArray))
648
"close_order" => array(
649
"function" => "close_order",
650
"signature" => array(array($xmlrpcInt, $xmlrpcInt))
652
"unlink_products"=>array(
653
"function" => "unlink_products",
654
"signature" => array(array($xmlrpcInt, $xmlrpcArray))
657
$server->functions_parameters_type= 'phpvals';