-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.html
88 lines (83 loc) · 2.52 KB
/
home.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
<script type="text/javascript">
function formatBirthday(stringDate){
var date = new Date(stringDate);
return date.toISOString();
};
var rootRef = new Firebase('https://micha-y-micha.firebaseio.com/');
var usersRef = rootRef.child("users");
usersRef.set({
dubrox: {
birthday: formatBirthday("1980-10-02 02:00"),
email: "[email protected]",
first_name: "Luca",
last_name: "Lauretta"
},
dsmontoya: {
birthday: formatBirthday("1994-11-12 02:00"),
email: "[email protected]",
first_name: "Daniel",
last_name: "Montoya"
},
sofia: {
birthday: formatBirthday("1990-12-01 02:00"),
email: "[email protected]",
first_name: "SofÃa",
last_name: "RÃos"
},
javiermontoya: {
birthday: formatBirthday("1960-04-08 02:00"),
email: "[email protected]",
first_name: "Javier",
last_name: "Montoya"
}
});
var creditsRef = rootRef.child("credits");
var creditsArray = [{
title: "Hacer crecer mi venta de pollos",
description: "Es necesario escoger la mejor descripción para este espacio.",
user: "javiermontoya",
amount: 10000,
months: 12,
interest_rate: 15,
expiration_date: formatBirthday("2015-12-29 00:00"),
photo_url: "http://fotos01.laprovincia.es/2013/08/02/646x260/tiempos-pollos.jpg",
status: "pending"
},
{
title: "mis vacaciones",
description: "Es necesario escoger la mejor descripción para este espacio.",
user: "javiermontoya",
amount: 900,
months: 12,
interest_rate: 15,
expiration_date: formatBirthday("2015-12-29 00:00"),
photo_url: "http://tainobeach.com/wp-content/uploads/2015/04/Vacation.jpg",
status: "active"
}];
console.log(creditsArray)
for (var a = 0; a < creditsArray.length; a++) {
console.log(creditsArray[a])
var credit = creditsRef.push(creditsArray[a]),
arr = ["dubrox", "dsmontoya", "ana"];
console.log(credit.key())
for (var i = 0; i < arr.length; i++) {
var transactionsRef = rootRef.child("transactions");
transactionsRef.push({
amount: creditsArray[a] == "pending" ? 600 : 300,
currency: "mxn",
medium: "card",
gateway: "openpay",
reference: "blahblablah",
user: arr[i],
credit: credit.key(),
approved: true
});
}
}
function destroyAll(){
creditsRef.set({});
paymentsRef.set({});
transactionsRef.set({});
}
</script>