当前位置: 首页>>代码示例>>PHP>>正文


PHP DateModules::GDateMinusGDate方法代码示例

本文整理汇总了PHP中DateModules::GDateMinusGDate方法的典型用法代码示例。如果您正苦于以下问题:PHP DateModules::GDateMinusGDate方法的具体用法?PHP DateModules::GDateMinusGDate怎么用?PHP DateModules::GDateMinusGDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateModules的用法示例。


在下文中一共展示了DateModules::GDateMinusGDate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: duty_year_month_day

function duty_year_month_day($staff_id = "", $personID = "", $toDate) {
    if ($staff_id == "" && $personID = "") {
        PdoDataAccess::PushException("يکي از دو پارامتر staff_id و PersonID بايد فرستاده شود");
        return false;                
    }
    $query = "select w.execute_date,
						w.contract_start_date ,
						w.contract_end_date ,
						w.person_type ,
						w.onduty_year ,
						w.onduty_month ,
						w.onduty_day ,
						w.annual_effect
			from writs as w";

    if ($personID != "")
        $query .= " join staff as s using(staff_id) where s.PersonID=" . $personID;

    else if ($staff_id != "")
        $query .= " where w.staff_id = $staff_id";

    $query .= " AND (w.history_only != " . HISTORY_ONLY . " OR w.history_only is null) AND w.execute_date <= '$toDate'
						order by w.execute_date DESC,w.writ_id DESC,w.writ_ver DESC
						limit 1";

    $temp = PdoDataAccess::runquery($query);

    if (count($temp) == 0)
        return array("year" => 0, "month" => 0, "day" => 0);

    $writ_rec = $temp[0];

    $temp_duration = 0;

    if (DateModules::CompareDate($toDate, $writ_rec['execute_date']) >= 0)
        $temp_duration = DateModules::GDateMinusGDate($toDate, $writ_rec['execute_date']);

    if ($writ_rec['annual_effect'] == HALF_COMPUTED)
        $temp_duration *= 0.5;
    else if ($writ_rec['annual_effect'] == DOUBLE_COMPUTED)
        $temp_duration *= 2;
    else if ($writ_rec['annual_effect'] == NOT_COMPUTED)
        $temp_duration = 0;

    $prev_writ_duration = DateModules::ymd_to_days($writ_rec['onduty_year'], $writ_rec['onduty_month'], $writ_rec['onduty_day']);

    $duration = $prev_writ_duration + $temp_duration;
    
       
    $return = array();
    DateModules::day_to_ymd($duration, $return['year'], $return['month'], $return['day']);

    return $return;
}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:54,代码来源:EmpGradReport.php

示例2: GetSavingLoanInfo

function GetSavingLoanInfo()
{
    if (isset($_SESSION["USER"]["portal"])) {
        $PersonID = $_SESSION["USER"]["PersonID"];
    } else {
        $PersonID = $_REQUEST["PersonID"];
    }
    //----------- check for all docs confirm --------------
    /*$dt = PdoDataAccess::runquery("select group_concat(distinct LocalNo) from ACC_docs 
    		join ACC_DocItems using(DocID) join ACC_tafsilis t using(TafsiliType,TafsiliID)
    		where TafsiliType=" . TAFTYPE_PERSONS . " 
    			AND ObjectID = ? AND CostID in(" . COSTID_saving . ")
    			AND DocType not in(" . DOCTYPE_STARTCYCLE . "," . DOCTYPE_ENDCYCLE . ")
    			AND DocStatus not in('CONFIRM','ARCHIVE')", array($PersonID));
    	if(count($dt) > 0 && $dt[0][0] != "")
    	{
    		$msg = "اسناد با شماره های [" . $dt[0][0] . "] تایید نشده اند.";
    		echo dataReader::getJsonData(array(), 0, $_GET["callback"], $msg);
    		die();
    	}*/
    //------------ get sum of savings ----------------
    $dt = PdoDataAccess::runquery("\n\t\tselect DocDate,sum(CreditorAmount-DebtorAmount) amount\n\t\tfrom ACC_DocItems di\n\t\t\tjoin ACC_docs d using(DocID)\n\t\t\tjoin ACC_tafsilis t using(TafsiliType,TafsiliID)\n\t\t\n\t\twhere TafsiliType=" . TAFTYPE_PERSONS . " \n\t\t\tAND ObjectID = ?\n\t\t\tAND CostID in(" . COSTID_saving . ")\n\t\t\tAND DocType not in(" . DOCTYPE_STARTCYCLE . "," . DOCTYPE_ENDCYCLE . ")\n\t\t\tAND BranchID=" . $_SESSION["accounting"]["BranchID"] . "\n\t\tgroup by DocDate\n\t\torder by DocDate", array($PersonID));
    if (count($dt) == 0) {
        $msg = "شخص مورد نظر فاقد حساب پس انداز می باشد";
        echo dataReader::getJsonData(array(), 0, $_GET["callback"], $msg);
        die;
    }
    //------------ get the Deposite amount -------------
    $totalAmount = 0;
    $totalDays = 0;
    for ($i = 1; $i < count($dt); $i++) {
        $days = DateModules::GDateMinusGDate($dt[$i]["DocDate"], $dt[$i - 1]["DocDate"]);
        $totalDays += $days;
        $totalAmount += $dt[$i - 1]["amount"] * $days;
    }
    $days = DateModules::GDateMinusGDate(DateModules::Now(), $dt[$i - 1]["DocDate"]);
    $totalDays += $days;
    $totalAmount += $dt[$i - 1]["amount"] * $days;
    $average = round($totalAmount / $totalDays);
    $returnArray = array("PersonID" => $PersonID, "FirstDate" => DateModules::miladi_to_shamsi($dt[0]["DocDate"]), "AverageAmount" => $average, "TotalMonths" => floor($totalDays / 30.5));
    echo dataReader::getJsonData($returnArray, 1, $_GET["callback"]);
    die;
}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:43,代码来源:saving.data.php

