annamaria-daneswood-25102012 /administrator/components/com_virtuemart/html/admin.booking_import.php

Language PHP Lines 67
MD5 Hash f4a16ca6366c6b7144f071ef78ddc350 Estimated Cost $1,114 (why?)
Repository https://bitbucket.org/dgough/annamaria-daneswood-25102012.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

global $psdb;

$psdb = new ps_DB();

function updateBooking($row) {
	global $psdb;
	
	//$order_number = $row->user_id.'_'.md5($row->rec);
	$total_gross = $row->price;
	
	$total_net = ($row->price / 1.105);
	$total_tax = ($row->price - ($row->price / 1.105));
	$state_tax = ($row->price - ($row->price / 1.06));
	$resort_tax = ($row->price - ($row->price / 1.045));
	
	$start = $row->start;
	$end = $row->end;
	
	$created = strtotime($row->rectime);
	
	$concat = $row->rec.'|'.$row->price.'|'.$order_number."\n";
	
	if (!$psdb->query("insert INTO #__{vm}_order_booking set 
				order_id='".$row->rec."',
				property_id='".$row->prop_id."',
				people='".$row->people."',
				arrival='".$start."',
				departure='".$end."',
				total='".$total_gross."',
				subtotal='".$total_net."',
				original='".$total_gross."',
				tax_total='".$total_tax."',
				tax_state='".$state_tax."',
				tax_resort='".$resort_tax."'
				")) {
		file_put_contents(dirname(__FILE__).'/failed_bookings.txt',$concat,FILE_APPEND);					
	} else {
		echo 'Done : '.$row->rec.'<br />';
	}
	
}

$db = new ps_DB();
$db->setQuery("select 
				tu.user_id, 
				ui.user_info_id, 
				tp.prop_id, 
				tb.* 
				from temp_bookings tb 
				left join temp_users tu on tb.custid=tu.rec 
				left join jos_users u on tu.user_id=u.id 
				left join jos_vm_user_info ui on u.id=ui.user_id 
				left join temp_props tp on tb.name=tp.old_property 
				where tp.prop_id != 0 AND tp.imported = 0 and tp.prop_id is not null");

$rows = $db->loadObjectList();

foreach ($rows as $row) {
	updateBooking($row);
	
}


?>
Back to Top