diff --git a/module/product/control.php b/module/product/control.php index 0abd2df670..14e70481b6 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -505,6 +505,15 @@ class product extends control if($product->program) $lines = array('') + $this->product->getLinePairs($product->program); if($this->config->systemMode == 'classic') $lines = array('') + $this->product->getLinePairs(); + /* Get programs. */ + $programs = $this->loadModel('program')->getTopPairs(); + if(!isset($programs[$product->program]) and $product->program) + { + $program = $this->program->getByID($product->program); + $programs = array($product->program => $program->name); + } + + $this->view->title = $this->lang->product->edit . $this->lang->colon . $product->name; $this->view->position[] = html::a($this->createLink($this->moduleName, 'browse'), $product->name); $this->view->position[] = $this->lang->product->edit; @@ -517,7 +526,7 @@ class product extends control $this->view->qdUsers = $qdUsers; $this->view->rdUsers = $rdUsers; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); - $this->view->programs = array('') + $this->loadModel('program')->getTopPairs(); + $this->view->programs = array('') + $programs; $this->view->lines = $lines; $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); $this->view->canChangeProgram = $canChangeProgram; @@ -586,13 +595,23 @@ class product extends control $rdUsers = $this->user->getPairs('nodeleted|devfirst', $appendRdUsers); if(!empty($this->config->user->moreLink)) $this->config->moreLinks["RD"] = $this->config->user->moreLink; - $programs = array(); + $programs = array(); + $unauthorizedPrograms = array(); if($this->config->systemMode == 'new') { - /* Get product lines by programs.*/ $programs = $this->program->getTopPairs(); - $lines = array(0 => ''); - foreach($programs as $id => $program) + + /* Get unauthorized programs. */ + $programIDList = array(); + foreach($products as $product) + { + if($product->program and !isset($programs[$product->program]) and !in_array($product->program, $programIDList)) $programIDList[] = $product->program; + } + $unauthorizedPrograms = $this->program->getPairsByList($programIDList); + + /* Get product lines by programs.*/ + $lines = array(0 => ''); + foreach($programs + $unauthorizedPrograms as $id => $program) { $lines[$id] = array('') + $this->product->getLinePairs($id); } @@ -602,16 +621,17 @@ class product extends control $lines = array('') + $this->product->getLinePairs(); } - $this->view->title = $this->lang->product->batchEdit; - $this->view->position[] = $this->lang->product->batchEdit; - $this->view->lines = $lines; - $this->view->productIDList = $productIDList; - $this->view->products = $products; - $this->view->poUsers = $poUsers; - $this->view->qdUsers = $qdUsers; - $this->view->rdUsers = $rdUsers; - $this->view->programID = $programID; - $this->view->programs = array('' => '') + $programs; + $this->view->title = $this->lang->product->batchEdit; + $this->view->position[] = $this->lang->product->batchEdit; + $this->view->lines = $lines; + $this->view->productIDList = $productIDList; + $this->view->products = $products; + $this->view->poUsers = $poUsers; + $this->view->qdUsers = $qdUsers; + $this->view->rdUsers = $rdUsers; + $this->view->programID = $programID; + $this->view->programs = array('' => '') + $programs; + $this->view->unauthorizedPrograms = $unauthorizedPrograms; unset($this->lang->product->typeList['']); $this->display(); diff --git a/module/product/js/all.js b/module/product/js/all.js index be3d533764..0b38c9a5e4 100644 --- a/module/product/js/all.js +++ b/module/product/js/all.js @@ -44,7 +44,7 @@ $(function() { if(!$(this).prop('checked')) checkedProduct = false; }) - console.log(checkedProduct); + if(checkedProduct) $('.check-all').addClass('checked'); if(!checkedProduct) $('.check-all').removeClass('checked'); }, 100) diff --git a/module/product/model.php b/module/product/model.php index 42fb36592a..d8cbd1a802 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -657,7 +657,7 @@ class productModel extends model $productID = (int)$productID; $products[$productID] = new stdClass(); - if($this->config->systemMode == 'new') $products[$productID]->program = $data->programs[$productID]; + if($this->config->systemMode == 'new' and isset($data->programs[$productID])) $products[$productID]->program = $data->programs[$productID]; $products[$productID]->name = $productName; $products[$productID]->line = (int)$data->lines[$productID]; $products[$productID]->PO = $data->POs[$productID]; diff --git a/module/product/view/batchedit.html.php b/module/product/view/batchedit.html.php index 8ada335cef..4428de2ff6 100755 --- a/module/product/view/batchedit.html.php +++ b/module/product/view/batchedit.html.php @@ -76,10 +76,15 @@