Example #1
0
 				$arFields = $obEl->getFields();
				$prop = $obEl->GetProperties();
				foreach ( $prop as $code => $data){
					$arFields ["PROPERTY_".strtoupper($code) ] =  $data["VALUE"];
				}
				$arFields["PROPERTIES"] = $prop;
				$values [ $arFields["ID"] ] = $arFields;
			}
			$arProperty["VALUES"] = $values;
			$arResult["PRELOAD_VALUES"]["$ID"] = $arProperty["VALUES"];

		}elseif( $ID == 81 && $arProperty["PROPERTY_TYPE"] == "G" && in_array( $ID , $arParams["PROPERTY_VALUES_PRELOAD"] )){

			include_once( getenv("DOCUMENT_ROOT")."/bitrix/templates/work_copy/class/class_contract.php");
			$arResult["PRELOAD_VALUES"]["$ID"] = IBlockContractHandler::getTOProgrammList();
		}
	}
	
	if ( 
		isset( $arResult["ELEMENT"]) &&
		isset( $arParams["CHOISE_BUTTON"] ) &&
		is_array( $arParams["CHOISE_BUTTON"] ) &&
		(count( $arParams["CHOISE_BUTTON"] ) > 0 ) 
		){
		/* Достаю значения свойства для свойств с выбором */
		
		$arforRequest = array();
		foreach  ( $arParams["CHOISE_BUTTON"] as $propertyID => $Q ){
			$IBlockID = $arResult["PROPERTY_LIST_FULL"][$propertyID]["LINK_IBLOCK_ID"];
			$values = array();
Example #2
0
function FormationName(&$arFields) {
	
	if ( $arFields['IBLOCK_ID'] == 24 ){
		// if iBLOCK_ID SK_CONTRACT
		try{

			global $APPLICATION;
			$include_file = __DIR__ .'/../templates/work_copy/class/class_contract.php';
			include_once ( $include_file );

			$no_errors = IBlockContractHandler::OnBeforeIBlockElementAddHandler( $arFields );

			if( is_array( $no_errors ) != true && $no_errors === true ){
				return true;
			}else{
				$APPLICATION->throwException( implode ("\n", $no_errors ));
				return false;
			}
		}catch( Exception $e ){

			ob_start();
				echo "\n ". __FILE__ ."\n";
				print_r ( $e->getMessage() );
				echo "\n ";
				$toLog = ob_get_contents();
			ob_end_clean();
			AddMessage2Log("$toLog", "my_module_id");
		}
	}elseif( $arFields['IBLOCK_ID'] == 23 ){
		try{
			global $APPLICATION;
			$include_file = __DIR__ .'/../templates/work_copy/class/class_chassis.php';
			include_once ( $include_file );

			$no_errors = IBlockChassisHandler::OnBeforeIBlockElementAddHandler( $arFields );

			if( is_array( $no_errors ) != true && $no_errors === true ){
				return true;
			}else{
				$APPLICATION->throwException( implode ("\n", $no_errors ));
				return false;
			}
		}catch( Exception $e ){
			echo $e->getMessage();
		}
	}elseif( $arFields['IBLOCK_ID'] == 22 ){
		try{

			global $APPLICATION;
			$include_file = __DIR__ .'/../templates/work_copy/class/class_client.php';
			include_once ( $include_file );

			$no_errors = IBlockClientHandler::OnBeforeIBlockElementAddHandler( $arFields );
		
			if( is_array( $no_errors ) != true && $no_errors === true ){
				return true;
			}else{
				$APPLICATION->throwException( implode ("\n", $no_errors ));
				return false;
			}
		}catch( Exception $e ){
			echo $e->getMessage();
		}
	}elseif( $arFields['IBLOCK_ID'] == 6  ){
		try{
			global $USER;
			CModule::IncludeModule('iblock');
			$dbEl = CIBlockElement::GetByID( $arFields["ID"] );
			if( $obEl = $dbEl->GetNextElement() ){

				$CurrentVal = $obEl->GetFields();
				$CurrentVal["PROPERTIES"] = $obEl->GetProperties();
				
				// ob_start();
				// echo "\n ". __FILE__ ."\n";
				// print_r ( $arFields );
				// print_r ( $CurrentVal );
				// echo "\n ";
				// $toLog = ob_get_contents();
				// ob_end_clean();
				// AddMessage2Log("$toLog", __METHOD__ . __LINE__);
				
				$log_mess = "";
				$newService_code = $arFields["PROPERTY_VALUES"][106] [ $CurrentVal ["PROPERTIES"]["service_code"]["PROPERTY_VALUE_ID"] ]["VALUE"];
				if( $CurrentVal ["PROPERTIES"]["service_code"]["VALUE"] !==  $newService_code ){
					$log_mess.= "Значение свойства «". $CurrentVal ["PROPERTIES"]["service_code"]["NAME"]."» изменено ".$CurrentVal["PROPERTIES"]["service_code"]["VALUE"]." => ".$newService_code." ;";
				}
				$newService_price = $arFields["PROPERTY_VALUES"][107] [ $CurrentVal ["PROPERTIES"]["service_price"]["PROPERTY_VALUE_ID"] ]["VALUE"];
				if( $CurrentVal ["PROPERTIES"]["service_price"]["VALUE"] !== $newService_price ){
					$log_mess.= "Значение свойства «". $CurrentVal ["PROPERTIES"]["service_price"]["NAME"]."» изменено ".$CurrentVal["PROPERTIES"]["service_price"]["VALUE"]." => ".$newService_price." ;";
				}
				
				if( $log_mess!="" ){
					CEventLog::Add(array(
						"SEVERITY"=>"SECURITY",
						"AUDIT_TYPE_ID"=>"SERVICE_CALC_ITEM_PRICE_CHANGE",
						"MODULE_ID"=>"IBLOCK",
						"ITEM_ID"=>$arFields["ID"],
						"USER_ID"=>$USER->GetID(),
						"DESCRIPTION"=>"$log_mess",
					));
				}
			}else{
				throw new Exception("Элемент с ID: ".$arFields["ID"]." не найден.");
			}
		}catch( Exception $e ){
				echo $e->getMessage();
		}			
	}
}
		$params = array ( "CURRENT_RUN" => $currentRun, "WASHING" => $with_out_washing, "RUN_AT_YEAR" => $run_at_year,"YEARS_OF_WORK" => $years_of_work );

		try{

			$result ["TO"] = GetTO( $propramTOID, $chId, true, $with_out_washing );
			calcCostTOWorks( $result ["TO"] );
			countTO  ( $result["TO"] , $years_of_work * $run_at_year, $currentRun );
			calcByTo ( $result , $run_at_year, $years_of_work , $currentRun );

		}catch(exception $e){
			$e->getMessage();
		}
	}

//		Если тип контракта «Гарантия+» или «Комплекс» добавляю стоимость DLP в стоимость контракта
		$DLP = IBlockContractHandler::getDLPConditions ( $chId , intval ( $_REQUEST['years_of_work']), $cntrct_transport_task );
	

	/*	Если машин >1 умножаю результат расчета на кол-во машин. */
	setlocale(LC_MONETARY, 'ru_RU');
	if( isset( $_REQUEST["cars"] ) && is_array ( $_REQUEST["cars"] ) && count($_REQUEST["cars"]) > 0 ){
		$k = count( $_REQUEST["cars"] );
		$for_one = $result["RESULTS"];	
		
		foreach ( $result["RESULTS"] as $field => &$val){
			$val = sprintf("%01.2f", $val * $k) ;
		}
	}

	$print = $result["RESULTS"];
	$print["FIRST_TO"] = $result["FIRST_TO"]["NAME"];
Example #4
0
IncludeTemplateLangFile ( getenv('DOCUMENT_ROOT') . SITE_TEMPLATE_PATH . '/lang/ru/sevice_calc.php' );

global $ar_Debug;
$ar_Debug = array("TIMES"=>array(),"OTHER"=>array());


/* include service calculator functions */
require_once ( getenv("DOCUMENT_ROOT").'/bitrix/templates/work_copy/functions/service_calculator/functions.php');
require_once ( getenv("DOCUMENT_ROOT")."/bitrix/templates/work_copy/class/class_contract.php");

if ( CModule::IncludeModule("iblock") ):

	$time_start = microtime(1);
	$arChassis = GetChassis();
	$arProgramTO = IBlockContractHandler::getTOProgrammList();
	$currentRun = 0;
	
	if ( ($programTO = intval($_REQUEST['programTO'] )) > 0 &&
		 ($chId = intval ( $_REQUEST['chassis'] )) > 0 &&
		 ($yw = intval ( $_REQUEST['years_of_work'] ) ) > 0 &&
		 ($ry = intval ( $_REQUEST['run_at_year'] ) ) >0 ){
		 
		$result = array ();
		if( $_REQUEST["chassis-type"] != "new" ){
			$currentRun = intval($_REQUEST["mileage"]);
		}
		
		$with_out_washing = ($_REQUEST["exclude_washing"] == "Y" )? true:false ;
		
		$discount = floatval($_REQUEST["discount"]);
<?php

include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/work_copy/class/CommercialDocx.php";
include getenv("DOCUMENT_ROOT") . "/bitrix/templates/work_copy/class/class_contract.php";
function PrepareContractName($name)
{
    $name = preg_replace('/([^0-9a-z\\/]+)/iu', "", $name);
    $name = preg_replace('/\\//iu', "_", $name);
    return $name;
}
$APPLICATION;
$USER;
$CID = intval($_REQUEST["CONTRACT_ID"]);
//check permission
$bPermission = IBlockContractHandler::CanRead($CID);
if (!$bPermission) {
    $APPLICATION->AuthForm("У вас нет права доступа к данному файлу.");
    exit;
}
$arContract = array();
$arCar = array();
$arDealer = array();
$arClient = array();
try {
    CModule::IncludeModule("iblock");
    $db_contract = CIBlockElement::GetList(array(), array("ID" => $CID, "IBLOCK_ID" => IBLOCK_SK_CONTRACT_ID), false, false, array("IBLOCK_ID", "ID", "DATE_CREATE", "NAME"));
    if ($ob_contract = $db_contract->GetNextElement()) {
        $arContract = $ob_contract->getFields();
        $arContract["PROPERTY"] = $ob_contract->getProperties();
        $db_chassis = CIBlockElement::GetList(array(), array("ID" => $arContract["PROPERTY"]["cntrct_model"]["VALUE"], "IBLOCK_ID" => IBLOCK_SK_CALC_CHASSIS_ID), false, false, array("IBLOCK_ID", "ID", "NAME"));