You are here

function drush_uc_csv_export_report in Ubercart CSV 7.2

Do the report

This follows the model used by the web interface, but allows for command line execution

File

./uc_csv.drush.inc, line 193

Code

function drush_uc_csv_export_report($of, $id = NULL) {

  // if the id is null, then present a list of available reports to export and have them
  // select from that list
  if (empty($id)) {

    // Get a list of all of the available reports
    $options = array();
    $result = db_query('SELECT * from {uc_csv_reports} ORDER BY report_name ASC');
    while ($rdata = $result
      ->fetchObject()) {
      $options[$rdata->rid] = $rdata->report_name;
    }
    $choice = drush_choice($options, dt('Which report do you wish to export?'));
    $form_state = array();
    $form_state['values']['rid'] = $choice;
    $data = uc_csv_select_report_to_export_submit(array(), $form_state);
  }
  else {
    $form_state = array();
    $form_state['values']['rid'] = $id;
    $data = uc_csv_select_report_to_export_submit(array(), $form_state);
  }
  $of = drush_get_option('of');
  if (!empty($of)) {
    _uc_csv_save_report($data['report'], $data['contents'], $of);
  }
}