Add php files

This commit is contained in:
2025-05-12 15:44:39 +00:00
parent c951760058
commit 82d5804ac4
9534 changed files with 2638137 additions and 0 deletions

View File

@@ -0,0 +1,287 @@
<?php
function getDocOperations($module, $id) {
$db = $GLOBALS['db'];
$doc = $db->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 .= '
<table style="width: 100%; font-size: 8pt;">
<tr>
<td style="width: ' . $w . '%">
<b><h1>'.$title.'</h1></b>
</td>
<td style="width: ' . $w2 . '%">
Dla dokumentu:
</td>
<td style="text-align: right">
<b>' . $doc['document_no'] . '</b>
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
</b>Data wystawienia:</b>
</td>
<td style="text-align: right">
<b>' . $doc['register_date'] . '</b>
</td>
</tr>
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Wystawił:
</td>
<td style="text-align: right">
<b>' . $user . '</b>
</td>
</tr>';
if ($module!='EcmStockDocMoves') {
$content.='
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Magazyn:
</td>
<td style="text-align: right">
<b>' . $stock . '</b>
</td>
</tr>';
} else {
$content.='
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Z magazynu:
</td>
<td style="text-align: right">
<b>' . $stock_out . '</b>
</td>
</tr>';
$content.='
<tr>
<td style="width: ' . $w . '%">
&nbsp;
</td>
<td style="width: ' . $w2 . '%">
Na magazyn:
</td>
<td style="text-align: right">
<b>' . $stock_in . '</b>
</td>
</tr>';
}
$content.='
</table><br>
';
$content .= '<br>';
// 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<br>Indeks',
'align' => 'left'
);
$columns ['qty'] = array (
'field' => array (
'quantity',
'unit_name'
),
'label' => 'Ilość<br>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 .= '
<table style="width: 100%; font-size: 7pt; border: 0.5 solid black; border-collapse: collapse"><thead>
<tr>
';
foreach ( $columns as $col ) {
$content .= '
<th style="border: 0.5 solid black; width: ' . $col ['width'] . '%;">' . $col ['label'] . '</th>
';
}
$content .= '
</tr></thead><tbody>
';
$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'].='<br>'.$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'].='<br>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'].='<br>Dokument wejścia: '.$app_list_strings['moduleList'][$in_doc['parent_type']].' '.$in_doc['parent_name'];
}
$content .= '<tr>';
foreach ( $columns as $col ) {
$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
foreach ( $col ['field'] as $f ) {
if ($f == 'position') {
$counter ++;
}
if (! $pos [$f] || $pos [$f] == '')
$pos [$f] = '-';
$content .= $pos [$f] . '<br>';
}
$content .= '</td>';
}
$content .= '</tr>';
}
$content .= '
</tbody></table>
';
$content .= '
<br><br>
<table style="font-size: 9pt; border: 0.5 solid black; border-collapse: collapse; width: 285px; margin-left: 60%">
';
if ($sum_in <> 0 )
$content .= '
<tr>
<td style="border: 0.5 solid black; width: 50%;">
Suma operacji wejścia
</td>
<td style="border: 0.5 solid black; text-align: right;">
' . format_number ( $sum_in,2,2 ) . '
</td>
</tr>
';
if ($sum_out <> 0)
$content .= '
<tr>
<td style="border: 0.5 solid black; width: 50%;">
Suma operacji wyjścia
</td>
<td style="border: 0.5 solid black; text-align: right;">
' . format_number ( $sum_out,2,2 ) . '
</td>
</tr>
';
$content .= '
</table>
';
return $content;
}
?>