Your IP : 18.218.251.50


Current Path : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/a537b/
Upload File :
Current File : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/a537b/propertyvariablecondition.tar

lang/en/propertyvariablecondition.php000064400000000104147737246610014115 0ustar00<?
$MESS ['BPPVC_EMPTY_CONDITION'] = "The condition is missing.";
?>lang/en/properties_dialog.php000064400000001131147737246610012330 0ustar00<?
$MESS ['BPFC_PD_ADD'] = "Add Condition";
$MESS ['BPFC_PD_AND'] = "AND";
$MESS ['BPFC_PD_CALENDAR'] = "Calendar";
$MESS ['BPFC_PD_CONDITION'] = "Condition";
$MESS ['BPFC_PD_IN'] = "contains";
$MESS ['BPFC_PD_DELETE'] = "Delete";
$MESS ['BPFC_PD_EQ'] = "equal to";
$MESS ['BPFC_PD_LT'] = "less than";
$MESS ['BPFC_PD_GT'] = "more than";
$MESS ['BPFC_PD_NO'] = "No";
$MESS ['BPFC_PD_NE'] = "not equal to";
$MESS ['BPFC_PD_GE'] = "not less than";
$MESS ['BPFC_PD_LE'] = "not more than";
$MESS ['BPFC_PD_FIELD'] = "Property Or Field";
$MESS ['BPFC_PD_VALUE'] = "Value";
$MESS ['BPFC_PD_YES'] = "Yes";
?>lang/en/.description.php000064400000000202147737246610011214 0ustar00<?
$MESS ['BPPVC_DESCR_DESCR'] = "A condition on a variable or parameter value";
$MESS ['BPPVC_DESCR_NAME'] = "Variable Value";
?>lang/ru/propertyvariablecondition.php000064400000000115147737246610014143 0ustar00<?
$MESS ['BPPVC_EMPTY_CONDITION'] = "Условие не указано";
?>lang/ru/properties_dialog.php000064400000001307147737246610012361 0ustar00<?
$MESS ['BPFC_PD_ADD'] = "Добавить условие";
$MESS ['BPFC_PD_AND'] = "И";
$MESS ['BPFC_PD_CALENDAR'] = "Календарь";
$MESS ['BPFC_PD_CONDITION'] = "Условие";
$MESS ['BPFC_PD_IN'] = "содержит";
$MESS ['BPFC_PD_DELETE'] = "Удалить";
$MESS ['BPFC_PD_EQ'] = "равно";
$MESS ['BPFC_PD_LT'] = "меньше";
$MESS ['BPFC_PD_GT'] = "больше";
$MESS ['BPFC_PD_NO'] = "Нет";
$MESS ['BPFC_PD_NE'] = "не равно";
$MESS ['BPFC_PD_GE'] = "не меньше";
$MESS ['BPFC_PD_LE'] = "не больше";
$MESS ['BPFC_PD_FIELD'] = "Свойство или переменная";
$MESS ['BPFC_PD_VALUE'] = "Значение";
$MESS ['BPFC_PD_YES'] = "Да";
?>lang/ru/.description.php000064400000000254147737246610011247 0ustar00<?
$MESS ['BPPVC_DESCR_DESCR'] = "Значение переменной или параметра";
$MESS ['BPPVC_DESCR_NAME'] = "Значение переменной";
?>lang/de/propertyvariablecondition.php000064400000000115147737246610014105 0ustar00<?
$MESS ['BPPVC_EMPTY_CONDITION'] = "Die Bedingung ist nicht vorhanden.";
?>lang/de/properties_dialog.php000064400000001124147737246610012320 0ustar00<?
$MESS ['BPFC_PD_ADD'] = "Neue Bedingung";
$MESS ['BPFC_PD_AND'] = "AND";
$MESS ['BPFC_PD_CALENDAR'] = "Kalender";
$MESS ['BPFC_PD_CONDITION'] = "Bedingung";
$MESS ['BPFC_PD_IN'] = "enthält";
$MESS ['BPFC_PD_DELETE'] = "Löschen";
$MESS ['BPFC_PD_EQ'] = "ist gleich";
$MESS ['BPFC_PD_LT'] = "weniger";
$MESS ['BPFC_PD_GT'] = "mehr";
$MESS ['BPFC_PD_NO'] = "Nein";
$MESS ['BPFC_PD_NE'] = "ungleich";
$MESS ['BPFC_PD_GE'] = "nicht weniger";
$MESS ['BPFC_PD_LE'] = "nicht mehr";
$MESS ['BPFC_PD_FIELD'] = "Eigenschaft oder Feld";
$MESS ['BPFC_PD_VALUE'] = "Wert";
$MESS ['BPFC_PD_YES'] = "Ja";
?>lang/de/.description.php000064400000000204147737246610011204 0ustar00<?
$MESS ['BPPVC_DESCR_DESCR'] = "Bedingung für die Variable oder Parameterwert";
$MESS ['BPPVC_DESCR_NAME'] = "Variabler Wert";
?>propertyvariablecondition.php000064400000015015147737246610012601 0ustar00<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

