-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
149 lines (118 loc) · 5.1 KB
/
index.php
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
require('common.php');
showTop('Donation Tracer');
if(i($QUERY, 'action')) {
$crud = new iframe\iframe\Crud("Donut_Donation");
$crud->addField('fundraiser_user_id', 'Fund Raiser ID', 'int');
$crud->addField('donor_id', 'Donor ID', 'int');
$crud->addField('with_user_id', 'With User ID', 'int');
$crud->addField('updated_by_user_id', 'Updater User ID', 'int');
$crud->save_states[] = 'action';
if(i($QUERY, 'action') == 'Search') {
$wheres = [];
if(!empty($_REQUEST['donation_id'])) {
$wheres[] = "(D.id='$_REQUEST[donation_id]')";
$crud->save_states[] = 'donation_id';
}
if(!empty($_REQUEST['donor_name'])) {
$name_parts = explode(" ", $_REQUEST['donor_name']);
$wheres[] = "(DN.name LIKE '%$_REQUEST[donor_name]%')";
$crud->save_states[] = 'donor_name';
}
if(!empty($_REQUEST['donor_phone'])) {
$name_parts = explode(" ", $_REQUEST['donor_phone']);
$wheres[] = "(DN.phone = '$_REQUEST[donor_phone]')";
$crud->save_states[] = 'donor_phone';
}
if(!empty($_REQUEST['donor_email'])) {
$name_parts = explode(" ", $_REQUEST['donor_email']);
$wheres[] = "(DN.email = '$_REQUEST[donor_email]')";
$crud->save_states[] = 'donor_email';
}
if(!empty($_REQUEST['user_name'])) {
$name_parts = explode(" ", $_REQUEST['user_name']);
$wheres[] = "(U.name LIKE '%$_REQUEST[user_name]%')";
$crud->save_states[] = 'user_name';
}
if(!empty($_REQUEST['user_phone'])) {
$wheres[] = "(U.phone = '$_REQUEST[user_phone]')";
$crud->save_states[] = 'user_phone';
}
if(!empty($_REQUEST['user_id'])) {
$wheres[] = "(U.id='$_REQUEST[user_id]')";
$crud->save_states[] = 'user_id';
}
if(!empty($_REQUEST['user_email'])) {
$wheres[] = "(U.email = '$_REQUEST[user_email]' OR U.mad_email = '$_REQUEST[user_email]')";
$crud->save_states[] = 'user_email';
}
if(!empty($_REQUEST['amount'])) {
$name_parts = explode(" ", $_REQUEST['amount']);
$wheres[] = "(D.amount = '$_REQUEST[amount]%')";
$crud->save_states[] = 'amount';
}
if(i($QUERY, 'action') == 'Search') {
$table = 'Donut_Donation';
$donor_id = 'donour_id';
$more_fields = '';
}
$query = "SELECT D.*, $more_fields
DN.name AS donor_name, DN.email AS donor_email, DN.phone AS donor_phone,
U.name, U.email, U.phone, C.name AS city_name
FROM $table D
INNER JOIN Donut_Donor DN ON DN.id=D.donor_id
INNER JOIN User U ON U.id=D.fundraiser_user_id
INNER JOIN City C ON U.city_id=C.id
WHERE " . implode(" AND ", $wheres);
// print $query; exit;
// $data = $sql->getAll($query);
// print "<pre>$query</pre>";
// dump($data);
$crud->setListingQuery($query);
$crud->addField('id', 'ID', 'int', [], ['url'=>'"donation.php?donation_id=$row[id]"', 'text'=>'$row["id"]'],'text', 'url');
$crud->addField('city_name', 'City', 'text', [], ['text'=> '$row["city_name"]']);
$crud->addField('status', 'Status', 'text');
$crud->addField('fundraiser_user_id', 'FundRaiser', 'int', [], ['url'=>'"user.php?action=edit&id=$row[fundraiser_user_id]"', 'text'=>'$row["name"]'],'text', 'url');
$crud->addField('donour_id', 'Donor', 'int', [], ['url'=>'"donors.php?action=edit&id=$row[donor_id]"', 'text'=>'$row["donor_name"]'],'text', 'url');
$crud->addField('updated_by_user_id', 'Updater', 'int', [], ['url'=>'"users.php?action=edit&id=$row[updated_by_user_id]"', 'text'=>'$row["name"]'],'text', 'url');
$crud->setListingFields('id', 'donour_id', 'fundraiser_user_id', 'status', 'amount', 'added_on', 'updated_on', 'updated_by_user_id', 'city_name');
$crud->allow['delete'] = false;
$crud->allow['bulk_operations'] = false;
}
$crud->printAction();
} else {
?>
<h1>Donation Tracer</h1>
<form method="post" class="form-area">
<fieldset>
<legend>Donor Info</legend>
<label for="donor_name">Donor Name</label>
<input type="text" name="donor_name" id="donor_name" value="" class="form-control" /><br />
<label for="donor_phone">Donor Phone</label>
<input type="text" name="donor_phone" id="donor_phone" value="" class="form-control" /><br />
<label for="donor_email">Donor Email</label>
<input type="text" name="donor_email" id="donor_email" value="" class="form-control" /><br />
</fieldset>
<fieldset>
<legend>User Info</legend>
<label for="user_name">User Name</label>
<input type="text" name="user_name" id="user_name" value="" class="form-control" /><br />
<label for="user_phone">User Phone Number</label>
<input type="text" name="user_phone" id="user_phone" value="" class="form-control" /><br />
<label for="user_email">User Email</label>
<input type="text" name="user_email" id="user_email" value="" class="form-control" /><br />
<label for="user_id">User ID</label>
<input type="text" name="user_id" id="user_id" value="" class="form-control" /><br />
</fieldset>
<fieldset>
<legend>Donation Info</legend>
<label for="donation_id">Donation ID</label>
<input type="text" name="donation_id" id="donation_id" value="" class="form-control" /><br />
<label for="amount">Amount</label>
<input type="text" name="amount" id="amount" value="" class="form-control" /><br />
</fieldset>
<input type="submit" value="Search" name="action" class="btn btn-success" />
</form>
<?php
}
showEnd();