示例#1
0
<td align="left">INVENTORY REPORT</td>

<td align="right" width="50%"><?php 
echo date("j M, Y", time());
?>
</td>
</tr>
</table>
</div><br /><br />
<?php 
if (!empty($page_list)) {
    echo "<table width='100%' border='0' cellspacing='0' cellpadding='5'>\r\r\n          \t<tr>\r\r\n\t\t\t<td class='listheader' nowrap>Item Name</td>\r\r\n\t\t\t\r\r\n\t\t\t<td class='listheader' nowrap>In</td>\r\r\n\t\t\t<td class='listheader' nowrap>Out</td>\r\r\n\t\t\t<td class='listheader' nowrap>Stocked</td>\t\t\t\r\r\n\t\t\t<td class='listheader' nowrap>Units</td>\r\r\n\t\t\t</tr>";
    $counter = 0;
    foreach ($page_list as $row) {
        $stocked = get_stocked($this, $row['id']);
        $sold = get_sold($this, $row['id']);
        $remaining = $stocked - $sold;
        #Assign zeros to empty values
        if (empty($stocked)) {
            $stocked = 0;
        }
        if (empty($sold)) {
            $sold = 0;
        }
        #Show one row at a time
        if ($row['reorderlevel'] >= $remaining) {
            echo "<tr style='color:red;" . get_row_color($counter, 2) . "'><td valign='top' nowrap>";
        } else {
            echo "<tr style='" . get_row_color($counter, 2) . "'>";
        }
示例#2
0
 function generate_report()
 {
     access_control($this);
     $schooldetails = $this->session->userdata('schoolinfo');
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     if ($this->input->post('generatepdf') || $this->input->post('generateexcel')) {
         $required_fields = array('type');
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         if ($validation_results['bool']) {
             $_POST = clean_form_data($_POST);
             $searchstring = '1';
             if ($_POST['type'] == 1) {
                 if (isset($_POST['datefrom']) && isset($_POST['dateto']) && $_POST['datefrom'] != "" && $_POST['dateto'] != "") {
                     $searchstring .= " AND  UNIX_TIMESTAMP(i.datecreated) <= '" . strtotime($_POST['dateto'] . ' 23:59:59') . "' AND UNIX_TIMESTAMP(i.datecreated) >= '" . strtotime($_POST['datefrom']) . "'";
                 }
                 if (isset($_POST['item']) && $_POST['item'] != "") {
                     $searchstring .= " AND i.itemid=" . $_POST['item'];
                 }
                 $querycode = 'get_inventory_list';
                 $data['dateto'] = $_POST['dateto'];
                 $data['datefrom'] = $_POST['datefrom'];
                 #Get the paginated list of the purchases
                 $data = paginate_list($this, $data, $querycode, array('isactive' => 'Y', 'searchstring' => ' i.school = ' . $schooldetails['id'] . ' AND (' . $searchstring . ')'));
                 $report_type = 'purchases_report';
                 $report_name = "PURCHASES REPORT";
                 if ($this->input->post('generateexcel')) {
                     $size = sizeof($data['page_list']);
                     $maxdate = date("j M, Y", GetTimeStamp($data['page_list'][$size - 1]['datecreated']));
                     $mindate = date("j M, Y", GetTimeStamp($data['page_list'][0]['datecreated']));
                     if (!empty($data['datefrom'])) {
                         $from = date("j M, Y", GetTimeStamp($data['datefrom']));
                     } else {
                         $from = $maxdate;
                     }
                     if (!empty($data['dateto'])) {
                         $to = date("j M, Y", GetTimeStamp($data['dateto']));
                     } else {
                         $to = $mindate;
                     }
                     $mydata = array($schooldetails['schoolname']);
                     $this->excelexport->addRow($mydata);
                     $mydata = array($report_name, "", "", "From :", $from, "", "", "To :", $to);
                     $this->excelexport->addRow($mydata);
                     $mydata = array("Date", "Item Name", "Supplier", "Invoice Number", "Quanity", "Price");
                     $this->excelexport->addRow($mydata);
                     $sum = 0;
                     foreach ($data['page_list'] as $row) {
                         $price = $row['price'] * $row['quantity'];
                         $sum += $price;
                         $mydata = array(date("j M, Y", GetTimeStamp($row['datecreated'])), $row['itemname'], $row['supplier'], $row['invoicenumber'], $row['quantity'], number_format($price, 0, '.', ','));
                         $this->excelexport->addRow($mydata);
                     }
                     $mydata = array("Total", "", "", "", "", number_format($sum, 0, '.', ','));
                     $this->excelexport->addRow($mydata);
                 }
             } elseif ($_POST['type'] == 3) {
                 if (isset($_POST['datefrom']) && isset($_POST['dateto']) && $_POST['datefrom'] != "" && $_POST['dateto'] != "") {
                     $searchstring .= " AND  UNIX_TIMESTAMP(i.datecreated) <= '" . strtotime($_POST['dateto'] . ' 23:59:59') . "' AND UNIX_TIMESTAMP(i.datecreated) >= '" . strtotime($_POST['datefrom']) . "'";
                 }
                 if (isset($_POST['item']) && $_POST['item'] != "") {
                     $searchstring .= " AND i.itemid=" . $_POST['item'];
                 }
                 $querycode = 'get_inventory_list';
                 $data['dateto'] = $_POST['dateto'];
                 $data['datefrom'] = $_POST['datefrom'];
                 #Get the paginated list of the deals
                 $data = paginate_list($this, $data, 'get_transaction_list', array('isactive' => 'Y', 'searchstring' => ' t.school = ' . $schooldetails['id'] . ' AND (' . $searchstring . ')'));
                 $report_type = 'issuing_report';
                 $report_name = "ISSUING REPORT";
                 if ($this->input->post('generateexcel')) {
                     $size = sizeof($data['page_list']);
                     $maxdate = date("j M, Y", GetTimeStamp($data['page_list'][$size - 1]['dateadded']));
                     $mindate = date("j M, Y", GetTimeStamp($data['page_list'][0]['dateadded']));
                     if (!empty($data['datefrom'])) {
                         $from = date("j M, Y", GetTimeStamp($data['datefrom']));
                     } else {
                         $from = $maxdate;
                     }
                     if (!empty($data['dateto'])) {
                         $to = date("j M, Y", GetTimeStamp($data['dateto']));
                     } else {
                         $to = $mindate;
                     }
                     $mydata = array($schooldetails['schoolname']);
                     $this->excelexport->addRow($mydata);
                     $mydata = array($report_name, "", "", "From :", $from, "", "", "To :", $to);
                     $this->excelexport->addRow($mydata);
                     $mydata = array("Date", "Item Name", "Quantity", "Issued To");
                     $this->excelexport->addRow($mydata);
                     foreach ($data['page_list'] as $row) {
                         $mydata = array(date("j M, Y", GetTimeStamp($row['dateadded'])), $row['itemname'], $row['quantity'], $row['firstname'] . " " . $row['lastname']);
                         $this->excelexport->addRow($mydata);
                     }
                 }
             } elseif ($_POST['type'] == 2) {
                 #Get the paginated list of the inventory
                 $data = paginate_list($this, $data, 'get_item_list', array('isactive' => 'Y', 'searchstring' => ' school = ' . $schooldetails['id']));
                 $report_type = 'inventory_report';
                 $report_name = "INVENTORY REPORT";
                 if ($this->input->post('generateexcel')) {
                     $mydata = array($schooldetails['schoolname']);
                     $this->excelexport->addRow($mydata);
                     $mydata = array($report_name, "", "", "", date("j M, Y", time()));
                     $this->excelexport->addRow($mydata);
                     $mydata = array("Item Name", "In", "Out", "Stocked", "Units");
                     $this->excelexport->addRow($mydata);
                     foreach ($data['page_list'] as $row) {
                         $stocked = get_stocked($this, $row['id']);
                         $sold = get_sold($this, $row['id']);
                         $remaining = $stocked - $sold;
                         #Assign zeros to empty values
                         if (empty($stocked)) {
                             $stocked = 0;
                         }
                         if (empty($sold)) {
                             $sold = 0;
                         }
                         $mydata = array($row['itemname'], $remaining, $sold, $stocked, $row['unitspecification']);
                         $this->excelexport->addRow($mydata);
                     }
                 }
             }
             #Format the statement
             $report_html = '';
             #$financial_details = array();
             $this->load->library('parser');
             $data['schoolname'] = $schooldetails['schoolname'];
             $data['report_html'] = $report_html;
             $output = $this->parser->parse('reports/' . $report_type, $data, true);
             if ($this->input->post('generatepdf')) {
                 gen_pdf($this, $output);
             } else {
                 $this->excelexport->download($report_type . '.xls');
             }
         }
         if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
         $data['formdata'] = $_POST;
     }
     $this->load->view('inventory/new_report_view');
 }