Esempio n. 1
0
function GroupSavePay()
{
    $pdo = PdoDataAccess::getPdoObject();
    $pdo->beginTransaction();
    $parts = json_decode($_POST["parts"]);
    $FirstPay = true;
    $DocObj = null;
    $sumAmount = 0;
    foreach ($parts as $partStr) {
        $arr = preg_split("/_/", $partStr);
        $RequestID = $arr[0];
        $PayAmount = $arr[1];
        $obj = new LON_BackPays();
        PdoDataAccess::FillObjectByArray($obj, $_POST);
        $obj->RequestID = $RequestID;
        $obj->PayAmount = $PayAmount;
        $obj->IsGroup = "YES";
        if ($obj->PayType == "9") {
            $obj->ChequeStatus = 3;
        }
        $obj->Add($pdo);
        $ReqObj = new LON_requests($RequestID);
        $PersonObj = new BSC_persons($ReqObj->ReqPersonID);
        if ($PersonObj->IsSupporter == "YES") {
            $result = RegisterSHRTFUNDCustomerPayDoc($DocObj, $obj, $_POST["CostID"], $_POST["TafsiliID"], $_POST["TafsiliID2"], isset($_POST["CenterAccount"]) ? true : false, $_POST["BranchID"], $_POST["FirstCostID"], $_POST["SecondCostID"], $pdo, true);
        } else {
            $result = RegisterCustomerPayDoc($DocObj, $obj, $_POST["CostID"], $_POST["TafsiliID"], $_POST["TafsiliID2"], isset($_POST["CenterAccount"]) ? true : false, $_POST["BranchID"], $_POST["FirstCostID"], $_POST["SecondCostID"], $pdo, true);
        }
        if (!$result) {
            $pdo->rollback();
            print_r(ExceptionHandler::PopAllExceptions());
            echo Response::createObjectiveResponse(false, "خطا در صدور سند حسابداری");
            die;
        }
        if ($FirstPay) {
            $DocID = LON_BackPays::GetAccDoc($obj->BackPayID, $pdo);
            $DocObj = new ACC_docs($DocID, $pdo);
            $FirstPay = false;
        }
        $sumAmount += $PayAmount * 1;
    }
    if ($_POST["PayType"] == "9") {
        $obj = new LON_BackPays();
        PdoDataAccess::FillObjectByArray($obj, $_POST);
        $obj->ChequeStatus = "1";
        $obj->PayAmount = $sumAmount;
        $result = RegisterOuterCheque($DocID, $obj, $pdo);
        $obj->ChequeStatus = "3";
        $result = RegisterOuterCheque($DocID, $obj, $pdo);
    }
    $pdo->commit();
    echo Response::createObjectiveResponse(true, "");
    die;
}
Esempio n. 2
0
     $TafsiliID2 = 1;
     // jari
     $CenterAccount = false;
     $BranchID = "";
     $FirstCostID = "";
     $SecondCostID = "";
     $ReqObj = new LON_requests($obj->RequestID);
     if ($ReqObj->BranchID != "3") {
         $CenterAccount = true;
         $BranchID = "3";
         $FirstCostID = 205;
         $SecondCostID = 17;
     }
     $PersonObj = new BSC_persons($ReqObj->ReqPersonID);
     if ($PersonObj->IsSupporter == "YES") {
         $res = RegisterSHRTFUNDCustomerPayDoc(null, $obj, $CostID, $TafsiliID, $TafsiliID2, $CenterAccount, $BranchID, $FirstCostID, $SecondCostID, $pdo);
     } else {
         $res = RegisterCustomerPayDoc(null, $obj, $CostID, $TafsiliID, $TafsiliID2, $CenterAccount, $BranchID, $FirstCostID, $SecondCostID, $pdo);
     }
     if (!$res) {
         $error = true;
     }
 }
 if ($error) {
     $pdo->rollBack();
     $result = "<br> عملیات پرداخت قسط در نرم افزار صندوق به درستی ثبت نگردید. " . "<br> وجه کسر شده حداکثر تا 72 ساعت به حساب شما برگشت خواهد شد.";
 } else {
     $pdo->commit();
     $payment = new Payment();
     $login = $payment->login(username, password);
     $login = $login['return'];
Esempio n. 3
0
function RegisterOuterCheque($DocID, $InChequeObj, $pdo, $CostID = "", $TafsiliID = "", $TafsiliID2 = "", $CenterAccount = "", $BranchID = "", $FirstCostID = "", $SecondCostID = "")
{
    /*@var $InChequeObj ACC_IncomeCheques */
    $CycleID = substr(DateModules::shNow(), 0, 4);
    //------------- get CostCodes --------------------
    $CostCode_guaranteeAmount_daryafti = FindCostID("904-04");
    $CostCode_guaranteeAmount2_daryafti = FindCostID("905-04");
    //-------------------- BranchID -----------------------
    $BackPays = $InChequeObj->GetBackPays($pdo);
    if (count($BackPays) > 0) {
        $FirstBranchID = $BackPays[0]["BranchID"];
    } else {
        $FirstBranchID = $_SESSION["accounting"]["BranchID"];
    }
    //---------------- add doc header --------------------
    if ($DocID == "") {
        $obj = new ACC_docs();
        $obj->RegDate = PDONOW;
        $obj->regPersonID = $_SESSION['USER']["PersonID"];
        $obj->DocDate = PDONOW;
        $obj->CycleID = $CycleID;
        $obj->BranchID = $FirstBranchID;
        $obj->DocType = DOCTYPE_INCOMERCHEQUE;
        $obj->description = "چک شماره " . $InChequeObj->ChequeNo;
        if (!$obj->Add($pdo)) {
            ExceptionHandler::PushException("خطا در ایجاد سند");
            return false;
        }
    } else {
        $obj = new ACC_docs($DocID, $pdo);
    }
    //----------------- add Doc items ------------------------
    $__ChequeAmount = $InChequeObj->ChequeAmount;
    $__ChequeID = $InChequeObj->IncomeChequeID;
    $__TafsiliID = $InChequeObj->TafsiliID;
    if ($__TafsiliID == "") {
        $dt = $InChequeObj->GetBackPays();
        if (count($dt) == 1) {
            $__TafsiliID = $dt[0]["TafsiliID"];
        }
    }
    $__SourceType = DOCTYPE_INCOMERCHEQUE;
    $itemObj = new ACC_DocItems();
    $itemObj->DocID = $obj->DocID;
    $itemObj->locked = "YES";
    $itemObj->TafsiliType = TAFTYPE_PERSONS;
    $itemObj->TafsiliID = $__TafsiliID;
    $itemObj->TafsiliType2 = TAFTYPE_ChequeStatus;
    $itemObj->TafsiliID2 = $InChequeObj->ChequeStatus;
    $itemObj->SourceType = $__SourceType;
    $itemObj->SourceID = $__ChequeID;
    $itemObj->details = "چک شماره " . $InChequeObj->ChequeNo;
    //............................................................
    if ($InChequeObj->ChequeStatus == INCOMECHEQUE_NOTVOSUL) {
        unset($itemObj->ItemID);
        $itemObj->CostID = $CostCode_guaranteeAmount_daryafti;
        $itemObj->DebtorAmount = $__ChequeAmount;
        $itemObj->CreditorAmount = 0;
        $itemObj->Add($pdo);
        unset($itemObj->ItemID);
        $itemObj->CostID = $CostCode_guaranteeAmount2_daryafti;
        $itemObj->DebtorAmount = 0;
        $itemObj->CreditorAmount = $__ChequeAmount;
        $itemObj->Add($pdo);
        if (ExceptionHandler::GetExceptionCount() > 0) {
            return false;
        }
        return $obj->DocID;
    }
    //............................................................
    if ($InChequeObj->ChequeStatus == INCOMECHEQUE_VOSUL) {
        unset($itemObj->ItemID);
        $itemObj->CostID = $CostCode_guaranteeAmount2_daryafti;
        $itemObj->DebtorAmount = $__ChequeAmount;
        $itemObj->CreditorAmount = 0;
        $itemObj->Add($pdo);
        unset($itemObj->ItemID);
        $itemObj->CostID = $CostCode_guaranteeAmount_daryafti;
        $itemObj->DebtorAmount = 0;
        $itemObj->CreditorAmount = $__ChequeAmount;
        $itemObj->Add($pdo);
        if (count($BackPays) > 0) {
            foreach ($BackPays as $row) {
                $BackPayObj = new LON_BackPays($row["BackPayID"]);
                $ReqObj = new LON_requests($BackPayObj->RequestID);
                $PersonObj = new BSC_persons($ReqObj->ReqPersonID);
                if ($PersonObj->IsSupporter == "YES") {
                    $result = RegisterSHRTFUNDCustomerPayDoc($obj, $BackPayObj, $CostID, $TafsiliID, $TafsiliID2, $CenterAccount, $BranchID, $FirstCostID, $SecondCostID, $pdo);
                } else {
                    $result = RegisterCustomerPayDoc($obj, $BackPayObj, $CostID, $TafsiliID, $TafsiliID2, $CenterAccount, $BranchID, $FirstCostID, $SecondCostID, $pdo);
                }
            }
        } else {
            if ($CenterAccount == "true") {
                unset($itemObj->ItemID);
                unset($itemObj->TafsiliType);
                unset($itemObj->TafsiliType2);
                unset($itemObj->TafsiliID2);
                unset($itemObj->TafsiliID);
                $itemObj->locked = "NO";
                $itemObj->CostID = $FirstCostID;
                $itemObj->DebtorAmount = $__ChequeAmount;
                $itemObj->CreditorAmount = 0;
                if (!$itemObj->Add($pdo)) {
                    ExceptionHandler::PushException("خطا در ایجاد سند");
                    return false;
                }
                $Secobj = new ACC_docs();
                $Secobj->RegDate = PDONOW;
                $Secobj->regPersonID = $_SESSION['USER']["PersonID"];
                $Secobj->DocDate = PDONOW;
                $Secobj->CycleID = $CycleID;
                $Secobj->BranchID = $BranchID;
                $Secobj->DocType = $__SourceType;
                if (!$Secobj->Add($pdo)) {
                    ExceptionHandler::PushException("خطا در ایجاد سند");
                    return false;
                }
                unset($itemObj->ItemID);
                unset($itemObj->TafsiliType);
                unset($itemObj->TafsiliType2);
                unset($itemObj->TafsiliID2);
                unset($itemObj->TafsiliID);
                $itemObj->DocID = $Secobj->DocID;
                $itemObj->CostID = $SecondCostID;
                $itemObj->DebtorAmount = 0;
                $itemObj->CreditorAmount = $__ChequeAmount;
                if (!$itemObj->Add($pdo)) {
                    ExceptionHandler::PushException("خطا در ایجاد سند");
                    return false;
                }
                unset($itemObj->ItemID);
                unset($itemObj->TafsiliType);
                unset($itemObj->TafsiliType2);
                unset($itemObj->TafsiliID2);
                unset($itemObj->TafsiliID);
                $CostObj = new ACC_CostCodes($CostID);
                $itemObj->CostID = $CostID;
                $itemObj->DebtorAmount = $__ChequeAmount;
                $itemObj->CreditorAmount = 0;
                $itemObj->TafsiliType = $CostObj->TafsiliType;
                if ($TafsiliID != "") {
                    $itemObj->TafsiliID = $TafsiliID;
                }
                $itemObj->TafsiliType2 = $CostObj->TafsiliType2;
                if ($TafsiliID2 != "") {
                    $itemObj->TafsiliID2 = $TafsiliID2;
                }
                if (!$itemObj->Add($pdo)) {
                    ExceptionHandler::PushException("خطا در ایجاد سند");
                    return false;
                }
            } else {
                unset($itemObj->ItemID);
                unset($itemObj->TafsiliType);
                unset($itemObj->TafsiliType2);
                unset($itemObj->TafsiliID2);
                unset($itemObj->TafsiliID);
                $itemObj->locked = "NO";
                $CostObj = new ACC_CostCodes($CostID);
                $itemObj->CostID = $CostID;
                $itemObj->DebtorAmount = $__ChequeAmount;
                $itemObj->CreditorAmount = 0;
                $itemObj->TafsiliType = $CostObj->TafsiliType;
                if ($TafsiliID != "") {
                    $itemObj->TafsiliID = $TafsiliID;
                }
                $itemObj->TafsiliType2 = $CostObj->TafsiliType2;
                if ($TafsiliID2 != "") {
                    $itemObj->TafsiliID2 = $TafsiliID2;
                }
                if (!$itemObj->Add($pdo)) {
                    ExceptionHandler::PushException("خطا در ایجاد سند");
                    return false;
                }
            }
            unset($itemObj->ItemID);
            $itemObj->locked = "YES";
            $itemObj->DocID = $obj->DocID;
            $itemObj->CostID = $InChequeObj->CostID;
            $itemObj->DebtorAmount = 0;
            $itemObj->CreditorAmount = $__ChequeAmount;
            $itemObj->TafsiliType = $InChequeObj->TafsiliType;
            $itemObj->TafsiliID = $InChequeObj->TafsiliID;
            $itemObj->TafsiliType2 = $InChequeObj->TafsiliType2;
            $itemObj->TafsiliID2 = $InChequeObj->TafsiliID2;
            if (!$itemObj->Add($pdo)) {
                ExceptionHandler::PushException("خطا در ایجاد سند");
                return false;
            }
        }
        if (ExceptionHandler::GetExceptionCount() > 0) {
            return false;
        }
        return true;
    }
    //............................................................
    if (array_search($InChequeObj->ChequeStatus, array(INCOMECHEQUE_EBTAL, INCOMECHEQUE_MOSTARAD, INCOMECHEQUE_BARGHASHTI_MOSTARAD, INCOMECHEQUE_MAKHDOOSH, INCOMECHEQUE_CHANGE)) !== false) {
        $itemObj->DocID = $obj->DocID;
        $itemObj->CostID = $CostCode_guaranteeAmount_daryafti;
        $itemObj->CreditorAmount = $__ChequeAmount;
        $itemObj->DebtorAmount = 0;
        $itemObj->TafsiliType = TAFTYPE_PERSONS;
        $itemObj->TafsiliID = $__TafsiliID;
        $itemObj->SourceType = $__SourceType;
        $itemObj->SourceID = $__ChequeID;
        $itemObj->details = "چک شماره " . $InChequeObj->ChequeNo;
        $itemObj->Add($pdo);
        unset($itemObj->ItemID);
        $itemObj->CostID = $CostCode_guaranteeAmount2_daryafti;
        $itemObj->CreditorAmount = 0;
        $itemObj->DebtorAmount = $__ChequeAmount;
        $itemObj->Add($pdo);
        //---------------------------------------------------------
        if (ExceptionHandler::GetExceptionCount() > 0) {
            return false;
        }
        return true;
    }
    return true;
}