'checkbox',
'#title' => t('Display email address for non-anonymous customers'),
'#default_value' => variable_get('ec_display_email', 1),
);
// Links settings.
$form['ec_links'] = array(
'#type' => 'fieldset',
'#title' => t('Links'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['ec_links']['ec_goto_cart_empty'] = array(
'#type' => 'textfield',
'#title' => t('Empty cart link'),
'#default_value' => variable_get('ec_goto_cart_empty', ''),
'#description' => t('If the user cart is empty, you can send him/her to a given page.'),
);
return system_settings_form($form);
}
/**
* Configure all workflow statuses.
*/
function ec_store_workflow_settings($form, &$form_state) {
$form = array();
$workflow = ec_store_transaction_workflow('types');
$form['ec_store_workflow'] = array(
'#tree' => TRUE,
);
foreach ($workflow as $key => $item) {
$form['ec_store_workflow'][$key]['workflow'] = array(
'#type' => 'value',
'#value' => $item['workflow'],
);
$form['ec_store_workflow'][$key]['description'] = array(
'#markup' => $item['description'],
);
$options = array(
EC_WORKFLOW_TYPE_IN_PROGRESS => t('In progress'),
EC_WORKFLOW_TYPE_COMPLETE => t('Complete'),
EC_WORKFLOW_TYPE_CANCEL => t('Cancel'),
);
$form['ec_store_workflow'][$key]['type'] = array(
'#markup' => $options[$item['type']],
);
$form['ec_store_workflow'][$key]['weight'] = array(
'#type' => 'weight',
'#default_value' => $item['weight'],
'#delta' => count($workflow) + 1,
);
$form['ec_store_workflow'][$key]['operations'] = array(
'#markup' => l(t('edit'), 'admin/config/store/store/workflow/' . $item['workflow'] . '/edit') . ' ' . l(t('delete'), 'admin/config/store/store/workflow/' . $item['workflow'] . '/delete'),
);
}
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
return $form;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function ec_store_workflow_settings_submit(&$form, &$form_state) {
foreach ($form_state['values']['ec_store_workflow'] as $record) {
drupal_write_record('ec_workflow_statuses', $record, 'workflow');
}
drupal_set_message(t('Workflow settings updated'));
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function ec_store_workflow_settings_edit($form, $form_state, $workflowid = NULL) {
$form = array();
if ($workflowid) {
$workflow = ec_store_transaction_workflow('types');
if (isset($workflow[$workflowid])) {
$item = $workflow[$workflowid];
$form['workflow'] = array(
'#type' => 'value',
'#value' => $item['workflow'],
);
}
else {
drupal_not_found();
}
}
else {
$item = array();
}
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => isset($item['description']) ? $item['description'] : NULL,
'#description' => t('Provide a short descriptions which will be used to identify which workflow state the transaction is in'),
);
$form['help'] = array(
'#type' => 'textarea',
'#title' => t('Help'),
'#default_value' => isset($item['help']) ? $item['help'] : NULL,
'#description' => t('Provide information on what the stage of the transaction workflow should be done.'),
);
$options = array(
EC_WORKFLOW_TYPE_IN_PROGRESS => t('In progress'),
EC_WORKFLOW_TYPE_COMPLETE => t('Complete'),
EC_WORKFLOW_TYPE_CANCEL => t('Cancel'),
);
$form['type'] = array(
'#type' => 'select',
'#title' => t('Type of workflow'),
'#default_value' => isset($item['type']) ? $item['type'] : NULL,
'#options' => $options,
'#description' => t('Provide type of workflow which will allow the system to idenitify the general purpose of the workflow.'),
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
if (!empty($item)) {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array('ec_store_workflow_settings_edit_submit_delete'),
);
}
return $form;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function ec_store_workflow_settings_edit_submit(&$form, &$form_state) {
if (isset($form_state['values']['workflow'])) {
drupal_write_record('ec_workflow_statuses', $form_state['values'], 'workflow');
}
else {
drupal_write_record('ec_workflow_statuses', $form_state['values']);
}
drupal_set_message(t('Workflow %name has been updated', array('%name' => $form_state['values']['description'])));
$form_state['redirect'] = 'admin/config/store/store/workflow';
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function ec_store_workflow_settings_edit_submit_delete(&$form, &$form_state) {
drupal_goto('admin/config/store/store/workflow/' . $form_state['values']['workflow'] . '/delete');
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function ec_store_workflow_settings_delete($form, $form_state, $workflowid) {
$form = array();
if ($workflowid) {
$workflow = ec_store_transaction_workflow('types');
if (isset($workflow[$workflowid])) {
$item = $workflow[$workflowid];
$form['workflow'] = array(
'#type' => 'value',
'#value' => $item['workflow'],
);
$form['name'] = array(
'#type' => 'value',
'#value' => $item['description'],
);
}
else {
drupal_not_found();
}
}
else {
drupal_not_found();
}
return confirm_form($form, t('Do you really want to delete the %name workflow', array('%name' => $item['description'])), 'admin/config/store/store/workflow', t('This action is permanent and cannot be undone'), t('Delete'), t('Cancel'));
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function ec_store_workflow_settings_delete_submit(&$form, &$form_state) {
db_delete('ec_workflow_statuses')
->condition('workflow', $form_state['values']['workflow'])
->execute();
drupal_set_message(t('Workflow %description has been deleted', array('%description' => $form_state['values']['name'])));
$form_state['redirect'] = 'admin/config/store/store/workflow';
}
/**
* Called by theme_store_invoice().
*/
function _theme_ec_store_invoice($txn, $print_mode = TRUE, $trial = FALSE) {
global $base_url;
$header = array();
$row = array();
if (empty($txn->mail) && $txn->uid > 0) {
$txn->mail = db_query('SELECT mail FROM {users} WHERE uid = :uid', array(':uid' => $txn->uid))->fetchField();
}
if (!empty($txn->items)) {
$header = array(t('Quantity'), t('Item'), t('Price'));
$shippable = FALSE;
foreach ($txn->items as $p) {
$prod = ec_product_load($p);
if (product_is_shippable($p->vid)) {
$shippable = TRUE;
}
$price = ec_store_adjust_misc($txn, $p);
$subtotal += (product_has_quantity($p) ? $p->qty * $price : $price);
$details = '';
if (0 && is_array($p->data)) {
foreach ($p->data as $key => $value) {
if (!empty($value)) {
$items[] = '' . check_plain($key) . ': ' . check_plain($value);
}
}
if (!empty($items)) {
$details = theme('item_list', array('items' => $items));
}
}
$row[] = array(
array(
'data' => $p->qty,
'align' => 'center',
'valign' => 'top',
),
'' . check_plain($p->title) . ' ' . (($prod->sku != '') ?
'[' . check_plain($prod->sku) . ']' : '') . '
' . $details,
array(
'data' => format_currency($price),
'valign' => 'top',
'align' => 'right',
),
);
}
if (is_array($txn->misc)) {
foreach ($txn->misc as $misc) {
if (empty($misc->seen)) {
$price = isset($misc->qty) ? $misc->price * $misc->qty : $misc->price;
$row[] = array(array(
'data' => "{$misc->description}: " .
format_currency($price),
'colspan' => 3,
'align' => 'right',
));
}
}
}
$row[] = array(array(
'data' => '
| $shipping_label | $billing_label |
|---|---|
| $shipping_to | $billing_to |
$shipping_method_label $shipping_method
$email_label $txn->mail