fetchByAssoc($db->query("SELECT * FROM ".strtolower($module)." WHERE id='$id'")); //die("SELECT * FROM ".strtolower($module)." WHERE id='$id'"); $q=" SELECT o.product_name, o.product_code, o.quantity, o.price, i.dd_unit_id, i.dd_unit_name, o.type, i.position, o.part_no, o.in_id FROM ecmstockoperations as o INNER JOIN ".strtolower(substr($module,0,-1))."items as i ON o.documentitem_id = i.id WHERE o.parent_type='$module' AND o.parent_id='$id' ORDER BY i.position"; //die($q); $positions = $db->query($q); $u = new User(); $u->retrieve($doc['created_by']); $user = $u->full_name; unset($u); if ($module!='EcmStockDocMoves') { $s = new EcmStock(); $s->retrieve($doc['stock_id']); $stock = $s->name; unset($s); } else { $s = new EcmStock(); $s->retrieve($doc['stock_in_id']); $stock_in = $s->name; unset($s); $s = new EcmStock(); $s->retrieve($doc['stock_out_id']); $stock_out = $s->name; unset($s); } global $app_list_strings; $title = 'Lista przychodowo/rozchodowa'; $doc['document_no'] = $app_list_strings['moduleList'][$module].' '.$doc['document_no']; if ($module == 'EcmStockDocOuts' || $module == 'EcmStockDocInsideOuts') $title = 'Lista rozchodowa'; else if ($module == 'EcmInvoiceOuts') { $inv_t = $db->fetchByAssoc($db->query("SELECT type FROM ecminvoiceouts WHERE id='$id'")); if ($inv_t['type']=='normal') { $doc['document_no'] = 'FV '.$doc['document_no']; $title = 'Lista rozchodowa'; } else if ($inv_t['type']=='correct') { $doc['document_no'] = 'FVKOR '.$doc['document_no']; $title = 'Lista przychodowa'; } } $w = "80"; // first column width $w2 = "15"; // second column width $content .= ' '; if ($module!='EcmStockDocMoves') { $content.=' '; } else { $content.=' '; $content.=' '; } $content.='

'.$title.'

Dla dokumentu: ' . $doc['document_no'] . '
  Data wystawienia: ' . $doc['register_date'] . '
  Wystawił: ' . $user . '
  Magazyn: ' . $stock . '
  Z magazynu: ' . $stock_out . '
  Na magazyn: ' . $stock_in . '

'; $content .= '
'; // start items table $columns = array (); $columns ['position'] = array ( 'field' => array ( 'position' ), 'label' => 'Lp.', 'align' => 'center' ); $columns ['name'] = array ( 'field' => array ( 'product_name', 'product_code' ), 'label' => 'Nazwa
Indeks', 'align' => 'left' ); $columns ['qty'] = array ( 'field' => array ( 'quantity', 'unit_name' ), 'label' => 'Ilość
J.m.', 'align' => 'right' ); $columns ['price'] = array ( 'field' => array ( 'price' ), 'label' => 'Cena', 'align' => 'right' ); $columns ['total'] = array ( 'field' => array ( 'total' ), 'label' => 'Wartość', 'align' => 'right' ); // set widths $totals = array (); $columns ['position'] ['width'] = '5'; $columns ['name'] ['width'] = '45'; $columns ['qty'] ['width'] = '10'; $columns ['price'] ['width'] = '20'; $columns ['total'] ['width'] = '20'; // rysujemy :) $content .= ' '; foreach ( $columns as $col ) { $content .= ' '; } $content .= ' '; $counter = 1; $app_list_strings; $sum_in = 0; $sum_out = 0; while ($pos = $db->fetchByAssoc($positions)) { $pos['position'] +=1; $pos['unit_name'] = $pos['dd_unit_name']; $pos['total'] = $pos['quantity'] * $pos['price']; if ($pos['type']=='0') $sum_in+=$pos['total']; else $sum_out += $pos['total']; $pos['total'] = format_number($pos['total'],2,2); $pos['price'] = format_number($pos['price'],2,2); $precision = $app_list_strings ['ecmproducts_unit_dom_precision'] [$pos ['dd_unit_id']]; $pos['quantity'] = format_number($pos['quantity'], $precision, $precision); if ($module == 'EcmStockDocCorrects' || $module == 'EcmStockDocMoves') { if ($pos['type'] == 0) $pos['quantity'] = '(+) '.$pos['quantity']; if ($pos['type'] == 1) $pos['quantity'] = '(-) '.$pos['quantity']; } if ($pos['part_no'] && $pos['part_no']!="") $pos['product_code'].='
'.$pos['part_no']; if ($module == 'EcmInvoiceOuts') if ($inv_t['type'] == 'normal') { $in_doc = $db->fetchByAssoc($db->query("SELECT parent_name, parent_type FROM ecmstockoperations WHERE id='".$pos['in_id']."'")); $pos['price'].='
Dokument wejścia: '.$app_list_strings['moduleList'][$in_doc['parent_type']].' '.$in_doc['parent_name']; } else if ($inv_t['type'] == 'correct') { $ecminvoiceoutitem_id = $db->fetchByAssoc($db->query("SELECT ecminvoiceoutitem_id as i FROM ecminvoiceouts WHERE id='".$pos['id']."'")); $in_doc = $db->fetchByAssoc($db->query("SELECT parent_name, parent_type FROM ecmstockoperations WHERE id = (SELECT in_id FROM ecmstockoperations WHERE documentitem_id='".$ecminvoiceoutitem_id['i']."')")); $pos['price'].='
Dokument wejścia: '.$app_list_strings['moduleList'][$in_doc['parent_type']].' '.$in_doc['parent_name']; } $content .= ''; foreach ( $columns as $col ) { $content .= ''; } $content .= ''; } $content .= '
' . $col ['label'] . '
'; foreach ( $col ['field'] as $f ) { if ($f == 'position') { $counter ++; } if (! $pos [$f] || $pos [$f] == '') $pos [$f] = '-'; $content .= $pos [$f] . '
'; } $content .= '
'; $content .= '

'; if ($sum_in <> 0 ) $content .= ' '; if ($sum_out <> 0) $content .= ' '; $content .= '
Suma operacji wejścia ' . format_number ( $sum_in,2,2 ) . '
Suma operacji wyjścia ' . format_number ( $sum_out,2,2 ) . '
'; return $content; } ?>