--- store.module.old 2007-01-02 11:14:40.000000000 +0100 +++ store.module 2007-01-03 18:01:54.000000000 +0100 @@ -251,7 +251,7 @@ function store_ec_settings() { the bottom of the product view which will allow the user select the quantity and other information.'), ); - + $form['product_cart_is_destination'] = array( '#type' => 'checkbox', '#title' => t('User is directed to the shopping cart after adding item.'), @@ -260,7 +260,58 @@ function store_ec_settings() { on the product page and a message will alert them that the item has been added to their cart.'), ); - + + // Begin invoice settings + $form['invoice'] = array( + '#type' => 'fieldset', + '#title' => t('Invoice settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE + ); + $form['invoice']['invoice_our__no'] = array( + '#type' => 'textfield', + '#title' => t('Your vat no'), + '#default_value' => variable_get('invoice_our_vat_no', 0), + '#size' => 40, + '#maxlength' => 180, + ); + $form['invoice']['invoice_bank'] = array( + '#type' => 'textfield', + '#title' => t('The name of your bank'), + '#default_value' => variable_get('invoice_bank', 0), + '#size' => 40, + '#maxlength' => 180, + ); + $form['invoice']['invoice_bank_account_no'] = array( + '#type' => 'textfield', + '#title' => t('Bank account no'), + '#default_value' => variable_get('invoice_bank_account_no', 0), + '#size' => 40, + '#maxlength' => 180, + ); + $form['invoice']['invoice_swift_code'] = array( + '#type' => 'textfield', + '#title' => t('SWIFT code'), + '#default_value' => variable_get('invoice_swift_code', 0), + '#size' => 40, + '#maxlength' => 180, + ); + $form['invoice']['invoice_prefered_currency'] = array( + '#type' => 'textfield', + '#title' => t('Your prefered currency'), + '#default_value' => variable_get('invoice_prefered_currency', 'USD'), + '#size' => 40, + '#maxlength' => 180, + ); + $form['payment_default_credit_time'] = array( + '#type' => 'textfield', + '#title' => t('Default credit'), + '#description' => t('The default days of credit you want to offer your customers'), + '#default_value' => variable_get('payment_default_credit_time', 8), + '#size' => 40, + '#maxlength' => 180, + ); + return $form; } @@ -307,13 +358,16 @@ function theme_store_invoice($txn, $prin $header = array(); $row = array(); + $date_type = 'custom'; + $custom_type = 'd.m.Y'; + $custom_type_payment = 'd.m.Y'; if (empty($txn->mail) && $txn->uid > 0) { $txn->mail = db_result(db_query('SELECT mail FROM {users} WHERE uid = %d', $txn->uid)); } if ($txn->items) { - $header = array(t('Quantity'), t('Item'), t('Price')); + $header = array(t('SKU'), t('Quantity'), t('Unit'), array('data' => t('Item'), 'align' => 'left'), t('Price'), t('%'), t('Amount')); $shippable = FALSE; foreach ($txn->items as $p) { @@ -335,47 +389,104 @@ function theme_store_invoice($txn, $prin } } - $row[] = array(array('data' => $p->qty, 'align' => 'center', 'valign' => 'top'), ''. check_plain($p->title). ' '. (($prod->sku != '') ? "[". check_plain($prod->sku) ."]" : ''). '
'. $details, array('data' => payment_format($price), 'valign' => 'top')); + $row[] = array(array('data' => (($prod->sku != '') ? check_plain($prod->sku) : check_plain($prod->nid)), 'width' => '81', 'align' => 'center', 'valign' => 'top'), array('data' => $p->qty, 'align' => 'center', 'valign' => 'top', 'width' => '40'), array('data' => 'stk.', 'align' => 'center', 'valign' => 'top', 'width' => '40'), array('data' => check_plain($p->title), 'align' => 'left', 'valign' => 'top', 'width' => '378'), array('data' => number_format($price,2, variable_get('payment_decimalsign', ','), variable_get('payment_digisign', '.')), 'valign' => 'top', 'width' => '75', 'align' => 'right'), array('data' => number_format(0.00,2, variable_get('payment_decimalsign', ','), variable_get('payment_digisign', '.')), 'align' => 'right', 'width' => '40', 'valign' => 'top'), array('data' => number_format($price*$p->qty,2, variable_get('payment_decimalsign', ','), variable_get('payment_digisign', '.')), 'align' => 'right', 'valign' => 'top', 'width' => '96')); } if (is_array($txn->misc)) { foreach ($txn->misc as $misc) { if (!$misc->seen) { - $row[] = array(array('data' => t("{$misc->description}: %price", array('%price' => payment_format($misc->price))), 'colspan' => 3, 'align' => 'right')); + $row[] = array(array('colspan' => 3), array('data' => $misc->description, 'valign' => 'top'), array('data' => number_format($misc->price,2, variable_get('payment_decimalsign', ','), variable_get('payment_digisign', '.')), 'align' => 'right', 'valign' => 'top'), array('data' => number_format(0.00,2, variable_get('payment_decimalsign', ','), variable_get('payment_digisign', '.')), 'align' => 'right', 'valign' => 'top'), array('data' => number_format($misc->price,2, variable_get('payment_decimalsign', ','), variable_get('payment_digisign', '.')), 'align' => 'right', 'valign' => 'top')); } } } - $row[] = array(array('data' => '
', 'colspan' => 3, 'align' => 'right')); - $row[] = array(array('data' => t('Total: %total', array('%total' => payment_format(store_transaction_calc_gross($txn)))), 'colspan' => 3, 'align' => 'right')); + //$row[] = array(array('data' => '
', 'colspan' => 3, 'align' => 'right')); } - $payment_info = t('
Ordered On: %order-date
', array('%order-date' => format_date($txn->created))); - if ($txn->duedate) { - $payment_info.= t('
Due Date: %due-date
', array('%due-date' => format_date($txn->duedate))); - } - $payment_info .= t('
Transaction ID: %txnid
', array('%txnid' => $trial ? t('Trial Invoice - Not Yet Posted') : $txn->txnid)); + $creation_date = t('
Date: %date
', array('%date' => format_date($txn->created,$date_type,$custom_type_payment))); + $payment_date = t('
Due Date: %due-date
', array('%due-date' => format_date($txn->duedate,$date_type,$custom_type_payment))); + $transaction_id = t('
Transaction ID: %txnid
', array('%txnid' => $trial ? t('Trial Invoice - Not Yet Posted') : $txn->txnid)); + $customer_id = t('
Customer no: %uid
', array('%uid' => $txn->uid)); + $EAN_no = t('
EAN no: %EAN_no
', array('%EAN_no' => db_result(db_query('SELECT value FROM {profile_values} WHERE fid = 1 AND uid = %d', $txn->uid)))); $css = base_path(). drupal_get_path('module', 'store') .'/invoice.css'; $site_name = t('%site-name Invoice', array('%site-name' => variable_get("site_name", "drupal"))); - if ($shipping_to = store_format_address($txn, 'shipping', 'html')) { - $shipping_label = t('Shipping to'); - } - - if ($billing_to = store_format_address($txn, 'billing', 'html')) { - $billing_label = t('Billing to'); - } - if ($txn->ship) { $shipping_method_label = t('Shipping method:'); $shipping_method = store_format_shipping_method($txn); } $email_label = t('E-mail:'); $items_label = t('Items ordered'); - $items_view = theme('table', $header, $row, array('cellpadding' => 3, 'cellspacing' => 3)); + $items_view = theme('table', $header, $row, array('cellpadding' => 0, 'cellspacing' => 0)); - $payment_label = t('Payment Info'); + if ($shipping_to = store_format_address($txn, 'shipping', 'html')) { + $shipping_label = t('Shipping to'); + } + if ($billing_to = store_format_address($txn, 'billing', 'html')) { + $billing_label = t('Billing to'); + } + + $header = array(); + $row = array(); + $header = array(array('data' => t('Delivery address:'), 'align' => 'left')); + $row[] = array(array('data' => $shipping_to, 'align' => 'left', 'valign' => 'top')); + + $delivery_address = theme('table', $header, $row, array('cellpadding' => 0, 'cellspacing' => 0)); + + $header = array(); + $row = array(); + + $header = array(t('Netto gross'), t('Tax bound'), t('Tax rate'), t('Tax'), t('Total')); + $row[] = array(array('data' => number_format(store_transaction_calc_gross($txn),variable_get('payment_decimal_places', 2), + variable_get('payment_decimal', '.'), + variable_get('payment_thousands', ',')), 'align' => 'center'), array('data' => number_format(store_transaction_calc_gross($txn),variable_get('payment_decimal_places', 2), + variable_get('payment_decimal', '.'), + variable_get('payment_thousands', ',')), 'align' => 'center'), array('data' => number_format(25,variable_get('payment_decimal_places', 2), + variable_get('payment_decimal', '.'), + variable_get('payment_thousands', ',')), 'align' => 'center'), array('data' => number_format(store_transaction_calc_gross($txn)*0.8,variable_get('payment_decimal_places', 2), + variable_get('payment_decimal', '.'), + variable_get('payment_thousands', ',')), 'align' => 'center'), array('data' => number_format(store_transaction_calc_gross($txn)*1.25,variable_get('payment_decimal_places', 2), + variable_get('payment_decimal', '.'), + variable_get('payment_thousands', ',')), 'align' => 'center')); + + $summary_view = theme('table', $header, $row, array('cellpadding' => 0, 'cellspacing' => 0)); + + $header = array(); + $row = array(); + + /* + * Lets set if this is a invoice or a credit note or something else + */ + if (store_transaction_calc_gross($txn) > 0) { + $transaction_type = t('Invoice'); + } else { + $transaction_type = t('Credit note'); + } + + // These parameters should be set somewhere else, than in the code!!! + $payment_terms_label = t('Terms of payment'); + $delivery_terms_label = t('Terms of delivery'); + $currency_label = t('Currency'); + $customervatno_label = t('Customer vat no.:'); + $ourvatno_label = t('Our vat no.:'); + $payable_to_label = t('Payable to:'); + + // We set the terms of payment according to the select payment method + $payment_method = $txn->payment_method; + if ($payment_method == 'paypal') { + $payment_terms = t('Credit card'); + $delivery_terms = t('Del. Duty paid'); + } else { + $payment_terms = t('Bank transfer'); + $delivery_terms = t('Del. Duty Unpaid'); + } + $currency = variable_get('invoice_prefered_currency',''); + $customervatno = ''; + $ourvatno = variable_get('invoice_our_vat_no',''); + $bank = variable_get('invoice_bank',''); + $bank_account = t('Account : ').variable_get('invoice_bank_account_no',''); + $swift_code = 'SWIFT : '.variable_get('invoice_swift_code',''); if ($print_mode) { $output .= << - +




EOD; } $output .= <<$site_name - +
- - + + - - +
$shipping_label$billing_label + $billing_to + +

+ $transaction_type +

+ $creation_date + $transaction_id + $customer_id + $payment_date +
$shipping_to$billing_to + $EAN_no +
- -

$shipping_method_label $shipping_method

-

$email_label $txn->mail

- -

$items_label

+
+ $delivery_address +
$items_view +
+ $summary_view +
-

$payment_label

- $payment_info +
+ + + + + + +
+ $payment_terms_label +
$delivery_terms_label +
$currency_label +
$customervatno_label +
$ourvatno_label
+
+ $payment_terms +
+ $delivery_terms +
+ $currency +
+
+ $ourvatno +
+ $payable_to_label +
+
+ $bank +
+ $bank_account +
+ $swift_code +
+
EOD; if ($print_mode) { @@ -730,6 +883,7 @@ function store_transaction_save($edit) { else { // INSERT if (!$edit['created']) { $edit['created'] = time(); + $edit['duedate'] = time() + (variable_get('payment_default_credit_time', 8) * 86400); } if (!$edit['payment_status']) {