示例3: ProcessPayment

function ProcessPayment()
{
    $paymentCalcObj = new manage_payment_calculation();
    $paymentCalcObj->__YEAR = DateModules::GetYear($_POST["end_date"]);
    $paymentCalcObj->__MONTH = DateModules::GetMonth($_POST["end_date"]);
    $paymentCalcObj->__CALC_NORMALIZE_TAX = isset($_POST['tax_normalize']) ? "1" : "0";
    $paymentCalcObj->__START_NORMALIZE_TAX_MONTH = $_POST['tax_n_m'];
    $paymentCalcObj->__START_NORMALIZE_TAX_YEAR = $_POST['tax_normalized_year'];
    $paymentCalcObj->__BACKPAY_BEGIN_FROM = 1;
    $paymentCalcObj->__CALC_NEGATIVE_FICHE = isset($_POST['negative_fiche']) ? "1" : "0";
    $paymentCalcObj->month_start = DateModules::shamsi_to_miladi($_POST["start_date"]);
    $paymentCalcObj->month_end = DateModules::shamsi_to_miladi($_POST["end_date"]);
    $paymentCalcObj->__MONTH_LENGTH = ceil(DateModules::GDateMinusGDate($paymentCalcObj->month_end, $paymentCalcObj->month_start) + 1);
    $paymentCalcObj->__MSG = $_POST["message"];
    // <editor-fold defaultstate="collapsed" desc="Create Where" >
    $where = "1=1";
    $whereParam = array();
    if (!empty($_POST["from_staff_id"])) {
        $where .= " AND s.staff_id >= :fsid";
        $whereParam[":fsid"] = $_POST["from_staff_id"];
    }
    if (!empty($_POST["to_staff_id"])) {
        $where .= " AND s.staff_id <= :tsid";
        $whereParam[":tsid"] = $_POST["to_staff_id"];
    }
    // </editor-fold>
    $paymentCalcObj->__WHERE = $where;
    $paymentCalcObj->__WHEREPARAM = $whereParam;
    if (isset($_POST["compute_backpay"])) {
        $res = $paymentCalcObj->run_back();
    } else {
        $res = $paymentCalcObj->run();
    }
    if (!$res) {
        echo Response::createObjectiveResponse(false, ExceptionHandler::popExceptionDescription());
        die;
    } else {
        echo Response::createObjectiveResponse(true, $paymentCalcObj->success_counter . "_" . $paymentCalcObj->fail_counter);
        die;
    }
}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:41,代码来源:payment.data.php

示例4: ComputeWagesAndDelays