class CBPPropertyVariableCondition
	extends CBPActivityCondition
{
	public $condition = null;

	public function __construct($condition)
	{
		$this->condition = $condition;
	}

	public function Evaluate(CBPActivity $ownerActivity)
	{
		if ($this->condition == null || !is_array($this->condition) || count($this->condition) <= 0)
			return true;

		if (!is_array($this->condition[0]))
			$this->condition = array($this->condition);

		$rootActivity = $ownerActivity->GetRootActivity();

		$result = true;
		foreach ($this->condition as $cond)
		{
			if ($rootActivity->IsPropertyExists($cond[0]))
			{
				if (!$this->CheckCondition($rootActivity->{$cond[0]}, $cond[1], $cond[2]))
				{
					$result = false;
					break;
				}
			}
			elseif ($rootActivity->IsVariableExists($cond[0]))
			{
				if (!$this->CheckCondition($rootActivity->GetVariable($cond[0]), $cond[1], $cond[2]))
				{
					$result = false;
					break;
				}
			}
		}

		return $result;
	}

	private function CheckCondition($field, $operation, $value)
	{
		$result = false;

		switch ($operation)
		{
			case ">":
				$result = ($field > $value);
				break;
			case ">=":
				$result = ($field >= $value);
				break;
			case "<":
				$result = ($field < $value);
				break;
			case "<=":
				$result = ($field <= $value);
				break;
			case "!=":
				$result = ($field != $value);
				break;
			default:
				$result = ($field == $value);
		}

		return $result;
	}

	public static function GetPropertiesDialog($documentType, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $defaultValue, $arCurrentValues = null, $formName = "")
	{
		if (count($arWorkflowParameters) <= 0 && count($arWorkflowVariables) <= 0)
			return null;

		$runtime = CBPRuntime::GetRuntime();
		$documentService = $runtime->GetService("DocumentService");
		$arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);

		if (!is_array($arCurrentValues))
		{
			$arCurrentValues = array();
			if (is_array($defaultValue))
			{
				$i = 0;
				foreach ($defaultValue as $value)
				{
					if (strlen($arCurrentValues["variable_condition_count"]) > 0)
						$arCurrentValues["variable_condition_count"] .= ",";
					$arCurrentValues["variable_condition_count"] .= $i;

					$arCurrentValues["variable_condition_field_".$i] = $value[0];
					$arCurrentValues["variable_condition_condition_".$i] = $value[1];
					$arCurrentValues["variable_condition_value_".$i] = $value[2];

					if (array_key_exists($value[0], $arWorkflowParameters))
					{
						if ($arFieldTypes[$arWorkflowParameters[$value[0]]["Type"]]["BaseType"] == "user")
						{
							if (!is_array($arCurrentValues["variable_condition_value_".$i]))
								$arCurrentValues["variable_condition_value_".$i] = array($arCurrentValues["variable_condition_value_".$i]);

							$arCurrentValues["variable_condition_value_".$i] = CBPHelper::UsersArrayToString($arCurrentValues["variable_condition_value_".$i], $arWorkflowTemplate, $documentType);
						}
					}
					elseif (array_key_exists($value[0], $arWorkflowVariables))
					{
						if ($arFieldTypes[$arWorkflowVariables[$value[0]]["Type"]]["BaseType"] == "user")
						{
							if (!is_array($arCurrentValues["variable_condition_value_".$i]))
								$arCurrentValues["variable_condition_value_".$i] = array($arCurrentValues["variable_condition_value_".$i]);

							$arCurrentValues["variable_condition_value_".$i] = CBPHelper::UsersArrayToString($arCurrentValues["variable_condition_value_".$i], $arWorkflowTemplate, $documentType);
						}
					}

					$i++;
				}
			}
		}

		$javascriptFunctions = $documentService->GetJSFunctionsForFields($documentType, "objFieldsPVC", $arWorkflowParameters + $arWorkflowVariables, $arFieldTypes);

		return $runtime->ExecuteResourceFile(
			__FILE__,
			"properties_dialog.php",
			array(
				"arCurrentValues" => $arCurrentValues,
				"arProperties" => $arWorkflowParameters,
				"arVariables" => $arWorkflowVariables,
				"formName" => $formName,
				"arFieldTypes" => $arFieldTypes,
				"javascriptFunctions" => $javascriptFunctions,
			)
		);
	}

	public static function GetPropertiesDialogValues($documentType, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues, &$arErrors)
	{
		$arErrors = array();

		if (!array_key_exists("variable_condition_count", $arCurrentValues) || strlen($arCurrentValues["variable_condition_count"]) <= 0)
		{
			$arErrors[] = array(
				"code" => "",
				"message" => GetMessage("BPPVC_EMPTY_CONDITION"),
			);
			return null;
		}

		$runtime = CBPRuntime::GetRuntime();
		$documentService = $runtime->GetService("DocumentService");
		$arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);

		$arResult = array();

		$arVariableConditionCount = explode(",", $arCurrentValues["variable_condition_count"]);
		foreach ($arVariableConditionCount as $i)
		{
			if (intval($i)."!" != $i."!")
				continue;

			$i = intval($i);

			if (!array_key_exists("variable_condition_field_".$i, $arCurrentValues) || strlen($arCurrentValues["variable_condition_field_".$i]) <= 0)
				continue;

			if (array_key_exists($arCurrentValues["variable_condition_field_".$i], $arWorkflowParameters))
			{
				if ($arFieldTypes[$arWorkflowParameters[$arCurrentValues["variable_condition_field_".$i]]["Type"]]["BaseType"] == "user")
					$arCurrentValues["variable_condition_value_".$i] = CBPHelper::UsersStringToArray($arCurrentValues["variable_condition_value_".$i], $documentType, $ae);
			}
			elseif (array_key_exists($arCurrentValues["variable_condition_field_".$i], $arWorkflowVariables))
			{
				if ($arFieldTypes[$arWorkflowVariables[$arCurrentValues["variable_condition_field_".$i]]["Type"]]["BaseType"] == "user")
					$arCurrentValues["variable_condition_value_".$i] = CBPHelper::UsersStringToArray($arCurrentValues["variable_condition_value_".$i], $documentType, $ae);
			}

			$arResult[] = array(
				$arCurrentValues["variable_condition_field_".$i],
				htmlspecialcharsback($arCurrentValues["variable_condition_condition_".$i]),
				(strlen($arCurrentValues["variable_condition_value_".$i]) > 0 ? $arCurrentValues["variable_condition_value_".$i] : $arCurrentValues["variable_condition_value_".$i."_1"]),
			);
		}

		if (count($arResult) <= 0)
		{
			$arErrors[] = array(
				"code" => "",
				"message" => GetMessage("BPPVC_EMPTY_CONDITION"),
			);
			return null;
		}

		return $arResult;
	}

}
?>properties_dialog.php000064400000022523147737246610011015 0ustar00<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
?>

