function RegisterInOutAccountDoc() { $CostID = $_REQUEST["BaseCostID"]; $BaseTafsiliID = $_REQUEST["BaseTafsiliID"]; $mode = $_POST["mode"] * 1; if ($mode < 0) { $query = "select ifnull(sum(CreditorAmount-DebtorAmount),0) remaindar\n\t\tfrom ACC_DocItems di\n\t\t\tjoin ACC_docs d using(DocID)\n\t\twhere d.CycleID=:c AND d.BranchID=:b AND \n\t\t\tdi.CostID=:cost AND di.TafsiliType = :t AND di.TafsiliID=:tid"; $param = array(":c" => $_SESSION["accounting"]["CycleID"], ":b" => $_SESSION["accounting"]["BranchID"], ":cost" => $CostID, ":t" => TAFTYPE_PERSONS, ":tid" => $BaseTafsiliID); $dt = PdoDataAccess::runquery($query, $param); //echo PdoDataAccess::GetLatestQueryString(); if ($_POST["amount"] > $dt[0][0] * 1) { echo Response::createObjectiveResponse(false, "مبلغ وارد شده بیشتر از مانده حساب می باشد"); die; } } $pdo = PdoDataAccess::getPdoObject(); $pdo->beginTransaction(); //---------------- add doc header -------------------- $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 = $mode > 0 ? DOCTYPE_SAVING_IN : DOCTYPE_SAVING_OUT; $obj->description = $mode > 0 ? "واریز به حساب" : "برداشت از حساب"; if (!$obj->Add($pdo)) { echo Response::createObjectiveResponse(false, "خطا در ایجاد سند"); die; } //------------------------------------------------- $itemObj = new ACC_DocItems(); $itemObj->DocID = $obj->DocID; $itemObj->CostID = $CostID; $itemObj->DebtorAmount = $mode > 0 ? 0 : $_POST["amount"]; $itemObj->CreditorAmount = $mode > 0 ? $_POST["amount"] : 0; $itemObj->TafsiliType = TAFTYPE_PERSONS; $itemObj->TafsiliID = $BaseTafsiliID; $itemObj->details = $_POST["description"]; if (!$itemObj->Add($pdo)) { echo Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString()); die; } $itemObj = new ACC_DocItems(); $itemObj->DocID = $obj->DocID; $itemObj->CostID = $_POST["CostID"]; $itemObj->DebtorAmount = $mode > 0 ? $_POST["amount"] : 0; $itemObj->CreditorAmount = $mode > 0 ? 0 : $_POST["amount"]; if ($itemObj->CostID == COSTID_Bank) { $itemObj->TafsiliType = TAFTYPE_BANKS; $itemObj->TafsiliID = $_POST["TafsiliID"]; $itemObj->TafsiliType2 = TAFTYPE_ACCOUNTS; $itemObj->TafsiliID2 = $_POST["TafsiliID2"]; } if (!$itemObj->Add($pdo)) { echo Response::createObjectiveResponse(false, ExceptionHandler::GetExceptionsToString()); die; } $pdo->commit(); echo Response::createObjectiveResponse(true, ""); die; }
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; }
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; }