237 lines
8.3 KiB
PHP
237 lines
8.3 KiB
PHP
<?php
|
|
/**
|
|
* The control file of productplan module of ZenTaoPMS.
|
|
*
|
|
* @copyright Copyright 2009-2013 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
|
|
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
|
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
|
* @package productplan
|
|
* @version $Id: control.php 4659 2013-04-17 06:45:08Z chencongzhi520@gmail.com $
|
|
* @link http://www.zentao.net
|
|
*/
|
|
class productplan extends control
|
|
{
|
|
/**
|
|
* Common actions
|
|
*
|
|
* @param int $productID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function commonAction($productID)
|
|
{
|
|
$this->loadModel('product');
|
|
$this->view->product = $this->product->getById($productID);
|
|
$this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$this->view->product->id}"), $this->view->product->name);
|
|
$this->product->setMenu($this->product->getPairs(), $productID);
|
|
}
|
|
|
|
/**
|
|
* Create a plan.
|
|
*
|
|
* @param int $product
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function create($product = '')
|
|
{
|
|
if(!empty($_POST))
|
|
{
|
|
$planID = $this->productplan->create();
|
|
if(dao::isError()) die(js::error(dao::getError()));
|
|
$this->loadModel('action')->create('productplan', $planID, 'opened');
|
|
die(js::locate($this->createLink('productplan', 'browse', "productID=$product"), 'parent'));
|
|
}
|
|
|
|
$this->commonAction($product);
|
|
|
|
$this->view->title = $this->lang->productplan->create;
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Edit a plan.
|
|
*
|
|
* @param int $planID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function edit($planID)
|
|
{
|
|
if(!empty($_POST))
|
|
{
|
|
$changes = $this->productplan->update($planID);
|
|
if(dao::isError()) die(js::error(dao::getError()));
|
|
if($changes)
|
|
{
|
|
$actionID = $this->loadModel('action')->create('productplan', $planID, 'edited');
|
|
$this->action->logHistory($actionID, $changes);
|
|
}
|
|
die(js::locate(inlink('view', "planID=$planID"), 'parent'));
|
|
}
|
|
|
|
$plan = $this->productplan->getByID($planID);
|
|
$this->commonAction($plan->product);
|
|
$this->view->title = $this->lang->productplan->edit;
|
|
$this->view->position[] = $this->lang->productplan->edit;
|
|
$this->view->plan = $plan;
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Delete a plan.
|
|
*
|
|
* @param int $planID
|
|
* @param string $confirm yes|no
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function delete($planID, $confirm = 'no')
|
|
{
|
|
if($confirm == 'no')
|
|
{
|
|
die(js::confirm($this->lang->productplan->confirmDelete, $this->createLink('productPlan', 'delete', "planID=$planID&confirm=yes")));
|
|
}
|
|
else
|
|
{
|
|
$plan = $this->productplan->getById($planID);
|
|
$this->productplan->delete(TABLE_PRODUCTPLAN, $planID);
|
|
die(js::locate(inlink('browse', "productID=$plan->product"), 'parent'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Browse plans.
|
|
*
|
|
* @param int $product
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function browse($product = 0)
|
|
{
|
|
$this->session->set('productPlanList', $this->app->getURI(true));
|
|
$this->commonAction($product);
|
|
$products = $this->product->getPairs();
|
|
$this->view->title = $products[$product] . $this->lang->colon . $this->lang->productplan->browse;
|
|
$this->view->position[] = $this->lang->productplan->browse;
|
|
$this->view->plans = $this->productplan->getList($product);
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* View plan.
|
|
*
|
|
* @param int $planID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function view($planID = 0)
|
|
{
|
|
$this->session->set('storyList', $this->app->getURI(true));
|
|
|
|
$plan = $this->productplan->getByID($planID, true);
|
|
if(!$plan) die(js::error($this->lang->notFound) . js::locate('back'));
|
|
$this->commonAction($plan->product);
|
|
$products = $this->product->getPairs();
|
|
$this->view->title = "PLAN #$plan->id $plan->title/" . $products[$plan->product];
|
|
$this->view->position[] = $this->lang->productplan->view;
|
|
$this->view->planStories= $this->loadModel('story')->getPlanStories($planID);
|
|
$this->view->products = $products;
|
|
$this->view->plan = $plan;
|
|
$this->view->actions = $this->loadModel('action')->getList('productplan', $planID);
|
|
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Link stories.
|
|
*
|
|
* @param int $planID
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function linkStory($planID = 0, $browseType = '', $param = 0)
|
|
{
|
|
$this->session->set('storyList', $this->app->getURI(true));
|
|
|
|
if(!empty($_POST['stories'])) $this->productplan->linkStory($planID);
|
|
|
|
$this->loadModel('story');
|
|
$plan = $this->productplan->getByID($planID);
|
|
$this->commonAction($plan->product);
|
|
$products = $this->product->getPairs();
|
|
|
|
/* Build search form. */
|
|
$queryID = ($browseType == 'bySearch') ? (int)$param : 0;
|
|
unset($this->config->product->search['fields']['module']);
|
|
unset($this->config->product->search['fields']['product']);
|
|
$this->config->product->search['actionURL'] = $this->createLink('productplan', 'linkStory', "planID=$planID&browseType=bySearch&queryID=myQueryID");
|
|
$this->config->product->search['queryID'] = $queryID;
|
|
$this->config->product->search['params']['product']['values'] = $products + array('all' => $this->lang->product->allProductsOfProject);
|
|
$this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts($products);
|
|
unset($this->lang->story->statusList['closed']);
|
|
$this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->story->statusList);
|
|
$this->loadModel('search')->setSearchParams($this->config->product->search);
|
|
|
|
if($browseType == 'bySearch')
|
|
{
|
|
$allStories = $this->story->getBySearch($plan->product, $queryID, 'id');
|
|
foreach($allStories as $key => $story)
|
|
{
|
|
if($story->status == 'closed') unset($allStories[$key]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$allStories = $this->story->getProductStories($this->view->product->id, $moduleID = '0', $status = 'draft,active,changed');
|
|
}
|
|
|
|
$this->view->title = $this->lang->productplan->linkStory;
|
|
$this->view->position[] = $this->lang->productplan->linkStory;
|
|
$this->view->allStories = $allStories;
|
|
$this->view->planStories= $this->story->getPlanStories($planID);
|
|
$this->view->products = $products;
|
|
$this->view->plan = $plan;
|
|
$this->view->plans = $this->dao->select('id, end')->from(TABLE_PRODUCTPLAN)->fetchPairs();
|
|
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* Unlink story
|
|
*
|
|
* @param int $storyID
|
|
* @param string $confirm yes|no
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function unlinkStory($storyID, $confirm = 'no')
|
|
{
|
|
if($confirm == 'no')
|
|
{
|
|
die(js::confirm($this->lang->productplan->confirmUnlinkStory, $this->createLink('productplan', 'unlinkstory', "storyID=$storyID&confirm=yes")));
|
|
}
|
|
else
|
|
{
|
|
$this->productplan->unlinkStory($storyID);
|
|
die(js::reload('parent'));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Batch unlink story.
|
|
*
|
|
* @param string $confirm
|
|
* @access public
|
|
* @return void
|
|
*/
|
|
public function batchUnlinkStory($confirm = 'no')
|
|
{
|
|
foreach($this->post->unlinkStories as $storyID)
|
|
{
|
|
$this->productplan->unlinkStory($storyID);
|
|
}
|
|
die(js::reload('parent'));
|
|
}
|
|
}
|