function displayCashier($date, $empno) { global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['OverShortDatabase']); $store = FormLib::get('store', 0); $dlog = DTransactionsModel::selectDlog($date); $totals = array(); $counts = array(); $names = array(); $counts["SCA"] = 0.0; $args = array($empno, $date . ' 00:00:00', $date . ' 23:59:59'); $totalsQ = "SELECT \n CASE WHEN trans_subtype IN ('CC','AX') THEN 'CC' ELSE trans_subtype END\n as trans_subtype,MAX(TenderName) as TenderName,\n -1*SUM(total) FROM {$dlog} as d LEFT JOIN " . $FANNIE_OP_DB . $dbc->sep() . "tenders as t\n ON d.trans_subtype=t.TenderCode\n WHERE emp_no = ?\n AND tdate BETWEEN ? AND ?\n AND trans_type='T'\n AND d.upc NOT IN ('0049999900001', '0049999900002')"; if ($store != 0) { $totalsQ .= ' AND d.store_id = ? '; $args[] = $store; } $totalsQ .= " GROUP BY \n CASE WHEN trans_subtype IN ('CC','AX') THEN 'CC' ELSE trans_subtype END\n ORDER BY TenderID"; $totalsP = $dbc->prepare_statement($totalsQ); $totalsR = $dbc->exec_statement($totalsP, $args); while ($totalsW = $dbc->fetch_row($totalsR)) { if (in_array($totalsW['trans_subtype'], OverShortTools::$EXCLUDE_TENDERS)) { continue; } $totals[$totalsW[0]] = $totalsW[2]; $names[$totalsW[0]] = $totalsW[1]; $counts[$totalsW[0]] = 0.0; } $model = new DailyCountsModel($dbc); $model->date($date); $model->emp_no($empno); foreach ($model->find() as $obj) { $counts[$obj->tender_type()] = $obj->amt(); } $posTotal = 0; $countTotal = 0; $osTotal = 0; // cash + checks required if (!isset($totals['CA'])) { $totals['CA'] = 0.0; } if (!isset($counts['CA'])) { $counts['CA'] = 0.0; } if (!isset($totals['CK'])) { $totals['CK'] = 0.0; } if (!isset($counts['CK'])) { $counts['CK'] = 0.0; } $ret = ""; $ret .= "<b>{$date}</b> - Emp. #{$empno}<br />"; $ret .= '<div class="form-group form-inline">'; $ret .= "<label>Starting cash</label>: \n <div class=\"input-group\">\n <span class=\"input-group-addon\">\$</span>\n <input class=\"form-control form-control-sm\" type=text onchange=\"resumSheet();\" \n id=countSCA value=\"" . $counts['SCA'] . "\" />\n </div>\n </div>"; $posTotal += $counts['SCA']; $ret .= "<input type=\"hidden\" class=\"tenderCode\" value=\"CA\" />"; $ret .= "<input type=\"hidden\" class=\"tenderCode\" value=\"CK\" />"; $ret .= "<form onsubmit=\"save(); return false;\">"; $ret .= "<table class=\"table\">"; $ret .= "<tr class=color><th>Cash</th><td>POS</td><td>Count</td><td>O/S</td><td>Cash Counter</td>"; $ret .= "<td> </td>"; $ret .= "<th>Checks</th><td>POS</td><td>Count</td><td>O/S</td><td>List checks</td></tr>"; $ret .= "<tr>"; $ret .= "<td> </td>"; $ret .= "<td id=posCA>" . $totals['CA'] . "</td>"; $ret .= "<td><div class=\"input-group\">\n <span class=\"input-group-addon\">\$</span>\n <input type=text onchange=\"resumSheet();\" id=countCA \n class=\"form-control form-control-sm\" value=\"" . $counts['CA'] . "\" />\n </div></td>"; $os = round($counts['CA'] - $totals['CA'] - $counts['SCA'], 2); $ret .= "<td id=osCA>{$os}</td>"; $posTotal += $totals['CA']; $countTotal += $counts['CA']; $osTotal += $os; $ret .= "<td rowspan=7><textarea rows=11 cols=7 id=cash-counter \n class=\"form-control\" onchange=\"sumCashCounter();\"></textarea></td>"; $ret .= "<td> </td>"; $ret .= "<td> </td>"; $ret .= "<td id=posCK>" . $totals['CK'] . "</td>"; $ret .= "<td id=countCK>" . $counts['CK'] . "</td>"; $os = round($counts['CK'] - $totals['CK'], 2); $ret .= "<td id=osCK>{$os}</td>"; $checks = ""; $model = new DailyChecksModel($dbc); $model->date($date); $model->emp_no($empno); $model->load(); $checks = ""; foreach (explode(",", $model->checks()) as $c) { if (is_numeric($c)) { $checks .= "{$c}\n"; } } $checks = substr($checks, 0, strlen($checks) - 1); $ret .= "<td rowspan=7><textarea rows=11 cols=7 id=checklisting \n class=\"form-control\" onchange=\"resumChecks();\">{$checks}</textarea></td>"; $ret .= "</tr>"; $posTotal += $totals['CK']; $countTotal += $counts['CK']; $osTotal += $os; $codes = array_keys($totals); for ($i = 0; $i < count($codes); $i++) { $code = $codes[$i]; if ($code == 'CA') { continue; } if ($code == 'CK') { continue; } $next = False; for ($j = $i + 1; $j < count($codes); $j++) { if ($codes[$j] == 'CA') { continue; } if ($codes[$j] == 'CK') { continue; } $next = $codes[$j]; $i += 1; // we're consuming two entries this iteration break; } //$ret .= "<tr><td colspan=9 height=4><span style=\"font-size:1%;\"> </span></td></tr>"; $ret .= "<tr class=color><th class=\"small\">" . $names[$code] . "</th><td>POS</td><td>Count</td><td>O/S</td>"; $ret .= "<input type=\"hidden\" class=\"tenderCode\" value=\"{$code}\" />"; $ret .= "<td> </td>"; if ($next) { $ret .= "<th class=\"small\">" . $names[$next] . "</th><td>POS</td><td>Count</td><td>O/S</td></tr>"; $ret .= "<input type=\"hidden\" class=\"tenderCode\" value=\"{$next}\" />"; } else { $ret .= "<th colspan=\"4\"> </th></tr>"; } $ret .= "<tr>"; $ret .= "<td> </td>"; $ret .= "<td id=pos{$code}>" . $totals[$code] . "</td>"; $ret .= "<td><div class=\"input-group\">\n <span class=\"input-group-addon\">\$</span>\n <input type=text onchange=\"resumSheet();\" id=count{$code} \n class=\"form-control form-control-sm\" value=\"" . $counts[$code] . "\" />\n </div></td>"; if (!isset($counts[$code])) { $counts[$code] = 0.0; } $os = round($counts[$code] - $totals[$code], 2); $ret .= "<td id=osCC>{$os}</td>"; $posTotal += $totals[$code]; $countTotal += $counts[$code]; $osTotal += $os; $ret .= "<td> </td>"; if ($next) { $ret .= "<td> </td>"; $ret .= "<td id=pos{$next}>" . $totals[$next] . "</td>"; $ret .= "<td><div class=\"input-group\">\n <span class=\"input-group-addon\">\$</span>\n <input type=text onchange=\"resumSheet();\" id=count{$next} \n class=\"form-control form-control-sm\" value=\"" . $counts[$next] . "\" />\n </div></td>"; if (!isset($counts[$next])) { $counts[$next] = 0.0; } $os = round($counts[$next] - $totals[$next], 2); $ret .= "<td id=os{$next}>{$os}</td>"; $posTotal += $totals[$next]; $countTotal += $counts[$next]; $osTotal += $os; } else { $ret .= "<td colspan=\"4\"> </td>"; } $ret .= "</tr>"; } $ret .= "<tr><td colspan=10 height=4><span style=\"font-size:1%;\"> </span></td></tr>"; $ret .= "<tr class=color>"; $ret .= "<th>Totals</th><td>POS</td><td>Count</td><td>O/S</td><td> </td>"; $model = new DailyNotesModel($dbc); $model->date($date); $model->emp_no($empno); $model->load(); $note = str_replace("''", "'", $model->note()); $ret .= "<td colspan=5 rowspan=2><textarea id=notes class=\"form-control\">{$note}</textarea></td></tr>"; $ret .= "<tr>"; $ret .= "<td> </td>"; $ret .= "<td id=posT>{$posTotal}</td>"; $ret .= "<td id=countT>{$countTotal}</td>"; $ret .= "<td id=osT>{$osTotal}</td>"; $ret .= "<td> </td>"; $ret .= "</tr>"; $ret .= "</table>"; $ret .= "<p><button type=submit class=\"btn btn-default\">Save</button></p>"; $ret .= "</form>"; $ret .= "<input type=hidden id=current_empno value=\"{$empno}\" />"; $ret .= "<input type=hidden id=current_date value=\"{$date}\" />"; return $ret; }