예제 #1
0
파일: Role.php 프로젝트: projectHN/mentor
    public function init()
    {
        $this->addAttributes(array('id' => 'dgSystemRoleFeature'));
        $roles = $this->getOption('roles') ?: [];
        $features = $this->getOption('features') ?: [];
        $roleCols = [];
        $userModel = new \User\Model\User();
        foreach ($roles as $role) {
            /*@var $role \System\Model\Role */
            $roleCols[$role->getId()] = $role->getName();
        }
        $header = new Row();
        $header->addColumn(array('name' => 'mcaName', 'content' => 'Quyền'));
        foreach ($roleCols as $roleId => $roleName) {
            $header->addColumn(array('name' => 'role_' . $roleId, 'content' => $roleName));
        }
        $this->addHeader($header);
        $mcaList = $this->getOption('mcaList');
        if (!$mcaList || !count($mcaList) || !isset($mcaList['modules']) || !count($mcaList['modules']) || !isset($mcaList['controllers']) || !count($mcaList['controllers']) || !isset($mcaList['actions']) || !count($mcaList['actions'])) {
            return $this;
        }
        $modules = $mcaList['modules'];
        $controllers = $mcaList['controllers'];
        $actions = $mcaList['actions'];
        foreach ($modules as $moduleId => $module) {
            $row = new Row();
            $row->addColumn(array('name' => 'mcaName', 'content' => '<b>' . ($module['description'] ?: $module['name']) . '</b>', 'attributes' => array('title' => $module['id'], 'class' => 'mark mcaName')));
            foreach ($roleCols as $roleId => $roleName) {
                $row->addColumn(array('name' => 'role_' . $roleId, 'content' => ''));
            }
            $this->addRow($row);
            if (isset($controllers[$module['id']]) && count($controllers[$module['id']])) {
                foreach ($controllers[$module['id']] as $controller) {
                    $row = new Row();
                    $row->addColumn(array('name' => 'mcaName', 'content' => '<b>' . ($controller['description'] ?: $controller['name']) . '</b>', 'attributes' => array('title' => $controller['id'], 'class' => 'mark mcaName', 'style' => 'padding-left: 50px;font-weight:bold;')));
                    foreach ($roleCols as $roleId => $roleName) {
                        $row->addColumn(array('name' => 'role_' . $roleId, 'content' => ''));
                    }
                    $this->addRow($row);
                    if (isset($actions[$controller['id']]) && count($actions[$controller['id']])) {
                        foreach ($actions[$controller['id']] as $action) {
                            $row = new Row();
                            $row->addColumn(array('name' => 'mcaName', 'content' => $action['description'] ?: $action['name'], 'attributes' => array('title' => $action['id'], 'class' => 'mcaName', 'style' => 'padding-left: 100px;')));
                            foreach ($roleCols as $roleId => $roleName) {
                                $checked = '';
                                if (isset($features[$action['id']][$roleId])) {
                                    $checked = 'checked="checked"';
                                }
                                $content = '<input type="checkbox" class="roleFeature"
										roleid="' . $roleId . '" actionid="' . $action['id'] . '" value="1" ' . $checked . '/>';
                                $row->addColumn(array('name' => 'role_' . $roleId, 'content' => $content, 'attributes' => ['class' => 'colControls']));
                            }
                            $this->addRow($row);
                        }
                    }
                }
            }
        }
    }
