<?php 
if (isset($price_final)) {
    ?>
    <div class="total-price">
      <?php 
    print $price_final;
    ?>
    </div>
  <?php 
}
?>

  <div class="foot-note">
    Gaarne het totaal bedrag van <?php 
print _format_decimals($grand_total);
?>
 overmaken op rekening nummer 626590922<br />
    ten name van C.A.M. Krijnen-Bruin te Berkhout<br />
    <br />
    iban: NL73ABNA0626590922<br />
    BIC;: ABNANL2A<br />
    <br />
    Ik wens je heel veel knutsel plezier.<br />
    Mocht je nog vragen of opmerkingen hebben tijdens het knutselen aarzel dan niet contact<br />
    met mij op te nemen.<br />
    <br />
    Met vriendelijke groeten,<br />
    <br />
    Tine Krijnen
</div>
Ejemplo n.º 2
0
/**
 * Implements theme_preprocess_node
 * Used for creating variables to print on the node.
 */
function bootsub_preprocess_node(&$variables)
{
    if ($variables['node']->type == 'invoice') {
        global $base_url;
        $euro = '&euro;';
        // Check if the invoice sold to field is set and has a title + vid.
        if (isset($variables['node']->field_invoice_sold_to[LANGUAGE_NONE][0]['entity']->title)) {
            $customer = $variables['node']->field_invoice_sold_to[LANGUAGE_NONE][0]['entity']->title;
            if (isset($variables['node']->field_invoice_sold_to[LANGUAGE_NONE][0]['entity']->vid)) {
                $vid = $variables['node']->field_invoice_sold_to[LANGUAGE_NONE][0]['entity']->vid;
                $node = node_load($vid);
                $variables['first_name'] = $node->field_customer_firstname[LANGUAGE_NONE][0]['value'];
                // Generate the information for the person selling to.
                $customer = array('name' => $node->field_customer_firstname[LANGUAGE_NONE][0]['value'] . ' ' . $node->field_customer_last_name[LANGUAGE_NONE][0]['value'], 'address' => $node->field_customer_address[LANGUAGE_NONE][0]['value'], 'postalcode_residence' => $node->field_customer_postalcode[LANGUAGE_NONE][0]['value'] . ' ' . $node->field_customer_residence[LANGUAGE_NONE][0]['value']);
                $variables['invoice_receiver'] = theme('item_list', array('items' => $customer));
            }
        }
        // The table header
        $header = array(t('Amount'), t('Price each'), t('Description'), t('Price'), t('Tax'), t('Tax high'), t('Tax low'));
        // Check if the products sold field is set.
        if (isset($variables['field_invoice_products_sold'])) {
            $product_list = array();
            // Initialize all variables as zero.
            $tax_low = 0;
            $tax_high = 0;
            $total_tax_low = 0;
            $total_tax_high = 0;
            $sub_total = 0;
            $grand_total = 0;
            $shipping = 3.5;
            // Loop through the array of sold products.
            foreach ($variables['field_invoice_products_sold'] as $id => $values) {
                // Generate a (new) array of products with title and price.
                $product_list[] = array('title' => $variables['field_invoice_products_sold'][$id]['entity']->title, 'price' => $variables['field_invoice_products_sold'][$id]['entity']->field_product_price[LANGUAGE_NONE][0]['value']);
                // Assign the variables for later math use.
                $price_each = $price = $variables['field_invoice_products_sold'][$id]['entity']->field_product_price[LANGUAGE_NONE][0]['value'];
                $description = $variables['field_invoice_products_sold'][$id]['entity']->title;
                $price = $variables['field_invoice_products_sold'][$id]['entity']->field_product_price[LANGUAGE_NONE][0]['value'];
                $tax = $variables['field_invoice_products_sold'][$id]['entity']->field_product_tax[LANGUAGE_NONE][0]['value'];
                // If low tax percentage.
                if ($tax == '6') {
                    $tax_low = round($price - $price / 1.06, 2);
                    $price = $price - $tax_low;
                    $total_tax_low += $tax_low;
                } elseif ($tax == '21') {
                    $tax_high = $price - $price / 1.21;
                    $price = $price - $tax_high;
                    $total_tax_high += $tax_high;
                }
                // Add the prices to generate sub total.
                $sub_total += $price;
                // Add the price each (with tax) to generate grand total.
                $grand_total += $price_each;
                // Fill the rows for the table.
                $price_rows[] = array('data' => array('1', _format_decimals($price_each), $description, _format_decimals($price), $tax . '%', _format_decimals($tax_high), _format_decimals($tax_low)));
            }
        }
        // Generate a variable for the product display table.
        $variables['invoice_product_display'] = theme('table', array('header' => $header, 'rows' => $price_rows, 'attributes' => array('width' => '100%')));
        // Finally add the shipping to the grand total.
        $grand_total = $grand_total + $shipping;
        $variables['grand_total'] = $grand_total;
        // Generate a total price and put in its variable.
        $price_items = array('sub' => t('Sub total') . ' ' . _format_decimals($sub_total), 'tax_high' => t('Tax high') . ' ' . _format_decimals($total_tax_high), 'tax_low' => t('Tax low') . ' ' . _format_decimals($total_tax_low), 'shipping' => t('Shipping costs') . ' ' . _format_decimals($shipping), 'final' => t('Grand total') . ' ' . _format_decimals($grand_total));
        // Place the theme item list in the price table.
        //$variables['price_final'] = theme('item_list', array('items' => $price_items));
        $costs_rows = array(array(t('Sub total'), _format_decimals($sub_total)), array(t('Tax high'), _format_decimals($total_tax_high)), array(t('Tax low'), _format_decimals($total_tax_low)), array(t('Shipping costs'), _format_decimals($shipping)), array(t('Grand total'), _format_decimals($grand_total)));
        $variables['price_final'] = theme('table', array('rows' => $costs_rows));
    }
}