9namespace Bitrix\Sale\Location\Util;
40 $this->time = (int)
$options[
'INITIAL_TIME'];
44 $this->useLock = (bool)(
$options[
'USE_LOCK'] ??
null);
54 $this->
logMessage(
'#############################',
false);
74 $ss = (int)(
$params[
'STEP_SIZE'] ?? 0);
79 $type = static::CALLBACK_TYPE_MANUAL;
82 $beforeCallback = (string)(
$params[
'ON_BEFORE_CALLBACK'] ??
'');
83 if ($beforeCallback ===
'')
85 $beforeCallback =
false;
87 $afterCallback = (string)(
$params[
'ON_AFTER_CALLBACK'] ??
'');
88 if ($afterCallback ===
'')
90 $afterCallback =
false;
94 'STEP_SIZE' => $ss ?: 1,
95 'PERCENT' => (int)(
$params[
'PERCENT'] ?? 0),
99 'CALLBACK' =>
$params[
'CALLBACK'],
100 'SUBPERCENT_CALLBACK' =>
$params[
'SUBPERCENT_CALLBACK'] ??
null,
101 'ON_BEFORE_CALLBACK' => $beforeCallback,
102 'ON_AFTER_CALLBACK' => $afterCallback,
104 $this->stagesByCode[
$params[
'CODE']] =& $this->stages[
count($this->stages) - 1];
109 if(!isset($_SESSION[$this->sessionKey][
'STAGE']))
112 if(!isset($_SESSION[$this->sessionKey][
'STEP']))
115 if(!isset($_SESSION[$this->sessionKey][
'DATA']))
128 $this->data =
array();
143 if($this->stage == 0 && $this->step == 0)
147 if(static::DEBUG_MODE)
150 if(!file_exists($logDir))
151 mkdir($logDir, 755,
true);
153 $this->
logMessage(
'PROCESS STARTED, STAGE '.$this->stages[0][
'CODE']);
159 if(!isset($this->stages[$this->stage]))
162 if(self::JUST_SHOW_STAGES)
168 if($this->stages[
$stage][
'ON_BEFORE_CALLBACK'] !=
false)
169 call_user_func(
array($this, $this->stages[
$stage][
'ON_BEFORE_CALLBACK']));
171 if($this->stages[$this->stage][
'TYPE'] == static::CALLBACK_TYPE_MANUAL)
172 call_user_func(
array($this, $this->stages[$this->stage][
'CALLBACK']));
173 elseif($this->stages[$this->stage][
'TYPE'] == static::CALLBACK_TYPE_QUOTA)
177 $result = call_user_func(
array($this, $this->stages[$this->stage][
'CALLBACK']));
188 if($this->stages[
$stage][
'ON_AFTER_CALLBACK'] !=
false)
189 call_user_func(
array($this, $this->stages[
$stage][
'ON_AFTER_CALLBACK']));
211 if(!isset($this->stagesByCode[
$code]))
214 if(($stepSize = intval($stepSize)) <= 0)
217 $this->stagesByCode[
$code][
'STEP_SIZE'] = $stepSize;
226 if ($this->stage <
count($this->stages))
228 $stageCode = $this->stages[
$this->stage][
'CODE'] ??
'UNDEFINED for '.$this->stage;
232 $stageCode =
'FINAL';
236 '### NEXT STAGE >>> ' . $stageCode
256 $stageIndex = $this->stagesByCode[
$code][
'ORDER'];
258 if($currIndex == $stageIndex)
return true;
261 return $currIndex > $stageIndex;
263 return $currIndex < $stageIndex;
280 foreach($this->stages as $sId =>
$info)
315 return $this->stagesByCode[
$code];
335 if (is_numeric($sNum))
337 $stage = $this->stages[$sNum][
'PERCENT'] ?? 0;
341 $stage = $this->stagesByCode[$sNum][
'PERCENT'] ?? 0;
364 $percent = $this->stage > 0 ? $this->stages[$this->stage - 1][
'PERCENT'] : 0;
367 $cb = (string)($this->stages[$this->stage][
'SUBPERCENT_CALLBACK'] ??
'');
368 if ($cb !==
'' && method_exists($this, $cb))
370 $addit = $this->$cb();
373 return $percent + $addit;
378 if(!$range)
return 0;
385 if(!$done || !$total)
389 $part = round($pRange * ($done / $total));
391 return $part >= $pRange ? $pRange : $part;
408 $this->timeLimit = max(
$timeLimit, static::MIN_TIME_LIMIT);
414 return $this->data[
'memory_peak'];
419 if (!isset($this->data[
'process_time']))
421 $this->data[
'process_time'] = time();
427 $mp = memory_get_peak_usage(
false);
429 if (!isset($this->data[
'memory_peak']))
431 $this->data[
'memory_peak'] = $mp;
435 if ($this->data[
'memory_peak'] < $mp)
437 $this->data[
'memory_peak'] = $mp;
450 if(!
Main\
IO\Directory::isDirectoryExists($logDir))
460 return $_SERVER[
'DOCUMENT_ROOT'].
'/'.str_replace(
'%BX_ROOT%',
BX_ROOT, self::DEBUG_FOLDER);
465 return $this->
getLogFileDir().str_replace(
'%SESSION_KEY%', $this->sessionKey, self::DEBUG_FILE);
470 if(!static::DEBUG_MODE || !mb_strlen(
$message))
482 $this->
logMessage(
'MEMORY USAGE: '.(memory_get_usage(
false) / (1024 * 1024)).
' MB',
false);
499 return $this->
getLogFileDir().str_replace(
'%SESSION_KEY%', $this->sessionKey, self::LOCK_FILE);
516 if(file_exists($file))
536 return time() - $this->data[
'process_time'];
556 $h = floor(
$time / 3600);
557 $m = floor((
$time - $h * 3600) / 60);
558 $s =
$time - $h * 3600 - $m * 60;
560 if(mb_strlen($m) == 1)
563 if(mb_strlen($s) == 1)
566 return $h.
':'.$m.
':'.$s;
571 return '['.date(
'H:i:s').
']';
608 $elem = current($from);
612 $block[
$code] = $elem;
static createDirectory($path)
static putFileContents($path, $data, $flags=self::REWRITE)
getStagePercent($sNum=false)
Percentage.
getSubPercentByTotalAndDone($total, $done=0)
const CALLBACK_TYPE_QUOTA
const CALLBACK_TYPE_MANUAL
stageCompare($code, $way)
setStepSize($code, $stepSize)
Staging.
getPercentFromToCurrent($codeFrom)
__construct($options=array())
logMessage($message='', $addTimeStamp=true)
onAfterPerformIteration()
getHitTime()
Diagnostics tools.
getPercentBetween($codeFrom, $codeTo)
onBeforePerformIteration()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']