Feb 16
< ?php final class Table extends Connector { private $TableSQL; private $TableName; private $TableClass; private $TableData; private $TableTitles; private $TableModule; private $ShowPagination; private $PageNumber; protected $RowsByPage;function __construct( $SQL, $Name, $Class, $Titles, $Module, $Pagination = true, $Page = 1 ) { $this->TableSQL = $SQL; $this->TableName = $Name; $this->TableClass = $Class; $this->TableTitles = $Titles; $this->TableModule = $Module; $this->ShowPagination = $Pagination; $this->PageNumber = $Page; $this->RowsByPage = 15;if($this->Pages($SQL)>1) { $SQL = $SQL." LIMIT ".(($Page-1)*$this->RowsByPage)."," . $this->RowsByPage; }$this->TableData = $this->Query( $SQL, true, $Titles ); $this->getTable(); } private function getTable() { $Output = "<table name='".$this->TableName."' id='".$this->TableName."' class='".$this->TableClass."' cellpadding=0 cellspacing=0>"; if( $this->TableTitles ) { $Start = 1; $Output .= "<thead>"; $Output .= "<tr>"; for( $i=0; $i<count( $this->TableData[0] ); $i++ ) { $Output .= "<th>" . $this->TableData[0][$i] . "</th>"; } $Output .= "</tr>"; $Output .= "</thead>"; } else { $Start = 0; } $Output .= "<tbody>"; $Color = "#ffffff"; for( $i=$Start; $i<count( $this->TableData ); $i++ ) { if($Color == "#f1f1f1") { $Color = "#ffffff"; } else { $Color = "#f1f1f1"; } $Output .= "<tr bgcolor='".$Color."' onclick=Go('driver.php?Module=".$this->TableModule."&Method=Edit&RegisterID=".$this->TableData[$i][0]."') title='Clique para editar este registro...'>"; for( $j=0; $j<count( $this->TableData[$i] ); $j++ ) { $Output .= "<td>" . $this->TableData[$i][$j] . "</td>"; } $Output .= "</tr>"; } $Output .= "</tbody>"; $Output .= "</table>"; print( $Output ); if($this->ShowPagination) { $this->PageLinks(); } } private function PageLinks() { if($this->ShowPagination) { print("<div id='Barra'>"); print("<img src='Resources/Images/InGrid/page-first.png' class='Paginacao' onclick=Go('driver.php?Module=".$this->TableModule."&Method=View&Page=1');>"); if($this->PageNumber >= 1) { print("<img src='Resources/Images/InGrid/page-prev.png' class='Paginacao' onclick=Go('driver.php?Module=".$this->TableModule."&Method=View&Page=".($this->PageNumber-1)."');>"); } else { print("<img src='Resources/Images/InGrid/page-prev.png' class='Paginacao'>"); } if($this->Pages($this->TableSQL) > 0) { print("<img src='Resources/Images/InGrid/page-next.png' class='Paginacao' onclick=Go('driver.php?Module=".$this->TableModule."&Method=View&Page=".($this->PageNumber+1)."');>"); } else { print("<img src='Resources/Images/InGrid/page-next.png' class='Paginacao'>"); } print("<img src='Resources/Images/InGrid/page-last.png' class='Paginacao' onclick=Go('driver.php?Module=".$this->TableModule."&Method=View&Page=".$this->Pages($this->TableSQL)."');>"); print("</div>"); } } } ?>