function get_z_report_table($kassa_id, $z_report_data) { $diff_count = 0; $yesterday_sum = calc_yesterday_cash($kassa_id, $z_report_data['date']); $today_sum = calc_today_cash($kassa_id, $z_report_data['date']); $today_credit = calc_today_credit($kassa_id, $z_report_data['date']); //echo 'Сумма по Z-отчету: <b>'.number_format($z_report_data['z_sum'], 2, '.', ' ').' руб.</b><br><br>'; $html = 'Сумма на начало ОД: <b>' . number_format($yesterday_sum, 2, '.', ' ') . ' руб.</b><br><br>'; $html .= '<table style="border:1px black solid" cellpadding="0" cellspacing="0">'; $html .= '<tr>'; $html .= '<td style="border:1px black solid; background-color: black; color: white;"></td>'; $html .= '<td style="border:1px black solid; background-color: black; color: white;"><b>Оператор</b></td>'; $html .= '<td style="border:1px black solid; background-color: black; color: white;"><b>Система</b></td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_open_day_sum'] == $z_report_data['open_day_sum']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Фактическая сумма в кассе на начало операционного дня</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['operator_open_day_sum'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['open_day_sum'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_close_day_sum'] == $z_report_data['close_day_sum']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Фактическая сумма в кассе на конец операционного дня</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['operator_close_day_sum'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['close_day_sum'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_count_check'] == $z_report_data['count_check']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Количество чеков</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['operator_count_check'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['count_check'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_count_beznal'] == $z_report_data['count_beznal']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Количество безнала</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['operator_count_beznal'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['count_beznal'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_count_pko'] == $z_report_data['count_pko']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Количество ПКО</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['operator_count_pko'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['count_pko'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_count_rko'] == $z_report_data['count_rko']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Количество РКО</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['operator_count_rko'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . $z_report_data['count_rko'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ((int) $z_report_data['operator_count_credit'] == (int) $z_report_data['count_credit']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Количество кредитов</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . (int) $z_report_data['operator_count_credit'] . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . (int) $z_report_data['count_credit'] . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_z_sum'] == $z_report_data['z_sum']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Сумма по Z-отчету</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . number_format($z_report_data['operator_z_sum'], 2, '.', ' ') . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . number_format($z_report_data['z_sum'], 2, '.', ' ') . '</td>'; $html .= '</tr>'; $html .= '<tr>'; if ($z_report_data['operator_beznal_sum'] == $z_report_data['beznal_sum']) { $color = 'rgba(78, 216, 51, 0.81)'; } else { $color = 'rgba(255, 255, 14, 0.81)'; $diff_count++; } $html .= '<td style="border:1px black solid; background-color: ' . $color . '">Сумма по безналу</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . number_format($z_report_data['operator_beznal_sum'], 2, '.', ' ') . '</td>'; $html .= '<td style="border:1px black solid; background-color: ' . $color . '" align="center">' . number_format($z_report_data['beznal_sum'], 2, '.', ' ') . '</td>'; $html .= '</tr>'; $html .= '</table>'; $html .= '<br>Сумма на конец ОД: <b>' . number_format($today_sum + $yesterday_sum, 2, '.', ' ') . ' руб.</b>'; return array('result' => $html, 'diff' => $diff_count); }
// Запрос для получения суммы на вчершаний остаток дня; $sql = "select sum(`sum`) as `sum` from `kassa_transactions` where `kassa_id` = '".$item['id']."' and date(`date`) = date(NOW() - INTERVAL 1 DAY)"; $yesterday_sum = $db_rs->one($sql); if ($yesterday_sum == ''){ $yesterday_sum = 0; } // Запрос для получения суммя на сегодняший остаток дня; $sql = "select sum(`sum`) as `sum` from `kassa_transactions` where `kassa_id` = '".$item['id']."' and date(`date`) = date(NOW()) AND `beznal` != '1';"; $today_sum = $db_rs->one($sql); if ($today_sum == ''){ $today_sum = 0; } */ $yesterday_sum = calc_yesterday_cash($item['id'], calc_last_kassa_cash_day($item['id'])); $today_sum = calc_today_cash($item['id'], calc_last_kassa_cash_day($item['id'])); $today_credit_sum = calc_today_credit($item['id'], calc_last_kassa_cash_day($item['id'])); $html .= '<td style="text-align: right">Сумма на начало последнего операционного дня</td>'; $html .= '<td style="font-size: 1.3em;"><b>' . number_format($yesterday_sum, 2, '.', ' ') . ' руб.</b></td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= '<td style="text-align: right">Сумма на конец последнего операционного дня</td>'; $html .= '<td style="font-size: 1.3em;"><b>' . number_format($today_sum + $yesterday_sum, 2, '.', ' ') . ' руб.</b></td>'; $html .= '</tr>'; // Безнал; $sql = "select sum(`sum`) as `sum` from `kassa_transactions` where `kassa_id` = '" . $item['id'] . "' and date(`date`) = date('" . calc_last_kassa_cash_day($item['id']) . "') AND `beznal` = '1' AND `sum` > 0;"; //echo $sql; $today_sum_beznal = $db_rs->one($sql); // Количество скидок по безналу; $sql = "SELECT sum(`sum`) as `sum` FROM `kassa_transactions` WHERE `kassa_id` = '" . $item['id'] . "' AND date(`date`) = date('" . calc_last_kassa_cash_day($item['id']) . "') AND `beznal` = '1' AND `sum` < 0;"; $beznal_discont = $db_rs->one($sql); if ($today_sum_beznal == '') {