C:\xampp\htdocs\kptv\admin\php\inc\db\recordstable.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php

class RecordsTable {
    var 
$width;
    var 
$titleClass;
    var 
$tableClass;
    var 
$fields;
    var 
$results;
    var 
$dbTableName;
    
    var 
$fFieldClass// first field class
    
var $nFieldClass// next field class

    
var $perPage 20;

    var 
$colWidths;
    var 
$classRowOver;    // color for on mouse over a row
    
    
var $exclude;

    var 
$deleteLink;
    var 
$onClickLink;
    var 
$addLink;
    
    var 
$clsTotalRecs "stTotalRecs";
    var 
$clsLinkNext "stLinkNext";
    
    var 
$tableName;
    
    var 
$fieldsP;
    var 
$valuesP;

    var 
$tableHeader;
    var 
$other;
    var 
$onClickVal "ID";
    var 
$duplicateLink false;


    function 
RecordsTable($fields$colWidths, &$results$dbTableName) {
        
$this->fields $fields;
        
$this->results $results;
        
$this->dbTableName $dbTableName;
        
$this->colWidths $colWidths;

        foreach(
$colWidths as $width)
            
$this->width+=$width;
    }
    
    function 
Generate() {
        
// on click link
//        " onclick = \"MM_goToURL('parent','" . $this->onClickLink . "&$onClickField=" . $onClickVal . "');\"";
        
        
$span 0;
        
$addLink_ "";
        if(
$this->addLink !="") {
            if(
strchr($this->addLink"js:")) { // javascript
                
$addLink_ $this->addLink;
                
$addLink_ str_replace("js:"""$addLink_);
            }
            else
                
$addLink_=" MM_goToURL('parent','" $this->addLink "');\"";
        }
        
        
$onClickLink "";
        
$out "";
        if(
$this->deleteLink != "") {
            
$out.="<form name=\"frmDelete\" method=\"post\" action=\"" $this->deleteLink ."\">";
            
$this->width+=100;
        }
        
$links_ 0;
        if(
$this->duplicateLink == true)
            
$duplicateLink_ "checkAddForm('$this->addLink')";
        else
            
$duplicateLink_ $addLink_//"MM_goToURL('parent','" . $this->addLink . "')";

        
if($this->deleteLink!=""$links_++;        
        if(
$addLink_!=""$links_++;
        
        if(
$links_ 0) {
            
$out.="<table width=\""$this->width "\" cellpadding=\"3\" cellspacing=\"3\" align = \"center\"><tr>";
            
$rem $this->width;
            if(
$this->addLink != "") {
                
$out.="<td class ='stTextButtonN' onMouseOver=\"javascript:this.className='stTextButtonO';\" onMouseOut=\"javascript:this.className ='stTextButtonN';\" width = '90' onclick = \"$duplicateLink_;\">Adauga</td>";
                
$rem-=90;
            }
            if(
$this->deleteLink != "") {
                
$out.="<td class ='stTextButtonN' onMouseOver=\"javascript:this.className='stTextButtonO';\" onMouseOut=\"javascript:this.className ='stTextButtonN';\" onClick=\"CheckDelFormAndSubmit()\" width = '90'>Sterge</td>";
                
$rem-=90;
            }
            
$out.="<td width=\"" $rem "\">&nbsp;</td></tr></table>";
        }

        
$out.= "<table width=\""$this->width "\" border=\"0\" bordercolor=\"#FFFFFF\" cellpadding=\"3\" cellspacing=\"0\" class=\"" $this->tableClass ."\" align = \"center\">";
                    
        
// title
        
$out.="\n\t<thead><tr>";
        
$span $count count($this->fields);
        for(
$i 0$i $count$i++) {
            
$out.="\t\t<th nowrap align = \"left\" height = \"25\" width=\"" $this->colWidths[$i] . "\" class = \"" $this->titleClass "\">" $this->tableHeader[$i] . "</th>";
        }
        if(
$this->deleteLink != "") {
            
$out.= "<th align = \"center\" width = \"20\"><img src=\"img/check.jpg\"></th>";
        }
        
$out.="\n\t</tr></thead><tbody>";
        
        
// pages        
        
$countPages count($this->results) / $this->perPage;
        
        
$hd "_hdPage_" $this->tableName;
        
        
$cPage 1;
        if(
array_key_exists($hd$_POST))
            
$cPage $_POST[$hd];
                
        
$i 1;        
        
$countRes count($this->results);
        
$st = ($cPage-1) * $this->perPage;        
            
        
$to $cPage $this->perPage;                
        if(
$to $countRes)
            
$to $countRes;
        
        
// echo "<pre>";
        // print_r($this->fields);
        // echo "<br /><hr />";
        
        // print_r($this->results);
        
        // records
        
for($p_ $st$p_ $to$p_++) {
            
$result $this->results[$p_];
            
            
$fclass_ $this->nFieldClass;
            if(
fmod($i++, 2) == 0)
                
$fclass_ $this->fFieldClass;
            
$out.="\n\t<tr class = \"" $fclass_ "\" style=\"height: 25\" onMouseOver=\"javascript:this.className='" $this->classRowOver "';\" onMouseOut=\"javascript:this.className ='" $fclass_ "'\"";
            
$out.=">";
            
            
// echo "<pre>";
            // print_r($this->fields);
            // echo "<br /><hr />";
            
            // print_r($result);
            
            
foreach($this->fields as $field) {
                
// echo $field."<br/>";
                
$out.= "\n\t\t<td";
                if(
$this->onClickLink !="") {
                    
$onClickField $this->onClickVal;
                    
$onClickVal $result->$onClickField;
                    if(
strchr($this->onClickLink"js:")) { // javascript
                        
$cl $this->onClickLink;
                        
$cl str_replace("js:"""$cl);
                        
$cl str_replace("ID"$onClickVal$cl);
                        
$out.=" onclick = \"$cl;\" ";
                    }
                    else 
                        
$out.=" onclick = \"MM_goToURL('parent','" $this->onClickLink "&$onClickField=" $onClickVal "');\"";
                }
                
$out.=">";
                
$out.=$result->$field;
                
$out.="</td>";
            }
            if(
$this->deleteLink != "")
                
$out.="\n\t\t<td><div align=\"center\"><input type=\"checkbox\" name=\"item[]\" value=\"" $result->$onClickField "\" /></div></td>";
            
$out.="</tr></tbody>";
        }
        
// results
        
$out.="<tr><td " . (($span)?"colspan = $span":"") . " align=\"center\" class = \"clsTotalRecs\">";
        
$out.="Numarul de inregistrari:" .  count($this->results);
        
$out.="</td></tr>";
        
        
        if(
$this->deleteLink != "") {
            
$out.="<input name=\"hdt\" type=\"hidden\" value=\"" $this->dbTableName "\" />";
            
$out.=$this->other;
            
$out.="\n</form>";
        }
                        
        if(
$this->tableName != "") {        
            
$out.="<tr><td " . (($span)?"colspan = $span":"") . " align=\"center\" class = \"clsTotalRecs\">";        
            
$out.="<form name=\"" $this->tableName "\" id=\"" $this->tableName "\" action=\"" .$_SERVER['REQUEST_URI'] . "\" method=\"post\">";
            
$out.="<input type=\"hidden\" id=\"$hd\" name=\"$hd\" value = \"\">";        
            
$out.="Pagina curenta: $cPage" Pagini: ";
                
            for(
$p 0$p $countPages$p++) {
                
$out.="<span class=\"clsLinkNext\" onclick=\"changePage(" . ($p+1) . ",'" $this->tableName "')\">" . ($p+1) . "</span>&nbsp;";
            }
            
            
$cnt count($this->fieldsP);
            for(
$i 0$i $cnt$i++) {
                
$out.="<input type=\"hidden\" id=\"" $this->fieldsP[$i] . "\" name=\""$this->fieldsP[$i] . "\" value = \""$this->valuesP[$i] ."\">";        
            }
            
            
$out.="</form>";        
            
$out.="</td></tr>";
        }
        
//
        
$out.="\n</table>";

        return 
$out;
    }

}

?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586