예제 #2
0
파일: Mca.php 프로젝트: projectHN/mentor
 public function init()
 {
     $this->addAttributes(array('id' => 'dgSystemFeatureMca', 'class' => 'table-hover'));
     $this->addHeader(['attributes' => array('id' => 'd'), 'options' => array(), 'columns' => array(array('name' => 'name', 'content' => 'Tên'), array('name' => 'description', 'content' => 'Mô tả'), array('name' => 'updatedDateTime', 'content' => '<i class="fa fa-calendar-o"></i>'), array('name' => 'dependency', 'content' => '<i class="fa fa-link"></i>'), array('name' => 'display', 'content' => 'Hiển thị'), array('name' => 'accountUsing', 'content' => 'Account'), array('name' => 'userUsing', 'content' => 'User'), array('name' => 'status', 'content' => 'Trạng thái'), array('name' => 'edit', 'content' => '<i class="fa fa-pencil-square-o"></i>'), array('name' => 'deploy', 'content' => '<i class="fa fa-cogs"></i>'), array('name' => 'remove', 'content' => '<i class="fa fa-trash-o color-red"></i>'))]);
     if ($this->getDataSource()) {
         $dataSource = $this->getDataSource();
         $modules = $dataSource['modules'];
         $controllers = $dataSource['controllers'];
         $actions = $dataSource['actions'];
         if ($modules && count($modules)) {
             foreach ($modules as $module) {
                 $row = new Row();
                 $row->setAttributes(array('mca_role' => 'module', 'idref' => $module['id'], 'class' => '_' . $module['name']));
                 $row->addColumn(array('name' => 'name', 'content' => $module['name'], 'attributes' => array('title' => $module['id'], 'class' => 'mark mcaName', 'style' => 'font-weight:bold;')));
                 $row->addColumn(array('name' => 'description', 'content' => $module['description'], 'attributes' => array('title' => $module['id'], 'class' => 'mark mcaDescription', 'style' => 'font-weight:bold;')));
                 $content = '';
                 if ($module['updatedDateTime']) {
                     $content = '<i class="fa fa fa-calendar-o" title="' . $module['updatedDateTime'] . '"></i>';
                 }
                 $row->addColumn(array('name' => 'updatedDateTime', 'content' => $content));
                 $row->addColumn(array('name' => 'dependency', 'content' => ''));
                 $row->addColumn(array('name' => 'display', 'content' => ''));
                 $row->addColumn(array('name' => 'accountUsing', 'content' => ''));
                 $row->addColumn(array('name' => 'userUsing', 'content' => ''));
                 $row->addColumn(array('name' => 'status', 'content' => $this->renderStatus($module['status']), 'attributes' => ['class' => 'colControls']));
                 $row->addColumn(array('name' => 'edit', 'content' => '<a class="editMca fa fa-pencil-square-o"></a>', 'attributes' => ['class' => 'colControls']));
                 $row->addColumn(array('name' => 'deploy', 'content' => '', 'attributes' => ['class' => 'colControls']));
                 $row->addColumn(array('name' => 'remove', 'content' => '<a class="removeMca fa fa-trash-o color-red"></a>', 'attributes' => ['class' => 'colControls']));
                 $this->addRow($row);
                 if (isset($controllers[$module['id']]) && count($controllers[$module['id']])) {
                     foreach ($controllers[$module['id']] as $controller) {
                         $row = new Row();
                         $row->setAttributes(array('mca_role' => 'controller', 'idref' => $controller['id'], 'class' => '_' . $module['name'] . '_' . $controller['name']));
                         $row->addColumn(array('name' => 'name', 'content' => $controller['name'], 'attributes' => array('title' => $controller['id'], 'class' => 'mark mcaName', 'style' => 'padding-left: 50px;font-weight:bold;')));
                         $row->addColumn(array('name' => 'description', 'content' => $controller['description'], 'attributes' => array('title' => $controller['id'], 'class' => 'mark mcaDescription', 'style' => 'padding-left: 50px;font-weight:bold;')));
                         $content = '';
                         if ($module['updatedDateTime']) {
                             $content = '<i class="fa fa fa-calendar-o" title="' . $controller['updatedDateTime'] . '"></i>';
                         }
                         $row->addColumn(array('name' => 'updatedDateTime', 'content' => $content));
                         $row->addColumn(array('name' => 'dependency', 'content' => ''));
                         $row->addColumn(array('name' => 'display', 'content' => ''));
                         $row->addColumn(array('name' => 'accountUsing', 'content' => ''));
                         $row->addColumn(array('name' => 'userUsing', 'content' => ''));
                         $row->addColumn(array('name' => 'status', 'content' => $this->renderStatus($controller['status']), 'attributes' => ['class' => 'colControls']));
                         $row->addColumn(array('name' => 'edit', 'content' => '<a class="editMca fa fa-pencil-square-o"></a>', 'attributes' => ['class' => 'colControls']));
                         $row->addColumn(array('name' => 'deploy', 'content' => '', 'attributes' => ['class' => 'colControls']));
                         $row->addColumn(array('name' => 'remove', 'content' => '<a class="removeMca fa fa-trash-o color-red"></a>', 'attributes' => ['class' => 'colControls']));
                         $this->addRow($row);
                         if (isset($actions[$controller['id']]) && count($actions[$controller['id']])) {
                             foreach ($actions[$controller['id']] as $action) {
                                 $row = new Row();
                                 $row->setAttributes(array('mca_role' => 'action', 'idref' => $action['id'], 'class' => '_' . $module['name'] . '_' . $controller['name'] . '_' . $action['name']));
                                 $row->addColumn(array('name' => 'name', 'content' => $action['name'], 'attributes' => array('title' => $action['id'], 'class' => 'mcaName', 'style' => 'padding-left: 100px;')));
                                 $row->addColumn(array('name' => 'description', 'content' => $action['description'], 'attributes' => array('title' => $action['id'], 'class' => 'mcaDescription', 'style' => 'padding-left: 100px;')));
                                 $content = '';
                                 if ($module['updatedDateTime']) {
                                     $content = '<i class="fa fa fa-calendar-o" title="' . $action['updatedDateTime'] . '"></i>';
                                 }
                                 $row->addColumn(array('name' => 'updatedDateTime', 'content' => $content, 'attributes' => ['class' => 'colControls']));
                                 $row->addColumn(array('name' => 'dependency', 'content' => '<a class="fa fa-link color-black addDependence"></a>', 'attributes' => ['class' => 'colControls']));
                                 $row->addColumn(array('name' => 'display', 'content' => $this->renderDisplay($action['display']), 'attributes' => ['class' => 'colControls']));
                                 $row->addColumn(array('name' => 'accountUsing', 'content' => ''));
                                 $row->addColumn(array('name' => 'userUsing', 'content' => ''));
                                 $row->addColumn(array('name' => 'status', 'content' => $this->renderStatus($action['status']), 'attributes' => ['class' => 'colControls']));
                                 $row->addColumn(array('name' => 'edit', 'content' => '<a class="editMca fa fa-pencil-square-o"></a>', 'attributes' => ['class' => 'colControls']));
                                 $row->addColumn(array('name' => 'deploy', 'content' => '', 'attributes' => ['class' => 'colControls']));
                                 $row->addColumn(array('name' => 'remove', 'content' => '<a class="removeMca fa fa-trash-o color-red"></a>', 'attributes' => ['class' => 'colControls']));
                                 $this->addRow($row);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #3
0
파일: User.php 프로젝트: projectHN/mentor
 /**
  * @author KienNN
  */
 public function init()
 {
     $this->setAttributes(array('id' => 'dgUser'));
     $this->addHeader(['attributes' => array(), 'options' => array(), 'columns' => array(array('name' => 'id', 'content' => 'ID'), array('name' => 'username', 'content' => 'Tên đăng nhập'), array('name' => 'role', 'content' => 'Phân quyền'), array('name' => 'company', 'content' => 'Trực thuộc'), array('name' => 'fullName', 'content' => 'Tên đầy đủ'), array('name' => 'mobile', 'content' => 'Mobile'), array('name' => 'email', 'content' => 'Email'), array('name' => 'createdBy', 'content' => 'Người tạo'), array('name' => 'createdDateTime', 'content' => 'Ngày tạo'), array('name' => 'active', 'content' => 'Kích hoạt'), array('name' => 'locked', 'content' => 'Khóa'), array('name' => 'edit', 'content' => '<i class="fa fa-edit"></i>', 'attributes' => ['class' => 'colControls', 'title' => 'Sửa']))]);
     if (!is_array($this->getDataSource()) && !$this->getDataSource() instanceof \Zend\Paginator\Paginator) {
         return;
     }
     if (!$this->getDataSource()->getCurrentModels()) {
         return null;
     }
     foreach ($this->getDataSource()->getCurrentModels() as $item) {
         /* @var $item \User\Model\User */
         $row = new Row();
         $row->addColumn(array('name' => 'id', 'content' => $item->getId(), 'attributes' => []));
         $content = '';
         $content .= $item->getUsername();
         if ($item->getOption('hasPrivateRole')) {
             $content .= '<i style="margin-left:3px;" data-toggle="tooltip" data-placement="top" data-original-title="có phân quyền riêng" class="glyphicon glyphicon-registration-mark text-danger"></i>';
         }
         $row->addColumn(array('name' => 'username', 'content' => $content, 'attributes' => []));
         $content = [];
         $content[] = $item->getRoleDisplayName();
         if ($item->getOption('role')) {
             foreach ($item->getOption('role') as $role) {
                 $content[] = '<span class="text-primary">' . $role . '</span>';
             }
         }
         $row->addColumn(array('name' => 'role', 'content' => implode('<div class="line-break"></div>', $content), 'attributes' => []));
         $content = [];
         if ($item->getOption('companies')) {
             foreach ($item->getOption('companies') as $companyName) {
                 $content[] = $companyName;
             }
         }
         if ($item->getOption('departments')) {
             foreach ($item->getOption('departments') as $departmentName) {
                 $content[] = '<span class="text-primary">' . $departmentName . '</span>';
             }
         }
         $row->addColumn(array('name' => 'company', 'content' => implode('<div class="line-break"></div>', $content), 'attributes' => []));
         $row->addColumn(array('name' => 'fullName', 'content' => $item->getFullName(), 'attributes' => []));
         $row->addColumn(array('name' => 'mobile', 'content' => $item->getMobile(), 'attributes' => []));
         $row->addColumn(array('name' => 'email', 'content' => $item->getEmail(), 'attributes' => []));
         $row->addColumn(array('name' => 'createdBy', 'content' => $item->getOption('createdBy') ? $item->getOption('createdBy')->getFullName() : '', 'attributes' => []));
         $row->addColumn(array('name' => 'createdDateTime', 'content' => $item->getCreatedDateTime(), 'attributes' => []));
         $content = '';
         if ($item->getActive()) {
             $content = '<a class="fa fa-check color-green icon changeActive" idref="' . $item->getId() . '"></a>';
         } else {
             $content = '<a class="fa fa-minus-circle color-red icon changeActive" idref="' . $item->getId() . '"></a>';
         }
         $row->addColumn(array('name' => 'active', 'content' => $content, 'attributes' => ['class' => 'colControls']));
         $content = '';
         if ($item->getLocked()) {
             $content = '<a class="fa fa-lock color-red icon changeLocked" idref="' . $item->getId() . '"></a>';
         } else {
             $content = '<a class="fa fa-unlock color-blue icon changeLocked" idref="' . $item->getId() . '"></a>';
         }
         $row->addColumn(array('name' => 'locked', 'content' => $content, 'attributes' => ['class' => 'colControls']));
         $row->addColumn(array('name' => 'edit', 'content' => '<a href="/system/user/edit?id=' . $item->getId() . '" class="fa fa-edit"></a>', 'attributes' => ['class' => 'colControls']));
         $this->addRow($row);
     }
 }
예제 #4
0
 public function init()
 {
     $this->addAttributes(array('id' => 'dgSystemCompanyFeature', 'class' => 'table-hover'));
     $mcaList = $this->getOption('mcaList');
     $features = $this->getOption('features');
     $compareFeatures = $this->getOption('compareFeatures');
     $compareTitle = $this->getOption('compareTitle');
     $companyId = $this->getOption('companyId');
     $hasCompareFeature = false;
     $hasFeature = false;
     if ($compareFeatures && count($compareFeatures)) {
         $hasCompareFeature = true;
     }
     if ($features && count($features)) {
         $hasFeature = true;
     }
     $header = new Row();
     $this->addHeader($header);
     $header->addColumn(array('name' => 'mcaName', 'content' => 'Quyền'));
     if ($compareTitle) {
         $header->addColumn(array('name' => 'compareFeature', 'content' => $compareTitle . ' <a class="fa fa-arrow-right color-red exchangeFeature"></a>'));
     }
     $header->addColumn(array('name' => 'feature', 'content' => 'Trạng thái'));
     if (!$mcaList || !count($mcaList) || !isset($mcaList['modules']) || !count($mcaList['modules']) || !isset($mcaList['controllers']) || !count($mcaList['controllers']) || !isset($mcaList['actions']) || !count($mcaList['actions'])) {
         return $this;
     }
     $modules = $mcaList['modules'];
     $controllers = $mcaList['controllers'];
     $actions = $mcaList['actions'];
     foreach ($modules as $moduleId => $module) {
         $row = new Row();
         $row->setAttributes(array('mca_role' => 'module', 'idref' => $module['id'], 'class' => '_' . $module['name']));
         $row->addColumn(array('name' => 'mcaName', 'content' => '<b>' . ($module['description'] ?: $module['name']) . '</b>', 'attributes' => array('title' => $module['id'], 'class' => 'mark mcaName')));
         if ($compareTitle) {
             $row->addColumn(array('name' => 'compareFeature', 'content' => ''));
         }
         $row->addColumn(array('name' => 'feature', 'content' => ''));
         $this->addRow($row);
         if (isset($controllers[$module['id']]) && count($controllers[$module['id']])) {
             foreach ($controllers[$module['id']] as $controller) {
                 $row = new Row();
                 $row->setAttributes(array('mca_role' => 'controller', 'idref' => $controller['id'], 'class' => '_' . $module['name'] . '_' . $controller['name']));
                 $row->addColumn(array('name' => 'mcaName', 'content' => '<b>' . ($controller['description'] ?: $controller['name']) . '</b>', 'attributes' => array('title' => $controller['id'], 'class' => 'mark mcaName', 'style' => 'padding-left: 50px;font-weight:bold;')));
                 if ($compareTitle) {
                     $row->addColumn(array('name' => 'compareFeature', 'content' => ''));
                 }
                 $row->addColumn(array('name' => 'feature', 'content' => ''));
                 $this->addRow($row);
                 if (isset($actions[$controller['id']]) && count($actions[$controller['id']])) {
                     foreach ($actions[$controller['id']] as $action) {
                         $row = new Row();
                         $row->setAttributes(array('mca_role' => 'action', 'idref' => $action['id'], 'class' => '_' . $module['name'] . '_' . $controller['name'] . '_' . $action['name']));
                         $row->addColumn(array('name' => 'mcaName', 'content' => $action['description'] ?: $action['name'], 'attributes' => array('title' => $action['id'], 'class' => 'mcaName', 'style' => 'padding-left: 100px;')));
                         if ($compareTitle) {
                             $content = '';
                             if ($hasCompareFeature) {
                                 if (isset($compareFeatures[$action['id']])) {
                                     $content = '<i class="fa icon fa-check color-green compareFeature"></i>';
                                 } else {
                                     $content = '<i class="fa icon fa-minus-circle color-red compareFeature"></i>';
                                 }
                             } else {
                                 $content = '<i class="fa icon fa-check color-green compareFeature"></i>';
                             }
                             $row->addColumn(array('name' => 'compareFeature', 'content' => $content, 'attributes' => ['class' => 'colControls']));
                         }
                         $content = '';
                         if ($hasFeature) {
                             if (isset($features[$action['id']])) {
                                 $content = '<a class="fa icon fa-check color-green changeStatus" idref="' . $action['id'] . '" companyid="' . $companyId . '"></a>';
                             } else {
                                 $content = '<a class="fa icon fa-minus-circle color-red changeStatus" idref="' . $action['id'] . '" companyid="' . $companyId . '"></a>';
                             }
                         } else {
                             $content = '<a class="fa icon fa-minus-circle color-red changeStatus" idref="' . $action['id'] . '" companyid="' . $companyId . '"></a>';
                         }
                         $row->addColumn(array('name' => 'feature', 'content' => $content, 'attributes' => ['class' => 'colControls']));
                         $this->addRow($row);
                     }
                 }
             }
         }
     }
 }
예제 #5
0
 /**
  *
  * @param Row|array $row
  * @throws Exception
  */
 public function addRow($row)
 {
     if ($row instanceof Row) {
         $row->setDataGrid($this);
         $this->rows[] = $row;
         return $row;
     } else {
         if (is_array($row)) {
             $r = new Row($row);
             $r->setDataGrid($this);
             $this->rows[] = $r;
             return $r;
         } else {
             throw new \Exception("row must be instantce of Row or an array");
         }
     }
 }