function ComputeWagesAndDelays($PartObj, $PayAmount, $StartDate, $PayDate)
{
    $MaxWage = max($PartObj->CustomerWage * 1, $PartObj->FundWage);
    if ($PartObj->PayInterval > 0) {
        $YearMonths = $PartObj->IntervalType == "DAY" ? floor(365 / $PartObj->PayInterval) : 12 / $PartObj->PayInterval;
    } else {
        $YearMonths = 12;
    }
    $TotalWage = round(ComputeWage($PayAmount, $MaxWage / 100, $PartObj->InstallmentCount, $PartObj->IntervalType, $PartObj->PayInterval));
    $CustomerFactor = $MaxWage == 0 ? 0 : $PartObj->CustomerWage / $MaxWage;
    $FundFactor = $MaxWage == 0 ? 0 : $PartObj->FundWage / $MaxWage;
    $AgentFactor = $MaxWage == 0 ? 0 : ($PartObj->CustomerWage - $PartObj->FundWage) / $MaxWage;
    ///...........................................................
    if ($PartObj->MaxFundWage * 1 > 0) {
        if ($PartObj->WageReturn == "INSTALLMENT") {
            $FundYears = YearWageCompute($PartObj, $PartObj->MaxFundWage * 1, $YearMonths);
        } else {
            $FundYears = array();
        }
    } else {
        $years = YearWageCompute($PartObj, $TotalWage * 1, $YearMonths);
        $FundYears = array();
        foreach ($years as $year => $amount) {
            $FundYears[$year] = round($FundFactor * $amount);
        }
    }
    $AgentYears = array();
    foreach ($years as $year => $amount) {
        $AgentYears[$year] = round($amount - $FundYears[$year]);
    }
    //.............................................................
    $endDelayDate = DateModules::AddToGDate($PayDate, $PartObj->DelayDays * 1, $PartObj->DelayMonths * 1);
    $DelayDuration = DateModules::GDateMinusGDate($endDelayDate, $PayDate) + 1;
    if ($StartDate == $PayDate) {
        if ($PartObj->DelayDays * 1 > 0) {
            $CustomerDelay = round($PayAmount * $PartObj->DelayPercent * $DelayDuration / 36500);
            $FundDelay = round($PayAmount * $PartObj->FundWage * $DelayDuration / 36500);
            $AgentDelay = round($PayAmount * ($PartObj->DelayPercent - $PartObj->FundWage) * $DelayDuration / 36500);
        } else {
            $CustomerDelay = round($PayAmount * $PartObj->DelayPercent * $PartObj->DelayMonths / 1200);
            $FundDelay = round($PayAmount * $PartObj->FundWage * $PartObj->DelayMonths / 1200);
            $AgentDelay = round($PayAmount * ($PartObj->DelayPercent - $PartObj->FundWage) * $PartObj->DelayMonths / 1200);
        }
    } else {
        $endDelayDate = DateModules::AddToGDate($StartDate, $PartObj->DelayDays * 1, $PartObj->DelayMonths * 1);
        $DelayDuration = DateModules::GDateMinusGDate($endDelayDate, $PayDate) + 1;
        $CustomerDelay = round($PayAmount * $PartObj->DelayPercent * $DelayDuration / 36500);
        $FundDelay = round($PayAmount * $PartObj->FundWage * $DelayDuration / 36500);
        $AgentDelay = round($PayAmount * ($PartObj->DelayPercent - $PartObj->FundWage) * $DelayDuration / 36500);
    }
    $CustomerYearDelays = SplitYears($PayDate, $endDelayDate, $CustomerDelay);
    //.............................................................
    return array("TotalFundWage" => round($TotalWage * $FundFactor), "TotalAgentWage" => round($TotalWage * $AgentFactor), "TotalCustomerWage" => round($TotalWage * $CustomerFactor), "FundWageYears" => $FundYears, "AgentWageYears" => $AgentYears, "TotalCustomerDelay" => $CustomerDelay, "TotalFundDelay" => $FundDelay, "TotalAgentDelay" => $AgentDelay, "CustomerYearDelays" => $CustomerYearDelays);
}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:54,代码来源:compute.inc.php

示例5: compute_salary_item2_19


//.........这里部分代码省略.........
				$education_level = MS_LEVEL;
			} else if ($education_level >= EDUCATION_LEVEL_DOCTORATE) {
				$education_level = PHD_LEVEL;
			}

			switch ($education_level) {
				case PHD_LEVEL :
					$this->param1 = 'دکتری';
					break;
				case MS_LEVEL :
					$this->param1 = 'کارشناسی ارشد';
					break;
				case BS_LEVEL :
					$this->param1 = 'کارشناسی';
					break;
				case HIGH_DIPLOMA_LEVEL :
					$this->param1 = 'فوق دیپلم';
					break;
				case DIPLOMA_LEVEL :
					$this->param1 = 'دیپلم';
					break;
				case UNDER_DIPLOMA_LEVEL :
					$this->param1 = 'زیر دیپلم';
					break;
			}

			$this->param4 = $writ_rec['onduty_year'] . ' سال و ' . $writ_rec['onduty_month'] . ' ماه و ' . $writ_rec['onduty_day'] . ' روز';

			//بررسی سنوات خدمت و اختلاف آن با سنوات خدمت در حکم.
			unset($duty_duration);
			$duty_duration_year = 0;
			$duty_duration_month = 0;
			$duty_duration_day = 0;

			$duty_qry = " SELECT s.work_start_date,
	    						 p.military_duration,
	    						 p.military_duration_day
	    				 FROM    staff s
	    				 		INNER JOIN persons p
	    				 			  ON (s.PersonID = p.PersonID)
	    				 WHERE s.staff_id = " . $writ_rec['staff_id'];

			$duty_res = parent::runquery($duty_qry);

			if ($duty_res[0]['work_start_date']) {

				$duty_duration = DateModules::GDateMinusGDate($writ_rec['execute_date'], $duty_res[0]['work_start_date']) +
						(floor($duty_res[0]['military_duration'] * 30.4375 + $duty_res[0]['military_duration_day'])) + 1;
				$duty_duration_year = floor($duty_duration / 366.25);
				$duty_duration_month = floor(($duty_duration - ($duty_duration_year * 366.25)) / 30);
				$duty_duration_day = floor($duty_duration - ($duty_duration_year * 366.25) - floor($duty_duration_month * 30));
			}

			$emp_qry = " SELECT SUM(pe.retired_duration_year) retired_duration_year,
	    						SUM(pe.retired_duration_month) retired_duration_month,
	    						SUM(pe.retired_duration_day) retired_duration_day
	    				  FROM   person_employments pe
                                 WHERE pe.PersonID = " . $writ_rec['PersonID'];

			$emp_res = parent::runquery($emp_qry);

			$duty_duration_year += $emp_res[0]['retired_duration_year'];
			$duty_duration_month += $emp_res[0]['retired_duration_month'];
			$duty_duration_day += $emp_res[0]['retired_duration_day'];

			//...........................................................................
			if ($duty_duration_day >= 30) {
				$duty_duration_month += floor($duty_duration_day / 30);
				$duty_duration_day -= floor(floor($duty_duration_day / 30) * 30);
			}

			if ($duty_duration_month >= 12) {
				$duty_duration_year += floor($duty_duration_month / 12);
				$duty_duration_month -= floor($duty_duration_month / 12) * 12;
			}

			$this->param2 = $duty_duration_year . ' سال و ' . $duty_duration_month . ' ماه و ' . $duty_duration_day . ' روز';

			$pqry = " SELECT value
        				 FROM  salary_params sp
        				 WHERE sp.param_type = " . SPT_HEIAT_OMANA_ABSORBTION_VALUE . " AND
					       sp.person_type = ".$writ_rec['person_type']." AND 	
        				       sp.from_date <= '" . $writ_rec['execute_date'] . "' AND
        				       sp.to_date >= '" . $writ_rec['execute_date'] . "' AND 
        				       sp.dim1_id = " . $education_level . " AND
        				       sp.dim2_id > " . $writ_rec['onduty_year'] . "
        				 ORDER BY sp.from_date DESC,sp.to_date DESC, dim2_id
        				 LIMIT 1 ";

			$pres = parent::runquery($pqry);
			if (count($pres) < 1) {
				parent::PushException(NOT_DEFINE_HEIAT_OMANA_PARAM);
				return false;
			}
			$value = $pres[0]['value'];
			$this->param3 = $value;
		}
		
		return $value;
	}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:101,代码来源:writ_item.class.php