<?= $javascriptFunctions ?>
<?
$arC = array(
	"=" => GetMessage("BPFC_PD_EQ"),
	">" => GetMessage("BPFC_PD_GT"),
	">=" => GetMessage("BPFC_PD_GE"),
	"<" => GetMessage("BPFC_PD_LT"),
	"<=" => GetMessage("BPFC_PD_LE"),
	"!=" => GetMessage("BPFC_PD_NE"),
	"in" => GetMessage("BPFC_PD_IN"),
);

$arVariableConditionCount = array(1);
if (array_key_exists("variable_condition_count", $arCurrentValues) && strlen($arCurrentValues["variable_condition_count"]) > 0)
	$arVariableConditionCount = explode(",", $arCurrentValues["variable_condition_count"]);

$arCurrentValues["variable_condition_count"] = "";
$bwfvcCounter = 0;
$defaultFieldValue = "";
foreach ($arVariableConditionCount as $i)
{
	if (intval($i)."!" != $i."!")
		continue;

	$i = intval($i);
	if (strlen($arCurrentValues["variable_condition_count"]) > 0)
	{
		$arCurrentValues["variable_condition_count"] .= ",";
		?>
		<tr id="bwfvc_deleterow_tr_<?= $i ?>">
			<td align="right" width="40%"><?= GetMessage("BPFC_PD_AND") ?></td>
			<td align="right" width="60%"><a href="#" onclick="BWFVCDeleteCondition(<?= $i ?>); return false;"><?= GetMessage("BPFC_PD_DELETE") ?></a></td>
		</tr>
		<?
	}
	$arCurrentValues["variable_condition_count"] .= $i;
	if ($i > $bwfvcCounter)
		$bwfvcCounter = $i;
	?>
	<tr>
		<td align="right" width="40%"><?= GetMessage("BPFC_PD_FIELD") ?>:</td>
		<td width="60%">
			<select name="variable_condition_field_<?= $i ?>" onchange="BWFVCChangeFieldType(<?= $i ?>, bwfvc_arFieldTypes[this.options[this.selectedIndex].value], this.options[this.selectedIndex].value, 1)">
				<?
				foreach ($arProperties as $key => $value)
				{
					if (strlen($defaultFieldValue) <= 0)
						$defaultFieldValue = $key;
					?><option value="<?= htmlspecialchars($key) ?>"<?= ($arCurrentValues["variable_condition_field_".$i] == $key) ? " selected" : "" ?>><?= htmlspecialchars($value["Name"]) ?></option><?
				}
				foreach ($arVariables as $key => $value)
				{
					if (strlen($defaultFieldValue) <= 0)
						$defaultFieldValue = $key;
					?><option value="<?= htmlspecialchars($key) ?>"<?= ($arCurrentValues["variable_condition_field_".$i] == $key) ? " selected" : "" ?>><?= htmlspecialchars($value["Name"]) ?></option><?
				}
				?>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right" width="40%"><?= GetMessage("BPFC_PD_CONDITION") ?>:</td>
		<td width="60%">
			<select name="variable_condition_condition_<?= $i ?>">
				<?
				foreach ($arC as $key => $value)
				{
					?><option value="<?= $key ?>"<?= ($arCurrentValues["variable_condition_condition_".$i] == $key) ? " selected" : "" ?>><?= $value ?></option><?
				}
				?>
			</select>
		</td>
	</tr>
	<tr>
		<td align="right" width="40%"><?= GetMessage("BPFC_PD_VALUE") ?>:</td>
		<td width="60%" id="id_td_variable_condition_value_<?= $i ?>">
			<input type="text" name="variable_condition_value_<?= $i ?>" value="<?= htmlspecialchars($arCurrentValues["variable_condition_value_".$i]) ?>">
		</td>
	</tr>
	<?
}
?>
<tr id="bwfvc_addrow_tr">
	<td align="center" colspan="2">
		<?= CAdminCalendar::ShowScript() ?>
		<script language="JavaScript">
		var bwfvc_arFieldTypes = {<?
		$fl = false;
		foreach ($arProperties as $key => $value)
		{
			if ($fl)
				echo ",";
			echo "'".CUtil::JSEscape($key)."':'".CUtil::JSEscape($value["Type"])."'";
			$fl = true;
		}
		foreach ($arVariables as $key => $value)
		{
			if ($fl)
				echo ",";
			echo "'".CUtil::JSEscape($key)."':'".CUtil::JSEscape($value["Type"])."'";
			$fl = true;
		}
		?>};

		var bwfvc_counter = <?= $bwfvcCounter + 1 ?>;

		function BWFVCChangeFieldType(ind, type, field, x)
		{
			var s = "";

			var valueTd = document.getElementById('id_td_variable_condition_value_' + ind);

			var valueOld = "";
			if (document.forms["<?= $formName ?>"]["variable_condition_value_" + ind])
			{
				if (document.forms["<?= $formName ?>"]["variable_condition_value_" + ind].type == "select")
					valueOld = document.forms["<?= $formName ?>"]["variable_condition_value_" + ind].options[document.<?= $formName ?>["field_condition_value_" + ind].selectedIndex].value;
				else
					valueOld = document.forms["<?= $formName ?>"]["variable_condition_value_" + ind].value;
			}

			valueTd.innerHTML = objFieldsPVC.GetGUIFieldEdit(field, valueOld, true, "variable_condition_value_" + ind);
		}

		function BWFVCAddCondition()
		{
			var addrowTr = document.getElementById('bwfvc_addrow_tr');
			var parentAddrowTr = addrowTr.parentNode;

			var cnt = parentAddrowTr.rows.length;
			for (i = 0; i < cnt; i++)
			{
				if (parentAddrowTr.rows[i].id != "bwfvc_addrow_tr")
					continue;

				var newRow = parentAddrowTr.insertRow(i);
				newRow.id = "bwfvc_deleterow_tr_" + bwfvc_counter;
				var newCell = newRow.insertCell(-1);
				newCell.width="40%";
				newCell.align="right";
				newCell.innerHTML = "<?= GetMessage("BPFC_PD_AND") ?>";
				var newCell = newRow.insertCell(-1);
				newCell.width="60%";
				newCell.align="right";
				newCell.innerHTML = '<a href="#" onclick="BWFVCDeleteCondition(' + bwfvc_counter + '); return false;"><?= GetMessage("BPFC_PD_DELETE") ?></a>';

				var newRow = parentAddrowTr.insertRow(i + 1);
				var newCell = newRow.insertCell(-1);
				newCell.width="40%";
				newCell.align="right";
				newCell.innerHTML = "<?= GetMessage("BPFC_PD_FIELD") ?>:";
				var newCell = newRow.insertCell(-1);
				newCell.width="60%";
				var newSelect = document.createElement("select");
				newSelect.setAttribute('bwfvc_counter', bwfvc_counter);
				newSelect.onchange = function(){BWFVCChangeFieldType(this.getAttribute("bwfvc_counter"), bwfvc_arFieldTypes[this.options[this.selectedIndex].value], this.options[this.selectedIndex].value), 2};
				newSelect.name = "variable_condition_field_" + bwfvc_counter;
				<?
				$i = -1;
				foreach ($arProperties as $key => $value)
				{
					$i++;
					?>newSelect.options[<?= $i ?>] = new Option("<?= htmlspecialchars($value["Name"]) ?>", "<?= htmlspecialchars($key) ?>");
					<?
				}
				foreach ($arVariables as $key => $value)
				{
					$i++;
					?>newSelect.options[<?= $i ?>] = new Option("<?= htmlspecialchars($value["Name"]) ?>", "<?= htmlspecialchars($key) ?>");
					<?
				}
				?>
				newCell.appendChild(newSelect);

				var newRow = parentAddrowTr.insertRow(i + 2);
				var newCell = newRow.insertCell(-1);
				newCell.width="40%";
				newCell.align="right";
				newCell.innerHTML = "<?= GetMessage("BPFC_PD_CONDITION") ?>:";
				var newCell = newRow.insertCell(-1);
				newCell.width="60%";
				var newSelect = document.createElement("select");
				newSelect.name = "variable_condition_condition_" + bwfvc_counter;
				<?
				$i = -1;
				foreach ($arC as $key => $value)
				{
					$i++;
					?>newSelect.options[<?= $i ?>] = new Option("<?= htmlspecialchars($value) ?>", "<?= htmlspecialchars($key) ?>");
					<?
				}
				?>
				newCell.appendChild(newSelect);

				var newRow = parentAddrowTr.insertRow(i + 3);
				var newCell = newRow.insertCell(-1);
				newCell.width="40%";
				newCell.align="right";
				newCell.innerHTML = "<?= GetMessage("BPFC_PD_VALUE") ?>:";
				var newCell = newRow.insertCell(-1);
				newCell.width="60%";
				newCell.id="id_td_variable_condition_value_" + bwfvc_counter;
				var newSelect = document.createElement("input");
				newSelect.type = "text";
				newSelect.name = "variable_condition_value_" + bwfvc_counter;
				newCell.appendChild(newSelect);

				BWFVCChangeFieldType(bwfvc_counter, bwfvc_arFieldTypes['<?= CUtil::JSEscape($defaultFieldValue) ?>'], '<?= CUtil::JSEscape($defaultFieldValue) ?>', 0);

				document.getElementById('id_variable_condition_count').value += "," + bwfvc_counter;
				bwfvc_counter++;

				break;
			}
		}

		function BWFVCDeleteCondition(ind)
		{
			var deleterowTr = document.getElementById('bwfvc_deleterow_tr_' + ind);
			var parentDeleterowTr = deleterowTr.parentNode;

			var cnt = parentDeleterowTr.rows.length;
			for (i = 0; i < cnt; i++)
			{
				if (parentDeleterowTr.rows[i].id != 'bwfvc_deleterow_tr_' + ind)
					continue;

				parentDeleterowTr.deleteRow(i + 3);
				parentDeleterowTr.deleteRow(i + 2);
				parentDeleterowTr.deleteRow(i + 1);
				parentDeleterowTr.deleteRow(i);

				var value = document.getElementById('id_variable_condition_count').value;
				var ar = value.split(",");
				value = "";
				for (j = 0; j < ar.length; j++)
				{
					if (ar[j] != ind)
					{
						if (value.length > 0)
							value += ",";
						value += ar[j];
					}
				}
				document.getElementById('id_variable_condition_count').value = value;

				break;
			}
		}

		<?
		foreach ($arVariableConditionCount as $i)
		{
			if (intval($i)."!" != $i."!")
				continue;

			$i = intval($i);
			$v = (array_key_exists("variable_condition_field_".$i, $arCurrentValues) ? $arCurrentValues["variable_condition_field_".$i] : $defaultFieldValue);
			?>
			BWFVCChangeFieldType(<?= $i ?>, bwfvc_arFieldTypes['<?= CUtil::JSEscape($v) ?>'], '<?= CUtil::JSEscape($v) ?>', 3);
			<?
		}
		?>
		</script>
		<input type="hidden" name="variable_condition_count" id="id_variable_condition_count" value="<?= htmlspecialchars($arCurrentValues["variable_condition_count"]) ?>">
		<a href="#" onclick="BWFVCAddCondition(); return false;"><?= GetMessage("BPFC_PD_ADD") ?></a>
	</td>
</tr>