private static function step2($page, $start, $rowsPerPage, $outData) { $excel = f::getParam("excel") == 1; $order = f::getParam("order") * 1; $orderDesc = f::getParam("orderDesc") * 1; $orderBy = $order == "" ? "" : " ORDER BY {$order}"; $clientId = f::dbRes("select client_id from fm_forms where id = {p:form_id}"); $siteTableId = "fm_userdata_" . substr("00" . $clientId, -3); $limit = $excel ? "" : " limit {$start}, {$rowsPerPage}"; $textFilter = ""; if (f::getParam("textFilter")) { $textFilter = " and user_data like '%" . f::dbEscape(f::getParam("textFilter")) . "%'"; } $sql = "select SQL_CALC_FOUND_ROWS id, date_format(created_date,'%d/%m/%Y %H:%i') as created_date, user_data \n\t\t\t\t\t\tfrom {d:siteTableId}\n\t\t\t\t\t\twhere form_id = {p:form_id} \n\t\t\t\t\t\t{n:textFilter}\n\t\t\t\t\t\torder by id desc {d:orderBy} {d:limit}"; $formData = f::dbFullRes($sql, array("siteTableId" => $siteTableId, "textFilter" => $textFilter, "orderBy" => $orderBy, "limit" => $limit)); foreach ($formData as $k => $v) { $formData[$k]["user_data"] = json_decode($formData[$k]["user_data"], true); } $totalRows = f::dbRes("SELECT FOUND_ROWS()"); if ($totalRows <= $page * $rowsPerPage) { $outData["nextPage"] = 0; } $form = f::dbFirstRow("select id, name, enabled_domains, detail \n\t\t\t\tfrom fm_forms \n\t\t\t\twhere id = {p:form_id}"); $form["detail"] = json_decode($form["detail"], true); $outData["form"] = $form; $outData["data"] = $formData; $outData["totalRows"] = $totalRows; $outData["order"] = $order; $outData["orderDesc"] = $orderDesc; $outData["end"] = min($outData["start"] + $rowsPerPage, $totalRows); if (!$excel) { f::setResponseJson($outData); } else { $out = self::prepareExcel($form, $formData); $formName = preg_replace("/[^A-Za-z0-9 ]/", '', $form["name"]); f::setExcelOutput($form["id"] . "_{$formName}_" . date("Ymd_His") . ".xls", $out); } }