Files
crm.e5.pl/modules/EcmProductReports/index_orders.php

162 lines
6.1 KiB
PHP
Raw Permalink Normal View History

2024-04-27 09:23:34 +02:00
<?
include_once("modules/EcmProductReports/vtigerConnector.php");
$vc=new vtigerConnector();
$vc->start=$_GET['start']+1;
$wc[]="purchaseorder.tracking_no!=''";
if($_GET['submit']){
if($_GET['product_name'])$wc[]="poproductrel.productname like '".$_GET['product_name']."%'";
if($_GET['product_code'])$wc[]="poproductrel.productcode like '".$_GET['product_code']."%'";
if($_GET['purchase_order'])$wc[]="purchaseorder.subject like '".$_GET['purchase_order']."%'";
if($_GET['status'])$wc[]="purchaseorder.postatus like '".$_GET['status']."'";
if($_GET['due_date_from'])$wc[]="purchaseorder.duedate>='".$GLOBALS['timedate']->to_display($_GET['due_date_from'],$GLOBALS['timedate']->get_date_format(),"Y-m-d")."'";
if($_GET['due_date_to'])$wc[]="purchaseorder.duedate<='".$GLOBALS['timedate']->to_display($_GET['due_date_to'],$GLOBALS['timedate']->get_date_format(),"Y-m-d")."'";
if($_GET['delivery_time_from']){
$dtf=$GLOBALS['timedate']->to_display($_GET['delivery_time_from'],$GLOBALS['timedate']->get_date_format(),"Y-m-d");
$exp=explode("-",$dtf);
//$ddtf=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])-37*24*3600);
$ddtf=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0]));
$wc[]="purchaseordercf.cf_532>='".$ddtf."'";
}
if($_GET['delivery_time_to']){
$dtt=$GLOBALS['timedate']->to_display($_GET['delivery_time_to'],$GLOBALS['timedate']->get_date_format(),"Y-m-d");
$exp=explode("-",$dtt);
//$ddtt=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])-37*24*3600);
$ddtt=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0]));
$wc[]="purchaseordercf.cf_532<='".$ddtt."'";
}
if($_GET['list_price_from'])$wc[]="poproductrel.listprice>='".$vc->unformatNumber($_GET['list_price_from'])."'";
if($_GET['list_price_to'])$wc[]="poproductrel.listprice<='".$vc->unformatNumber($_GET['list_price_to'])."'";
if($_GET['quantity_from'])$wc[]="poproductrel.quantity>='".$vc->unformatNumber($_GET['quantity_from'])."'";
if($_GET['quantity_to'])$wc[]="poproductrel.quantity<='".$vc->unformatNumber($_GET['quantity_to'])."'";
}
$vc->pp=99999;
$vc->where=@implode(" and ",$wc);
if(!$_GET['start'])$vc->limit="0,".$vc->pp;
else $vc->limit=$_GET['start'].",".$vc->pp;
if($_GET['order_by'])$vc->order_by=$_GET['order_by'];
else $vc->order_by="purchaseorder.duedate";
if($_GET['sorder'])$vc->sorder=$_GET['sorder'];
else $vc->sorder="desc";
$vc->getData();
$cnt=$vc->getCount();
$data=$vc->data;
for($i=0;$i<count($data);$i++){
if($_REQUEST['category'] || $_REQUEST['active']){
$cat=mysql_fetch_array(mysql_query("select product_category_id as cid,product_active from ecmproducts where code='".$data[$i]['productcode']."'"));
if($cat['cid']!=$_REQUEST['category'])continue;
if(!$cat['product_active'])continue;
}
$dat[]=$data[$i];
}
$data=$dat;
$_SESSION['EcmProductReportsData']=$data;
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td width="19"><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td>
<td width="402"><h2>Orders Reports: Orders on sea </h2></td></tr></table><br />
<table class="h3Row" width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td nowrap="nowrap">
<h3>Orders List</h3>
</td>
<td width="100%">
<img src="include/images/blank.gif" alt="" width="1" height="1">
</td>
</tr>
</tbody>
</table>
<?
if($_GET['start']+$vc->pp>=$vc->count && $_GET['start']-$vc->pp>0){ // >= >=
$btns=array(0,0,0,0);
}
elseif($_GET['start']+$vc->pp<$vc->count && $_GET['start']-$vc->pp>=0){ // < >=
$btns=array(1,1,1,1);
}
elseif($_GET['start']+$vc->pp>=$vc->count){ // >= <
$btns=array(1,1,0,0);
}
elseif($_GET['start']+$vc->pp<$vc->count && $_GET['start']-$vc->pp<0){ // < <
$btns=array(0,0,1,1);
}
print '<form action="index.php" method="post">';
print '<input type="hidden" value="EcmProductReports" name="module">';
print '<input type="hidden" value="CreateXLS" name="action">';
print '<input type="hidden" name="where" value="'.$vc->where.'">';
print '<input type="hidden" name="order_by" value="'.$vc->order_by.'">';
print '<input type="hidden" name="sorder" value="'.$vc->sorder.'">';
print '<input type="hidden" name="limit" value="'.$vc->limit.'">';
print '<input type="hidden" name="start" value="'.($vc->start-1).'">';
print '<input type="hidden" name="to_pdf" value="1">';
print '<div id="products_list">';
print '<table cellpadding="0" cellspacing="0" width="1300" border="0" class="ListView">';
?>
<tr>
<td colspan="9">
<table width="100%">
<tr>
<td width="50%">
<?
//print '<input type="submit" value="Create XLS" class="button" onclick="this.form.action.value=\'CreateXLS\';">&nbsp;';
//print '<input type="submit" value="Create PDF" class="button" onclick="this.form.action.value=\'CreatePDF\';">';
?>
</td>
<td id="listViewPaginationButtons" class="listViewPaginationTdS1" width="100%" align="right" nowrap="nowrap">
<? echo $vc->generateButtons($btns); ?>
</td>
</tr>
</table>
</td></tr>
<?
print '<tr>';
print $vc->sortableColumn("Delivery date","purchaseorder.cf_532",$_GET['sorder'],20);
print $vc->sortableColumn("Id","purchaseorder.purchaseorderid",$_GET['sorder'],10);
print $vc->sortableColumn("Subject","purchaseorder.subject",$_GET['sorder'],10);
print $vc->sortableColumn("Tracking No","purchaseorder.tracking_no",$_GET['sorder'],10);
print $vc->sortableColumn("CBM","purchaseorder.cbm",$_GET['sorder'],10);
print '</tr>';
foreach($data as $dd){
$do[$dd['purchaseorderid']]=$dd;
}
foreach($do as $data){
$duedate=$data['duedate'];
$deliverydate=$data['deliverydate'];
$exp=explode("-",$duedate);
$dtime=date("Y-m-d",@mktime(0,0,0,$exp[1],$exp[2],$exp[0]));
print '<tr>';
print '<td class="oddListRowS1" width="1%">'.$deliverydate.'</td>';
print '<td class="oddListRowS1" width="20%"><a href="http://81.89.194.6/crm/index.php?module=Orders&action=DetailView&record='.$data['purchaseorderid'].'">'.$data['purchaseorderid'].'</a></td>';
print '<td class="oddListRowS1" width="1%">'.$data['subject'].'</td>';
print '<td class="oddListRowS1" width="1%">'.$data['tracking_no'].'</td>';
print '<td class="oddListRowS1" width="1%">'.$data['cbm'].'</td>';
print '</tr>';
}
print '</table>';
print '</div>';
print '</form>';
?>