addHelperPath('App/License/View/Helper/', 'App\License\View\Helper\\'); $this->addColumn('text', 'id', ['title' => '#', 'orderBy' => 'id']); $this->addColumn('text', 'vendorName', [ 'title' => 'Vendor', 'orderBy' => 'vendorName', 'initCallback' => [$this, 'initVendorBlacklistColumn'], ]); $this->addColumn('naicsCodes', 'naicsCodes', ['title' => 'Vendor Classifications']); $this->addColumn('date', 'added', ['title' => 'Submitted', 'orderBy' => 'added']); $this->addColumn('date', 'expiredOn', ['title' => 'Expires', 'orderBy' => 'expiredOn']); if (AclPermission::isTribalAccount()) { $this->addColumn('status', 'status', [ 'orderBy' => 'tribeStatus', 'tribeStatuses' => $this->getConfigArray('tribeStatuses'), 'statuses' => $this->getConfigArray('statuses'), ]); } else { $this->addColumn('tribes', 'tribes', [ 'title' => 'Status', 'orderBy' => 'status', 'statuses' => $this->getConfigArray('statuses'), 'tribeStatuses' => $this->getConfigArray('tribeStatuses'), ]); } $this->addColumn('backgroundScreening', 'bgScreeningReport', ['title' => 'Background Screening']); $this->addColumn('money', 'total', ['title' => 'Total', 'orderBy' => 'total']); if ($this->isAllowFullPermission()) { $actions = [ 'approve' => [], 'pending' => [], 'decline' => [], 'renew' => ['confirm' => true], 'disable' => ['confirm' => true], 'view' => [], 'edit' => [], ]; } else { $actions = []; if (in_array('approve', $this->_allowedActions)) { $actions['approve'] = []; } if (in_array('pending', $this->_allowedActions)) { $actions['pending'] = []; } if (in_array('decline', $this->_allowedActions)) { $actions['decline'] = []; } if (in_array('renew', $this->_allowedActions)) { $actions['renew'] = ['confirm' => true]; } if (in_array('disable', $this->_allowedActions)) { $actions['disable'] = ['confirm' => true]; } if (in_array('view', $this->_allowedActions)) { $actions['view'] = []; } if (in_array('edit', $this->_allowedActions)) { $actions['edit'] = []; } } if ($this->isAllowDelete()) { $actions['delete'] = []; } if ($this->isViewExportPdf()) { $actions[] = [ 'title' => 'expPdf', 'target' => '_blank', 'url' => PdfExportView::getViewUrl() . '/{id}', ]; } // $this->addColumn('options', 'options', [ // 'actions' => $actions, // 'initCallback' => function (array $options) { // switch ($options['row']['status']) { // case Entity::STATUS_PENDING: // unset($options['column']['actions']['renew']); // unset($options['column']['actions']['disable']); // break; // case Entity::STATUS_APPROVED: // unset($options['column']['actions']['approve']); // break; // case Entity::STATUS_EXPIRED: // unset($options['column']['actions']['approve']); // unset($options['column']['actions']['disable']); // break; // } // }, // ]); $this->addColumn('options', 'options', [ 'actions' => $actions, 'initCallback' => function (array $options) { // application statuses switch ($options['row']['status']) { case Entity::STATUS_ACTIVE: unset($options['column']['actions']['renew']); break; case Entity::STATUS_EXPIRED: unset($options['column']['actions']['disable']); break; } switch ($options['row']['isBlacklisted']) { case 'y': unset($options['column']['actions']['approve']); break; case 'n': break; } if (AclPermission::isTribalAccount()) { switch ($options['row']['tribeStatus']) { case Entity::STATUS_EXPIRED: unset($options['column']['actions']['approve']); unset($options['column']['actions']['decline']); unset($options['column']['actions']['pending']); break; case Entity::TRIBE_STATUS_PENDING: unset($options['column']['actions']['pending']); break; case Entity::TRIBE_STATUS_APPROVED: unset($options['column']['actions']['approve']); if ($options['row']['tribeSurcharge'] !== null) { unset($options['column']['actions']['pending']); } break; case Entity::TRIBE_STATUS_DECLINED: unset($options['column']['actions']['decline']); break; case Entity::TRIBE_STATUS_APPROVED_PENDING: unset($options['column']['actions']['approve']); break; } } else { // tribe statuses $tribeStatuses = array_column($options['row']['tribes'], 'status'); if ($tribeStatuses) { $tribeStatuses = array_unique($tribeStatuses); $tribeActionsFlags = [ 'approve' => false, 'decline' => false, 'pending' => false, ]; if (in_array(Entity::TRIBE_STATUS_PENDING, $tribeStatuses)) { $tribeActionsFlags['approve'] = true; $tribeActionsFlags['decline'] = true; } if (in_array(Entity::TRIBE_STATUS_APPROVED_PENDING, $tribeStatuses)) { $tribeActionsFlags['decline'] = true; $tribeActionsFlags['pending'] = true; } if (in_array(Entity::TRIBE_STATUS_APPROVED, $tribeStatuses)) { $tribeActionsFlags['decline'] = true; foreach ($options['row']['tribes'] as $tribe) { if ($tribe['status'] == Entity::TRIBE_STATUS_APPROVED && $tribe['surcharge'] === null) { $tribeActionsFlags['pending'] = true; break; } } } if (in_array(Entity::TRIBE_STATUS_DECLINED, $tribeStatuses)) { $tribeActionsFlags['approve'] = true; $tribeActionsFlags['pending'] = true; } foreach ($tribeActionsFlags as $action => $flag) { if (!$flag) { unset($options['column']['actions'][$action]); } } } } }, ]); return $this; } public function isAllowDelete() { return $this->allowDelete; } public function setAllowDelete($allowDelete) { $this->allowDelete = $allowDelete; return $this; } public function isAllowFullPermission() { return $this->_allowFullPermission; } public function setAllowFullPermission($value) { $this->_allowFullPermission = $value; return $this; } public function setAllowedActions($value) { $this->_allowedActions = $value; return $this; } public function isViewExportPdf() { return $this->viewExportPdf; } public function setViewExportPdf($viewExportPdf) { $this->viewExportPdf = $viewExportPdf; return $this; } }