/var/www/hkosl.com/dirsignage_old/html/search_result.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
    
include_once("webadmin/configure.php");

    
$search_word $_REQUEST["search_word"];
    
$action $_REQUEST["action"];

    
$search_result "";

    if (!empty(
$search_word) && !empty($action)) {
        if (
$action == 4) { //company info
            
$sql "select * from company where id = ? and status = ? and deleted = ?";
            
$parameters = array((int)$search_word"1""0");

            if (!(
$sth $dbh->prepare($sql))) {
                throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
            }

            if (!
$sth->execute($parameters)) {
                throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
            }

            
$company_info $sth->fetch(PDO::FETCH_ASSOC);


            
ob_start();
            
?>
            <div style="width: 25%; float: left;">
                <?php if(!empty($company_info{"logo"})){ ?>
                    <img src="images/company_logo/<?=$company_info{"logo"}?>" style="width: 100%;"/>
                <?php } else { echo "&nbsp;"; } ?>

            </div>

            <div style="width: 75%; float: left;">
                <table style="margin-left: 20px;">
                    <tr>
                        <td style="width: 175px;"><?php if($_SESSION["langcode"] == 'en') echo 'Co.Name';  else echo '公司名稱'?> : </td>
                        <td>
                            <?=$company_info{"companyname_en"}?><br><br>
                            <?=$company_info{"companyname_tc"}?>
                        </td>
                    </tr>

                    <tr>
                        <td><?php if($_SESSION["langcode"] == 'en') echo 'Room';  else echo '單位'?> : </td>
                        <td>
                            <?=$company_info{"room_no"}?>
                        </td>
                    </tr>

                    <tr>
                        <td><?php if($_SESSION["langcode"] == 'en') echo 'Tel';  else echo '電話號碼'?> : </td>
                        <td>
                            <?=$company_info{"telephone"}?>
                        </td>
                    </tr>

                    <tr>
                        <td><?php if($_SESSION["langcode"] == 'en') echo 'Fax';  else echo '傳真號碼'?> : </td>
                        <td>
                            <?=$company_info{"fax"}?>
                        </td>
                    </tr>

                    <tr>
                        <td><?php if($_SESSION["langcode"] == 'en') echo 'Email';  else echo '電郵地址'?> : </td>
                        <td>
                            <?=$company_info{"email"}?>
                        </td>
                    </tr>

                    <tr>
                        <td><?php if($_SESSION["langcode"] == 'en') echo 'Website';  else echo '網頁'?> : </td>
                        <td>
                            <?=$company_info{"website"}?>
                        </td>
                    </tr>

                    <tr>
                        <td><?php if($_SESSION["langcode"] == 'en') echo 'Address';  else echo '地址'?> : </td>
                        <td style="word-wrap: break-word;">
                            <?=$company_info{"companyaddress_en"}?><br><br>
                            <?=$company_info{"companyaddress_tc"}?>
                        </td>
                    </tr>
                </table>

            </div>
<?php
            $search_result 
ob_get_contents();

            
ob_end_clean();

        } else if (
$action == 3) {
            
$sql               "select * from company where status = ? and deleted = ? ";
            
$parameters        = array("1""0");
            
$all_disable_floor explode(","$disable_floor);
            foreach (
$all_disable_floor as $this_disable_floor) {
                
$sql .= " and floor != ?";
                
$parameters[] = $this_disable_floor;
            }
            
$sql .= " order by companyname_en ASC";

            
//var_dump($sql);

        
} else if ($action == 2) {
            
$sql "select * from company where floor = ? and status = ? and deleted = ? order by floor ASC, companyname_en ASC";

            
$parameters = array($search_word"1""0");
        } else {
            
$sql "select * from company where (floor like ? || companyname_en like ? || companyname_tc like ?) and ( status = ? and deleted = ?) order by floor ASC, companyname_en ASC";

            
$parameters = array("%" $search_word "%""%" $search_word "%""%" $search_word "%""1""0");
        }


        if(
$action != 4){
            if (!(
$sth $dbh->prepare($sql))) {
                throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
            }

            if (!
$sth->execute($parameters)) {
                throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
            }


            
$i 1;
            while (
$company_info $sth->fetch(PDO::FETCH_ASSOC)) {
                if (
$i == 1) {
                    
$search_result .= '<ul class="result_list letter_option" style="font-size: 33px;">';
                }

                
$company_name $company_info{"companyname_" $_SESSION["langcode"]};

                if(
$_SESSION["langcode"] == "en"){
                    if(empty(
$company_name)){
                        
$company_name $company_info{"companyname_tc"};
                    }

                }else{
                    if(empty(
$company_name)){
                        
$company_name $company_info{"companyname_en"};
                    }
                }



                
$search_result .= '<li class="rl_item" onclick="search_result('.$company_info{"id"}.',4)">

                            <div style="width: 90%; float: left;">
                                ' 
$company_name '
                            </div>

                            <div style=" width: 2%;float: right;">
                                &raquo;&nbsp;
                            </div>

                    </li>'
;

                
$i++;
            }

            if (
$i 1) {
                
$search_result .= '</ul>';
            }
        }

    }

    echo 
$search_result;
?>