diff --git a/module/execution/model.php b/module/execution/model.php index 3ed0a6c0ed..4d412450aa 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -354,6 +354,11 @@ class executionModel extends model $this->lang->project->name = $this->lang->execution->name; $this->lang->project->code = $this->lang->execution->code; } + else + { + $this->lang->project->name = $this->lang->execution->execName; + $this->lang->project->code = $this->lang->execution->execCode; + } $this->dao->insert(TABLE_EXECUTION)->data($sprint) ->autoCheck($skipFields = 'begin,end') @@ -361,7 +366,7 @@ class executionModel extends model ->checkIF($sprint->begin != '', 'begin', 'date') ->checkIF($sprint->end != '', 'end', 'date') ->checkIF($sprint->end != '', 'end', 'ge', $sprint->begin) - ->checkIF(!empty($sprint->code), 'code', 'unique') + ->checkIF(!empty($sprint->code), 'code', 'unique', "type in ('sprint','stage')") ->exec(); /* Add the creater to the team. */ @@ -499,6 +504,7 @@ class executionModel extends model foreach(explode(',', $this->config->execution->edit->requiredFields) as $field) { if(isset($this->lang->execution->$field)) $this->lang->project->$field = $this->lang->execution->$field; + if($oldExecution->type == 'stage' and $field == 'name') $this->lang->project->name = str_replace($this->lang->executionCommon, $this->lang->project->stage, $this->lang->project->name); } /* Update data. */ @@ -508,7 +514,7 @@ class executionModel extends model ->checkIF($execution->begin != '', 'begin', 'date') ->checkIF($execution->end != '', 'end', 'date') ->checkIF($execution->end != '', 'end', 'ge', $execution->begin) - ->check('code', 'unique', "id != $executionID and code != '' and deleted = '0'") + ->checkIF(!empty($execution->code), 'code', 'unique', "id != $executionID and type in ('sprint','stage')") ->where('id')->eq($executionID) ->limit(1) ->exec(); @@ -639,7 +645,7 @@ class executionModel extends model ->checkIF($execution->begin != '', 'begin', 'date') ->checkIF($execution->end != '', 'end', 'date') ->checkIF($execution->end != '', 'end', 'gt', $execution->begin) - ->checkIF($execution->code != '', 'code', 'unique', "id NOT " . helper::dbIN($data->executionIDList) . " and deleted='0'") + ->checkIF(!empty($execution->code), 'code', 'unique', "id NOT " . helper::dbIN($data->executionIDList) . " and type in ('sprint','stage')") ->where('id')->eq($executionID) ->limit(1) ->exec(); diff --git a/module/product/config.php b/module/product/config.php index c5f8291efc..ba9339760b 100644 --- a/module/product/config.php +++ b/module/product/config.php @@ -85,8 +85,8 @@ $config->product->search['params']['lastEditedDate'] = array('operator' => '=', $config->product->create = new stdclass(); $config->product->edit = new stdclass(); -$config->product->create->requiredFields = 'name'; -$config->product->edit->requiredFields = 'name'; +$config->product->create->requiredFields = 'name,code'; +$config->product->edit->requiredFields = 'name,code'; $config->product->editor = new stdclass(); $config->product->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/product/model.php b/module/product/model.php index e9e891a509..7f5169436c 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -555,7 +555,7 @@ class productModel extends model $this->dao->insert(TABLE_PRODUCT)->data($product)->autoCheck() ->batchCheck($this->config->product->create->requiredFields, 'notempty') ->checkIF(!empty($product->name), 'name', 'unique') - ->checkIF(!empty($product->name), 'code', 'unique') + ->checkIF(!empty($product->code), 'code', 'unique') ->exec(); if(!dao::isError()) @@ -625,8 +625,8 @@ class productModel extends model $product = $this->loadModel('file')->processImgURL($product, $this->config->product->editor->edit['id'], $this->post->uid); $this->dao->update(TABLE_PRODUCT)->data($product)->autoCheck() ->batchCheck($this->config->product->edit->requiredFields, 'notempty') + ->checkIF(!empty($product->code), 'code', 'unique', "id != $productID") ->check('name', 'unique', "id != $productID and deleted = '0'") - ->check('code', 'unique', "id != $productID and deleted = '0'") ->where('id')->eq($productID) ->exec(); diff --git a/module/product/view/create.html.php b/module/product/view/create.html.php index 4ba5d04185..845e7267f4 100644 --- a/module/product/view/create.html.php +++ b/module/product/view/create.html.php @@ -52,6 +52,10 @@