'Receive Check', 'page callback' => 'drupal_get_form', 'page arguments' => array('uc_payment_pack_receive_check_form', 3), 'access arguments' => array('view all orders'), 'type' => MENU_CALLBACK, 'file' => 'uc_payment_pack.admin.inc', ); return $items; } function uc_payment_pack_theme() { return array( 'uc_payment_method_other_form' => array( 'arguments' => array('form' => NULL), ), 'uc_payment_pack_receive_check_form' => array( 'arguments' => array('form' => NULL), 'file' => 'uc_payment_pack.admin.inc', ), ); } /** * Implementation of hook_init(). */ function uc_payment_pack_init() { global $conf; $conf['i18n_variables'][] = 'uc_cod_policy'; $conf['i18n_variables'][] = 'uc_check_policy'; } /** * Implementation of hook_payment_method(). */ function uc_payment_pack_payment_method() { $methods[] = array( 'id' => 'check', 'name' => t('Check'), 'title' => t('Check or money order'), 'desc' => t('Pay by mailing a check or money order.'), 'callback' => 'uc_payment_method_check', 'weight' => 1, 'checkout' => TRUE, 'no_gateway' => TRUE, ); $methods[] = array( 'id' => 'cod', 'name' => t('COD'), 'title' => t('Cash on delivery'), 'desc' => t('Pay cash on delivery on pick-up.'), 'callback' => 'uc_payment_method_cod', 'weight' => 1, 'checkout' => FALSE, 'no_gateway' => TRUE, ); $methods[] = array( 'id' => 'other', 'name' => t('Other'), 'title' => t('Other'), 'desc' => t('A generic payment method type.'), 'callback' => 'uc_payment_method_other', 'weight' => 10, 'checkout' => FALSE, 'no_gateway' => TRUE, ); return $methods; } /** * Handle the generic payment method "Other." */ function uc_payment_method_other($op, &$arg1) { switch ($op) { case 'order-view': case 'customer-view': // Fetch the description for the payment entered by the administrator. if ($description = db_result(db_query("SELECT description FROM {uc_payment_other} WHERE order_id = %d", $arg1->order_id))) { return t('Description: @desc', array('@desc' => $description)); } break; case 'order-details': $details = drupal_get_form('uc_payment_method_other_form', $arg1); return uc_strip_form($details); case 'edit-process': $changes['payment_details']['pm_other_description'] = check_plain($_POST['pm_other_description']); return $changes; case 'order-load': if ($description = db_result(db_query("SELECT description FROM {uc_payment_other} WHERE order_id = %d", $arg1->order_id))) { $arg1->payment_details['description'] = $description; } break; case 'order-save': db_query("DELETE FROM {uc_payment_other} WHERE order_id = %d", $arg1->order_id); if (!empty($arg1->payment_details['pm_other_description'])) { db_query("INSERT INTO {uc_payment_other} (order_id, description) VALUES (%d, '%s')", $arg1->order_id, $arg1->payment_details['pm_other_description']); } break; } } function uc_payment_method_other_form($form_state, $order) { $form['pm_other_description'] = array( '#type' => 'textfield', '#size' => 32, '#maxlength' => 64, '#default_value' => $order->payment_details['description'], ); return $form; } function theme_uc_payment_method_other_form($form) { $output = '
' . t('Description:') .' | ' . drupal_render($form['pm_other_description']) .' |
'. t('Orders totalling more than !number are not eligible for COD.', array('!number' => uc_price($max, $context))) .'
'; } if (variable_get('uc_cod_delivery_date', FALSE)) { $details .= uc_strip_form(drupal_get_form('uc_payment_method_cod_form', $arg1)); } return $details; case 'cart-process': if (variable_get('uc_cod_delivery_date', FALSE)) { $arg1->payment_details['delivery_month'] = intval($_POST['cod_delivery_month']); $arg1->payment_details['delivery_day'] = intval($_POST['cod_delivery_day']); $arg1->payment_details['delivery_year'] = intval($_POST['cod_delivery_year']); } return TRUE; case 'cart-review': if (variable_get('uc_cod_delivery_date', FALSE)) { $date = uc_date_format($arg1->payment_details['delivery_month'], $arg1->payment_details['delivery_day'], $arg1->payment_details['delivery_year']); $review[] = array('title' => t('Delivery Date'), 'data' => $date); } return $review; case 'order-view': case 'customer-view': if (variable_get('uc_cod_delivery_date', FALSE)) { $output = t('Desired delivery date:') .''); $month = (!empty($order->payment_details['delivery_month'])) ? $order->payment_details['delivery_month'] : format_date(time(), 'custom', 'n'); $form['cod_delivery_month'] = uc_select_month(NULL, $month); $form['table2'] = array('#value' => ' | '); $day = (!empty($order->payment_details['delivery_day'])) ? $order->payment_details['delivery_day'] : format_date(time(), 'custom', 'j'); $form['cod_delivery_day'] = uc_select_day(NULL, $day); $form['table3'] = array('#value' => ' | '); $year = (!empty($order->payment_details['delivery_year'])) ? $order->payment_details['delivery_year'] : format_date(time(), 'custom', 'Y'); $form['cod_delivery_year'] = uc_select_year(NULL, $year, format_date(time(), 'custom', 'Y'), format_date(time(), 'custom', 'Y') + 1); $form['table4'] = array('#value' => ' |
' . uc_address_format(variable_get('uc_store_name', ''), NULL, variable_get('uc_store_company', ''), variable_get('uc_store_street1', ''), variable_get('uc_store_street2', ''), variable_get('uc_store_city', ''), variable_get('uc_store_zone', ''), variable_get('uc_store_postal_code', ''), variable_get('uc_store_country', 840)) .'
'. variable_get('uc_check_policy', '') .'
'; } else { $details = t('Checks should be made out to:') .'' . uc_address_format(variable_get('uc_check_mailing_name', ''), NULL, variable_get('uc_check_mailing_company', ''), variable_get('uc_check_mailing_street1', ''), variable_get('uc_check_mailing_street2', ''), variable_get('uc_check_mailing_city', ''), variable_get('uc_check_mailing_zone', ''), variable_get('uc_check_mailing_postal_code', ''), variable_get('uc_check_mailing_country', 840)) .'
'. variable_get('uc_check_policy', '') .'
'; } return $details; case 'cart-review': if (!variable_get('uc_check_mailing_street1', FALSE)) { $review[] = array('title' => t('Mail to'), 'data' => uc_address_format(variable_get('uc_store_name', ''), NULL, variable_get('uc_store_company', ''), variable_get('uc_store_street1', ''), variable_get('uc_store_street2', ''), variable_get('uc_store_city', ''), variable_get('uc_store_zone', ''), variable_get('uc_store_postal_code', ''), variable_get('uc_store_country', 840))); } else { $review[] = array('title' => t('Mail to'), 'data' => uc_address_format(variable_get('uc_check_mailing_name', ''), NULL, variable_get('uc_check_mailing_company', ''), variable_get('uc_check_mailing_street1', ''), variable_get('uc_check_mailing_street2', ''), variable_get('uc_check_mailing_city', ''), variable_get('uc_check_mailing_zone', ''), variable_get('uc_check_mailing_postal_code', ''), variable_get('uc_check_mailing_country', 840))); } return $review; case 'order-view': if (!variable_get('uc_payment_tracking', TRUE)) { return ''; } $result = db_query("SELECT clear_date FROM {uc_payment_check} WHERE " ."order_id = %d ", $arg1->order_id); if ($check = db_fetch_object($result)) { $output = t('Clear Date:') .' '. format_date($check->clear_date, 'custom', variable_get('uc_date_format_default', 'm/d/Y')); } else { $output = l(t('Receive Check'), 'admin/store/orders/'. $arg1->order_id .'/receive_check'); } $output .= '