-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_list_proc.php
128 lines (115 loc) · 4.37 KB
/
bank_list_proc.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
<?php
$accessBank = '';
if( $bankAuth == false )
$accessBank = "No Access";
$smarty->assign("accessBank",$accessBank);
error_reporting(E_ALL & ~E_NOTICE);
if ($_GET['mode'] == 'delete')
{
DeleteBank($_GET['bank_id']);
header("Location:bank_list.php?page=1&sort=all");
}
/***********************************************************/
/**
* *********************************
* Get Sort And Page From the URL
* *********************************
**/
if(isset($_GET['page'])) {
$Page = $_GET['page'];
} else {
$Page = 1;
}
$RowsPerPage = DEF_PAGE_SIZE;
$PageNum = 1;
if(isset($_GET['page'])) {
$PageNum = $_GET['page'];
}
$Offset = ($PageNum - 1) * $RowsPerPage;
/**
* *************************
* Create Sort For Pagging
* *************************
**/
$Self = $_SERVER['PHP_SELF'];
$NumberOnly = '[0-9]';
$Sorting .= "<a href=\"$Self?page=1&sort=1\">" . $NumberOnly . "</a>";
$LetterLinks = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
for ($i = 0; $i < count($LetterLinks); $i++) {
$Sorting .= " ";
$Sorting .= "<a href=\"$Self?page=1&sort=".$LetterLinks[$i]."\">".$LetterLinks[$i]."</a>";
}
$Sorting .= " ";
$Sorting .= "<a href=\"$Self?page=1&sort=all\">View All</a>";
/**
* *******************
* Query For Pagging
* *******************
**/
$projecttower = array();
if ($_GET['sort'] == "1") {
$QueryMember = "SELECT A.BANK_ID,A.BANK_NAME,A.BANK_LOGO,A.BANK_DETAIL,A.SERVICE_IMAGE_ID FROM ".BANK_LIST." AS A WHERE BANK_NAME BETWEEN '0' AND '9' ORDER BY A.BANK_ID DESC";
} else if ($_GET['sort'] == "all") {
$QueryMember = "SELECT A.BANK_ID,A.BANK_NAME,A.BANK_LOGO,A.BANK_DETAIL,A.SERVICE_IMAGE_ID FROM ".BANK_LIST." AS A WHERE 1 ORDER BY A.BANK_NAME DESC";
} else {
$QueryMember = "SELECT A.BANK_ID,A.BANK_NAME,A.BANK_LOGO,A.BANK_DETAIL,A.SERVICE_IMAGE_ID FROM ".BANK_LIST." AS A WHERE left(BANK_NAME,1)='".$_GET['sort']."' ORDER BY A.BANK_ID DESC";
}
$QueryExecute = mysql_query($QueryMember) or die(mysql_error());
$NumRows = mysql_num_rows($QueryExecute);
$smarty->assign("NumRows",$NumRows);
/**
* *********************************
* Create Next and Previous Button
* *********************************
**/
$PagingQuery = "LIMIT $Offset, $RowsPerPage";
$QueryExecute_1 = mysql_query($QueryMember." ".$PagingQuery) ;
while ($dataArr2 = mysql_fetch_array($QueryExecute_1))
{
array_push($projecttower, $dataArr2);
}
//Read image from image service
$objectType = "bank";
$img_path = array();
$img_alt = array();
foreach ($projecttower as $k => $v) {
$objectId = $v['BANK_ID'];
$service_image_id = $v['SERVICE_IMAGE_ID'];
//$url = readFromImageService($objectType, $objectId);
$url = ImageServiceUpload::$image_upload_url."?objectType=$objectType&objectId=".$objectId;
$content = file_get_contents($url);
$imgPath = json_decode($content);
$data = array();
foreach($imgPath->data as $k1=>$v1){
$data[$k1]['SERVICE_IMAGE_PATH'] = $v1->absolutePath;
$data[$k1]['alt_text'] = $v1->altText;
}
$img_path[$k] = $data[0]['SERVICE_IMAGE_PATH'];
$img_alt[$k] = $data[0]['alt_text'];
}
$smarty->assign("projecttower", $projecttower);
$smarty->assign("image_path", $img_path);
$smarty->assign("image_alt", $img_alt);
$MaxPage = (ceil($NumRows/$RowsPerPage))?ceil($NumRows/$RowsPerPage):'1' ;
$Num = $_GET['num'];
$Sort = $_GET['sort'];
if ($PageNum > 1) {
$Page = $PageNum - 1;
$Prev = " <a href=\"$Self?page=$Page&sort=$Sort\">[Prev]</a> ";
$First = " <a href=\"$Self?page=1&sort=$Sort\">[First Page]</a> ";
} else {
$Prev = ' [Prev] ';
$First = ' [First Page] ';
}
if ($PageNum < $MaxPage) {
$Page = $PageNum + 1;
$Next = " <a href=\"$Self?page=$Page&sort=$Sort\">[Next]</a> ";
$Last = " <a href=\"$Self?page=$MaxPage&sort=$Sort\">[Last Page]</a> ";
} else {
$Next = ' [Next] ';
$Last = ' [Last Page] ';
}
$Pagginnation = "<DIV align=\"left\"><font style=\"font-size:11px; color:#000000;\">" . $First . $Prev . " Showing page <strong>$PageNum</strong> of <strong>$MaxPage</strong> pages " . $Next . $Last . "</font></DIV>";
$smarty->assign("Pagginnation", $Pagginnation);
$smarty->assign("Sorting", $Sorting);
?>