diff --git a/module/backup/control.php b/module/backup/control.php index 650d157317..96c2dbbeee 100644 --- a/module/backup/control.php +++ b/module/backup/control.php @@ -113,11 +113,11 @@ class backup extends control } /* Delete expired backup. */ - $sqlFiles = glob("{$this->backupPath}*.sql.php"); - if(!empty($sqlFiles)) + $backupFiles = glob("{$this->backupPath}*.php"); + if(!empty($backupFiles)) { $time = time(); - foreach($sqlFiles as $file) + foreach($backupFiles as $file) { if($time - filemtime($file) > $this->config->backup->holdDays * 24 * 3600) unlink($file); } diff --git a/module/branch/control.php b/module/branch/control.php index 1e105daac2..177ddf17a4 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -51,10 +51,10 @@ class branch extends control public function ajaxGetBranches($productID) { $product = $this->loadModel('product')->getById($productID); - if($product->type == 'normal') die(); + if(empty($product) or $product->type == 'normal') die(); $branches = $this->branch->getPairs($productID); - die(html::select('branch[]', $branches, '', "class='form-control'")); + die(html::select('branch', $branches, '', "class='form-control'")); } } diff --git a/module/branch/model.php b/module/branch/model.php index 08d6c74f04..f2d2901baf 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -37,5 +37,19 @@ class branchModel extends model return dao::isError(); } + + public function getByProducts($products, $params = '') + { + $branches = $this->dao->select('*')->from(TABLE_BRANCH)->where('product')->in($products)->andWhere('deleted')->eq(0)->fetchAll(); + + $branchGroups = array(); + foreach($branches as $branch) + { + if(!isset($branchGroups[$branch->product]) and strpos($params, 'noempty') === false) $branchGroups[$branch->product][0] = $this->lang->branch->all; + $branchGroups[$branch->product][$branch->id] = $branch->name; + } + + return $branchGroups; + } } diff --git a/module/project/control.php b/module/project/control.php index 3279a5d7e1..cdcaf998db 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -900,10 +900,11 @@ class project extends control $name = ''; $code = ''; $team = ''; - $products = ''; + $products = array(); $whitelist = ''; $acl = 'open'; + $productIDList = array(); if($copyProjectID) { $copyProject = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($copyProjectID)->fetch(); @@ -912,7 +913,8 @@ class project extends control $team = $copyProject->team; $acl = $copyProject->acl; $whitelist = $copyProject->whitelist; - $products = join(',', array_keys($this->project->getProducts($copyProjectID))); + $products = $this->project->getProducts($copyProjectID); + foreach($products as $product) $productIDList[$product->id] = $product->id; } if(!empty($_POST)) @@ -931,7 +933,7 @@ class project extends control $this->view->position[] = $this->view->title; $this->view->projects = array('' => '') + $this->projects; $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->allProducts = $this->loadModel('product')->getPairs('noclosed|nocode'); + $this->view->allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode'); $this->view->name = $name; $this->view->code = $code; $this->view->team = $team; @@ -939,6 +941,7 @@ class project extends control $this->view->whitelist = $whitelist; $this->view->acl = $acl ; $this->view->copyProjectID = $copyProjectID; + $this->view->branchGroups = $this->loadModel('branch')->getByProducts($productIDList); $this->display(); } @@ -986,10 +989,14 @@ class project extends control $position[] = html::a($browseProjectLink, $project->name); $position[] = $this->lang->project->edit; - $allProducts = $this->loadModel('product')->getPairs('noclosed|nocode'); + $allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode'); $linkedProducts = $this->project->getProducts($project->id); - $allProducts += $linkedProducts; - $linkedProducts = join(',', array_keys($linkedProducts)); + $productIDList = array(); + foreach($linkedProducts as $product) + { + if(!isset($allProducts[$product->id])) $allProducts[$product->id] = $product->name; + $productIDList[$product->id] = $product->id; + } $this->view->title = $title; $this->view->position = $position; @@ -1002,6 +1009,7 @@ class project extends control $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->allProducts = $allProducts; $this->view->linkedProducts = $linkedProducts; + $this->view->branchGroups = $this->loadModel('branch')->getByProducts($productIDList); $this->display(); } @@ -1343,14 +1351,21 @@ class project extends control $allProducts = $this->product->getPairs('noclosed|nocode'); $linkedProducts = $this->project->getProducts($project->id); // Merge allProducts and linkedProducts for closed product. - $allProducts += $linkedProducts; - $linkedProducts = join(',', array_keys($linkedProducts)); + $products = array(); + foreach($linkedProducts as $product) + { + if(!isset($allProducts[$product->id])) $allProducts[$product->id] = $product->name; + if(!isset($products[$product->id])) $products[$product->id] = $product; + $products[$product->id]->branches[$product->branch] = $product->branch; + } + $linkedProducts = $products; /* Assign. */ $this->view->title = $title; $this->view->position = $position; $this->view->allProducts = $allProducts; $this->view->linkedProducts = $linkedProducts; + $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($allProducts)); $this->display(); } diff --git a/module/project/css/manageproducts.css b/module/project/css/manageproducts.css index dd728adb6b..bdf0ad390b 100644 --- a/module/project/css/manageproducts.css +++ b/module/project/css/manageproducts.css @@ -1,7 +1,6 @@ #productsBox {padding: 20px;} -#productsBox > label {padding: 8px 15px; border:1px solid #ddd; min-width: 31%} -#productsBox > label > input {margin-left: 0; margin-right: 5px;} -#productsBox > label:hover {background: #f1f1f1} -#productsBox > label.checked, #productsBox > label.checked:hover {background: #E5FFE6; border: 1px solid #229F24;} -.radio-inline+.radio-inline, .checkbox-inline+.checkbox-inline {margin-left: 0;} -.checkbox-inline {margin-right: 10px; margin-bottom: 10px;} +#productsBox > .col-sm-4 {padding: 8px 15px; border:1px solid #ddd; min-height:48px; margin-bottom:5px; width:32%; margin-right:8px;} +#productsBox > .col-sm-4 label {display:block} +#productsBox > .col-sm-4:hover {background: #f1f1f1} +#productsBox > .col-sm-4.checked, #productsBox > .col-sm-4.checked:hover {background: #E5FFE6; border: 1px solid #229F24;} +.col-sm-4+.col-sm-4 {margin-left: 0;} diff --git a/module/project/js/common.js b/module/project/js/common.js index 81e42134c1..3ab3f88f01 100644 --- a/module/project/js/common.js +++ b/module/project/js/common.js @@ -109,6 +109,31 @@ function computeEndDate(delta) computeWorkDays(); } +function loadBranches(product) +{ + if($('#productsBox .input-group:last select:first').val() != 0) + { + var length = $('#productsBox .input-group').size(); + $('#productsBox .row').append('