* Finish task#7735.

This commit is contained in:
leiyong
2020-09-07 10:15:34 +08:00
parent d769b87004
commit 229dc9bee8
2 changed files with 143 additions and 41 deletions
+17 -9
View File
@@ -400,24 +400,32 @@ class my extends control
/**
* My programs.
*
* @param int $recTotal
* @param varchar $date
* @param varchar $direction
* @param string $status
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function program($recTotal = 0, $date = '', $direction = 'next')
{
$this->app->loadLang('program');
public function program($status = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
{
$this->loadModel('program');
$this->app->loadLang('project');
$this->app->session->set('programList', $this->app->getURI(true));
/* Set the pager. */
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage = 50, $pageID = 1);
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->view->position[] = $this->lang->my->myProgram;
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->myProgram;
$this->view->programs = $this->loadModel('program')->getList($status = 'all', $orderBy = 'id_desc', $pager);
$this->view->position[] = $this->lang->my->myProgram;
$this->view->programs = $this->program->getList($status, $orderBy, $pager, true);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->pager = $pager;
$this->view->status = $status;
$this->view->orderBy = $orderBy;
$this->display();
}
+126 -32
View File
@@ -11,7 +11,8 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<div id="mainMenu" class="clearfix hide">
<?php js::set('orderBy', $orderBy);?>
<div id="mainMenu" class="clearfix">
<div class="btn-toolbar pull-left">
<span class='btn btn-link btn-active-text'><span class='text'><?php echo $lang->my->myProgram;?></span></span>
</div>
@@ -27,37 +28,130 @@
</p>
</div>
<?php else:?>
<table class="table has-sort-head table-fixed" id='programList'>
<thead>
<tr class='text-center'>
<th class='w-id'><?php echo $lang->idAB;?></th>
<th class='w-160px text-left'><?php echo $lang->program->code;?></th>
<th class='c-name text-left'><?php echo $lang->program->name;?></th>
<th class='c-date'><?php echo $lang->program->begin;?></th>
<th class='c-date'><?php echo $lang->program->end;?></th>
<th class='c-status'><?php echo $lang->statusAB;?></th>
</tr>
</thead>
<tbody>
<?php foreach($programs as $program):?>
<tr class='text-center'>
<td><?php echo $program->id;?></td>
<td class='text-left'><?php echo $program->code;?></td>
<td class='text-left'><?php echo html::a($this->createLink('program', 'index', "programID=$program->id", '', '', $program->id), $program->name);?></td>
<td><?php echo $program->begin;?></td>
<td><?php echo $program->end;?></td>
<td class="c-status">
<?php if(isset($program->delay)):?>
<span class="status-project status-delayed" title='<?php echo $lang->project->delayed;?>'> <?php echo $lang->project->delayed;?></span>
<?php else:?>
<?php $statusName = $this->processStatus('program', $program);?>
<span class="status-project status-<?php echo $program->status?>" title='<?php echo $statusName;?>'> <?php echo $statusName;?></span>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php $canOrder = (common::hasPriv('program', 'updateOrder') and strpos($orderBy, 'order') !== false)?>
<form class='main-table' id='programForm' method='post' data-ride='table' data-nested='true' data-expand-nest-child='false' data-checkable='false'>
<table class='table has-sort-head table-fixed table-nested' id='programList'>
<?php $vars = "status=$status&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
<thead>
<tr>
<th class='c-id w-80px'>
<?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?>
</th>
<th class='w-100px'><?php common::printOrderLink('code', $orderBy, $vars, $lang->program->code);?></th>
<th class='table-nest-title'><?php common::printOrderLink('name', $orderBy, $vars, $lang->program->name);?></th>
<th class='w-80px'><?php common::printOrderLink('status', $orderBy, $vars, $lang->program->status);?></th>
<th class='w-100px'><?php common::printOrderLink('begin', $orderBy, $vars, $lang->program->begin);?></th>
<th class='w-100px'><?php common::printOrderLink('end', $orderBy, $vars, $lang->program->end);?></th>
<th class='w-100px'><?php common::printOrderLink('budget', $orderBy, $vars, $lang->program->budget);?></th>
<th class='w-100px'><?php common::printOrderLink('PM', $orderBy, $vars, $lang->program->PM);?></th>
<th class='text-center w-240px'><?php echo $lang->actions;?></th>
<?php if($canOrder):?>
<th class='w-60px sort-default'><?php common::printOrderLink('order', $orderBy, $vars, $lang->project->orderAB);?></th>
<?php endif;?>
</tr>
</thead>
<tbody id='programTableList'>
<?php foreach($programs as $program):?>
<?php
$trClass = '';
$trAttrs = "data-id='$program->id' data-order='$program->order' data-parent='$program->parent'";
if($program->isCat)
{
$trAttrs .= " data-nested='true'";
if($program->parent == '0') $trClass .= ' is-top-level table-nest-child-hide';
else $trClass .= ' is-top-level table-nest-hide';
}
if($program->parent)
{
if(!$program->isCat) $trClass .= ' is-nest-child';
$trClass .= ' table-nest-hide';
$trAttrs .= " data-nest-parent='$program->parent' data-nest-path='$program->path'";
}
else if(!$program->isCat) $trClass .= ' no-nest';
$trAttrs .= " class='$trClass'";
?>
<tr <?php echo $trAttrs;?>>
<td class='c-id'>
<?php printf('%03d', $program->id);?>
</td>
<td class='text-left'><?php echo $program->code;?></td>
<td class='text-left pgm-title table-nest-title' title='<?php echo $program->name?>'>
<span class="table-nest-icon icon<?php if($program->isCat) echo ' table-nest-toggle' ?>"></span>
<?php echo $program->isCat ? $program->name : html::a($this->createLink('program', 'index', "programID=$program->id", '', '', $program->id), $program->name);?>
</td>
<td class='c-status'><span class="status-program status-<?php echo $program->status?>"><?php echo zget($lang->project->statusList, $program->status, '');?></span></td>
<td class='text-center'><?php echo $program->begin;?></td>
<td class='text-center'><?php echo $program->end == '0000-00-00' ? '' : $program->end;?></td>
<td class='text-left'><?php echo $program->budget . ' ' . zget($lang->program->unitList, $program->budgetUnit);?></td>
<td><?php echo zget($users, $program->PM);?></td>
<td class='text-center c-actions'>
<?php common::printIcon('program', 'group', "programID=$program->id", $program, 'list', 'group');?>
<?php common::printIcon('program', 'manageMembers', "programID=$program->id", $program, 'list', 'persons');?>
<?php common::printIcon('program', 'start', "programID=$program->id", $program, 'list', '', '', 'iframe', true);?>
<?php common::printIcon('program', 'activate', "programID=$program->id", $program, 'list', '', '', 'iframe', true);?>
<?php common::printIcon('program', 'suspend', "programID=$program->id", $program, 'list', '', '', 'iframe', true);?>
<?php common::printIcon('program', 'close', "programID=$program->id", $program, 'list', '', '', 'iframe', true);?>
<?php if(common::hasPriv('program', 'edit')) echo html::a($this->createLink("program", "edit", "programID=$program->id"), "<i class='icon-edit'></i>", '', "class='btn' title='{$lang->edit}'");?>
<?php common::printIcon('program', 'create', "template=&programID=$program->id", '', 'list', 'treemap-alt', '', '', '', '', $this->lang->program->children);?>
<?php if(common::hasPriv('program', 'delete')) echo html::a($this->createLink("program", "delete", "programID=$program->id"), "<i class='icon-trash'></i>", 'hiddenwin', "class='btn' title='{$lang->delete}'");?>
</td>
<?php if($canOrder):?>
<td class='sort-handler text-center'><i class="icon icon-move"></i></td>
<?php endif;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class='table-footer'>
<?php $pager->show('right', 'pagerjs');?>
</div>
</form>
<style>
.w-240px {width:240px;}
#programTableList.sortable-sorting > tr {opacity: 0.7}
#programTableList.sortable-sorting > tr.drag-row {opacity: 1;}
#programTableList > tr.drop-not-allowed {opacity: 0.1!important}
</style>
<script>
$(function()
{
var $list = $('#programTableList');
$list.addClass('sortable').sortable(
{
reverse: orderBy === 'order_desc',
selector: 'tr',
dragCssClass: 'drag-row',
trigger: $list.find('.sort-handler').length ? '.sort-handler' : null,
canMoveHere: function($ele, $target)
{
return $ele.data('parent') === $target.data('parent');
},
start: function(e)
{
e.targets.filter('[data-parent!="' + e.element.attr('data-parent') + '"]').addClass('drop-not-allowed');
},
finish: function(e)
{
var orders = {};
e.list.each(function()
{
orders[$(this.item).data('id')] = this.order;
});
$.post(createLink('project', 'updateOrder'), {'projects' : orders, 'orderBy' : orderBy});
var $thead = $list.closest('table').children('thead');
$thead.find('.headerSortDown, .headerSortUp').removeClass('headerSortDown headerSortUp').addClass('header');
$thead.find('th.sort-default .header').removeClass('header').addClass('headerSortDown');
e.element.addClass('drop-success');
setTimeout(function(){e.element.removeClass('drop-success');}, 800);
$list.children('.drop-not-allowed').removeClass('drop-not-allowed');
}
});
});
</script>
<?php endif;?>
</div>
<?php include '../../common/view/footer.html.php';?>