'.__('You don\'t have enough privileges to access this area!').'');
}
ob_start();
// check if there is any active stock take proccess
$stk_query = $dbs->query("SELECT * FROM stock_take WHERE is_active=1");
if ($stk_query->num_rows < 1) {
echo '
'.__('NO stock taking proccess initialized yet!').'
';
} else {
// get stock take data
$stk_data = $stk_query->fetch_assoc();
// check if this file included directly
if (!defined('REPECT_INCLUDE') AND !isset($_GET['print'])) {
?>
table_attr = 'align="center" id="dataList" cellpadding="3" cellspacing="0"';
// make an array for report table row
$report_row[__('Stock Take Name')] = $stk_data['stock_take_name'];
$report_row[__('Total Item Stock Taked')] = $stk_data['total_item_stock_taked'];
// stock take item lost
$report_row[__('Total Item Lost')] = intval($stk_data['total_item_lost']);
if ($report_row[__('Total Item Lost')] < 1) {
$report_row[__('Total Item Lost')] = __('None');
}
// stock take item on loan
if (empty($stk_data['total_item_loan'])) {
$report_row[__('Total Item On Loan')] = __('None');
} else {
$report_row[__('Total Item On Loan')] = $stk_data['total_item_loan'];
}
// stock take total checked item
$checked_count = $stk_data['total_item_stock_taked']-$stk_data['total_item_lost'];
$checked_procent = floor(($checked_count/$stk_data['total_item_stock_taked'])*100);
$progress_bar = '';
$report_row[__('Total Checked/Scanned Items')] = $checked_count.' ('.$checked_procent.'%) '.$progress_bar;
// stock take participants data
$report_row[__('Stock Take Participants')] = '';
// get other stock take users
$st_other_users_q = $dbs->query('SELECT DISTINCT checked_by, COUNT(item_id) AS num_count FROM stock_take_item GROUP BY checked_by ORDER BY `num_count` DESC');
while ($st_other_users_d = $st_other_users_q->fetch_row()) {
if ($st_other_users_d[0] != $stk_data['stock_take_users']) {
$report_row[__('Stock Take Participants')] .= '- '.$st_other_users_d[0].' ('.$st_other_users_d[1].' '.__('items already checked').')
'; //mfc
}
}
// destroy query object
unset($st_other_users_q);
$report_row[__('Stock Take Participants')] .= '
';
// stock take start date
$report_row[__('Start Date')] = nl2br($stk_data['start_date']);
// stock take end date
$report_row[__('End Date')] = nl2br($stk_data['end_date']);
// initial row count
$row = 1;
foreach ($report_row as $headings => $report_data) {
$table->appendTableRow(array($headings, ':', $report_data));
// set cell attribute
$table->setCellAttr($row, 0, 'class="alterCell" style="width: 170px;"');
$table->setCellAttr($row, 1, 'class="alterCell" style="width: 1%;"');
$table->setCellAttr($row, 2, 'class="alterCell2" style="width: auto;"');
$row++;
}
/* GENERAL REPORT */
echo $table->printTable();
/* DECIMAL CLASSES ITEM STATUS */
$class_num = 0;
$row_class = 'alterCell';
$arr_status = array('m', 'e', 'l');
$class_count_str = '';
$class_count_str .= '
';
while ($class_num < 10) {
$row_class = ($class_num%2 == 0)?'alterCell':'alterCell2';
$class_count_str .= ''.$class_num.''.__(' classes').' | '; //mfc
foreach ($arr_status as $status) {
$cls_q = $dbs->query("SELECT COUNT(item_code) FROM stock_take_item WHERE TRIM(classification) LIKE '$class_num%' AND status='$status'");
$cls_d = $cls_q->fetch_row();
// append to string
$class_count_str .= ''.$cls_d[0].' | ';
}
$class_count_str .= '
';
$class_num++;
}
/* NON DECIMAL NUMBER CLASSES ITEM STATUS */
$cls_q = $dbs->query("SELECT DISTINCT classification FROM stock_take_item WHERE TRIM(classification) NOT REGEXP '^[0123456789]'");
while ($cls_d = $cls_q->fetch_row()) {
$row_class = ($row_class == 'alterCell')?'alterCell2':'alterCell';
$class_count_str .= ''.$cls_d[0].' classes | ';
foreach ($arr_status as $status) {
$cls_count_q = $dbs->query("SELECT COUNT(item_code) FROM stock_take_item WHERE TRIM(classification)='".$cls_d[0]."' AND status='$status'");
$cls_count_d = $cls_count_q->fetch_row();
// append to string
$class_count_str .= ''.$cls_count_d[0].' | ';
}
$class_count_str .= '
';
}
/* DECIMAL CLASSES AND NON DECIMAL NUMBER ITEM STATUS END */
// table end
$class_count_str .= '
';
echo $class_count_str;
/* COLLECTION TYPE ITEM STATUS */
$coll_type_count_str = '';
$coll_type_count_str .= '
';
$ct_q = $dbs->query("SELECT DISTINCT coll_type_name FROM stock_take_item");
$row = 1;
while ($ct_d = $ct_q->fetch_row()) {
$row_class = ($row%2 == 0)?'alterCell':'alterCell2';
$coll_type_count_str .= ''.$ct_d[0].' | ';
foreach ($arr_status as $status) {
$ct_count_q = $dbs->query("SELECT COUNT(item_code) FROM stock_take_item WHERE coll_type_name='".$ct_d[0]."' AND status='$status'");
$ct_count_d = $ct_count_q->fetch_row();
// append to string
$coll_type_count_str .= ''.$ct_count_d[0].' | ';
}
$coll_type_count_str .= '
';
$row++;
}
// table end
$coll_type_count_str .= '
';
echo $coll_type_count_str;
/* COLLECTION TYPE ITEM STATUS END */
// output report
$report_content = ob_get_clean();
// check if we are on printed mode
if (isset($_GET['print'])) {
// html strings
$html_str = ''.$sysconf['library_name'].' Current Stock Take Report';
$html_str .= ''."\n";
$html_str .= '';
$html_str .= ''."\n";
$html_str .= ''.$sysconf['library_name'].' - Current Stock Take Report
';
$html_str .= '
'."\n";
$html_str .= $report_content;
$html_str .= ''."\n";
$html_str .= ''."\n";
// write to file
$file_write = @file_put_contents(REPBS.'stock_take_print_result.html', $html_str);
if ($file_write) {
// open result in new window
echo '';
} else { utility::jsAlert('ERROR! Membership statistic report failed to generate, possibly because '.REPBS.' directory is not writable'); }
exit();
} else {
echo $report_content;
}
}