317 lines
14 KiB
PHP
317 lines
14 KiB
PHP
|
|
<?php
|
||
|
|
if (!$_GET['year']) $_GET['year']=date('Y');
|
||
|
|
?>
|
||
|
|
<style type="text/css">
|
||
|
|
.MYoddListRowS1 {
|
||
|
|
font-size: 12px;
|
||
|
|
padding-left: 5px;
|
||
|
|
padding-right: 12px;
|
||
|
|
padding-bottom: 5px;
|
||
|
|
padding-top: 3px;
|
||
|
|
vertical-align: middle;
|
||
|
|
}
|
||
|
|
|
||
|
|
.MYlistViewThS1 {
|
||
|
|
font-size: 11px;
|
||
|
|
font-weight: bold;
|
||
|
|
text-align: left;
|
||
|
|
padding-left: 5px;
|
||
|
|
padding-right: 11px;
|
||
|
|
padding-bottom: 5px;
|
||
|
|
padding-top: 3px;
|
||
|
|
border-left: none;
|
||
|
|
border-right: none;
|
||
|
|
border-top: 1px solid #cccccc;
|
||
|
|
border-bottom: 1px solid #cccccc;
|
||
|
|
background: #ebebed;
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
<script type="text/javascript">
|
||
|
|
function createOrderLink(column) {
|
||
|
|
<?php
|
||
|
|
if ($_GET ['order_by'])
|
||
|
|
echo 'var order_by =\'' . $_GET ['order_by'] . '\';';
|
||
|
|
else
|
||
|
|
echo 'var order_by =\'p.name\';';
|
||
|
|
if ($_GET ['order_type'])
|
||
|
|
echo 'var order_type =\'' . $_GET ['order_type'] . '\';';
|
||
|
|
else
|
||
|
|
echo 'var order_type =\'ASC\';';
|
||
|
|
|
||
|
|
if (!$_GET['year']) $_GET['year'] = date('%Y');
|
||
|
|
|
||
|
|
// $_GET copy
|
||
|
|
$get = '';
|
||
|
|
echo 'var get=\'\';';
|
||
|
|
foreach ( $_GET as $k => $v ) {
|
||
|
|
if (($k != 'order_by') && ($k != 'order_type'))
|
||
|
|
if (is_array ( $v )) {
|
||
|
|
$tmp = '';
|
||
|
|
foreach ( $v as $k2 => $v2 )
|
||
|
|
$tmp .= '&' . $k . '[]=' . $v2;
|
||
|
|
echo 'var get=get+\'' . $tmp . '\';';
|
||
|
|
} else
|
||
|
|
echo 'var get=get+\'&' . $k . '=' . $v . '\';';
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|
||
|
|
var link;
|
||
|
|
if (column == order_by) {
|
||
|
|
if (order_type == 'ASC')
|
||
|
|
link='index.php?order_by='+column+'&order_type=DESC'+get;
|
||
|
|
if (order_type == 'DESC') {
|
||
|
|
link='index.php?order_by='+column+'&order_type=ASC'+get;
|
||
|
|
}
|
||
|
|
} else
|
||
|
|
link='index.php?order_by='+column+'&order_type=ASC'+get;
|
||
|
|
location.href = link;
|
||
|
|
}
|
||
|
|
|
||
|
|
function showhide(id) {
|
||
|
|
var el = document.getElementById(id);
|
||
|
|
|
||
|
|
if (el.style.display == "none")
|
||
|
|
el.style.display="block";
|
||
|
|
else
|
||
|
|
el.style.display="none";
|
||
|
|
}
|
||
|
|
function setTableSize() {
|
||
|
|
var header_height=document.getElementById('header').offsetHeight;
|
||
|
|
var header_width=document.getElementById('header').offsetWidth;
|
||
|
|
var left_width=document.getElementById('left').offsetWidth;
|
||
|
|
var screen_height = screen.height;
|
||
|
|
var screen_width = screen.width;
|
||
|
|
var new_height = (screen_height-header_height-300)+'px';
|
||
|
|
document.getElementById('myListView').style.height=new_height;
|
||
|
|
var new_width = (screen_width-left_width-50);
|
||
|
|
document.getElementById('tableDiv').style.width=new_width+'px';
|
||
|
|
document.getElementById('tableDiv').style.width=new_width+'px';
|
||
|
|
}
|
||
|
|
function clearSearch() {
|
||
|
|
link='index.php?module=EcmPurchaseOrders&action=reportPurchaseOrders';
|
||
|
|
location.href = link;
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
<?php global $mod_strings;?>
|
||
|
|
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2><?php echo "Innowacyjny raport sprzedaży" ?></h2></td></tr></table><br />
|
||
|
|
<ul class="tablist" style="width:1130px;">
|
||
|
|
<li>
|
||
|
|
<a class="current" href="#">Basic Search</a>
|
||
|
|
</li>
|
||
|
|
</ul>
|
||
|
|
<form action="index.php" method="get" name="search_reports">
|
||
|
|
<input type="hidden" name="module" value="EcmReports" /> <input
|
||
|
|
type="hidden" name="action" value="SalesReportCategories" />
|
||
|
|
<table style="border-top: 0px none; margin-bottom: 4px;width:1130px;" class="tabForm" border="0" cellpadding="0" cellspacing="0">
|
||
|
|
<tbody>
|
||
|
|
<tr>
|
||
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">Rok</td>
|
||
|
|
<td class="dataField" width="15%" nowrap="nowrap">
|
||
|
|
<select name="year" id="year">
|
||
|
|
<?
|
||
|
|
$ey=(int)date("Y");
|
||
|
|
$sy=2000;
|
||
|
|
for($i=$sy;$i<=$ey;$i++){
|
||
|
|
echo '<option value="'.$i.'"';
|
||
|
|
if($i==$_GET['year'])echo ' selected';
|
||
|
|
echo '>'.$i.'</option>';
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
</select>
|
||
|
|
</td>
|
||
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">Nazwa kontrahena</td>
|
||
|
|
<td class="dataField" width="25%" nowrap="nowrap">
|
||
|
|
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
|
||
|
|
<input name="account" id="account" value="<?php echo $_REQUEST['account'];?>" type="hidden">
|
||
|
|
<input name="btn_account_name" tabindex="" title="Wybierz[Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"search_reports","field_to_name_array":{"id":"account","name":"account_name"}}, "single", true);' type="button">
|
||
|
|
</td>
|
||
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">Produkcja</td>
|
||
|
|
<td class="dataField" width="15%" nowrap="nowrap">
|
||
|
|
<select name="active">
|
||
|
|
<option value="" <? if($_REQUEST['active']=="")echo "selected";?>>Wszystkie</option>
|
||
|
|
<option value="active" <? if($_REQUEST['active']=="active")echo "selected";?>>Tak</option>
|
||
|
|
<option value="inactive" <? if($_REQUEST['active']=="inactive")echo "selected";?>>Nie</option>
|
||
|
|
</select>
|
||
|
|
</td>
|
||
|
|
</tr><tr>
|
||
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">Status</td>
|
||
|
|
<td class="dataField" width="30%" nowrap="nowrap">
|
||
|
|
<select name="status">
|
||
|
|
<option value="" <? if($_REQUEST['status']=="")echo "selected";?>>Wszystkie</option>
|
||
|
|
<option value="active" <? if($_REQUEST['status']=="active")echo "selected";?>>Aktywny</option>
|
||
|
|
<option value="dead" <? if($_REQUEST['status']=="dead")echo "selected";?>>Wycofany</option>
|
||
|
|
<option value="new" <? if($_REQUEST['status']=="new")echo "selected";?>>Nowy</option>
|
||
|
|
</select>
|
||
|
|
</td>
|
||
|
|
<td colspan=2>
|
||
|
|
<input name="hide_zeros" type="checkbox" <?php if ($_REQUEST['hide_zeros']=='on') echo 'checked';?>/>Ukryj puste wartości</input>
|
||
|
|
</td>
|
||
|
|
<td class="dataLabel" width="10%" nowrap="nowrap">Typ faktury</td>
|
||
|
|
<td class="dataField" width="30%" nowrap="nowrap">
|
||
|
|
<select name="invoice_kind">
|
||
|
|
<option value="" <? if($_REQUEST['invoice_kind']=="")echo "selected";?>>Wszystkie</option>
|
||
|
|
<option value="country" <? if($_REQUEST['invoice_kind']=="country")echo "selected";?>>Krajowa</option>
|
||
|
|
<option value="foreign" <? if($_REQUEST['invoice_kind']=="foreign")echo "selected";?>>Zagraniczna</option>
|
||
|
|
</select>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
<input class="button" name="submit"
|
||
|
|
value="Szukaj"
|
||
|
|
type="submit">
|
||
|
|
<input class="button" name="clear" value="Wyczyść" type="button" onClick="location.href='index.php?module=EcmReports&action=SalesReportCategories&return_module=EcmReports&return_action=DetailView&parentTab=Raporty';">
|
||
|
|
<input class="button" name="hide"
|
||
|
|
value="<?php echo $mod_strings['LBL_REPORT_BTN_HIDESHOW']; ?>"
|
||
|
|
type="button" onClick="showhide('search_box');">
|
||
|
|
<?php
|
||
|
|
// create GET for XLS
|
||
|
|
$get = '';
|
||
|
|
foreach ( $_GET as $k => $v ) {
|
||
|
|
if (($k != 'module') && ($k != 'action') && ($k != 'purchase_order_status') && ($k != 'submit') && ($k != 'usertheme'))
|
||
|
|
$get .= '&' . $k . '=' . $v;
|
||
|
|
}
|
||
|
|
if (count ( $_GET ['purchase_order_status'] ) > 0) {
|
||
|
|
$wh_status = array ();
|
||
|
|
foreach ( $_GET ['purchase_order_status'] as $status ) {
|
||
|
|
$get .= '&purchase_order_status[]=' . $status;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
|
||
|
|
<input class="button" name="hide"
|
||
|
|
value="Generuj XLS" type="button"
|
||
|
|
onClick="window.location='index.php?module=EcmPurchaseOrders&action=createReportXLS<? echo $get; ?>'">
|
||
|
|
<?php
|
||
|
|
// create query
|
||
|
|
// $wh_products = array();
|
||
|
|
// $wh_orders = array();
|
||
|
|
if ($_GET ['submit']) {
|
||
|
|
if ($_GET ['product_name'])
|
||
|
|
$wh_products [] = "p.name LIKE '%" . $_GET ['product_name'] . "%'";
|
||
|
|
if ($_GET ['product_code'])
|
||
|
|
$wh_products [] = "p.code LIKE '%" . $_GET ['product_code'] . "%'";
|
||
|
|
if ($_GET ['purchase_order_number'])
|
||
|
|
$wh_orders [] = "o.document_no LIKE '%" . $_GET ['purchase_order_number'] . "%'";
|
||
|
|
if (count ( $_GET ['purchase_order_status'] ) > 0) {
|
||
|
|
$wh_status = array ();
|
||
|
|
foreach ( $_GET ['purchase_order_status'] as $status ) {
|
||
|
|
$wh_status [] = "o.status ='" . $status . "'";
|
||
|
|
}
|
||
|
|
$wh_orders [] = "(" . implode ( " OR ", $wh_status ) . ")";
|
||
|
|
}
|
||
|
|
if ($_GET ['user'])
|
||
|
|
$wh_orders [] = "o.assigned_user_id = '" . $_GET ['user'] . "'";
|
||
|
|
if ($_GET ['category'])
|
||
|
|
$wh_products [] = "p.product_category_id = '" . $_GET ['category'] . "'";
|
||
|
|
if ($_GET ['tracking_no'])
|
||
|
|
$wh_orders [] = "o.tracking_no LIKE '%" . $_GET ['tracking_no'] . "%'";
|
||
|
|
if ($_GET ['account_id'])
|
||
|
|
$wh_orders [] = "o.parent_id = '" . $_GET ['account_id'] . "'";
|
||
|
|
}
|
||
|
|
|
||
|
|
if (($_GET ['order_by']) && $_GET ['order_type'])
|
||
|
|
$order_by = " ORDER BY " . $_GET ['order_by'] . ' ' . $_GET ['order_type'];
|
||
|
|
else
|
||
|
|
$order_by = " ORDER BY p.name ASC";
|
||
|
|
|
||
|
|
$query = "SELECT p.name, p.product_category_name, o.date_entered, o.document_no, o.status, po.product_quantity, o.delivery_date, o.tracking_no, u.first_name, u.last_name, po.ecmpurchaseorder_id, po.ecmproduct_id, p.code, o.parent_id, o.parent_name FROM ecmproducts_ecmpurchaseorders AS po ";
|
||
|
|
$query .= "INNER JOIN ecmproducts AS p ON p.id=po.ecmproduct_id ";
|
||
|
|
if (isset ( $wh_products ))
|
||
|
|
$query .= " AND " . implode ( " AND ", $wh_products );
|
||
|
|
$query .= "INNER JOIN ecmpurchaseorders AS o ON o.id=po.ecmpurchaseorder_id AND o.deleted='0' ";
|
||
|
|
if (isset ( $wh_orders ))
|
||
|
|
$query .= " AND " . implode ( " AND ", $wh_orders );
|
||
|
|
$query .= "INNER JOIN users As u ON o.assigned_user_id=u.id";
|
||
|
|
|
||
|
|
?>
|
||
|
|
<div id="tableDiv" style="width: 1370px">
|
||
|
|
<table width="100%">
|
||
|
|
<tr>
|
||
|
|
<td>
|
||
|
|
|
||
|
|
<table width="1170" id="myListViewTableHead" class="h3Row"
|
||
|
|
border="0" cellpadding="0" cellspacing="0">
|
||
|
|
<tr>
|
||
|
|
<td style="width: 90px; min-width: 90px; max-width: 90px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('p.code')">Kod<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 220px; min-width: 220px; max-width: 220px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('p.name')">Nazwa<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 190px; min-width: 190px; max-width: 190px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('p.product_category_name')">Kategoria<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 140px; min-width: 140px; max-width: 140px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('o.parent_name')">Nazwa dostawcy<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 80px; min-width: 80px; max-width: 80px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('o.date_entered')">Data zamówienia<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 90px; min-width: 90px; max-width: 80px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('o.document_no')">Numer zamówienia<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 100px; min-width: 100px; max-width: 100px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('o.status')">Status zamówienia<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 130px; min-width: 130px; max-width: 130px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('p.user')">Użytkownik<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 60px; min-width: 60px; max-width: 60px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('po.product_quantity')">Ilość<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 90px; min-width: 90px; max-width: 90px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('o.delivery_date')">Data dostawy<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
<td style="width: 130px; min-width: 130px; max-width: 130px;"
|
||
|
|
class="MYlistViewThS1"><a class="listViewThLinkS1"
|
||
|
|
href="javascript:createOrderLink('o.tracking_no')">Informacje dod.<img
|
||
|
|
src="themes/Sugar/images/arrow.gif" border="0" /></td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
|
||
|
|
<table id="myListViewTableData" border="0" cellpadding="0"
|
||
|
|
cellspacing="0">
|
||
|
|
<?php
|
||
|
|
// $max_width = "style=\"max-width: 200px;\"";
|
||
|
|
$result = $GLOBALS ['db']->query ( $query );
|
||
|
|
while ( $r = $GLOBALS ['db']->fetchByAssoc ( $result ) ) {
|
||
|
|
foreach ( $r as $k => $v )
|
||
|
|
if (! $v)
|
||
|
|
$v = " ";
|
||
|
|
// style=\"width: 100px; min-width: 100px; max-width:100px; \"
|
||
|
|
echo "<tr><td style=\"width: 80px; min-width: 80px; max-width:80px; \" class=\"MYoddListRowS1\"><a href=\"index.php?module=EcmProducts&action=DetailView&record=" . $r ['ecmproduct_id'] . "\">" . $r ['code'] . "</a></td>";
|
||
|
|
echo "<td style=\"width: 210px; min-width: 210px; max-width:210px; \" class=\"MYoddListRowS1\"><a href=\"index.php?module=EcmProducts&action=DetailView&record=" . $r ['ecmproduct_id'] . "\">" . $r ['name'] . "</a></td>";
|
||
|
|
echo "<td style=\"width: 180px; min-width: 180px; max-width:180px; \" class=\"MYoddListRowS1\">" . $r ['product_category_name'] . "</td>";
|
||
|
|
echo "<td style=\"width: 130px; min-width: 130px; max-width:130px; \"class=\"MYoddListRowS1\"><a href=\"index.php?module=Accounts&action=DetailView&record=" . $r ['parent_id'] . "\">" . $r ['parent_name'] . "</a></td>";
|
||
|
|
echo "<td style=\"width: 80px; min-width: 80px; max-width: 80px; \" class=\"MYoddListRowS1\">" . substr ( $r ['date_entered'], 0, 10 ) . "</td>";
|
||
|
|
echo "<td style=\"width: 80px; min-width: 80px; max-width:80px; \" class=\"MYoddListRowS1\"><a href=\"index.php?module=EcmPurchaseOrders&action=DetailView&record=" . $r ['ecmpurchaseorder_id'] . "\">" . $r ['document_no'] . "</a></td>";
|
||
|
|
echo "<td style=\"width: 80px; min-width: 80px; max-width:80px; \" class=\"MYoddListRowS1\">" . $GLOBALS ['app_list_strings'] ['ecmpurchaseorders_status_dom'][$r['status']]."</td>";
|
||
|
|
echo "<td style=\"width: 130px; min-width: 130px; max-width:130px; \" class=\"MYoddListRowS1\">".$r['first_name'].' '.$r['last_name']."</td>";
|
||
|
|
echo "<td style=\"width: 60px; min-width: 60px; max-width:60px; \" class=\"MYoddListRowS1\">".$r['product_quantity']."</td>";
|
||
|
|
echo "<td style=\"width: 90px; min-width: 90px; max-width:90px; \" class=\"MYoddListRowS1\">".$r['delivery_date']."</td>";
|
||
|
|
echo "<td style=\"width: 130px; min-width: 130px; max-width:130px; \" class=\"MYoddListRowS1\">".$r['tracking_no']."</td></tr>";
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<script type="text/javascript">setTableSize();</script>
|
||
|
|
<a onClick="document.getElementById('plist').scrollLeft-=125;"><button class="button"><<</button></a>
|