Merge branch 'sprint/217_25551' into 'master'

* Fix bug#25551,25591,25593

See merge request easycorp/zentaopms!4627
This commit is contained in:
王怡栋
2022-07-22 02:20:54 +00:00
3 changed files with 21 additions and 8 deletions
+19 -6
View File
@@ -157,7 +157,7 @@ class action extends control
$repeatObject = $this->dao->select('*')->from(TABLE_PRODUCT)
->where('id')->ne($oldAction->objectID)
->andWhere("(name = '{$product->name}' and program = {$programID})", true)
->orWhere("code = '{$product->code}'")
->beginIF($product->code)->orWhere("code = '{$product->code}'")->fi()
->markRight(1)
->andWhere('deleted')->eq('0')
->fetch();
@@ -182,13 +182,26 @@ class action extends control
if($repeatObject)
{
$result = preg_match('/_(\d+)$/', $repeatObject->name, $nameMatches);
$replaceName = $result ? preg_replace('/_(\d+)$/', '_' . ($nameMatches[1] + 1), $repeatObject->name) : $repeatObject->name . '_1';
$result = preg_match('/_(\d+)$/', $repeatObject->code, $codeMatches);
$replaceCode = $result ? preg_replace('/_(\d+)$/', '_' . ($codeMatches[1] + 1), $repeatObject->code) : $repeatObject->code . '_1';
$table = $oldAction->objectType == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$object = $oldAction->objectType == 'product' ? $product : $project;
$existNames = $this->dao->select('name')->from($table)->where('name')->like($repeatObject->name . '_%')->fetchPairs();
for($i = 1; $i < 10000; $i ++)
{
$replaceName = $repeatObject->name . '_' . $i;
if(!in_array($replaceName, $existNames)) break;
}
$replaceCode = '';
if($object->code)
{
$existCodes = $this->dao->select('code')->from($table)->where('code')->like($repeatObject->code . '_%')->fetchPairs();
for($i = 1; $i < 10000; $i ++)
{
$replaceCode = $repeatObject->code . '_' . $i;
if(!in_array($replaceCode, $existCodes)) break;
}
}
if($repeatObject->name == $object->name and $repeatObject->code and $repeatObject->code == $object->code)
{
if($confirmChange == 'no') return print(js::confirm(sprintf($this->lang->action->repeatChange, $this->lang->{$oldAction->objectType}->common, $replaceName, $replaceCode), $this->createLink('action', 'undelete', "action={$actionID}&browseType={$browseType}&confirmChange=yes")));
+1 -1
View File
@@ -234,7 +234,7 @@ class program extends control
$this->action->logHistory($actionID, $changes);
}
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browse')));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->session->programList ? $this->session->programList : inLink('browse')));
}
$program = $this->program->getByID($programID);
+1 -1
View File
@@ -43,7 +43,7 @@
<div class="table-empty-tip">
<p>
<span class="text-muted"><?php echo $lang->program->noProgram;?></span>
<?php common::printLink('program', 'create', '', "<i class='icon icon-plus'></i> " . $lang->program->create, '', "class='btn btn-info'");?>
<?php if($status == 'all') common::printLink('program', 'create', '', "<i class='icon icon-plus'></i> " . $lang->program->create, '', "class='btn btn-info'");?>
</p>
</div>
<?php else:?>