Ejemplo n.º 1
0
	/**
	 * Extends the XML invoice address in params
	 *
	 * @param  SimpleXMLElement     $param
	 * @param  PluginTable          $pluginObject
	 * @param  cbpaidPaymentBasket  $paymentBasket  (the data being displayed)
	 * @param  boolean              $isSaving
	 * @return SimpleXMLElement
	 */
	public function onxmlBeforeCbSubsDisplayOrSaveInvoice( /** @noinspection PhpUnusedParameterInspection */ $param, $pluginObject, $paymentBasket, $isSaving ) {
		global $_CB_framework, $_PLUGINS;

		$paymentItems			=	$paymentBasket->loadPaymentItems();
		$taxableTotalizers		=	$paymentBasket->loadPaymentTotalizers();

		$_PLUGINS->loadPluginGroup( 'user/plug_cbpaidsubscriptions/plugin/cbsubstax/validations', null, ( $_CB_framework->getUi() == 2 ? 0 : 1 ) );

		$taxRulesRates				=	cbpaidPaymentTotalizer_salestax::getApplicableRatesWithoutBusinessCheck( $paymentBasket, $paymentItems, $taxableTotalizers );
		$fromXml					=	array();
		foreach ( $taxRulesRates as $AllTaxRates ) {
			foreach ( $AllTaxRates as $taxRate ) {
				//$taxRate	= NEW cbpaidsalestaxTotalizertype();

				$business_check		=	$taxRate->business_check;
				if ( $business_check ) {
					$absoluteValidationsPath	=	$_CB_framework->getCfg('absolute_path') . '/'. $_PLUGINS->getPluginRelPath( $pluginObject ) . '/plugin/cbsubstax/validations/' . $business_check;
					$valphp		=	$absoluteValidationsPath . '/validation.php';
					if ( is_readable( $valphp ) ) {
						/** @noinspection PhpIncludeInspection */
						include_once $valphp;
						// $className	=	'cbpaidValidate_' . $tax->business_check;
					}
					$fromFile		=	$absoluteValidationsPath . '/xml/edit.invoice.xml';
					if ( is_readable( $fromFile ) ) {
						$fromRoot	=	new SimpleXMLElement( $fromFile, LIBXML_NONET | ( defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0 ), true );
						$fromXml	=	array_merge( $fromXml, $fromRoot->xpath( '/*/editinvoicevalidationintegration/*' ) );
					}
				}
			}
		}
		return $fromXml;
	}