Exemplo n.º 1
0
function selectDocItems()
{
    $where = "DocID=:did";
    $whereParam = array(":did" => $_REQUEST["DocID"]);
    if (isset($_GET["fields"]) && !empty($_GET["query"])) {
        switch ($_GET["fields"]) {
            case "TafsiliID":
                $where .= " AND t.tafsiliDesc like :tl";
                $whereParam[":tl"] = "%" . $_GET["query"] . "%";
                break;
            case "moinID":
                $where .= " AND moinTitle like :tl";
                $whereParam[":tl"] = "%" . $_GET["query"] . "%";
                break;
            case "TafsiliID2":
                $where .= " AND t2.tafsiliDesc like :tl";
                $whereParam[":tl"] = "%" . $_GET["query"] . "%";
                break;
            case "kolID":
                $where .= " AND kolTitle like :tl";
                $whereParam[":tl"] = "%" . $_GET["query"] . "%";
                break;
            case "DebtorAmount":
                $where .= " AND DebtorAmount = :tl";
                $whereParam[":tl"] = $_GET["query"];
                break;
            case "CreditorAmount":
                $where .= " AND CreditorAmount = :tl";
                $whereParam[":tl"] = $_GET["query"];
                break;
            case "CostDesc":
                $where .= " AND (cc.CostCode like :cd or concat_ws('-',b1.blockDesc,b2.BlockDesc,b3.BlockDesc) like :cd)";
                $whereParam[":cd"] = "%" . $_GET["query"] . "%";
                break;
        }
    }
    $where .= dataReader::makeOrder();
    $temp = ACC_DocItems::GetAll($where, $whereParam);
    //print_r(ExceptionHandler::PopAllExceptions());
    $no = $temp->rowCount();
    $temp = PdoDataAccess::fetchAll($temp, $_GET["start"], $_GET["limit"]);
    //..........................................................................
    $dt = PdoDataAccess::runquery("\n\t\tselect sum(DebtorAmount) bd,sum(CreditorAmount) bs\n\t\tfrom ACC_DocItems\n\t\twhere DocID=? \n\t\tgroup by DocID", array($_REQUEST["DocID"]));
    $bdSum = count($dt) != 0 ? $dt[0]["bd"] : 0;
    $bsSum = count($dt) != 0 ? $dt[0]["bs"] : 0;
    //..........................................................................
    echo dataReader::getJsonData($temp, $no, $_GET["callback"], $bdSum . "," . $bsSum);
    die;
}