return $this->add('select', $elementName, $settings['label'], NULL, $settings['required'], $props);
}
+ /**
+ * Add actions menu to results form.
+ *
+ * @param $tasks
+ */
+ public function addTaskMenu($tasks) {
+ if (is_array($tasks) && !empty($tasks)) {
+ $tasks = array('' => ts('Actions')) + $tasks;
+ $this->add('select', 'task', NULL, $tasks, FALSE, array('class' => 'crm-select2 crm-action-menu huge crm-search-result-actions'));
+ if (empty($this->_actionButtonName)) {
+ $this->_actionButtonName = $this->getButtonName('next', 'action');
+ }
+ $this->assign('actionButtonName', $this->_actionButtonName);
+ $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'hiddenElement crm-search-go-button'));
+
+ // Radio to choose "All items" or "Selected items only"
+ $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked'));
+ $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all');
+ $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']);
+ $this->assign('ts_all_id', $allRowsRadio->_attributes['id']);
+
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js', 1, 'html-header');
+ }
+ }
+
/**
* Set options and attributes for chain select fields based on the controlling field's value
*/
$this->_instanceButtonName = $this->getButtonName('submit', 'save');
$this->_createNewButtonName = $this->getButtonName('submit', 'next');
- $this->_printButtonName = $this->getButtonName('submit', 'print');
- $this->_pdfButtonName = $this->getButtonName('submit', 'pdf');
- $this->_csvButtonName = $this->getButtonName('submit', 'csv');
$this->_groupButtonName = $this->getButtonName('submit', 'group');
$this->_chartButtonName = $this->getButtonName('submit', 'chart');
}
*/
public function buildInstanceAndButtons() {
CRM_Report_Form_Instance::buildForm($this);
-
- $label = $this->_id ? ts('Update Report') : ts('Create Report');
-
- $this->addElement('submit', $this->_instanceButtonName, $label);
- $this->addElement('submit', $this->_printButtonName, ts('Print Report'));
- $this->addElement('submit', $this->_pdfButtonName, ts('PDF'));
+ $this->_actionButtonName = $this->getButtonName('submit');
+ $this->addTaskMenu($this->getActions($this->_id));
if ($this->_id) {
$this->addElement('submit', $this->_createNewButtonName,
ts('Save a Copy') . '...');
}
- $this->assign('instanceForm', $this->_instanceForm);
-
- $label = $this->_id ? ts('Print Report') : ts('Print Preview');
- $this->addElement('submit', $this->_printButtonName, $label);
-
- $label = $this->_id ? ts('PDF') : ts('Preview PDF');
- $this->addElement('submit', $this->_pdfButtonName, $label);
-
- $label = $this->_id ? ts('Export to CSV') : ts('Preview CSV');
+ $this->addElement('submit', $this->_instanceButtonName,
+ ts('Update Report'));
- if ($this->_csvSupported) {
- $this->addElement('submit', $this->_csvButtonName, $label);
- }
+ $this->assign('instanceForm', $this->_instanceForm);
// CRM-16274 Determine if user has 'edit all contacts' or equivalent
$permission = CRM_Core_Permission::getPermission();
$this->addElement('submit', $this->_groupButtonName, '', array('style' => 'display: none;'));
$this->addChartOptions();
+ $showResultsLabel = $this->getResultsLabel();
$this->addButtons(array(
array(
'type' => 'submit',
- 'name' => ts('Preview Report'),
+ 'name' => $showResultsLabel,
'isDefault' => TRUE,
),
)
);
}
+ /**
+ * Has this form been submitted already?
+ *
+ * @return bool
+ */
+ public function resultsDisplayed() {
+ $buttonName = $this->controller->getButtonName();
+ return ($buttonName || $this->_outputMode);
+ }
+
+ /**
+ * Get the actions for this report instance.
+ *
+ * @param int $instanceId
+ *
+ * @return array
+ */
+ protected function getActions($instanceId) {
+ $actions = array(
+ 'html' => $this->getResultsLabel(),
+ 'save' => ts('Update'),
+ 'copy' => ts('Save a Copy'),
+ 'print' => ts('Print Report'),
+ 'pdf' => ts('Print to PDF'),
+ );
+ if (empty($instanceId)) {
+ $actions['save'] = ts('Create Report');
+ }
+
+ if ($this->_outputMode || $this->_id) {
+ $actions['html'] = ts('Refresh Results');
+ }
+
+ if ($this->_csvSupported) {
+ $actions['csv'] = ts('Export as CSV');
+ }
+
+ if (!empty($this->_charts)) {
+ $this->assign('charts', $this->_charts);
+ if ($this->_format != '') {
+ $actions['tabular'] = ts('View as tabular data');
+ }
+ if ($this->_format != 'pieChart') {
+ $actions['pieChart'] = ts('View as pie chart');
+ }
+ if ($this->_format != 'barChart') {
+ $actions['barChart'] = ts('View as bar graph');
+ }
+ }
+
+ if (CRM_Core_Permission::check('administer Reports')) {
+ $actions['delete'] = ts('Delete report');
+ }
+
+ return $actions;
+ }
+
/**
* Main build form function.
*/
public function processReportMode() {
$this->setOutputMode();
+ $buttonName = $this->controller->getButtonName();
$this->_sendmail
= CRM_Utils_Request::retrieve(
'sendmail',
elseif ($this->_outputMode == 'copy' && $this->_criteriaForm) {
$this->_createNew = TRUE;
}
+ $this->assign('outputMode', $this->_outputMode);
$this->assign('outputMode', $this->_outputMode);
$this->assign('printOnly', $printOnly);
if ($this->_outputMode == 'save' || $this->_outputMode == 'copy') {
$this->_createNew = ($this->_outputMode == 'copy');
- // Do not pass go. Do not collect another chance to re-run the same query.
- // This will be called from the button - there is an earlier response to the url
- // perhaps they can still be consolidated more.
CRM_Report_Form_Instance::postProcess($this);
}
$this->beginPostProcessCommon();
LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id)
AND {$this->_aliases['civicrm_address']}.is_primary = 1\n";
+ if ($buttonName == $this->_createNewButtonName) {
+ $this->_outputMode = 'copy';
+ }
}
}