public function test_pDate() { $actual = _pDate('2015-11-12'); //$this->assertEquals($actual,'12/11/2015'); $this->assertEquals(true, true); }
function loadForm() { $dataPost = $_POST; if (isset($dataPost["frmID"])) { $sForm = $dataPost["frmID"]; unset($dataPost["frmID"]); } else { $sForm = null; } $sTable = ""; $sWhere = ""; $sCols = ""; $sql = ""; if ($sForm != null && strlen($sForm) > 0) { $tbl = _dbtable("forms"); $sql = "SELECT submit_table,submit_wherecol,datatable_cols FROM {$tbl} WHERE id={$sForm} AND blocked='false'"; $res1 = _dbQuery($sql); if ($res1 && _db()->recordCount($res1) > 0) { $data = _db()->fetchData($res1); $sTable = $data["submit_table"]; $sWhere = $data["submit_wherecol"]; $sCols = $data["datatable_cols"]; } } elseif (isset($dataPost["submit_table"]) && isset($dataPost["submit_wherecol"])) { $sTable = $dataPost["submit_table"]; $sWhere = $dataPost["submit_wherecol"]; if (isset($dataPost["frmCols"])) { $sCols = $dataPost["frmCols"]; unset($dataPost["frmCols"]); } unset($dataPost["submit_table"]); unset($dataPost["submit_wherecol"]); } elseif (isset($dataPost["table"]) && isset($dataPost["wherecols"])) { $sTable = $dataPost["table"]; $sWhere = $dataPost["wherecols"]; if (isset($dataPost["cols"])) { $sCols = $dataPost["cols"]; unset($dataPost["cols"]); } unset($dataPost["table"]); unset($dataPost["wherecols"]); } $sWhere = explode(",", $sWhere); $arr = array(); foreach ($sWhere as $a => $b) { if (isset($dataPost[$b])) { $arr[$b] = $dataPost[$b]; } } $sWhere = $arr; $sWhere = generateWhere($sWhere); $tblCols = _db()->getTableInfo($sTable); $arrCols = array(); foreach ($tblCols[0] as $a => $b) { $arrCols[$b] = $tblCols[1][$a]; } $tblCols = $arrCols; if ($sCols == null && strlen(trim($sCols)) <= 0) { $sCols = array(); foreach ($dataPost as $a => $b) { if (array_key_exists($a, $tblCols)) { array_push($sCols, $a); } } $sCols = implode(",", $sCols); } else { $tempCols = explode(",", $sCols); $sCols = array(); foreach ($tempCols as $a) { if (array_key_exists($a, $tblCols)) { array_push($sCols, $a); } } $sCols = implode(",", $sCols); } if (strlen($sCols) <= 0) { exit(""); } $sql = "SELECT {$sCols} FROM {$sTable}"; if (strlen($sWhere) > 0) { $sql .= " WHERE {$sWhere}"; } $res1 = _dbQuery($sql); if ($res1 && _db()->recordCount($res1) > 0) { $data = _db()->fetchData($res1); foreach ($data as $a => $b) { if ($b == null || $b == "null") { $data[$a] = ""; } elseif ($tblCols[$a] == "date") { $data[$a] = _pDate($b); } elseif ($tblCols[$a] == "datetime") { $b = explode(" ", $b); $data[$a] = _pDate($b[0]) . " {$b[1]}"; } } if (!isset($_REQUEST["format"])) { $_REQUEST["format"] = "json"; } //printFormattedArray($data); printServiceMsg($data); } }