示例6: get_retired_coef

 private function get_retired_coef()
 {
     $coefficient = 1;
     //init
     if ($this->staffRow['last_retired_pay'] != NULL && $this->staffRow['last_retired_pay'] != '0000-00-00' && DateModules::CompareDate($this->staffRow['last_retired_pay'], $this->month_start) == -1) {
         $coefficient = 0;
     } elseif ($this->staffRow['last_retired_pay'] != NULL && $this->staffRow['last_retired_pay'] != '0000-00-00' && DateModules::CompareDate($this->staffRow['last_retired_pay'], $this->month_end) != 1) {
         $coefficient = (round(DateModules::GDateMinusGDate($this->staffRow['last_retired_pay'], $this->month_start)) + 1) / $this->__MONTH_LENGTH;
     }
     return $coefficient;
 }
开发者ID:jafarkhani,项目名称:rtfund,代码行数:11,代码来源:arrear_pay_calculation.class.php

示例7: get_arrear_document


//.........这里部分代码省略.........
                   else
                       $Row .= "<td>" .DateModules::miladi_to_shamsi($res[$i]['current_execute_date']). "</td>";
                   */
                if ($res[$i]['current_execute_date'] == $res[$i + 1]['current_execute_date']) {
                    //$Row .= "<td>" . DateModules::AddToJDate($toDate, 1) . "</td>";
                    $sdate = DateModules::AddToJDate($toDate, 1);
                }
                /*else if ($sdate != "" && $sdate > '0000-00-00' && empty($res[$i + 1]['current_execute_date']))
                                $Row .= "<td>" . $t . "/12/29" . "</td>";
                            elseif($res[$i + 1]['current_execute_date'] !='0000-00-00' && DateModules::CompareDate(DateModules::miladi_to_shamsi($res[$i + 1]['current_execute_date']),$LAST_PAY_DATE) == 1  )
                            {
                                  $Row .= "<td>" . $LAST_PAY_DATE . "</td>";
                                
                            }
                            else
                                $Row .= "<td>" . ( empty($res[$i + 1]['current_execute_date']) ? $toDate : DateModules::miladi_to_shamsi($res[$i + 1]['current_execute_date']) ) . "</td>";
                */
                if (!empty($LD[$t]['lastDate'])) {
                    $toDate2 = DateModules::shamsi_to_miladi(DateModules::AddToJDate($LD[$t]['lastDate'], 1));
                } else {
                    if ($LastDate == '0000-00-00') {
                        $toDate2 = DateModules::shamsi_to_miladi($t + 1 . "/01/01");
                    } else {
                        $toDate2 = DateModules::CompareDate(str_replace("/", "-", DateModules::shamsi_to_miladi($t . "/12/30")), str_replace("/", "-", DateModules::shamsi_to_miladi($LastDate))) >= 0 ? DateModules::AddToJDate($LastDate, 1) : DateModules::shamsi_to_miladi($t + 1 . "/01/01");
                    }
                }
                $endDate = empty($res[$i + 1]['current_execute_date']) ? $toDate2 : $res[$i + 1]['current_execute_date'];
                if ($res[$i]['current_execute_date'] == $res[$i + 1]['current_execute_date']) {
                    $endDate = $toDate2;
                }
                if ($sdate != "" && $sdate > '0000-00-00' && empty($res[$i + 1]['current_execute_date'])) {
                    $endDate = $t + 1 . "/1/01";
                    if ($resPerInfo[0]['person_type'] == 3) {
                        $DayNo = round(DateModules::GDateMinusGDate(DateModules::shamsi_to_miladi($endDate), DateModules::shamsi_to_miladi($sdate)));
                        $DayNo2 = calculate_duration($sdate, $endDate);
                    } else {
                        $DayNo = calculate_duration($sdate, $endDate);
                    }
                } else {
                    if ($resPerInfo[0]['person_type'] == 3) {
                        $DayNo = round(DateModules::GDateMinusGDate(DateModules::shamsi_to_miladi($endDate), $res[$i]['current_execute_date']));
                        $DayNo2 = calculate_duration($res[$i]['current_execute_date'], $endDate);
                    } else {
                        $DayNo = calculate_duration($res[$i]['current_execute_date'], $endDate);
                    }
                }
                if ($res[$i + 1]['current_execute_date'] != '0000-00-00' && DateModules::CompareDate(DateModules::miladi_to_shamsi($res[$i + 1]['current_execute_date']), $LAST_PAY_DATE) == 1) {
                    $DayNo = calculate_duration($res[$i]['current_execute_date'], DateModules::shamsi_to_miladi($LAST_PAY_DATE));
                }
                // $Row .= "<td>" . $DayNo . "</td>";
                $sumDiff = $MainVal = 0;
                $RetInc = $TaxInc = $InsInc = 0;
                for ($j = 0; $j < count($ResITM); $j++) {
                    $val1 = get_writSalaryItem_value($res[$i]["current_writ_id"], $res[$i]["current_writ_ver"], $res[$i]["staff_id"], $ResITM[$j]["salary_item_type_id"]);
                    $val2 = get_writSalaryItem_value($res[$i]["prev_writ_id"], $res[$i]["prev_writ_ver"], $res[$i]["staff_id"], $ResITM[$j]["salary_item_type_id"]);
                    $RetRes = PdoDataAccess::runquery(" select retired_include , tax_include , insure_include \r\n                                                      from salary_item_types where salary_item_type_id = " . $ResITM[$j]["salary_item_type_id"]);
                    //  $Row .= "<td>" . CurrencyModulesclass::toCurrency($val1 - $val2) . (($val1 - $val2) < 0 ? "-&nbsp;" : "" ) . "</td>";
                    $sumDiff += $val1 - $val2;
                    if (empty($Itm[$j]['sumVal'])) {
                        $Itm[$j]['sumVal'] = 0;
                        $Itm[$j]['sumCol'] = 0;
                    }
                    $Itm[$j]['sumVal'] += $val1 - $val2;
                    if ($ResITM[$j]["month_length_effect"] == 0 && $resPerInfo[0]['person_type'] == 3) {
                        $Itm[$j]['sumCol'] += round(($val1 - $val2) * $DayNo2 / 30);
                        $MainVal += round(($val1 - $val2) * $DayNo2 / 30);
开发者ID:jafarkhani,项目名称:rtfund,代码行数:67,代码来源:salary_utils.inc.php

示例8: AddPerson

 function AddPerson($staffObject, $pic = "")
 {
     $pdo = PdoDataAccess::getPdoObject();
     if ($pdo->beginTransaction()) {
         if ($this->military_from_date != NULL || $this->military_from_date != '0000-00-00') {
             $Vyear = 0;
             $Vmonth = $Vday = 0;
             $resDay = DateModules::GDateMinusGDate($this->military_to_date, $this->military_from_date);
             DateModules::day_to_ymd($resDay, $Vyear, $Vmonth, $Vday);
             $mm = $Vyear * 12 + $Vmonth;
             $dd = $Vday;
             $this->military_duration = $mm;
             $this->military_duration_day = $dd;
         }
         if (parent::insert("HRM_persons", $this, $pdo) === false) {
             parent::PushException(ER_PERSON_DONT_SAVE);
             $pdo->rollBack();
             return false;
         }
         $this->PersonID = parent::InsertID();
         $staffObject->PersonID = $this->PersonID;
         $staffObject->person_type = $this->person_type;
         $return = $staffObject->AddStaff($pdo);
         if (!$return) {
             parent::PushException(ER_PERSON_DONT_SAVE);
             $pdo->rollBack();
             return false;
         }
         if ($return) {
             $pdo->commit();
         }
         $daObj = new DataAudit();
         $daObj->ActionType = DataAudit::Action_add;
         $daObj->MainObjectID = $this->PersonID;
         $daObj->TableName = "HRM_persons";
         $daObj->execute();
         return true;
     } else {
         return false;
     }
 }
开发者ID:jafarkhani,项目名称:rtfund,代码行数:41,代码来源:person.class.php

示例9: DelayInstallments

function DelayInstallments()
{
    $RequestID = $_POST["RequestID"];
    $InstallmentID = $_POST["InstallmentID"];
    $newDate = $_POST["newDate"];
    $PartObj = LON_ReqParts::GetValidPartObj($RequestID);
    $pdo = PdoDataAccess::getPdoObject();
    $pdo->beginTransaction();
    if ($_POST["IsRemainCompute"] == " 0") {
        $dt = LON_installments::SelectAll("r.RequestID=? AND InstallmentID>=?", array($RequestID, $InstallmentID));
        $days = 0;
        for ($i = 0; $i < count($dt); $i++) {
            $obj = new LON_installments();
            $obj->InstallmentID = $dt[$i]["InstallmentID"];
            $obj->IsDelayed = "YES";
            if (!$obj->EditInstallment($pdo)) {
                $pdo->rollBack();
                echo Response::createObjectiveResponse(false, "1");
                die;
            }
            //...........................................
            if ($days == 0) {
                $newDate = DateModules::shamsi_to_miladi($newDate, "-");
                $days = DateModules::GDateMinusGDate($newDate, $dt[$i]["InstallmentDate"]);
            }
            $obj = new LON_installments();
            $obj->RequestID = $RequestID;
            $obj->InstallmentDate = DateModules::AddToGDate($dt[$i]["InstallmentDate"], $days);
            $extraWage = round($dt[$i]["InstallmentAmount"] * $PartObj->CustomerWage * $days / 36500);
            $obj->InstallmentAmount = $dt[$i]["InstallmentAmount"] * 1 + $extraWage;
            if (!$obj->AddInstallment($pdo)) {
                $pdo->rollBack();
                echo Response::createObjectiveResponse(false, "2");
                die;
            }
        }
    } else {
        $dt = array();
        $dt2 = LON_requests::ComputePayments($RequestID, $dt);
        $index = 0;
        $ComputeRecord = $dt2[$index++];
        $days = 0;
        for ($i = 0; $i < count($dt); $i++) {
            if ($dt[$i]["InstallmentID"] < $InstallmentID) {
                while ($ComputeRecord["InstallmentID"] == $dt[$i]["InstallmentID"]) {
                    $ComputeRecord = $dt2[++$index];
                }
                continue;
            }
            $remain = 0;
            while ($ComputeRecord["InstallmentID"] == $dt[$i]["InstallmentID"]) {
                $remain = $ComputeRecord["remainder"];
                $ComputeRecord = $index + 1 < count($dt2) ? $dt2[++$index] : null;
            }
            $obj = new LON_installments();
            $obj->InstallmentID = $dt[$i]["InstallmentID"];
            $obj->IsDelayed = "YES";
            if (!$obj->EditInstallment($pdo)) {
                $pdo->rollBack();
                echo Response::createObjectiveResponse(false, "1");
                die;
            }
            //...........................................
            if ($days == 0) {
                $newDate = DateModules::shamsi_to_miladi($newDate, "-");
                $days = DateModules::GDateMinusGDate($newDate, $dt[$i]["InstallmentDate"]);
            }
            $obj = new LON_installments();
            $obj->RequestID = $RequestID;
            $obj->InstallmentDate = DateModules::AddToGDate($dt[$i]["InstallmentDate"], $days);
            $extraWage = round($remain * $PartObj->CustomerWage * $days / 36500);
            $obj->InstallmentAmount = $dt[$i]["InstallmentAmount"] * 1 + $extraWage;
            if (!$obj->AddInstallment($pdo)) {
                $pdo->rollBack();
                echo Response::createObjectiveResponse(false, "2");
                die;
            }
        }
    }
    if (ExceptionHandler::GetExceptionCount() > 0) {
        $pdo->rollBack();
        print_r(ExceptionHandler::PopAllExceptions());
        echo Response::createObjectiveResponse(false, "");
        die;
    }
    $pdo->commit();
    echo Response::createObjectiveResponse(true, "");
    die;
}
开发者ID:jafarkhani,项目名称:rtfund,代码行数:89,代码来源:request.data.php

示例10: RegisterWarrantyDoc

function RegisterWarrantyDoc($ReqObj, $WageCost, $BankTafsili, $AccountTafsili, $Block_CostID, $DocID, $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;
    }
    //------------------- compute wage ------------------
    $days = DateModules::GDateMinusGDate($ReqObj->EndDate, $ReqObj->StartDate);
    //if(DateModules::YearIsLeap($CycleID));
    $days -= 1;
    $TotalWage = round($days * $ReqObj->amount * 0.9 * $ReqObj->wage / 36500) + $ReqObj->RegisterAmount * 1;
    $years = SplitYears(DateModules::miladi_to_shamsi($ReqObj->StartDate), DateModules::miladi_to_shamsi($ReqObj->EndDate), $TotalWage);
    //--------------- check pasandaz remaindar -----------------
    $dt = PdoDataAccess::runquery("select sum(CreditorAmount-DebtorAmount) remain\r\n\t\tfrom ACC_DocItems join ACC_docs using(DocID) where CycleID=? AND CostID=?\r\n\t\t\tAND TafsiliType=? AND TafsiliID=? AND BranchID=?", array($CycleID, $CostCode_pasandaz, TAFTYPE_PERSONS, $PersonTafsili, $ReqObj->BranchID));
    if ($WageCost == "209-10" && $dt[0][0] * 1 < $ReqObj->amount * 0.1) {
        ExceptionHandler::PushException("مانده حساب پس انداز مشتری کمتر از 10% مبلغ ضمانت نامه می باشد");
        return false;
    }
    if ($WageCost == "209-10" && $dt[0][0] * 1 < $ReqObj->amount * 0.1 + $TotalWage) {
        ExceptionHandler::PushException("مانده حساب پس انداز مشتری کمتر از مبلغ کارمزد می باشد");
        return false;
    }
    if ($ReqObj->IsBlock == "YES") {
        if ($Block_CostID != "" && $Block_CostID != $CostCode_pasandaz) {
            $dt = PdoDataAccess::runquery("select sum(CreditorAmount-DebtorAmount) remain\r\n\t\t\tfrom ACC_DocItems join ACC_docs using(DocID) where CycleID=? AND CostID=?\r\n\t\t\t\tAND TafsiliType=? AND TafsiliID=? AND BranchID=?", array($CycleID, $Block_CostID, TAFTYPE_PERSONS, $PersonTafsili, $ReqObj->BranchID));
        }
        $amount = $ReqObj->amount * 1;
        if ($WageCost == "209-10") {
            $amount += $ReqObj->amount * 0.1 + $TotalWage;
        }
        if ($dt[0][0] * 1 < $amount) {
            ExceptionHandler::PushException("مانده حساب انتخابی جهت بلوکه کمتر از مبلغ ضمانت نامه می باشد");
            return false;
        }
    }
    //---------------- add doc header --------------------
    if ($DocID == null) {
        $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;
        $DocObj->description = "ضمانت نامه " . $ReqObj->_TypeDesc . " به شماره " . $ReqObj->RequestID . " به نام " . $ReqObj->_fullname;
        if (!$DocObj->Add($pdo)) {
            ExceptionHandler::PushException("خطا در ایجاد سند");
            return false;
        }
    } else {
        $DocObj = new ACC_docs($DocID);
    }
    //----------------- add Doc items ------------------------
    $itemObj = new ACC_DocItems();
    $itemObj->DocID = $DocObj->DocID;
    $itemObj->TafsiliType = TAFTYPE_PERSONS;
    $itemObj->TafsiliID = $PersonTafsili;
    $itemObj->SourceType = DOCTYPE_WARRENTY;
    $itemObj->SourceID = $ReqObj->RequestID;
    $itemObj->SourceID2 = $ReqObj->ReqVersion;
    $itemObj->locked = "YES";
    $itemObj->CostID = $CostCode_warrenty;
    $itemObj->DebtorAmount = $ReqObj->amount;
    $itemObj->CreditorAmount = 0;
    if (!$itemObj->Add($pdo)) {
        ExceptionHandler::PushException("خطا در ثبت ردیف ضمانت نامه");
        return false;
    }
    unset($itemObj->ItemID);
    $itemObj->CostID = $CostCode_warrenty_commitment;
    $itemObj->DebtorAmount = 0;
    $itemObj->CreditorAmount = $ReqObj->amount;
    if (!$itemObj->Add($pdo)) {
        ExceptionHandler::PushException("خطا در ثبت ردیف تعهد ضمانت نامه");
        return false;
    }
    //------------------- compute wage -----------------------
    $curYear = substr(DateModules::miladi_to_shamsi($ReqObj->StartDate), 0, 4) * 1;
    foreach ($years as $Year => $amount) {
        if ($amount == 0) {
            continue;
        }
        $YearTafsili = FindTafsiliID($Year, TAFTYPE_YEARS);
//.........这里部分代码省略.........
开发者ID:jafarkhani,项目名称:rtfund,代码行数:101,代码来源:import.data.php

示例11: ComputePaymentsBaseOnInstallment

 private static function ComputePaymentsBaseOnInstallment($RequestID, &$installments, $pdo = null)
 {
     $returnArr = array();
     $pays = PdoDataAccess::runquery("\r\n\t\t\tselect substr(p.PayDate,1,10) PayDate, sum(PayAmount) PayAmount, sum(PayAmount) FixPayAmount\r\n\t\t\t\tfrom LON_BackPays p\r\n\t\t\t\tleft join ACC_IncomeCheques i using(IncomeChequeID)\r\n\t\t\t\tleft join BaseInfo bi on(bi.TypeID=6 AND bi.InfoID=p.PayType)\r\n\t\t\t\twhere RequestID=? AND \r\n\t\t\t\t\tif(p.PayType=" . BACKPAY_PAYTYPE_CHEQUE . ",i.ChequeStatus=" . INCOMECHEQUE_VOSUL . ",1=1)\r\n\r\n\t\t\t\tgroup by substr(PayDate,1,10)\r\n\t\t\t\torder by substr(PayDate,1,10)", array($RequestID), $pdo);
     $PayRecord = count($pays) == 0 ? null : $pays[0];
     $payIndex = 1;
     $Forfeit = 0;
     for ($i = 0; $i < count($installments); $i++) {
         if ($installments[$i]["IsDelayed"] == "YES") {
             continue;
         }
         $forfeitDays = 0;
         $installments[$i]["CurForfeitAmount"] = 0;
         $installments[$i]["ForfeitAmount"] = 0;
         $installments[$i]["ForfeitDays"] = 0;
         $installments[$i]["remainder"] = 0;
         $installments[$i]["FixPayAmount"] = 0;
         $installments[$i]["PayAmount"] = 0;
         $installments[$i]["UsedPayAmount"] = 0;
         $installments[$i]["PayDate"] = '';
         if ($PayRecord == null) {
             $installments[$i]["TotalRemainder"] = $i == 0 ? 0 : $installments[$i - 1]["TotalRemainder"];
             $ToDate = DateModules::Now();
             $amount = $installments[$i]["InstallmentAmount"];
             $forfeitDays = DateModules::GDateMinusGDate($ToDate, $installments[$i]["InstallmentDate"]);
             $CurForfeit = round($amount * $installments[$i]["ForfeitPercent"] * $forfeitDays / 36500);
             if ($installments[$i]["InstallmentDate"] < $ToDate) {
                 $installments[$i]["ForfeitDays"] = $forfeitDays;
                 $Forfeit += $CurForfeit;
                 $installments[$i]["ForfeitAmount"] = $Forfeit;
                 $installments[$i]["CurForfeitAmount"] = $CurForfeit;
                 $installments[$i]["remainder"] = $amount;
                 $installments[$i]["TotalRemainder"] += $amount + $CurForfeit;
             } else {
                 $installments[$i]["ForfeitDays"] = 0;
                 $installments[$i]["CurForfeitAmount"] = 0;
                 $installments[$i]["ForfeitAmount"] = $Forfeit;
                 $installments[$i]["remainder"] = $amount;
                 $installments[$i]["TotalRemainder"] += $amount;
             }
             $returnArr[] = $installments[$i];
             continue;
         } else {
             $installments[$i]["TotalRemainder"] = 0;
         }
         $remainder = $installments[$i]["InstallmentAmount"];
         $StartDate = $installments[$i]["InstallmentDate"];
         while (true) {
             $ToDate = $PayRecord == null ? DateModules::Now() : $PayRecord["PayDate"];
             if ($PayRecord != null) {
                 $installments[$i]["FixPayAmount"] = $PayRecord["FixPayAmount"] * 1;
                 $installments[$i]["PayAmount"] = $PayRecord["PayAmount"] * 1;
                 $installments[$i]["UsedPayAmount"] = $PayRecord["PayAmount"] * 1;
                 $installments[$i]["PayDate"] = $PayRecord["PayDate"];
             } else {
                 $installments[$i]["FixPayAmount"] = 0;
                 $installments[$i]["PayAmount"] = 0;
                 $installments[$i]["UsedPayAmount"] = 0;
                 $installments[$i]["PayDate"] = DateModules::Now();
             }
             $forfeitDays = DateModules::GDateMinusGDate($ToDate, $StartDate);
             $CurForfeit = round($remainder * $installments[$i]["ForfeitPercent"] * $forfeitDays / 36500);
             if ($StartDate < $ToDate) {
                 $installments[$i]["ForfeitDays"] = $forfeitDays;
                 $installments[$i]["CurForfeitAmount"] = $CurForfeit;
                 $Forfeit += $CurForfeit;
             }
             if ($PayRecord == null) {
                 $installments[$i]["TotalRemainder"] += $CurForfeit;
                 $installments[$i]["remainder"] = $remainder;
                 $installments[$i]["ForfeitAmount"] = $Forfeit;
                 $returnArr[] = $installments[$i];
                 break;
             }
             if ($remainder <= $PayRecord["PayAmount"] * 1) {
                 $PayRecord["PayAmount"] = $PayRecord["PayAmount"] * 1 - $remainder;
                 $installments[$i]["UsedPayAmount"] = $remainder;
                 $remainder = 0;
                 $installments[$i]["TotalRemainder"] = $Forfeit;
                 $installments[$i]["remainder"] = 0;
                 $installments[$i]["ForfeitAmount"] = $Forfeit;
                 if ($PayRecord["PayAmount"] == 0) {
                     $StartDate = max($PayRecord["PayDate"], $installments[$i]["InstallmentDate"]);
                     $PayRecord = $payIndex < count($pays) ? $pays[$payIndex++] : null;
                 }
                 $returnArr[] = $installments[$i];
                 break;
             }
             $remainder = $remainder - $PayRecord["PayAmount"] * 1;
             $StartDate = max($PayRecord["PayDate"], $installments[$i]["InstallmentDate"]);
             $installments[$i]["TotalRemainder"] = $remainder + $Forfeit;
             $installments[$i]["remainder"] = $remainder;
             $installments[$i]["ForfeitAmount"] = $Forfeit;
             $PayRecord = $payIndex < count($pays) ? $pays[$payIndex++] : null;
             $returnArr[] = $installments[$i];
         }
     }
     if ($Forfeit > 0) {
         while (true) {
             if ($PayRecord["PayAmount"] > 0) {
//.........这里部分代码省略.........
开发者ID:jafarkhani,项目名称:rtfund,代码行数:101,代码来源:request.class.php


注:本文中的DateModules::GDateMinusGDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。