/** * Return options for this object * * @param User $user * @return array */ function getOptions($user) { $options = new NamedList(); if ($this->canView($user) && !$this->isCanceled()) { $options->add('view_pdf', array('url' => $this->getPdfUrl(), 'text' => $this->getStatus() == INVOICE_STATUS_DRAFT ? lang('Preview PDF') : lang('View PDF'))); } // if if ($this->canIssue($user) && instance_of($this->getCompany(), 'Company')) { $options->add('issue', array('url' => $this->getIssueUrl(), 'text' => lang('Issue'))); } // if if ($this->canCancel($user)) { $options->add('cancel', array('url' => $this->getCancelUrl(), 'text' => lang('Cancel'), 'confirm' => lang('Are you sure that you want to cancel this invoice? All existing payments associated with this invoice will be deleted!'), 'method' => 'post')); } if ($user->getSystemPermission('can_manage_invoices')) { $options->add('duplicate', array('url' => $this->getDuplicateUrl(), 'text' => lang('Duplicate'))); } // if if ($this->countTimeRecords()) { $options->add('time', array('url' => $this->getDuplicateUrl(), 'text' => lang('Time Records (:count)', array('count' => $this->countTimeRecords())))); } // if if ($this->canEdit($user)) { $options->add('edit', array('url' => $this->getEditUrl(), 'text' => lang('Edit'))); } // if if ($this->canDelete($user)) { $options->add('delete', array('url' => $this->getDeleteUrl(), 'text' => lang('Delete'), 'confirm' => lang('Are you sure that you want to delete this invoice?'), 'method' => 'post')); } // if return $options->count() ? $options : null; }