Files
crm.e5.pl/modules/EcmInvoiceOutOlds/ListProducts.php

210 lines
6.8 KiB
PHP
Raw Normal View History

2024-04-27 09:23:34 +02:00
<?
if(!$_GET['date_from'])$date_from=date("Y-m-d");
else $date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
if(!$_GET['date_to'])$date_to=date("Y-m-d");
else $date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
?>
<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>Faktury: Sprzedane produkty</h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get">
<input type="hidden" name="module" value="EcmInvoiceOutOlds" />
<input type="hidden" name="action" value="ListProducts" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data od </td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data do </td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Kategoria </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="category_id">
<option value="">wybierz</option>
<?php
?>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmInvoiceOutOlds&action=ListProducts';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Utwórz XLS" onclick="location.href=\'index.php?module=EcmInvoiceOutOlds&action=CreateXLSProducts&to_pdf=1&date_from='.$date_from.'&date_to='.$date_to.'\';">';
?>
</form><br />
<h2>Data: <? echo $GLOBALS['timedate']->to_display_date($date);?></h2>
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr>';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Nr.";
$t.=$tde;
$t.=$tds1;
$t.="Index";
$t.=$tde;
$t.=$tds1;
$t.="Nazwa";
$t.=$tde;
$t.=$tds1;
$t.="Faktura";
$t.=$tde;
$t.=$tds1;
$t.="Ilość";
$t.=$tde;
$t.=$tds1;
$t.="Cena";
$t.=$tde;
$t.=$tds1;
$t.="Razem netto";
$t.=$tde;
$t.=$tds1;
$t.="Razem Vat";
$t.=$tde;
$t.=$tds1;
$t.="Razem brutto";
$t.=$tde;
$t.=$tre;
$i=1;
$z="select ecminvoiceoutolditems.*,ecminvoiceoutolds.document_no as dno,ecminvoiceoutolds.id as sid,ecminvoiceoutolds.type as type,ecminvoiceoutolds.currency_value as currency_value from ecminvoiceoutolditems inner join ecminvoiceoutolds on ecminvoiceoutolditems.ecminvoiceoutold_id=ecminvoiceoutolds.id where ecminvoiceoutolds.deleted='0' and ecminvoiceoutolds.register_date>='".$date_from."' and ecminvoiceoutolds.register_date<='".$date_to."' and ecminvoiceoutolditems.deleted='0'";
$db = $GLOBALS['db'];
$w=$db->query($z);
echo $db->error;
while($r=$db->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else $currency_value=$r['currency_value'];
$total_netto=$currency_value*$r['price']*$r['quantity'];
$total_vat=$currency_value*$r['price']*$r['quantity']*($r['ecmvat_value']/100);
$total_brutto=$currency_value*$r['price']*$r['quantity']*(1+$r['ecmvat_value']/100);
if($r['type']=="correct"){
$rr=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select price,quantity,ecmvat_value from ecminvoiceoutolditems where id='".$r['ecminvoiceoutolditem_id']."'"));
$total_netto-=$currency_value*$rr['price']*$rr['quantity'];
$total_vat-=$currency_value*$rr['price']*$rr['quantity']*($rr['ecmvat_value']/100);
$total_brutto-=$currency_value*$rr['price']*$rr['quantity']*(1+$rr['ecmvat_value']/100);
$r['price']=$currency_value*$rr['price'];
$r['quantity']-=$rr['quantity'];
}
if($r['quantity']==0)continue;
$t.=$trs;
$t.=$tds;
$t.=$i;
$t.=$tde;
$t.=$tds;
$t.=$r['code'];
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=EcmProducts&action=DetailView&record='.$r['ecmproduct_id'].'">'.$r['name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOutOlds&action=DetailView&record='.$r['sid'].'">'.$r['dno'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=((int)$r['quantity']);
$t.=$tde;
$t.=$tds;
$t.=number_format($r['price'],2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_netto,2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_vat,2,",",".");
$t.=$tde;
$t.=$tds;
$t.=number_format($total_brutto,2,",",".");
$t.=$tde;
$t.=$tre;
//$sum_price+=$r['price'];
$sum_total_netto+=$total_netto;
$sum_total_vat+=$total_vat;
$sum_total_brutto+=$total_brutto;
$sum_qty+=$r['quantity'];
$i++;
}
$t.=$trs;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=$tde;
$t.=$tds1;
$t.=(int)$sum_qty;
$t.=$tde;
$t.=$tds1;
$t.=@number_format(($sum_total/$sum_qty),2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_netto,2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_vat,2,",",".");
$t.=$tde;
$t.=$tds1;
$t.=number_format($sum_total_brutto,2,",",".");
$t.=$tde;
$t.=$tre;
$t.=$tbe;
echo $t;
?>