Пример #1
0
 function BlockTrigger($pdo = null)
 {
     if (!isset($this->TafsiliType) || !isset($this->TafsiliID)) {
         return true;
     }
     $BlockedAmount = ACC_CostBlocks::GetBlockAmount($this->CostID, $this->TafsiliType, $this->TafsiliID, $pdo);
     if ($BlockedAmount > 0) {
         $temp = PdoDataAccess::runquery("select ifnull(sum(CreditorAmount-DebtorAmount),0) remain\n\t\t\t\tfrom ACC_DocItems join ACC_docs using(DocID)\n\t\t\t\twhere CycleID=? AND CostID=? AND TafsiliType=? AND TafsiliID=? AND ItemID<>?", array($_SESSION["accounting"]["CycleID"], $this->CostID, $this->TafsiliType, $this->TafsiliID, $this->ItemID), $pdo);
         if ($temp[0][0] * 1 - $BlockedAmount < $this->DebtorAmount * 1) {
             ExceptionHandler::PushException("مبلغ وارد شده بیشتر از مبلغ قابل برداشت می باشد " . "<br>مبلغ قابل برداشت : " . ($temp[0][0] * 1 - $BlockedAmount));
             return false;
         }
     }
     return true;
 }
Пример #2
0
function GetAllCostBlocks()
{
    $temp = ACC_CostBlocks::Get();
    $dt = PdoDataAccess::fetchAll($temp, $_GET["start"], $_GET["limit"]);
    echo dataReader::getJsonData($dt, $temp->rowCount(), $_GET["callback"]);
    die;
}
Пример #3
0
function EndWarrantyDoc($ReqObj, $pdo)
{
    /*@var $ReqObj WAR_requests */
    //------------- get CostCodes --------------------
    $CostCode_warrenty = FindCostID("300");
    $CostCode_warrenty_commitment = FindCostID("700");
    $CostCode_wage = FindCostID("750-07");
    $CostCode_FutureWage = FindCostID("760-07");
    $CostCode_fund = FindCostID("100");
    $CostCode_seporde = FindCostID("690");
    $CostCode_pasandaz = FindCostID("209-10");
    $CostCode_guaranteeAmount_zemanati = FindCostID("904-02");
    $CostCode_guaranteeAmount_daryafti = FindCostID("904-04");
    $CostCode_guaranteeAmount2_zemanati = FindCostID("905-02");
    $CostCode_guaranteeAmount2_daryafti = FindCostID("905-04");
    //------------------------------------------------
    $CycleID = substr(DateModules::miladi_to_shamsi($ReqObj->StartDate), 0, 4);
    //------------------ find tafsilis ---------------
    $PersonTafsili = FindTafsiliID($ReqObj->PersonID, TAFTYPE_PERSONS);
    if (!$PersonTafsili) {
        ExceptionHandler::PushException("تفصیلی مربوطه یافت نشد.[" . $ReqObj->PersonID . "]");
        return false;
    }
    //---------------- add doc header --------------------
    $DocObj = new ACC_docs();
    $DocObj->RegDate = PDONOW;
    $DocObj->regPersonID = $_SESSION['USER']["PersonID"];
    $DocObj->DocDate = PDONOW;
    $DocObj->CycleID = $CycleID;
    $DocObj->BranchID = $ReqObj->BranchID;
    $DocObj->DocType = DOCTYPE_WARRENTY_END;
    $DocObj->description = "خاتمه ضمانت نامه " . $ReqObj->_TypeDesc . " به شماره " . $ReqObj->RequestID . " به نام " . $ReqObj->_fullname;
    if (!$DocObj->Add($pdo)) {
        ExceptionHandler::PushException("خطا در ایجاد سند");
        return false;
    }
    //----------------- add Doc items ------------------------
    $itemObj = new ACC_DocItems();
    $itemObj->DocID = $DocObj->DocID;
    $itemObj->TafsiliType = TAFTYPE_PERSONS;
    $itemObj->TafsiliID = $PersonTafsili;
    $itemObj->SourceType = DOCTYPE_WARRENTY_END;
    $itemObj->SourceID = $ReqObj->RequestID;
    $itemObj->SourceID2 = $ReqObj->ReqVersion;
    $itemObj->locked = "YES";
    $itemObj->CostID = $CostCode_warrenty;
    $itemObj->CreditorAmount = $ReqObj->amount;
    $itemObj->DebtorAmount = 0;
    if (!$itemObj->Add($pdo)) {
        ExceptionHandler::PushException("خطا در ثبت ردیف ضمانت نامه");
        return false;
    }
    unset($itemObj->ItemID);
    $itemObj->CostID = $CostCode_warrenty_commitment;
    $itemObj->CreditorAmount = 0;
    $itemObj->DebtorAmount = $ReqObj->amount;
    if (!$itemObj->Add($pdo)) {
        ExceptionHandler::PushException("خطا در ثبت ردیف تعهد ضمانت نامه");
        return false;
    }
    //---------------------------- block Cost ----------------------------
    if ($ReqObj->IsBlock == "YES") {
        $dt = PdoDataAccess::runquery("select * from ACC_blocks where SourceType=? AND SourceID=?", array(DOCTYPE_WARRENTY, $ReqObj->RequestID));
        if (count($dt) > 0) {
            $blockObj = new ACC_CostBlocks($dt[0]["BlockID"]);
            $blockObj->IsActive = "NO";
            $blockObj->Edit($pdo);
        }
    }
    //---------- ردیف های تضمین  ----------
    $SumAmount = 0;
    $countAmount = 0;
    $dt = PdoDataAccess::runquery("\r\n\t\tSELECT DocumentID, ParamValue, InfoDesc as DocTypeDesc\r\n\t\t\tFROM DMS_DocParamValues\r\n\t\t\tjoin DMS_DocParams using(ParamID)\r\n\t\t\tjoin DMS_documents d using(DocumentID)\r\n\t\t\tjoin BaseInfo b on(InfoID=d.DocType AND TypeID=8)\r\n\t\t\tleft join ACC_DocItems on(SourceType=" . DOCTYPE_DOCUMENT . " AND SourceID=DocumentID)\r\n\t\twhere ItemID is null AND b.param1=1 AND \r\n\t\t\tparamType='currencyfield' AND ObjectType='warrenty' AND ObjectID=?", array($ReqObj->RequestID), $pdo);
    foreach ($dt as $row) {
        unset($itemObj->ItemID);
        $itemObj->CostID = $CostCode_guaranteeAmount_zemanati;
        $itemObj->DebtorAmount = 0;
        $itemObj->CreditorAmount = $row["ParamValue"];
        $itemObj->TafsiliType = TAFTYPE_PERSONS;
        $itemObj->TafsiliID = $PersonTafsili;
        $itemObj->SourceType = DOCTYPE_DOCUMENT;
        $itemObj->SourceID = $row["DocumentID"];
        $itemObj->details = $row["DocTypeDesc"];
        $itemObj->Add($pdo);
        $SumAmount += $row["ParamValue"] * 1;
        $countAmount++;
    }
    if ($SumAmount > 0) {
        unset($itemObj->ItemID);
        unset($itemObj->TafsiliType);
        unset($itemObj->TafsiliID);
        unset($itemObj->details);
        $itemObj->CostID = $CostCode_guaranteeAmount2_zemanati;
        $itemObj->DebtorAmount = $SumAmount;
        $itemObj->CreditorAmount = 0;
        $itemObj->Add($pdo);
    }
    if (ExceptionHandler::GetExceptionCount() > 0) {
        return false;
    }
    return $DocObj->DocID;
}