Example #1
0
    echo $mindate;
}
?>
</td>
</tr>
</table>
</div><br /><br />
<?php 
#Show search results
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>Date Borrowed</td>\r\r\n           \t<td class='listheader' nowrap>Title</td>\r\r\n\t\t\t<td class='listheader' nowrap>Returned / Borrowed</td>\r\r\n\t\t\t<td class='listheader' nowrap>Name</td>\r\r\n\t\t\t\r\r\n\t\t\t<td class='listheader' nowrap>Date Expected</td>\r\r\n\t\t\t</tr>";
    $counter = 0;
    foreach ($page_list as $row) {
        #check expiry of rental period
        $currentdate = date("Y-m-d H:i:s");
        $borrower_status = check_borrower_status($this, $row['borrowerid']);
        #Show one row at a time
        echo "<tr style='" . get_row_color($counter, 2) . "'>";
        echo "\r\r\n\t\t\r\r\n\t\t<td valign='top'>" . date("j M, Y", GetTimeStamp($row['datetaken'])) . "</td>\r\r\n\t\t\r\r\n\t\t<td valign='top'>" . $row['stocktitle'] . "</td>'\r\r\n\t\t\r\r\n\t\t<td valign='top'>" . ($row['copiestaken'] - $borrower_status) . "/" . $row['copiestaken'] . "</td>\r\r\n\t\t\r\r\n\t\t<td valign='top'>" . $row['firstname'] . " " . $row['lastname'] . "</td>\r\r\n\t\t\r\r\n\t\t\r\r\n\t\t\r\r\n\t\t<td valign='top'>" . date("j M, Y", GetTimeStamp($row['returndate'])) . "</td>\r\r\n\t\t\r\r\n\t\t</tr>";
        $counter++;
    }
    echo "<tr></table>";
} else {
    echo format_notice("There are no borrowing data matching that criteria at the moment.");
}
?>
<br /><br />
<?php 
$this->load->view('incl/footer');
?>
Example #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'] == 7) {
                 if (isset($_POST['datefrom']) && isset($_POST['dateto']) && $_POST['datefrom'] != "" && $_POST['dateto'] != "") {
                     $searchstring .= " AND  UNIX_TIMESTAMP(b.datetaken) <= '" . strtotime($_POST['dateto'] . ' 23:59:59') . "' AND UNIX_TIMESTAMP(b.datetaken) >= '" . (strtotime($_POST['datefrom']) - 86400) . "'";
                 }
                 if (isset($_POST['item']) && $_POST['item'] != "") {
                     $searchstring .= " AND b.stockid=" . $_POST['item'];
                 }
                 $data['dateto'] = $_POST['dateto'];
                 $data['datefrom'] = $_POST['datefrom'];
                 #Get the paginated list of the purchases
                 $data = paginate_list($this, $data, 'get_borrower_list', array('isactive' => 'Y', 'searchstring' => ' b.school = ' . $schooldetails['id'] . ' AND (' . $searchstring . ')'));
                 $report_type = 'borrowing_report';
                 $report_name = "BORROWING REPORT";
                 if ($this->input->post('generateexcel')) {
                     $size = sizeof($data['page_list']);
                     $maxdate = date("j M, Y", GetTimeStamp($data['page_list'][$size - 1]['datetaken']));
                     $mindate = date("j M, Y", GetTimeStamp($data['page_list'][0]['datetaken']));
                     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 Borrowed", "Title", "Returned / Borrowed", "Name", "Date Expected");
                     $this->excelexport->addRow($mydata);
                     foreach ($data['page_list'] as $row) {
                         #check expiry of rental period
                         $currentdate = date("Y-m-d H:i:s");
                         $borrower_status = check_borrower_status($this, $row['borrowerid']);
                         $mydata = array(date("j M, Y", GetTimeStamp($row['datetaken'])), $row['stocktitle'], $row['copiestaken'] - $borrower_status . "/" . $row['copiestaken'], $row['firstname'] . " " . $row['lastname'], date("j M, Y", GetTimeStamp($row['returndate'])));
                         $this->excelexport->addRow($mydata);
                     }
                 }
             } elseif ($_POST['type'] == 5) {
                 if (isset($_POST['datefrom']) && isset($_POST['dateto']) && $_POST['datefrom'] != "" && $_POST['dateto'] != "") {
                     $searchstring .= " AND  UNIX_TIMESTAMP(l.createdon) <= '" . strtotime($_POST['dateto'] . ' 23:59:59') . "' AND UNIX_TIMESTAMP(l.createdon) >= '" . (strtotime($_POST['datefrom']) - 86400) . "'";
                 }
                 if (isset($_POST['item']) && $_POST['item'] != "") {
                     $searchstring .= " AND i.itemid=" . $_POST['item'];
                 }
                 $data['dateto'] = $_POST['dateto'];
                 $data['datefrom'] = $_POST['datefrom'];
                 #Get the paginated list of the purchases
                 $data = paginate_list($this, $data, 'get_stock_items_list', array('isactive' => 'Y', 'searchstring' => ' s.school = ' . $schooldetails['id'] . ' AND (' . $searchstring . ')'));
                 $report_type = 'library_stock_report';
                 $report_name = "LIBRARY STOCK 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 Added", "Serial Number", "Title", "ISBN Number");
                     $this->excelexport->addRow($mydata);
                     foreach ($data['page_list'] as $row) {
                         $mydata = array(date("j M, Y", GetTimeStamp($row['datecreated'])), $row['serialnumber'], $row['stocktitle'], $row['isbnnumber']);
                         $this->excelexport->addRow($mydata);
                     }
                 }
             } elseif ($_POST['type'] == 4) {
                 #Get the paginated list of the inventory
                 $data = paginate_list($this, $data, 'get_stock_list', array('isactive' => 'Y', 'searchstring' => ' school = ' . $schooldetails['id']));
                 $report_type = 'library_report';
                 $report_name = "LIBRARY 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("Date", "Title", "Stocked", "Available", "Out");
                     $this->excelexport->addRow($mydata);
                     foreach ($data['page_list'] as $row) {
                         $stocked = get_all_stock_items($this, $row['id']);
                         $in = get_stock_items($this, $row['id'], 1);
                         $out = get_stock_items($this, $row['id'], 0);
                         $mydata = array(date("j M, Y", GetTimeStamp($row['createdon'])), $row['stocktitle'], $stocked, $in, $out);
                         $this->excelexport->addRow($mydata);
                     }
                 }
             } elseif ($_POST['type'] == 8) {
                 if (isset($_POST['datefrom']) && isset($_POST['dateto']) && $_POST['datefrom'] != "" && $_POST['dateto'] != "") {
                     $searchstring .= " AND  UNIX_TIMESTAMP(r.returndate) <= '" . strtotime($_POST['dateto'] . ' 23:59:59') . "' AND UNIX_TIMESTAMP(r.returndate) >= '" . (strtotime($_POST['datefrom']) - 86400) . "'";
                 }
                 if (isset($_POST['item']) && $_POST['item'] != "") {
                     $searchstring .= " AND s.id=" . $_POST['item'];
                 }
                 $data['dateto'] = $_POST['dateto'];
                 $data['datefrom'] = $_POST['datefrom'];
                 #Get the paginated list of the purchases
                 $data = paginate_list($this, $data, 'get_return_list', array('isactive' => 'Y', 'searchstring' => ' b.school = ' . $schooldetails['id'] . ' AND (' . $searchstring . ')'));
                 $report_type = 'returning_report';
                 $report_name = "RETURNING REPORT";
                 if ($this->input->post('generateexcel')) {
                     $size = sizeof($data['page_list']);
                     $maxdate = date("j M, Y", GetTimeStamp($data['page_list'][$size - 1]['returndate']));
                     $mindate = date("j M, Y", GetTimeStamp($data['page_list'][0]['returndate']));
                     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 Returned", "Title", "Serial Number");
                     $this->excelexport->addRow($mydata);
                     foreach ($data['page_list'] as $row) {
                         $mydata = array(date("j M, Y", GetTimeStamp($row['returndate'])), $row['stocktitle'], $row['stocktitle'], $row['serialnumber']);
                         $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('library/new_report_view');
 }