Files
crm.twinpol.com/modules/EcmProductStockIndexs/ListViewProductsAjax.php
2025-05-12 15:44:39 +00:00

74 lines
3.5 KiB
PHP
Executable File

<?
global $mod_strings;
$_SESSION['stock_order_by']=$_REQUEST['order_by'];
$_SESSION['stock_sorder']=$_REQUEST['sorder'];
$_SESSION['stock_sorder']=$_REQUEST['sorder'];
$_SESSION['stock_id']=$_REQUEST['pricebook_id'];
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmproductstockindexs where id='".$_REQUEST['stock_id']."'"));
$name=$r['name'];
function sortLink($order_by,$sorder,$title)
{
if($order_by==$_REQUEST['order_by'])
{
if($sorder=="desc")
{
$img='<img border="0" src="themes/Sugar/images/arrow_down.gif" width="8" height="10" align="absmiddle" alt="">';
$s="asc";
}
else
{
$img='<img border="0" src="themes/Sugar/images/arrow_up.gif" width="8" height="10" align="absmiddle" alt="">';
$s="desc";
}
}
else
{
$img='<img border="0" src="themes/Sugar/images/arrow.gif" width="8" height="10" align="absmiddle" alt="">';
$s=$sorder;
}
return '<a style="cursor:pointer;" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmProductStockIndexs&action=ListViewProductsAjax&stock_id='.$_REQUEST['stock_id'].'&order_by='.$order_by.'&sorder='.$s.'\',\'products\');">'.$title.'&nbsp;'.$img.'</a>';
}
$c=array("ecmproductstockindexin.price_in","ecmproductstockindexin.date_in","ecmproductstockindexin.quantity_in","ecmproductstockindexin.quantity_out","ecmproductstockindexin.pz_id");
$t=array($mod_strings['LBL_PRICE'],$mod_strings['LBL_DATE'],$mod_strings['LBL_QTY_IN'],$mod_strings['LBL_QTY_OUT'],$mod_strings['LBL_PZ']);
$sorder=$_REQUEST['sorder'];
print '<h4>Products List:</h4><br>';
print '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="ListView"><tr>';
print '<td class="listViewThS1">'.sortLink("ecmproducts.name",$sorder,$mod_strings['LBL_PRODUCT_NAME']).'</td>';
for($i=0;$i<count($t);$i++)
{
$corder_by=$c[$i];
if($t[$i])print '<td class="listViewThS1">'.sortLink($corder_by,$sorder,$t[$i]).'</td>';
}
print '<td class="listViewThS1">&nbsp;</td>';
print '<td class="listViewThS1">&nbsp;</td>';
print '</tr>';
$z="select ecmproductstockindexins.*,ecmproducts.name as product_name,ecmproductstockindexdocins.name as pz_name from ecmproductstockindexins inner join ecmproducts on ecmproducts.id=ecmproductstockindexins.product_id inner join ecmproductstockindexdocins on ecmproductstockindexdocins.id=ecmproductstockindexins.pz_id where ecmproductstockindexins.stock_id='".$_REQUEST['stock_id']."' order by ".$_REQUEST['order_by']." ".$_REQUEST['sorder'];
$result = $GLOBALS['db']->query($z);
while($row=$GLOBALS['db']->fetchByAssoc($result))
{
print '<tr>';
print '<td class="oddListRowS1"><a href="index.php?module=EcmProducts&action=DetailView&record='.$row['product_id'].'">'.$row['product_name'].'</a></td>';
for($i=0;$i<count($t);$i++)
{
if($t[$i])
{
if($c[$i]=="ecmproductstockindexin.pz_id")print '<td class="oddListRowS1"><a href="index.php?module=EcmProductStockIndexDocIns&action=DetailView&record='.$row['pz_id'].'">'.$row['pz_name'].'</a></td>';
elseif($c[$i]=="ecmproductstockindexin.date_in")print '<td class="oddListRowS1">'.$timedate->to_display($row['date_in'],"Y-m-d",$timedate->get_date_format()).'</td>';
elseif($c[$i]=="ecmproductstockindexin.price_in")print '<td class="oddListRowS1">'.number_format($row['price_in'],2,$GLOBALS['sugar_config']['default_decimal_seperator'],$GLOBALS['sugar_config']['default_number_grouping_seperator']).'</td>';
else print '<td class="oddListRowS1">'.$row[str_replace("ecmproductstockindexin.","",$c[$i])].'</td>';
}
}
print '</tr>';
}
print '</table>';
?>