Ejemplo n.º 1
0
 public static function chargeBalance($receipt, $program = "charge", $trans_num = '')
 {
     PrehLib::chargeOK();
     $labels = array();
     $labels['charge'] = array("Current IOU Balance:", 1);
     $labels['debit'] = array("Debit available:", -1);
     $db = Database::tDataConnect();
     list($emp, $reg, $trans) = explode('-', $trans_num, 3);
     $ar_depts = MiscLib::getNumbers(CoreLocal::get('ArDepartments'));
     $checkQ = "SELECT trans_id \n               FROM localtranstoday \n               WHERE \n                emp_no=" . (int) $emp . "\n                AND register_no=" . (int) $reg . "\n                AND trans_no=" . (int) $trans;
     if (count($ar_depts) == 0) {
         $checkQ .= " AND trans_subtype='MI'";
     } else {
         $checkQ .= " AND (trans_subtype='MI' OR department IN (";
         foreach ($ar_depts as $ar_dept) {
             $checkQ .= $ar_dept . ',';
         }
         $checkQ = substr($checkQ, 0, strlen($checkQ) - 1) . '))';
     }
     $checkR = $db->query($checkQ);
     $num_rows = $db->num_rows($checkR);
     $currActivity = CoreLocal::get("memChargeTotal");
     $currBalance = CoreLocal::get("balance") - $currActivity;
     if (($num_rows > 0 || $currBalance != 0) && CoreLocal::get("memberID") != CoreLocal::get('defaultNonMem')) {
         $chargeString = $labels["{$program}"][0] . " \$" . sprintf("%.2f", $labels["{$program}"][1] * $currBalance);
         $receipt = $receipt . "\n\n" . self::biggerFont(self::centerBig($chargeString)) . "\n";
     }
     return $receipt;
 }