Getting following error when viewing an invoice

user warning: Unknown column 'sin.organization_nid' in 'where clause' query: SELECT n.*, sit.* FROM node AS n INNER JOIN storminvoiceitem sit ON n.vid=sit.vid WHERE (sit.invoice_nid=684) AND (n.uid=6 OR sin.organization_nid=50) AND ('storm_access'='storm_access') AND ( n.status=1 AND n.type='storminvoiceitem' ) ORDER BY sit.weight in path/modules/storm/storminvoice/storminvoice.admin.inc on line 379.

This is happening when the user has View of user organization permission, because the storminvoice_access_sql function in storminvoice.module adds the where clause:

  if (user_access('Storm invoice: view of user organization')) {
    if (!empty($cond)) $cond .= ' OR ';
    $cond .= 'sin.organization_nid='. $user->stormorganization_nid;
  }

But the query never includes storminvoice table.

Comments

Mark_Watson27’s picture

Added the storminvoice table to the query will resolve this

In the file storminvoice.admin.inc in function storminvoice_items add INNER JOIN storminvoice sin on sin.nid=sit.invoice_nid to the query on line 372 so it becomes
$s = "SELECT n.*, sit.* FROM {node} AS n INNER JOIN {storminvoiceitem} sit ON n.vid=sit.vid INNER JOIN storminvoice sin on sin.nid=sit.invoice_nid WHERE n.status=1 AND n.type='storminvoiceitem' ORDER BY sit.weight";

Mark_Watson27’s picture

Status: Active » Needs review

Added the storminvoice table to the query will resolve this

In the file storminvoice.admin.inc in function storminvoice_items add INNER JOIN storminvoice sin on sin.nid=sit.invoice_nid to the query on line 372 so it becomes
$s = "SELECT n.*, sit.* FROM {node} AS n INNER JOIN {storminvoiceitem} sit ON n.vid=sit.vid INNER JOIN storminvoice sin on sin.nid=sit.invoice_nid WHERE n.status=1 AND n.type='storminvoiceitem' ORDER BY sit.weight";

Magnity’s picture

Status: Needs review » Fixed

I've committed that fix - with the change that the table name must have {} around it in case of prefixing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.