? 735418.patch
? 735418_2.patch
? 738020.patch
? 738020_2.patch
? 738020_3.patch
? 887638.patch
? 924002.patch
? 924436.patch
? storminvoice/storminvoice_report_html.tpl.php.txt
Index: storminvoice/storminvoice.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/storm/storminvoice/storminvoice.module,v
retrieving revision 1.4.4.85
diff -u -p -r1.4.4.85 storminvoice.module
--- storminvoice/storminvoice.module	27 Oct 2010 13:47:33 -0000	1.4.4.85
+++ storminvoice/storminvoice.module	30 Oct 2010 11:21:16 -0000
@@ -138,8 +138,9 @@ function storminvoice_theme() {
       'arguments' => array('node', 'report', 'language'),
     ),
     'storminvoice_report_html' => array(
-      'file'      => 'storminvoice.theme.inc',
-      'arguments' => array('node', 'language'),
+//      'file'      => 'storminvoice.theme.inc',
+      'template' => 'storminvoice_report_html',
+      'arguments' => array('node' => null, 'language' => null, 'language1' => null, 'status' => null, 'countries' => null, 'mycurrency' => null, 'myorg' => null, 'organization' => null, 'project' => null),
     ),
     'storminvoice_report_pdf' => array(
       'file'      => 'storminvoice.theme.inc',
Index: storminvoice/storminvoice.theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/storm/storminvoice/storminvoice.theme.inc,v
retrieving revision 1.2.4.59
diff -u -p -r1.2.4.59 storminvoice.theme.inc
--- storminvoice/storminvoice.theme.inc	27 Oct 2010 13:47:33 -0000	1.2.4.59
+++ storminvoice/storminvoice.theme.inc	30 Oct 2010 11:21:17 -0000
@@ -440,8 +440,34 @@ function theme_storminvoice_view($node, 
 }
 
 function theme_storminvoice_report($node, $report, $language) {
+
+  $languages = explode(',', $language);
+  $language = $languages[0];
+  $language1 = '';
+  if (array_key_exists(1, $languages)) {
+    $language1 = $languages[1];
+  }
+
+  $status = 'open';
+  if ($node->paymentdate) {
+    $status = 'paid';
+  }
+  else if ($node->duedate < time()) {
+    $status = 'overdue';
+  }
+
+  $countries = stormattribute_attributes_bydomain('Country');
+  $countries = $countries['values'];
+  $currencies = stormattribute_attributes_bydomain('Currency');
+  $currencies = $currencies['values'];
+  $myorg = node_load(variable_get('storm_organization_nid', 0));
+  $mycurrency = $currencies[$myorg->currency];
+
+  $organization = node_load($node->organization_nid);
+  $project = node_load($node->project_nid);
+
   if($report=='html') {
-    print theme('storminvoice_report_html', $node, $language); 
+    print theme('storminvoice_report_html', $node, $language, $language1, $status, $countries, $mycurrency, $myorg, $organization, $project); 
   }
   else if ($report=='pdf') {
     theme('storminvoice_report_pdf', $node, $language); 
@@ -673,7 +699,7 @@ function theme_storminvoice_report_pdf($
     return $pdf->Output($dir.$filename, "S");
   }
 }
-
+/*
 function theme_storminvoice_report_html($node, $language) {
   $languages = explode(',', $language);
   $language = $languages[0];
@@ -912,7 +938,7 @@ function theme_storminvoice_report_html(
 
   return theme('storm_report', $header, $o, $title, $footer, $headtitle);
 }
-
+*/
  /* Code to create invoice auto_add link
  * Input billable and billed to determine what the link is.
  * 
Index: storminvoice/storminvoice_report_html.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/storm/storminvoice/Attic/storminvoice_report_html.tpl.php,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 storminvoice_report_html.tpl.php
--- storminvoice/storminvoice_report_html.tpl.php	26 Oct 2010 15:13:08 -0000	1.1.2.1
+++ storminvoice/storminvoice_report_html.tpl.php	30 Oct 2010 11:21:17 -0000
@@ -0,0 +1,243 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ */
+
+/*  $languages = explode(',', $language);
+  $language = $languages[0];
+  $language1 = '';
+  if (array_key_exists(1, $languages)) {
+    $language1 = $languages[1];
+  }
+
+  $status = 'open';
+  if ($node->paymentdate) {
+    $status = 'paid';
+  }
+  else if ($node->duedate < time()) {
+    $status = 'overdue';
+  }
+
+  $countries = stormattribute_attributes_bydomain('Country');
+  $countries = $countries['values'];
+  $currencies = stormattribute_attributes_bydomain('Currency');
+  $currencies = $currencies['values'];
+  $myorg = node_load(variable_get('storm_organization_nid', 0));
+  $mycurrency = $currencies[$myorg->currency];
+
+  $organization = node_load($node->organization_nid);
+  $project = node_load($node->project_nid);
+*/
+  $o = '';
+  $title = t('Invoice', array(), $language);
+  if ($language1) $title .= '<br />'. t('Invoice', array(), $language1);
+  $headtitle = $title . ' '. $myorg->title . ' : ' . $organization->title . ' - ' . $node->number;
+
+  $o .= '<div>';
+  $o .= '<div id="storminvoice_billto"><table>';
+  $o .= '<tr><td class="storminvoice_billto_title">';
+  $o .= t('Bill To :', array(), $language);
+  if ($language1) $o .= '<br />'. t('Bill to :', array(), $language1);
+  $o .= '</td></tr>';
+  $o .= '<tr><td>';
+  $o .= '<strong>'. $organization->fullname .'</strong>';
+  $o .= '<br />';
+  $o .= $organization->address;
+  $o .= '<br />';
+  $o .= $organization->city;
+  $o .= '<br />';
+  $o .= $organization->provstate .' '. $organization->zip .' '. $countries[$organization->country];
+  $o .= '<br />';
+  if ($organization->taxid) {
+    $o .= t('Tax ID', array(), $language);
+    if ($language1) $o .= ' / '. t('Tax ID', array(), $language1);
+    $o .= ' : '. $organization->taxid;
+  }
+  $o .= '</td></tr>';
+  $o .= '</table></div>';
+
+  $o .= '<div id="storminvoice_details"><table>';
+  $o .= '<tr>';
+  $o .= '<td class="storminvoice_details_title">';
+  $o .= t('Invoice#', array(), $language);
+  if ($language1) $o .= '<br />'. t('Invoice#', array(), $language1);
+  $o .='</td>';
+  $o .= '<td class="storminvoice_details_title">';
+  $o .= t('Currency', array(), $language);
+  if ($language1) $o .= '<br />'. t('Currency', array(), $language1);
+  $o .= '</td>';
+  $o .= '<td class="storminvoice_details_title">';
+  $o .= t('Date', array(), $language);
+  if ($language1) $o .= '<br />'. t('Date', array(), $language1);
+  $o .= '</td>';
+  $o .= '<td class="storminvoice_details_title">';
+  $o .= t('Reference', array(), $language);
+  if ($language1) $o .= '<br />'. t('Reference', array(), $language1);
+  $o .= '</td>';
+  $o .= '</tr>';
+  $o .= '<tr>';
+  $o .= '<td>'. $node->number .'</td>';
+  $o .= '<td>'. $mycurrency .'</td>';
+  $o .= '<td>'. format_date($node->requestdate, 'custom', 'Y-m-d') .'</td>';
+  $o .= '<td>'. $node->reference .'</td>';
+  $o .= '</tr>';
+  $o .= '<tr>';
+  $o .= '<td class="storminvoice_details_title" colspan="2">';
+  $o .= t('Due total', array(), $language);
+  if ($language1) $o .= '<br />'. t('Due total', array(), $language1);
+  $o .= '</td>';
+  $o .= '<td class="storminvoice_details_title">';
+  $o .= t('Due date', array(), $language);
+  if ($language1) $o .= '<br />'. t('Due date', array(), $language1);
+  $o .= '</td>';
+  $o .= '<td class="storminvoice_details_title">';
+  $o .= t('Terms', array(), $language);
+  if ($language1) $o .= '<br />'. t('Terms', array(), $language1);
+  $o .= '</td>';
+  $o .= '</tr>';
+  $o .= '<tr>';
+  $o .= '<td style="text-align: center; font-weight: bold;" colspan="2">';
+  $o .= $mycurrency .' '. sprintf('%.2f', $node->total);
+  if ($organization->currency != $myorg->currency) {
+    $o .= '<br />';
+    $o .= '('. $organization->currency .' '. sprintf('%.2f', $node->totalcustomercurr) .')';
+  }
+  $o .= '</td>';
+  $o .= '<td>'. format_date($node->duedate, 'custom', 'Y-m-d') .'</td>';
+  $o .= '<td>'. variable_get('storminvoice_payment_terms', '') .'</td>';
+  $o .= '</tr>';
+  $o .= '</table></div>';
+  $o .= '</div>';
+
+  $description = t('Description', array(), $language);
+  if ($language1) $description .= '<br />'. t('Description', array(), $language1);
+
+  $amount = t('Amount', array(), $language);
+  if ($language1) $amount .= '<br />'. t('Amount', array(), $language1);
+
+  if ($node->tax1) {
+  $tax1 = variable_get('storm_tax1_name', 'Tax 1');
+  if ($language1) $tax1 .= '<br />'. variable_get('storm_tax1_name', 'Tax 1');
+  }
+  
+  if ($node->tax2) {
+  $tax2 = variable_get('storm_tax2_name', 'Tax 2');
+  if ($language1) $tax2 .= '<br />'. variable_get('storm_tax2_name', 'Tax 2');
+  }
+
+  $total = t('Total', array(), $language);
+  if ($language1) $total .= '<br />'. t('Total', array(), $language1);
+
+  $header = array(
+    array(
+      'data' => $description,
+    ),
+    array(
+      'data' => $amount,
+    ),
+  );
+  if ($node->tax1) {
+    $header[] = array(
+      'data' => $tax1,
+    );
+  }
+  if ($node->tax2) {
+    $header[] = array(
+      'data' => $tax2,
+    );
+  }
+    $header[] = array(
+      'data' => $total,
+    );
+
+  $items = storminvoice_getitems($node->vid);
+  $rows = array();
+  foreach ($items as $i) {
+    $rows[] = array(
+      array(
+        'data' => $i->description,
+      ),
+      array(
+        'data' => sprintf('%.2f', $i->amount),
+        'style' => 'text-align: right;',
+      ),
+    );
+    if ($node->tax1) {
+      $rows[end(array_keys($rows))][] = array(
+        'data' => sprintf('%.2f', $i->tax1),
+        'style' => 'text-align: right;',
+      );
+    }
+    if ($node->tax2) {
+      $rows[end(array_keys($rows))][] = array(
+        'data' => sprintf('%.2f', $i->tax2),
+        'style' => 'text-align: right;',
+      );
+    }
+      $rows[end(array_keys($rows))][] = array(
+        'data' => sprintf('%.2f', $i->total),
+        'style' => 'text-align: right;',
+      );
+  }
+
+  $total = t('Total', array(), $language);
+  if ($language1) $total .= ' / '. t('Total', array(), $language1);
+
+  $rows[] = array(
+    array(
+      'data' => $total,
+      'style' => 'font-weight: bold; text-align: center; background-color: #e9e9e9;',
+    ),
+    array(
+      'data' => sprintf('%.2f', $node->amount),
+      'style' => 'text-align: right;',
+    ),
+  );
+    
+  if ($node->tax1) {
+    $rows[end(array_keys($rows))][] = array(
+      'data' => sprintf('%.2f', $node->tax1),
+      'style' => 'text-align: right;',
+    );
+  }
+  if ($node->tax2) {
+    $rows[end(array_keys($rows))][] = array(
+      'data' => sprintf('%.2f', $node->tax2),
+      'style' => 'text-align: right;',
+    );
+  }
+    $rows[end(array_keys($rows))][] = array(
+      'data' => sprintf('%.2f', $node->total),
+      'style' => 'text-align: right;',
+    );
+
+  $o .= '<div id="storminvoice_items">'. theme('table', $header, $rows) .'</div>';
+
+  // Specific to Italian invoices
+  if ($node->taxexempt && $language1=='it') {
+    $o .= '<div id="storminvoice_tax_exempt">';
+    $o .= t('Tax exempt art. 7', array(), $language);
+    if ($language1) $o .= '<br />'. t('Tax exempt art. 7', array(), $language1);
+    $o .= '</div>';
+  }
+
+  $o .= '<div id="storminvoice_payment_modes"><table>';
+  $o .= '<tr><td class="storminvoice_payment_title">';
+  $o .= t('Payment', array(), $language);
+  if ($language1) $o .= '<br />'. t('Payment', array(), $language1);
+  $o .= '</td></tr>';
+  $o .= '<tr><td>';
+  $o .= variable_get('storminvoice_payment_modes', '');
+  $o .= '</td></tr>';
+  $o .= '</table></div>';
+
+  if ($status=='paid') {
+    $o .= '<div id="paid">';
+    $o .= '<h2>'. t('Paid in full', array(), $language) .'</h2>';
+    if ($language1) $o .= '<h2>'. t('Paid in full', array(), $language1) .'</h2>';
+    $o .= '</div>';
+  }
+
+  print theme('storm_report', $header, $o, $title, $footer, $headtitle);
