[eluser]paynterc[/eluser]
From the controller:
if(isset($_POST['form'])){
$data_qry['query'] = $this->db_model->getSearchResults($_POST['form']);
}else{
$data_qry['query'] = null;
}
$data_exp['headerexport'] = "Content-Disposition: attachment; filename=\"Shipments_".time().".xls\"";
$this->load->view("exportheader",$data_exp);
$this->load->view($_SESSION['shipsearch']['r_view'],$data_qry);
From model:
<?php
class DB_model extends Model {
function DB_model()
{
parent::Model();
}
function getSearchResults ($criteria)
{
$sumt="summary_table";
$this->db->select('*');
if($criteria['startdate']!='' && $criteria['enddate']!=''){
$datecrit=array($sumt . '.billingdate >=' => date("Y-m-d",strtotime($criteria['startdate'])), $sumt.'.billingdate <=' => date("Y-m-d",strtotime($criteria['enddate'])));
$this->db->where($datecrit);
}elseif($criteria['startdate']!=''){
$datecrit=array($sumt . '.billingdate >=' => date("Y-m-d",strtotime($criteria['startdate'])));
$this->db->where($datecrit);
}
if($criteria['org']!=''){
$orgcrit=array('org'=>$criteria['org']);
$this->db->where($salesorgcrit);
}
$query = $this->db->get($sumt);
$str = $this->db->last_query();
//echo "<br>" . $str . "<p>";
if ($query->num_rows() > 0) {
return $query;
} else {
return null;
}
}
}
?>
From the view:
<center>
<table border="0" class="bigger_table">
<tr>
<td class="gray_dark_bgcolor center">
<table border="0" width="100%">
<tr class="blue_dark_bgcolor">
<td align="left" width=100><font size="-2">Cust#</font></td>
<td align="left"><font size="-2">Cust Name</font></td>
<td align="left"><font size="-2">PO#</font></td>
<td align="left"><font size="-2">ORG#</font></td>
</tr>
<?php
if($query){
$i=1;
foreach($query->result() as $myrow1b){
($i % 2) ? $tableclass = "gray_lite_bgcolor_row" : $tableclass = "blue_med_bgcolor_row";
?>
<tr class="<?= $tableclass ?>">
<td align="left"><?= $myrow1b->custnumber ?></td>
<td align="left"><?= $myrow1b->custname ?></td>
<td align="left"><?= $myrow1b->ponumber ?></td>
<td align="left"><?= $myrow1b->org ?></td>
</tr>
<?php
$i++;
}
}
?>
</table>
</td>
</tr>
</table>
</center>