public static function getAll() { global $lC_Database, $lC_Language, $_module; $result = array('entries' => array()); $result = array('aaData' => array()); $media = $_GET['media']; /* Total Records */ $QresultTotal = $lC_Database->query('select count(*) as total from :table_countries'); $QresultTotal->bindTable(':table_countries', TABLE_COUNTRIES); $QresultTotal->execute(); $result['iTotalRecords'] = $QresultTotal->valueInt('total'); $QresultTotal->freeResult(); /* Paging */ $sLimit = " LIMIT 0,25 "; if (isset($_GET['iDisplayStart'])) { if ($_GET['iDisplayLength'] != -1) { $sLimit = " LIMIT " . $_GET['iDisplayStart'] . ", " . $_GET['iDisplayLength']; } } /* Ordering */ if (isset($_GET['iSortCol_0'])) { $sOrder = " ORDER BY "; for ($i = 0; $i < (int) $_GET['iSortingCols']; $i++) { $sOrder .= lC_Countries_Admin::fnColumnToField($_GET['iSortCol_' . $i]) . " " . $_GET['sSortDir_' . $i] . ", "; } $sOrder = substr_replace($sOrder, "", -2); } /* Filtering */ $sWhere = ""; if ($_GET['sSearch'] != "") { $sWhere = " WHERE countries_name LIKE '%" . $_GET['sSearch'] . "%' OR " . "countries_iso_code_2 LIKE '%" . $_GET['sSearch'] . "%' OR " . "countries_iso_code_3 LIKE '%" . $_GET['sSearch'] . "%' "; } /* Total Filtered Records */ $QresultFilterTotal = $lC_Database->query('select count(*) as total from :table_countries' . $sWhere . $sOrder); $QresultFilterTotal->bindTable(':table_countries', TABLE_COUNTRIES); $QresultFilterTotal->execute(); $result['iTotalDisplayRecords'] = $QresultFilterTotal->valueInt('total'); $QresultFilterTotal->freeResult(); /* Main Listing Query */ $Qcountries = $lC_Database->query('select * from :table_countries' . $sWhere . $sOrder . $sLimit); $Qcountries->bindTable(':table_countries', TABLE_COUNTRIES); $Qcountries->execute(); while ($Qcountries->next()) { $Qzones = $lC_Database->query('select count(*) as total_zones from :table_zones where zone_country_id = :zone_country_id'); $Qzones->bindTable(':table_zones', TABLE_ZONES); $Qzones->bindInt(':zone_country_id', $Qcountries->valueInt('countries_id')); $Qzones->execute(); $check = '<td><input class="batch" type="checkbox" name="batch[]" value="' . $Qcountries->valueInt('countries_id') . '" id="' . $Qcountries->valueInt('countries_id') . '"></td>'; $name = '<td><a href="' . lc_href_link_admin(FILENAME_DEFAULT, 'countries=' . $Qcountries->valueInt('countries_id')) . '"><span class="icon-folder icon-orange"></span> ' . $Qcountries->valueProtected('countries_name') . '</a></td>'; $code = '<td> <table width="100%" border="0"> <tr> <td>' . lc_image('../images/worldflags/' . strtolower($Qcountries->value('countries_iso_code_2')) . '.png', $Qcountries->value('countries_iso_code_3')) . '</td> <td align="center" width="50%">' . $Qcountries->value('countries_iso_code_2') . '</td> <td align="center" width="50%">' . $Qcountries->value('countries_iso_code_3') . '</td> </tr> </table> </td>'; $total = '<td>' . $Qzones->valueInt('total_zones') . '</td>'; $action = '<td class="align-right vertical-center"><span class="button-group compact" style="white-space:nowrap;"> <a href="' . ((int) ($_SESSION['admin']['access']['locale'] < 3) ? '#' : 'javascript://" onclick="editCountry(\'' . $Qcountries->valueInt('countries_id') . '\')') . '" class="button icon-pencil' . ((int) ($_SESSION['admin']['access']['locale'] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_edit')) . '</a> <a href="' . ((int) ($_SESSION['admin']['access']['locale'] < 4) ? '#' : 'javascript://" onclick="deleteCountry(\'' . $Qcountries->valueInt('countries_id') . '\', \'' . urlencode($Qcountries->valueProtected('countries_name')) . '\')') . '" class="button icon-trash with-tooltip' . ((int) ($_SESSION['admin']['access']['locale'] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a> </span></td>'; $result['aaData'][] = array("{$check}", "{$name}", "{$code}", "{$total}", "{$action}"); $result['entries'][] = array_merge($Qcountries->toArray(), $Qzones->toArray()); } $result['sEcho'] = intval($_GET['sEcho']); if ($Qcountries->numberOfRows() > 0) { $Qzones->freeResult(); } $Qcountries->freeResult(); return $result; }