MP_Reports::get_all_calc( array $arr )

Get all calculations per period.


Parameters Parameters

$arr

(array) (Required) parameters


Top ↑

Return Return

(array)


Top ↑

Source Source

File: mortgage-platform/Inc/Callback/MP_Reports.php

	public function get_all_calc( $arr ) {

		$leads = $this->get_id_for_period( $arr, array( MortgagePlatform::$lead, MortgagePlatform::$abandoned_lead ) );

		$calc = array();
		if ( $leads ) {
			foreach ( $leads as $lead ) {

				if ( get_post_type( $lead ) === MortgagePlatform::$lead ) {

					$calc = $this->get_calc( $lead, __( 'Lead', 'mortgage_platform' ) );

					/*$l_lead    = __( 'Lead', 'mortgage_platform' );
					$lead_calc = get_post_meta( $lead, MortgagePlatform::$prefix . 'lead_searches' );
					$l_calc    = [];
					foreach ( $lead_calc as $item ) {
						if ( ! empty( $item['loanAmount'] ) && $item['loanAmount'] != '0' &&
							 ! empty( $item['interest'] ) && $item['interest'] != '0' &&
							 ! empty( $item['downPayment'] ) && $item['downPayment'] != '0' &&
							 ! empty( $item['term'] ) && $item['term'] != '0'
						) {
							$loanAmount  = (int) preg_replace( "/[^0-9]/", '', $item['loanAmount'] );
							$interest    = (int) preg_replace( "/[^0-9]/", '', $item['interest'] );
							$downPayment = (int) preg_replace( "/[^0-9]/", '', $item['downPayment'] );
							$term        = $item['term'];

							$l_calc = array( $loanAmount, $interest, $downPayment, $term );

							array_push( $calc, array( $l_lead, $l_calc ) );
						}
					}*/
				}

				if ( get_post_type( $lead ) === MortgagePlatform::$abandoned_lead ) {

					$calc = $this->get_calc( $lead, __( 'Abandoned Lead', 'mortgage_platform' ) );
					/*$ab_lead      = __( 'Abandoned Lead', 'mortgage_platform' );
					$ab_lead_calc = get_post_meta( $lead, MortgagePlatform::$prefix . 'abandoned_lead_searches' );
					$ab_calc      = [];
					foreach ( $ab_lead_calc as $ab_item ) {
						if ( ! empty( $ab_item['loanAmount'] ) && $ab_item['loanAmount'] != '0' &&
							 ! empty( $ab_item['interest'] ) && $ab_item['interest'] != '0' &&
							 ! empty( $ab_item['downPayment'] ) && $ab_item['downPayment'] != '0' &&
							 ! empty( $ab_item['term'] ) && $ab_item['term'] != '0'
						) {
							$ab_loanAmount  = (int) preg_replace( "/[^0-9]/", '', $ab_item['loanAmount'] );
							$ab_interest    = (int) preg_replace( "/[^0-9]/", '', $ab_item['interest'] );
							$ab_downPayment = (int) preg_replace( "/[^0-9]/", '', $ab_item['downPayment'] );
							$ab_term        = $ab_item['term'];

							$ab_calc = array( $ab_loanAmount, $ab_interest, $ab_downPayment, $ab_term );

							array_push( $calc, array( $ab_lead, $ab_calc ) );
						}
					}*/
				}
			}
		}

		return $calc;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.