예제 #1
0
function Equalization_UpdateChecks()
{
    $BankID = $_POST["BankID"];
    $result = "";
    require_once "phpExcelReader.php";
    $data = new Spreadsheet_Excel_Reader();
    $data->setOutputEncoding('utf-8');
    $data->setRowColOffset(0);
    $data->read($_FILES["attach"]["tmp_name"]);
    $pdo = PdoDataAccess::getPdoObject();
    $pdo->beginTransaction();
    //--------------- add to equalizations -------------
    $EqualObj = new ACC_equalizations();
    $EqualObj->RegDate = PDONOW;
    $EqualObj->BankID = $BankID;
    $EqualObj->ImportFile = fread(fopen($_FILES["attach"]["tmp_name"], 'r'), $_FILES["attach"]["size"]);
    $EqualObj->Add($pdo);
    //----------- insert DocHeader --------------------
    $obj = new ACC_docs();
    $obj->RegDate = PDONOW;
    $obj->regPersonID = $_SESSION['USER']["PersonID"];
    $obj->DocDate = PDONOW;
    $obj->CycleID = $_SESSION["accounting"]["CycleID"];
    $obj->BranchID = $_SESSION["accounting"]["BranchID"];
    $obj->DocType = DOCTYPE_EQUALCHECKS;
    $obj->description = "مغایرت گیری بانکی / به روز رسانی چک ها ";
    if (!$obj->Add($pdo)) {
        ExceptionHandler::PushException("خطا در ایجاد سند");
        return false;
    }
    $successCount = 0;
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        $checkNo = "";
        switch ($BankID) {
            case "4":
                // اقتصاد نوین
                $TafsiliID = "";
                $TafsiliID2 = "";
                if (empty($data->sheets[0]['cells'][$i][1])) {
                    continue;
                }
                $cellData = $data->sheets[0]['cells'][$i][1];
                if (isset($cellData) && strpos(trim($cellData), "چک عادي ش.") !== false) {
                    $arr = preg_split("/\\//", $cellData);
                    $checkNo = $arr[2];
                    $checkNo = substr($checkNo, 0, strpos($checkNo, "صندوق پژوهش"));
                }
                break;
        }
        if ($checkNo == "") {
            continue;
        }
        //---------------- add doc items --------------------
        $dt = PdoDataAccess::runquery("\r\n\t\t\tSELECT * FROM ACC_IncomeCheques \r\n\t\t\t\twhere ChequeNo=? AND ChequeStatus<>" . INCOMECHEQUE_VOSUL, array($checkNo), $pdo);
        if (count($dt) > 0) {
            $inChequeObj = new ACC_IncomeCheques($dt[0]["IncomeChequeID"]);
            $inChequeObj->EqualizationID = $EqualObj->EqualizationID;
            $inChequeObj->ChequeStatus = INCOMECHEQUE_VOSUL;
            $inChequeObj->Edit($pdo);
            $temp = $inChequeObj->GetBackPays($pdo);
            foreach ($temp as $row) {
                $BackPayObj = new LON_BackPays($row["BackPayID"]);
                $BackPayObj->EqualizationID = $EqualObj->EqualizationID;
                $BackPayObj->Edit($pdo);
            }
            ACC_IncomeCheques::AddToHistory($inChequeObj->IncomeChequeID, $inChequeObj->ChequeStatus, $pdo);
            RegisterOuterCheque($obj->DocID, $inChequeObj, $pdo, COSTID_Bank, $TafsiliID, $TafsiliID2);
            $successCount++;
            $result .= "شماره چک : " . $checkNo . " به روز رسانی شد <br>";
        } else {
            $result .= "<font color=red> شماره چک : " . $checkNo . " یافت نشد </font><br>";
        }
    }
    if ($successCount == 0) {
        $pdo->rollBack();
    } else {
        $pdo->commit();
    }
    echo Response::createObjectiveResponse(true, $successCount == 0 ? "هیچ چکی به روز نگردید" : $result);
    die;
}
예제 #2
0
function SaveLoanCheque()
{
    $pdo = PdoDataAccess::getPdoObject();
    $pdo->beginTransaction();
    $DocID = "";
    $cheques = json_decode($_POST["cheques"]);
    foreach ($cheques as $cheque) {
        $obj = new ACC_IncomeCheques();
        PdoDataAccess::FillObjectByJsonData($obj, $cheque);
        $obj->ChequeStatus = INCOMECHEQUE_NOTVOSUL;
        if (!$obj->Add($pdo)) {
            echo Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString());
            die;
        }
        //................. add back pays ........................
        $bobj = new LON_BackPays();
        $bobj->PayDate = $obj->ChequeDate;
        $bobj->IncomeChequeID = $obj->IncomeChequeID;
        $bobj->RequestID = $_POST["RequestID"];
        $bobj->PayAmount = $obj->ChequeAmount;
        $bobj->PayType = BACKPAY_PAYTYPE_CHEQUE;
        $bobj->Add($pdo);
        //.......................................................
        ACC_IncomeCheques::AddToHistory($obj->IncomeChequeID, $obj->ChequeStatus, $pdo);
        //--------------------------------------------
        $DocID = RegisterOuterCheque($DocID, $obj, $pdo);
        if (!$DocID) {
            print_r(ExceptionHandler::PopAllExceptions());
            echo Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString());
            die;
        }
    }
    $pdo->commit();
    echo Response::createObjectiveResponse(true, "");
    die;
}