コード例 #1
0
ファイル: PISearchPage.php プロジェクト: phpsmith/IS4C
 public function get_id_first_last_handler()
 {
     if (empty($this->id) && empty($this->last) && empty($this->first)) {
         return true;
         // invalid search
     }
     if (!empty($this->id)) {
         $account = \COREPOS\Fannie\API\member\MemberREST::get($this->id);
         if ($account != false) {
             header('Location: PIMemberPage.php?id=' . $this->id);
             return false;
         }
         $json = array('idCardUPC' => BarcodeLib::padUPC($this->id));
         $accounts = \COREPOS\Fannie\API\member\MemberREST::search($json, 0, true);
         foreach ($accounts as $a) {
             header('Location: PIMemberPage.php?id=' . $a['cardNo']);
             return false;
         }
     } else {
         $json = array('customers' => array(array('firstName' => $this->first, 'lastName' => $this->last)));
         $accounts = \COREPOS\Fannie\API\member\MemberREST::search($json, 250, true);
         if (count($accounts) == 1) {
             header('Location: PIMemberPage.php?id=' . $accounts[0]['cardNo']);
             return false;
         } else {
             $this->results = $accounts;
         }
     }
     return true;
 }
コード例 #2
0
ファイル: MemCard.php プロジェクト: phpsmith/IS4C
 function GetSearchResults()
 {
     $FANNIE_MEMBER_UPC_PREFIX = FannieConfig::config('FANNIE_MEMBER_UPC_PREFIX');
     $dbc = $this->db();
     $ret = array();
     $mc = "";
     $mc = FormLib::get_form_value('MemCard_mc');
     if (!preg_match("/^\\d+\$/", $mc)) {
         return $ret;
     }
     $mcc = "";
     if (strlen($mc) == 13) {
         $mcc = $mc;
     } else {
         if (strlen($mc) == 11) {
             $mcc = sprintf("00%s", $mc);
         } else {
             $mcc = sprintf("%s%05d", $FANNIE_MEMBER_UPC_PREFIX, (int) $mc);
         }
     }
     $json = array('idCardUPC' => $mcc);
     $accounts = \COREPOS\Fannie\API\member\MemberREST::search($json, 0, true);
     $ret = array();
     foreach ($accounts as $account) {
         foreach ($account['customers'] as $customer) {
             $ret[$account['cardNo']] = $customer['firstName'] . ' ' . $customer['lastName'];
         }
     }
     return $ret;
 }
コード例 #3
0
ファイル: RecallReport.php プロジェクト: phpsmith/IS4C
 public function fetch_report_data()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $upc = BarcodeLib::padUPC(FormLib::get('upc'));
     $date1 = $this->form->date1;
     $date2 = $this->form->date2;
     $dlog = DTransactionsModel::selectDlog($date1, $date2);
     $q = $dbc->prepare("\n            SELECT d.card_no,\n                sum(quantity) as qty,\n                sum(total) as amt\n            FROM {$dlog} AS d \n            WHERE d.upc=? AND \n                tdate BETWEEN ? AND ?\n            GROUP BY d.card_no\n            ORDER BY d.card_no");
     $r = $dbc->exec_statement($q, array($upc, $date1 . ' 00:00:00', $date2 . ' 23:59:59'));
     $data = array();
     while ($w = $dbc->fetch_row($r)) {
         $account = \COREPOS\Fannie\API\member\MemberREST::get($w['card_no']);
         if ($account == false) {
             continue;
         }
         $customer = array();
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $customer = $c;
                 break;
             }
         }
         $record = array($w['card_no'], $customer['lastName'] . ', ' . $customer['firstName'], $account['addressFirstLine'] . ' ' . $account['addressSecondLine'], $account['city'], $account['state'], $account['zip'], $customer['phone'], $customer['altPhone'], $customer['email'], sprintf('%.2f', $w['qty']), sprintf('%.2f', $w['amt']));
         $data[] = $record;
     }
     return $data;
 }
コード例 #4
0
 function preprocess()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $FANNIE_EMP_NO = $this->config->get('EMP_NO');
     $FANNIE_REGISTER_NO = $this->config->get('REGISTER_NO');
     $FANNIE_CORRECTION_DEPT = $this->config->get('PATRONAGE_DEPT');
     /**
       Use fannie settings if properly configured
     */
     if (is_numeric($FANNIE_EMP_NO)) {
         $this->CORRECTION_CASHIER = $FANNIE_EMP_NO;
     }
     if (is_numeric($FANNIE_REGISTER_NO)) {
         $this->CORRECTION_LANE = $FANNIE_REGISTER_NO;
     }
     if (is_numeric($FANNIE_CORRECTION_DEPT)) {
         $this->CORRECTION_DEPT = $FANNIE_CORRECTION_DEPT;
     }
     if (FormLib::get_form_value('submit1', False) !== false) {
         $this->mode = 'confirm';
     } elseif (FormLib::get_form_value('submit2', False) !== False) {
         $this->mode = 'finish';
     }
     // error check inputs
     if ($this->mode != 'init') {
         $this->date = FormLib::get_form_value('date');
         $this->tn = FormLib::get_form_value('trans_num');
         $this->cn2 = FormLib::get_form_value('memTo');
         if (!is_numeric($this->cn2)) {
             $this->errors .= "<div class=\"alert alert-danger\">Error: member given (" . $this->cn2 . ") isn't a number</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         $account = \COREPOS\Fannie\API\member\MemberREST::get($this->cn2);
         if ($account == false) {
             $this->errors .= "<div class=\"alert alert-success\">Error: no such member: " . $this->cn2 . "</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $this->name2 = $c['firstName'] . ' ' . $c['lastName'];
                 break;
             }
         }
         $dlog = DTransactionsModel::selectDlog($this->date);
         $q = $dbc->prepare_statement("SELECT card_no FROM {$dlog} WHERE trans_num=? AND\n                tdate BETWEEN ? AND ?\n                ORDER BY card_no DESC");
         $r = $dbc->exec_statement($q, array($this->tn, $this->date . ' 00:00:00', $this->date . ' 23:59:59'));
         if ($dbc->num_rows($r) == 0) {
             $this->errors .= "<div class=\"alert alert-error\">Error: receipt not found: " . $this->tn . "</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         $w = $dbc->fetchRow($r);
         $this->cn1 = is_array($w) ? $w[0] : 0;
         $q = $dbc->prepare_statement("SELECT SUM(CASE WHEN trans_type in ('I','M','D') then total else 0 END)\n                FROM {$dlog} WHERE trans_num=? AND tdate BETWEEN ? AND ?");
         $r = $dbc->exec_statement($q, array($this->tn, $this->date . ' 00:00:00', $this->date . ' 23:59:59'));
         $w = $dbc->fetchRow($r);
         $this->amt = is_array($w) ? $w[0] : 0;
     }
     return True;
 }
コード例 #5
0
 public function post_id_handler()
 {
     if (!is_array($this->id)) {
         $this->id = array($this->id);
     }
     $today = date("F j, Y");
     $pdf = new FPDF('L', 'in', array(3.5, 5.0));
     $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     $primary = "";
     $pdf->SetAutoPageBreak(true, 0);
     $pdf->SetFont("Gill", "", 10);
     //Meat of the statement
     foreach ($this->id as $card_no) {
         $account = \COREPOS\Fannie\API\member\MemberREST::get($card_no);
         $pdf->AddPage();
         $pdf->SetXY(3.0, 1.45);
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $pdf->Cell(2, 0.25, $c['firstName'] . ' ' . $c['lastName'], "", 1, "L");
                 break;
             }
         }
         $pdf->SetX(3.0);
         $pdf->Cell(2, 0.25, $account['addressFirstLine'], "", 1, "L");
         if ($account['addressSecondLine']) {
             $pdf->SetX(3.0);
             $pdf->Cell(2, 0.25, $account['addressSecondLine'], "", 1, "L");
         }
         $pdf->SetX(3.0);
         $str = $account['city'] . ", " . $account['state'] . " " . $account['zip'];
         $pdf->Cell(2, 0.25, $str, "", 1, "L");
     }
     $pdf->Output('member postcards.pdf', 'D');
     return false;
 }
コード例 #6
0
ファイル: SubAgreement.php プロジェクト: phpsmith/IS4C
 function AutoFill($meminfo)
 {
     $this->SetFont('Arial', '', 10);
     if ($meminfo['stock']['paid-in-full']) {
         $this->SetXY(15, 94);
     } else {
         $this->SetXY(15, 106);
     }
     $this->Cell(0, 0, 'X', 0, 1);
     if ($meminfo['stock']['b'] > 0 && $meminfo['stock']['b'] < 80) {
         $this->SetXY(125, 106);
         $this->Cell(0, 0, sprintf('%.2f', $meminfo['stock']['b']), 0, 1);
     }
     if ($meminfo['stock']['total'] < 100) {
         $this->SetXY(60, 113);
         $this->Cell(0, 0, sprintf('%.2f', 100 - $meminfo['stock']['total']), 0, 1);
         $this->SetXY(135, 113);
         $start = strtotime($meminfo['date']);
         $nextyear = mktime(0, 0, 0, date('n', $start), date('j', $start), date('Y', $start) + 1);
         $this->Cell(0, 0, date('Y-m-d', $nextyear), 0, 1);
     }
     $primary = \COREPOS\Fannie\API\Member\MemberREST::getPrimary($meminfo);
     $household = \COREPOS\Fannie\API\Member\MemberREST::getHousehold($meminfo);
     $this->SetXY(53, 134);
     $this->Cell(0, 0, $this->getName($primary, 0), 0, 1);
     $this->SetXY(20, 153);
     $this->Cell(0, 0, $this->getName($household, 0), 0, 1);
     $this->SetXY(75, 153);
     $this->Cell(0, 0, $this->getName($household, 1), 0, 1);
     $this->SetXY(135, 153);
     $this->Cell(0, 0, $this->getName($household, 2), 0, 1);
     $this->SetXY(36, 161);
     $this->Cell(0, 0, $meminfo['addressFirstLine'], 0, 1);
     $this->SetXY(146, 161);
     $this->Cell(0, 0, $meminfo['addressSecondLine'], 0, 1);
     $this->SetXY(22, 169);
     $this->Cell(0, 0, $meminfo['city'], 0, 1);
     $this->SetXY(98, 170);
     $this->Cell(0, 0, $meminfo['state'], 0, 1);
     $this->SetXY(149, 170);
     $this->Cell(0, 0, $meminfo['zip'], 0, 1);
     $this->SetXY(25, 178);
     $this->Cell(0, 0, $primary[0]['phone'], 0, 1);
     $phoneAlt = '';
     $this->SetXY(104, 179);
     $this->Cell(0, 0, $phoneAlt, 0, 1);
     $this->SetXY(24, 186);
     $this->Cell(0, 0, $primary[0]['email'], 0, 1);
     $this->SetXY(169, 188);
     $this->Cell(0, 0, $meminfo['contactAllowed'] ? 'X' : '', 0, 1);
     $this->SetXY(176, 188);
     $this->Cell(0, 0, !$meminfo['contactAllowed'] ? 'X' : '', 0, 1);
     $this->Image($meminfo['signature'], 35, 203, 60, 0, 'jpg');
     $this->SetXY(142, 209);
     $this->Cell(0, 0, date('Y-m-d', strtotime($meminfo['date'])), 0, 1);
     $this->SetXY(40, 231);
     $this->Cell(0, 0, $meminfo['cardNo'], 0, 1);
     $this->SetXY(151, 232);
     $this->Cell(0, 0, $meminfo['stock']['total'], 0, 1);
 }
コード例 #7
0
 public function run()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $r = $dbc->query('SELECT CardNo FROM custdata WHERE personNum=1 ORDER BY CardNo DESC');
     while ($w = $dbc->fetchRow($r)) {
         echo "Migrating account " . $w['CardNo'] . "\n";
         \COREPOS\Fannie\API\member\MemberREST::get($w['CardNo']);
     }
 }
コード例 #8
0
ファイル: MemDates.php プロジェクト: phpsmith/IS4C
 function saveFormData($memNum)
 {
     $json = array('cardNo' => $memNum, 'startDate' => FormLib::get('MemDates_start'), 'endDate' => FormLib::get('MemDates_end'));
     $resp = \COREPOS\Fannie\API\member\MemberREST::post($memNum, $json);
     if ($resp['errors'] > 0) {
         return "Error: problem saving start/end dates<br />";
     } else {
         return "";
     }
 }
コード例 #9
0
ファイル: PIApply.php プロジェクト: phpsmith/IS4C
 /**
   Update a member account based on a JSON encoded array
 */
 public function get_json_handler()
 {
     $json = json_decode(base64_decode($this->json), true);
     if (!is_array($json)) {
         echo 'Invalid data!';
         return false;
     }
     $rest = array('cardNo' => $json['card_no'], 'addressFirstLine' => $json['addr1'], 'addressSecondLine' => $json['addr2'], 'city' => $json['city'], 'state' => $json['state'], 'zip' => $json['zip'], 'customers' => array(array('accountHolder' => 1, 'firstName' => $json['fn'], 'lastName' => $json['ln'], 'phone' => $json['ph'], 'email' => $json['email'])));
     \COREPOS\Fannie\API\member\MemberREST::post($json['card_no'], $rest);
     header('Location: PIMemberPage.php?id=' . $json['card_no']);
     return false;
 }
コード例 #10
0
ファイル: AR.php プロジェクト: phpsmith/IS4C
 function saveFormData($memNum)
 {
     $limit = FormLib::get_form_value('AR_limit', 0);
     $json = array('cardNo' => $memNum, 'chargeLimit' => $limit, 'customers' => array());
     $account = self::getAccount();
     $json['customerAccountID'] = $account['customerAccountID'];
     foreach ($account['customers'] as $c) {
         if ($c['accountHolder']) {
             $json['customers'][] = array('customerID' => $c['customerID'], 'customerAccountID' => $account['customerAccountID'], 'chargeAllowed' => $limit == 0 ? 0 : 1, 'accountHolder' => 1, 'cardNo' => $memNum);
         } elseif ($c['customerID']) {
             // unnecessary to specify all customers in old schema
             // new schema will only update correctly if IDs exist
             $json['customers'][] = array('customerID' => $c['customerID'], 'cardNo' => $memNum, 'chargeAllowed' => $limit == 0 ? 0 : 1, 'accountHolder' => 0);
         }
     }
     $resp = \COREPOS\Fannie\API\member\MemberREST::post($memNum, $json);
     if ($resp['errors'] > 0) {
         return 'Error: Problem saving A/R limit<br />';
     } else {
         return '';
     }
 }
コード例 #11
0
 function process_file($linedata)
 {
     $mn_index = $this->get_column_index('memnum');
     $st_index = $this->get_column_index('street');
     $st2_index = $this->get_column_index('street2');
     $city_index = $this->get_column_index('city');
     $state_index = $this->get_column_index('state');
     $zip_index = $this->get_column_index('zip');
     $ph_index = $this->get_column_index('ph1');
     $ph2_index = $this->get_column_index('ph2');
     $email_index = $this->get_column_index('email');
     foreach ($linedata as $line) {
         // get info from file and member-type default settings
         // if applicable
         $cardno = $line[$mn_index];
         if (!is_numeric($cardno)) {
             continue;
         }
         // skip bad record
         $street = $st_index !== False ? $line[$st_index] : "";
         $street2 = $st2_index !== False ? $line[$st2_index] : "";
         $city = $city_index !== False ? $line[$city_index] : "";
         $state = $state_index !== False ? $line[$state_index] : "";
         $zip = $zip_index !== False ? $line[$zip_index] : "";
         $ph1 = $ph_index !== False ? $line[$ph_index] : "";
         $ph2 = $ph2_index !== False ? $line[$ph2_index] : "";
         $email = $email_index !== False ? $line[$email_index] : "";
         $json = array('cardNo' => $cardno, 'addressFirstLine' => $street, 'addressSecondLine' => $street2, 'city' => $city, 'state' => $state, 'zip' => $zip, 'customers' => array(array('phone' => $ph1, 'altPhone' => $ph2, 'email' => $email, 'accountHolder' => 1)));
         $resp = \COREPOS\Fannie\API\member\MemberREST::post($cardno, $json);
         if ($resp['errors'] > 0) {
             $this->stats['errors'][] = "Error importing member {$cardno}";
         } else {
             $this->stats['imported']++;
         }
     }
     return true;
 }
コード例 #12
0
ファイル: SetMemDatesTask.php プロジェクト: phpsmith/IS4C
 public function run()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $equityP = $dbc->prepare('
         SELECT e.payments,
             e.startdate
         FROM ' . $this->config->get('TRANS_DB') . $dbc->sep() . 'equity_live_balance AS e
         WHERE e.memnum = ?
     ');
     $accounts = \COREPOS\Fannie\API\member\MemberREST::get();
     foreach ($accounts as $account) {
         if ($account['startDate'] != '' && $account['startDate'] != '0000-00-00 00:00:00') {
             // date has been assigned already
             continue;
         }
         $equityR = $dbc->execute($equityP, array($account['cardNo']));
         if (!$equityR || $dbc->numRows($equityR) == 0) {
             // no equity
             continue;
         }
         $equity = $dbc->fetchRow($equityR);
         /**
           If an equity payment has been made,
           assign start date to that equity payment's date.
           If equity is not fully paid, set the end
           date one year in the future.
         */
         if ($equity['payments'] > 0) {
             if ($account['startDate'] == '' || $account['startDate'] == '0000-00-00 00:00:00') {
                 $account['startDate'] = $equity['startdate'];
             }
             if ($equity['payments'] < 100) {
                 $ts = strtotime($equity['startdate']);
                 $next_year = date('Y-m-d', mktime(0, 0, 0, date('n', $ts), date('j', $ts), date('Y', $ts) + 1));
                 $account['endDate'] = $next_year;
             }
             $account['contactAllowed'] = 1;
             $resp = \COREPOS\Fannie\API\member\MemberREST::post($account['cardNo'], $account);
             if ($resp['errors'] > 0) {
                 $this->cronMsg('Error setting account dates for account #' . $account['cardNo']);
             }
         }
     }
     /**
       Re-fetch accounts with update dates
       and set notification message in custReceiptMessages
       and/or CustomerNotifications
     */
     $accounts = \COREPOS\Fannie\API\member\MemberREST::get();
     $old_table = false;
     if ($dbc->tableExists('custReceiptMessage')) {
         $dbc->query("DELETE FROM custReceiptMessage WHERE msg_text LIKE 'EQUITY OWED% == %'");
         $old_table = true;
     }
     $new_table = false;
     if ($dbc->tableExists('CustomerNotifications')) {
         $dbc->query('DELETE FROM CustomerNotifications WHERE source=\'SetMemDatesTask\'');
         $new_table = true;
     }
     foreach ($accounts as $account) {
         if ($account['endDate'] == '' || $account['endDate'] == '0000-00-00 00:00:00') {
             // no due date
             continue;
         }
         if ($account['memberStatus'] != 'PC') {
             // not a member
             continue;
         }
         $equityR = $dbc->execute($equityP, array($account['cardNo']));
         if (!$equityR || $dbc->numRows($equityR) == 0) {
             // no equity
             continue;
         }
         $equity = $dbc->fetchRow($equityR);
         if ($equity['payments'] >= 100) {
             // clear end date from paid-in-full
             $account['endDate'] = '0000-00-00 00:00:00';
             $resp = \COREPOS\Fannie\API\member\MemberREST::post($account['cardNo'], $account);
             continue;
         }
         $msg = 'EQUITY OWED $' . sprintf('%.2f', 100 - $equity['payments']) . ' == DUE DATE ' . date('m/d/Y', strtotime($account['endDate']));
         if ($old_table) {
             $model = new CustReceiptMessageModel($dbc);
             $model->card_no($account['cardNo']);
             $model->msg_text($msg);
             $model->modifier_module('WfcEquityMessage');
             $model->save();
         }
         if ($new_table) {
             $model = new CustomerNotificationsModel($dbc);
             $model->cardNo($account['cardNo']);
             $model->source('SetMemDatesTask');
             $model->type('receipt');
             $model->message($msg);
             $model->modifierModule('WfcEquityMessage');
             $model->save();
         }
     }
 }
コード例 #13
0
ファイル: PISignaturePage.php プロジェクト: phpsmith/IS4C
 protected function get_id_view()
 {
     $this->addScript('../../../src/javascript/signature_pad-1.5.0/signature_pad.js');
     $this->addScript('sig.js');
     $mem = \COREPOS\Fannie\API\member\MemberREST::get($this->id);
     $primary = \COREPOS\Fannie\API\Member\MemberREST::getPrimary($mem);
     if ($mem === false) {
         return '<div class="alert alert-danger">Owner not found</div>' . $this->get_view();
     }
     $ret = '<form method="post" id="sign-form">
         <p>
             <label>Owner</label>
             <input type="hidden" name="id" value="' . $this->id . '" />
             ' . $mem['cardNo'] . ' ' . $primary[0]['firstName'] . ' ' . $primary[0]['lastName'] . '
         </p>
         <p id="sign-p">
             <label>Sign Here</label>
             <canvas id="sign-canvas" 
                 style="width:100%;height:200px;border-radius:4px;border-style:solid;border-color:black;border-width:1px;">
             </canvas>
         </p>
         <p class="clearfix">
             <button type="button" class="btn btn-default btn-lg pull-left" id="btn-clear">Clear</button>
             <button type="button" class="btn btn-default btn-lg pull-right" id="btn-accept">Accept</button>
         </p>
         </form>';
     return $ret;
 }
コード例 #14
0
 public function post_id_handler()
 {
     $numbers = array("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty");
     if (!is_array($this->id)) {
         $this->id = array($this->id);
     }
     $today = date("F j, Y");
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Medium.php');
     //Meat of the statement
     foreach ($this->id as $card_no) {
         $pdf->AddPage();
         $pdf->Image('new_letterhead_horizontal.png', 5, 10, 200);
         $pdf->SetFont('Gill', '', '12');
         $pdf->Ln(45);
         $account = \COREPOS\Fannie\API\member\MemberREST::get($card_no);
         $pdf->Cell(10, 10, $today, 0);
         $pdf->Ln(15);
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $firstname = ucwords(strtolower($c['firstName']));
                 $lastname = ucwords(strtolower($c['lastName']));
                 $fullname = $firstname . " " . $lastname;
                 break;
             }
         }
         //Member address
         $pdf->Cell(10, 10, trim($fullname), 0);
         $pdf->Ln(5);
         $pdf->Cell(80, 10, $account['addressFirstLine'], 0);
         if ($account['addressSecondLine']) {
             $pdf->Cell(80, 10, $account['addressSecondLine'], 0);
         }
         $pdf->Cell(90, 10, $account['city'] . ', ' . $account['state'] . '   ' . $account['zip'], 0);
         $pdf->Ln(15);
         $pdf->MultiCell(0, 5, "Dear " . $firstname . ",");
         $pdf->Ln(5);
         $txt = "We have received your Application to Terminate your membership at WFC. The\nBoard reviews termination requests annually in ";
         $pdf->SetFont("Gill", "", "12");
         $pdf->Write(5, str_replace("\n", " ", $txt));
         $pdf->SetFont("Gill", "B", "12");
         $pdf->Write(5, "February");
         $pdf->SetFont("Gill", "", "12");
         $txt = ". Refunds, less any indebtedness owed to WFC, are authorized for payment in\nthe order received subject to the financial health of WFC and receipt of additional stock\nfrom new members. Your stock will be refunded as soon as possible based on these criteria.";
         $pdf->Write(5, str_replace("\n", " ", $txt) . "\n");
         $pdf->Ln(5);
         $txt = "Submission of an Application to Terminate immediately inactivates your owner\nbenefits and discounts and your right to participate in governance of WFC. Please keep us\nadvised of any changes in your mailing address.";
         $pdf->MultiCell(0, 5, str_replace("\n", ' ', $txt));
         $pdf->Ln(5);
         $txt = "If you have any questions, please do not hesitate to ask. I can be reached at the\nnumber above or at mms@wholefoods.coop. Thank you.";
         $pdf->MultiCell(0, 5, str_replace("\n", ' ', $txt));
         $pdf->Ln(5);
         $pdf->MultiCell(0, 5, "Thank you for your support of WFC");
         $pdf->Ln(10);
         $pdf->MultiCell(0, 5, "Sincerely yours,");
         $pdf->MultiCell(0, 5, "WHOLE FOODS COMMUNITY CO-OP, INC.");
         $pdf->Ln(10);
         $pdf->MultiCell(0, 5, "Amanda Borgren");
         $pdf->MultiCell(0, 5, "Owner Services");
     }
     $pdf->Output('member term letters.pdf', 'D');
     return false;
 }
コード例 #15
0
ファイル: MemArEquityDumpTool.php プロジェクト: phpsmith/IS4C
 function preprocess()
 {
     global $FANNIE_AR_DEPARTMENTS;
     global $FANNIE_EQUITY_DEPARTMENTS;
     global $FANNIE_OP_DB;
     global $FANNIE_EMP_NO, $FANNIE_REGISTER_NO;
     global $FANNIE_MISC_DEPT;
     /**
       Use fannie settings if properly configured
     */
     if (is_numeric($FANNIE_EMP_NO)) {
         $this->CORRECTION_CASHIER = $FANNIE_EMP_NO;
     }
     if (is_numeric($FANNIE_REGISTER_NO)) {
         $this->CORRECTION_LANE = $FANNIE_REGISTER_NO;
     }
     if (is_numeric($FANNIE_MISC_DEPT)) {
         $this->DEFAULT_DEPT = $FANNIE_MISC_DEPT;
     }
     if (empty($FANNIE_AR_DEPARTMENTS)) {
         $this->errors .= '<div class="alert alert-danger">Error: no AR departments found</div>';
         return True;
     }
     if (empty($FANNIE_EQUITY_DEPARTMENTS)) {
         $this->errors .= '<div class="alert alert-danger">Error: no Equity departments found</div>';
         return True;
     }
     $ret = preg_match_all("/[0-9]+/", $FANNIE_AR_DEPARTMENTS, $depts);
     if ($ret == 0) {
         $this->errors .= '<div class="alert alert-danger">Error: can\'t read AR department definitions</div>';
         return True;
     }
     $temp_depts = array_pop($depts);
     $ret = preg_match_all("/[0-9]+/", $FANNIE_EQUITY_DEPARTMENTS, $depts);
     if ($ret == 0) {
         $this->errors .= '<div class="alert alert-danger">Error: can\'t read Equity department definitions</div>';
         return True;
     }
     $temp_depts2 = array_pop($depts);
     foreach ($temp_depts2 as $num) {
         $temp_depts[] = $num;
     }
     $dlist = "(";
     $dArgs = array();
     foreach ($temp_depts as $d) {
         $dlist .= "?,";
         $dArgs[] = $d;
     }
     $dlist = substr($dlist, 0, strlen($dlist) - 1) . ")";
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $q = $dbc->prepare_statement("SELECT dept_no,dept_name FROM departments WHERE dept_no IN {$dlist}");
     $r = $dbc->exec_statement($q, $dArgs);
     if ($dbc->num_rows($r) == 0) {
         $this->errors .= '<div class="alert alert-danger">Error: department(s) don\'t exist.</div>';
         return true;
     }
     $this->depts = array();
     while ($row = $dbc->fetch_row($r)) {
         $this->depts[$row[0]] = $row[1];
     }
     if (FormLib::get_form_value('submit1', False) !== False) {
         $this->mode = 'confirm';
     } elseif (FormLib::get_form_value('submit2', False) !== False) {
         $this->mode = 'finish';
     }
     // error check inputs
     if ($this->mode != 'init') {
         $this->dept1 = FormLib::get_form_value('deptFrom');
         $this->dept2 = FormLib::get_form_value('deptTo');
         $this->amount = FormLib::get_form_value('amount');
         $this->cn = FormLib::get_form_value('card_no');
         if (!is_numeric($this->amount)) {
             $this->errors .= "<div class=\"alert alert-danger\">Error: amount given (" . $this->amount . ") isn't a number</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         if (!is_numeric($this->cn)) {
             $this->errors .= "<div class=\"alert alert-danger\">Error: member given (" . $this->cn1 . ") isn't a number</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         if ($this->dept1 == $this->dept2) {
             $this->errors .= "<div class=\"alert alert-danger\">Error: departments are the same; nothing to convert</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         $account = \COREPOS\Fannie\API\member\MemberREST::get($this->cn);
         if ($account == false) {
             $this->errors .= "<div class=\"alert alert-success\">Error: no such member: " . $this->cn . "</div>" . "<br /><br />" . "<a href=\"\" onclick=\"back(); return false;\">Back</a>";
             return True;
         }
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $this->name1 = $c['firstName'] . ' ' . $c['lastName'];
                 break;
             }
         }
     }
     return True;
 }
コード例 #16
0
ファイル: MemberEditor.php プロジェクト: phpsmith/IS4C
 function body_content()
 {
     global $FANNIE_MEMBER_MODULES;
     $ret = '';
     $list = FormLib::get_form_value('l');
     $ret .= '<form action="MemberEditor.php" method="post">';
     $ret .= sprintf('<input type="hidden" name="memNum" value="%d" />', $this->memNum);
     if (is_array($list)) {
         foreach ($list as $l) {
             $ret .= sprintf('<input type="hidden" name="l[]" value="%d" />', $l);
         }
     }
     $load = array();
     $editJS = '';
     $ret .= '<div class="container-fluid">
         <div id="alert-area">';
     if (!empty($this->msgs)) {
         $ret .= '<div class="alert alert-danger">' . $this->msgs . '</div>';
     }
     $current_width = 100;
     $account = \COREPOS\Fannie\API\member\MemberREST::get($this->memNum);
     \COREPOS\Fannie\API\member\MemberModule::setAccount($account);
     FannieAPI::listModules('MemberModule');
     foreach ($FANNIE_MEMBER_MODULES as $mm) {
         if (!class_exists($mm)) {
             continue;
         }
         $instance = new $mm();
         if ($current_width + $instance->width() > 100) {
             $ret .= '</div>' . "\n" . '<div class="row">';
             $current_width = 0;
         }
         switch ($instance->width()) {
             case \COREPOS\Fannie\API\member\MemberModule::META_WIDTH_THIRD:
                 $ret .= '<div class="col-sm-4">' . "\n";
                 break;
             case \COREPOS\Fannie\API\member\MemberModule::META_WIDTH_HALF:
                 $ret .= '<div class="col-sm-6">' . "\n";
                 break;
             case \COREPOS\Fannie\API\member\MemberModule::META_WIDTH_FULL:
             default:
                 $ret .= '<div class="col-sm-12">' . "\n";
                 break;
         }
         $ret .= $instance->showEditForm($this->memNum, $this->country);
         $ret .= '</div>';
         $current_width += $instance->width();
         $editJS .= $instance->getEditJavascript();
         foreach ($instance->getEditLoadCommands() as $cmd) {
             $load[] = $cmd;
         }
     }
     $ret .= '</div>';
     // close last module row
     $ret .= '</div>';
     // close fluid-container
     $ret .= '<p>';
     if (is_array($list)) {
         $ret .= '<button type="submit" name="saveBtn" value="Save &amp; Next"
             class="btn btn-default">Save &amp; Next</button>';
         $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     }
     $ret .= '<button type="submit" name="saveBtn" value="Save" 
         class="btn btn-default btn-core">Save</button>';
     $ret .= '<button type="reset" class="btn btn-default btn-reset">Reset Form</button>';
     $ret .= '</p>';
     $ret .= '</form>';
     if ($editJS != '') {
         $ret .= '<script type="text/javascript">' . $editJS . '</script>';
     }
     foreach ($load as $cmd) {
         $this->add_onload_command($cmd);
     }
     return $ret;
 }
コード例 #17
0
ファイル: ContactInfo.php プロジェクト: phpsmith/IS4C
 function getSearchResults()
 {
     $fn = FormLib::get_form_value('ContactInfo_fn');
     $ln = FormLib::get_form_value('ContactInfo_ln');
     $addr = FormLib::get_form_value('ContactInfo_addr');
     $city = FormLib::get_form_value('ContactInfo_city');
     $state = FormLib::get_form_value('ContactInfo_state');
     $zip = FormLib::get_form_value('ContactInfo_zip');
     $email = FormLib::get_form_value('ContactInfo_email');
     $json = array();
     $customer = array();
     if (!empty($fn)) {
         $customer['firstName'] = $fn;
     }
     if (!empty($ln)) {
         $customer['lastName'] = $ln;
     }
     if (!empty($addr)) {
         $json['addressFirstLine'] = $addr;
     }
     if (!empty($city)) {
         $json['city'] = $city;
     }
     if (!empty($state)) {
         $json['state'] = $state;
     }
     if (!empty($zip)) {
         $json['zip'] = $zip;
     }
     if (!empty($email)) {
         $customer['email'] = $email;
     }
     $json['customers'] = array($customer);
     $accounts = \COREPOS\Fannie\API\member\MemberREST::search($json, 0, true);
     $ret = array();
     foreach ($accounts as $account) {
         foreach ($account['customers'] as $customer) {
             $ret[$account['cardNo']] = $customer['firstName'] . ' ' . $customer['lastName'];
         }
     }
     return $ret;
 }
コード例 #18
0
ファイル: PIMemberPage.php プロジェクト: phpsmith/IS4C
 protected function post_id_handler()
 {
     global $FANNIE_OP_DB, $FANNIE_TRANS_DB;
     $this->card_no = $this->id;
     if ($this->auth_mode == 'None') {
         return $this->unknownRequestHandler();
     }
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $note = FormLib::get_form_value('notetext');
     $hash = FormLib::get_form_value('_notetext');
     if (base64_decode($hash) != $note) {
         $noteP = $dbc->prepare_statement('INSERT INTO memberNotes
                 (cardno, note, stamp, username) VALUES
                 (?, ?, ' . $dbc->now() . ', ?)');
         $noteR = $dbc->exec_statement($noteP, array($this->card_no, str_replace("\n", '<br />', $note), $this->current_user));
     }
     $json = array('cardNo' => $this->id, 'customers' => array());
     $account_holder = array('accountHolder' => 1);
     $account_holder['firstName'] = FormLib::get('FirstName');
     $account_holder['lastName'] = FormLib::get('LastName');
     $account_holder['customerID'] = FormLib::get('customerID');
     $json['addressFirstLine'] = FormLib::get('address1');
     $json['addressSecondLine'] = FormLib::get('address2');
     $json['city'] = FormLib::get('city');
     $json['state'] = FormLib::get('state');
     $json['zip'] = FormLib::get('zip');
     $account_holder['phone'] = FormLib::get('phone');
     $account_holder['altPhone'] = FormLib::get('phone2');
     $account_holder['email'] = FormLib::get('email');
     $json['contactAllowed'] = FormLib::get('mailflag', 0);
     $upc = FormLib::get_form_value('upc', false);
     if ($upc !== false) {
         if ($upc != '') {
             $json['idCardUPC'] = BarcodeLib::padUPC($upc);
         } else {
             $json['idCardUPC'] = '';
         }
     }
     if ($this->auth_mode == 'Full') {
         $json['customerTypeID'] = FormLib::get('memType');
         $json['chargeLimit'] = FormLib::get('chargelimit');
         $default = new MemtypeModel($dbc);
         $default->memtype($json['customerTypeID']);
         $default->load();
         $account_holder['discount'] = $default->discount();
         $account_holder['staff'] = $default->staff();
         $account_holder['chargeAllowed'] = $json['chargeLimit'] == 0 ? 0 : 1;
         $account_holder['lowIncomeBenefits'] = $default->ssi();
         $start = FormLib::get('start_date', '');
         /**
           Interface hides 1900-01-01 dates from the end-user
           but that's not identical to 0000-00-00. A blank submission
           should preserve that 1900-01-01 date.
         */
         if ($start == '' && FormLib::get('nonBlankStart') != '') {
             $start = FormLib::get('nonBlankStart');
         }
         $json['startDate'] = $start;
         $json['endDate'] = FormLib::get('end_date');
     } else {
         // get account defaults for additional names if needed
         $account = \COREPOS\Fannie\API\member\MemberREST::get($this->card_no);
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $account_holder['discount'] = $c['discount'];
                 $account_holder['staff'] = $c['staff'];
                 $account_holder['lowIncomeBenefits'] = $c['lowIncomeBenefits'];
                 $account_holder['chargeAllowed'] = $c['chargeAllowed'];
             }
         }
     }
     $json['customers'][] = $account_holder;
     $names = array('first' => FormLib::get_form_value('fn'), 'last' => FormLib::get_form_value('ln'));
     $fn = FormLib::get_form_value('fn');
     $ln = FormLib::get_form_value('ln');
     $hhID = FormLib::get('hhID');
     for ($i = 0; $i < count($fn); $i++) {
         $set = array('first' => isset($fn[$i]) ? $fn[$i] : '', 'last' => isset($ln[$i]) ? $ln[$i] : '', 'id' => isset($hhID[$i]) ? $hhID[$i] : '');
         $json['customers'][] = array('customerID' => $hhID[$i], 'accountHolder' => 0, 'firstName' => $set['first'], 'lastName' => $set['last'], 'discount' => $account_holder['discount'], 'staff' => $account_holder['staff'], 'lowIncomeBenefits' => $account_holder['lowIncomeBenefits'], 'chargeAllowed' => $account_holder['chargeAllowed']);
     }
     $resp = \COREPOS\Fannie\API\member\MemberREST::post($this->card_no, $json);
     $custdata = new CustdataModel($dbc);
     $custdata->CardNo($this->card_no);
     foreach ($custdata->find() as $c) {
         $c->pushToLanes();
     }
     $cards = new MemberCardsModel($dbc);
     $cards->card_no($this->card_no);
     $cards->load();
     $cards->pushToLanes();
     header('Location: PIMemberPage.php?id=' . $this->card_no);
     return false;
 }
コード例 #19
0
ファイル: DTrans.php プロジェクト: phpsmith/IS4C
 /**
   Add a transaction record directly to dtransactions on the backend
   @param $connection [SQLManager] database connection
   @param $trans_no [integer] transaction number (dtransactions.trans_no)
   @param $params [array] of column_name => value
 
   If emp_no and register_no values are not specified, the defaults
   are the configuration settings FANNIE_EMP_NO and FANNIE_REGISTER_NO.
 
   The following columns are always calculated by addItem() and values
   set in $params will be ignored:
   - datetime (always current)
   - trans_id (assigned based on existing records)
   Additionally, the following values are looked up if $params['card_no']
   is specified:
   - memType
   - staff
 */
 public static function addItem(SQLManager $connection, $trans_no, $params)
 {
     $config = FannieConfig::factory();
     $model = new DTransactionsModel($connection);
     $model->whichDB($config->get('TRANS_DB'));
     $model->trans_no($trans_no);
     $model->emp_no($config->get('EMP_NO'));
     if (isset($params['emp_no'])) {
         $model->emp_no($params['emp_no']);
     }
     $model->register_no($config->get('REGISTER_NO'));
     if (isset($params['register_no'])) {
         $model->register_no($params['register_no']);
     }
     $current_records = $model->find('trans_id', true);
     if (count($current_records) == 0) {
         $model->trans_id(1);
     } else {
         $last = $current_records[0];
         $model->trans_id($last->trans_id() + 1);
     }
     if (isset($params['card_no'])) {
         $account = \COREPOS\Fannie\API\member\MemberREST::get($params['card_no']);
         if ($account) {
             $model->memType($account['customerTypeID']);
             $model->staff($account['customers'][0]['staff']);
         }
     }
     $defaults = self::$DEFAULTS;
     $skip = array('datetime', 'emp_no', 'register_no', 'trans_no', 'trans_id');
     foreach ($defaults as $name => $value) {
         if (in_array($name, $skip)) {
             continue;
         }
         if (isset($params[$name])) {
             $model->{$name}($params[$name]);
         } else {
             $model->{$name}($value);
         }
     }
     $model->datetime(date('Y-m-d H:i:s'));
     if ($model->save()) {
         return true;
     } else {
         return false;
     }
 }
コード例 #20
0
ファイル: MemberSearchPage.php プロジェクト: phpsmith/IS4C
 function form_content()
 {
     global $FANNIE_MEMBER_MODULES, $FANNIE_OP_DB;
     $ret = '';
     $review = FormLib::get_form_value('review', False);
     if ($review !== false) {
         $ret .= '<fieldset><legend>Review</legend>';
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $account = \COREPOS\Fannie\API\member\MemberREST::get($review);
         $ret .= 'Saved Member #' . $review . ' (';
         if ($account) {
             foreach ($account['customers'] as $row) {
                 if ($row['accountHolder']) {
                     $ret .= $row['firstName'] . ' ' . $row['lastName'];
                     break;
                 }
             }
         }
         $ret .= ')';
         $ret .= '<br /><a href="MemberEditor.php?memNum=' . $review . '">Edit Again</a>';
         $list = FormLib::get('l');
         if (!class_exists('MemberEditor')) {
             include dirname(__FILE__) . '/MemberEditor.php';
         }
         $links = MemberEditor::memLinksPrevNext($review, $list);
         if (!empty($links[0])) {
             $ret .= '&nbsp;&nbsp;&nbsp;' . $links[0];
         }
         if (!empty($links[1])) {
             $ret .= '&nbsp;&nbsp;&nbsp;' . $links[1];
         }
         $ret .= '</fieldset>';
     }
     $ret .= '<div class="well">
         Enter criteria to find one member or a list members from which to choose.</div>';
     $ret .= '<form action="MemberSearchPage.php" method="get">';
     $ret .= '<div class="container-fluid">';
     $ret .= '<div class="form-group form-inline row">
         <label>Member Number</label>
         <input type="text" name="memNum" id="mn" class="form-control" />
         </div>';
     $searchJS = '';
     $load = array();
     FannieAPI::listModules('MemberModule');
     foreach ($FANNIE_MEMBER_MODULES as $mm) {
         if (class_exists($mm)) {
             $instance = new $mm();
             if ($instance->hasSearch()) {
                 $ret .= $instance->showSearchForm($this->country);
                 $searchJS .= $instance->getSearchJavascript();
                 foreach ($instance->getSearchLoadCommands() as $cmd) {
                     $load[] = $cmd;
                 }
             }
         }
     }
     $ret .= '</div>';
     $ret .= '<p><button type="submit" value="Search" name="doSearch" 
         class="btn btn-default">Search</button></p>';
     $ret .= '</form>';
     $ret .= '<script type="text/javascript" src="../item/autocomplete.js"></script>';
     if ($searchJS != '') {
         $ret .= '<script type="text/javascript">' . $searchJS . '</script>';
     }
     foreach ($load as $cmd) {
         $this->add_onload_command($cmd);
     }
     return $ret;
 }
コード例 #21
0
ファイル: SuspensionsReport.php プロジェクト: phpsmith/IS4C
 function fetch_report_data()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $date1 = $this->form->date1;
     $date2 = $this->form->date2;
     $code = FormLib::get_form_value('reason', '0');
     $args = array($date1 . ' 00:00:00', $date2 . ' 23:59:59');
     $query = 'SELECT s.cardno as card_no,
                 s.type as sus_type,
                 s.suspDate,
                 r.textStr
               FROM suspensions AS s
                 LEFT JOIN reasoncodes AS r ON s.reasoncode & r.mask <> 0
               WHERE s.suspDate BETWEEN ? AND ?';
     if ($code != 0) {
         $args[] = $code;
         $query .= ' AND s.reasoncode & ? <> 0 ';
     }
     $query .= ' ORDER BY s.cardno';
     $prep = $dbc->prepare($query);
     $res = $dbc->execute($prep, $args);
     $data = array();
     $num = $dbc->num_rows($res);
     $record = array(0, 1, 2, '', 4, 5, 6, 7, 8, 9, 10);
     for ($i = 0; $i < $num; $i++) {
         $row = $dbc->fetch_row($res);
         if ($row['card_no'] != $record[0] && $record[0] != 0) {
             $record[3] = substr($record[3], 0, strlen($record[3]) - 2);
             $account = \COREPOS\Fannie\API\member\MemberREST::get($record[0]);
             $record[6] = $account['addressFirstLine'];
             $record[7] = $account['city'];
             $record[8] = $account['state'];
             $record[9] = $account['zip'];
             foreach ($account['customers'] as $customer) {
                 $record[4] = $customer['lastName'];
                 $record[5] = $customer['firstName'];
                 $record[10] = $customer['phone'];
             }
             $data[] = $record;
             $record = array(0, 1, 2, '', 4, 5, 6, 7, 8, 9, 10);
         }
         $record[0] = $row['card_no'];
         $record[1] = $row['sus_type'] == 'I' ? 'INACTIVE' : 'TERMED';
         $record[2] = $row['suspDate'];
         $record[3] .= $row['textStr'] . ', ';
         $last_row = $i == $num - 1 ? true : false;
         if ($last_row) {
             $record[3] = substr($record[3], 0, strlen($record[3]) - 2);
             $account = \COREPOS\Fannie\API\member\MemberREST::get($record[0]);
             $record[6] = $account['addressFirstLine'];
             $record[7] = $account['city'];
             $record[8] = $account['state'];
             $record[9] = $account['zip'];
             foreach ($account['customers'] as $customer) {
                 $record[4] = $customer['lastName'];
                 $record[5] = $customer['firstName'];
                 $record[10] = $customer['phone'];
             }
             $data[] = $record;
         }
     }
     return $data;
 }
コード例 #22
0
ファイル: PISuspensionPage.php プロジェクト: phpsmith/IS4C
 function post_id_handler()
 {
     global $FANNIE_OP_DB;
     if (!FannieAuth::validateUserQuiet('editmembers') && !FannieAuth::validateUserQuiet('editmembers_csc')) {
         return $this->unknown_request_handler();
     }
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $status = FormLib::get_form_value('status', 'INACT');
     $codes = FormLib::get_form_value('reasoncodes', array());
     $code = 0;
     foreach ($codes as $selected_code) {
         $code = $code | (int) $selected_code;
     }
     $cas_model = new CustomerAccountSuspensionsModel($dbc);
     $cas_model->card_no($this->id);
     $current_id = 0;
     $account = \COREPOS\Fannie\API\member\MemberREST::get($this->id);
     if ($code == 0) {
         // reactivate account
         // add history/log record, restore settings, delete suspensions record
         $history = new SuspensionHistoryModel($dbc);
         $history->username($this->current_user);
         $history->cardno($this->id);
         $history->reasoncode(-1);
         $history->post('Account reactivated');
         $history->postdate(date('Y-m-d H:i:s'));
         $history->save();
         $cas_model->reasonCode(0);
         $cas_model->suspensionTypeID(0);
         $cas_model->active(0);
         $cas_model->username($this->current_user);
         $cas_model->tdate(date('Y-m-d H:i:s'));
         $cas_model->save();
         if (isset($this->__models['suspended'])) {
             $json = array('cardNo' => $this->id, 'activeStatus' => '', 'memberStatus' => $this->__models['suspended']->memtype2(), 'customerTypeID' => $this->__models['suspended']->memtype1(), 'chargeLimit' => $this->__models['suspended']->chargelimit(), 'contactAllowed' => $this->__models['suspended']->mailflag(), 'customers' => array());
             foreach ($account['customers'] as $c) {
                 $c['discount'] = $this->__models['suspended']->discount();
                 $c['chargeAllowed'] = 1;
                 $json['customers'][] = $c;
             }
             \COREPOS\Fannie\API\member\MemberREST::post($this->id, $json);
             $cust = new CustdataModel($dbc);
             $cust->CardNo($this->id);
             foreach ($cust->find() as $obj) {
                 $obj->pushToLanes();
             }
             $this->__models['suspended']->delete();
         }
     } elseif (isset($this->__models['suspended'])) {
         // account already suspended
         // add history/log record, update suspended record
         $m_status = 0;
         if ($status == 'TERM') {
             $this->__models['suspended']->type('T');
             $m_status = 2;
         } else {
             $this->__models['suspended']->type('I');
             $m_status = 1;
         }
         $this->__models['suspended']->reasoncode($code);
         $this->__models['suspended']->suspDate(date('Y-m-d H:i:s'));
         $this->__models['suspended']->save();
         $history = new SuspensionHistoryModel($dbc);
         $history->username($this->current_user);
         $history->cardno($this->id);
         $history->reasoncode($code);
         $history->postdate(date('Y-m-d H:i:s'));
         $history->save();
         $changed = false;
         $cas_model->active(1);
         // find most recent active record
         $current = $cas_model->find('tdate', true);
         foreach ($current as $obj) {
             if ($obj->reasonCode() != $code || $obj->suspensionTypeID() != $m_status) {
                 $changed = true;
             }
             $cas_model->savedType($obj->savedType());
             $cas_model->savedMemType($obj->savedMemType());
             $cas_model->savedDiscount($obj->savedDiscount());
             $cas_model->savedChargeLimit($obj->savedChargeLimit());
             $cas_model->savedMailFlag($obj->savedMailFlag());
             // copy "saved" values from current active
             // suspension record. should only be one
             break;
         }
         // only add a record if something changed.
         // count($current) of zero means there is no
         // record. once the migration to the new data
         // structure is complete, that check won't
         // be necessary
         if ($changed || count($current) == 0) {
             $cas_model->reasonCode($code);
             $cas_model->username($this->current_user);
             $cas_model->tdate(date('Y-m-d H:i:s'));
             $cas_model->suspensionTypeID($m_status);
             $current_id = $cas_model->save();
         }
         $json = array('cardNo' => $this->id, 'activeStatus' => $status);
         \COREPOS\Fannie\API\member\MemberREST::post($this->id, $json);
     } else {
         // suspend active account
         // create suspensions and log/history records
         // set custdata & meminfo to inactive
         $discount = 0;
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $discount = $c['discount'];
                 break;
             }
         }
         $susp = new SuspensionsModel($dbc);
         $susp->cardno($this->id);
         $susp->type($status == 'TERM' ? 'T' : 'I');
         $susp->memtype1($account['customerTypeID']);
         $susp->memtype2($account['memberStatus']);
         $susp->suspDate(date('Y-m-d H:i:s'));
         $susp->reason('');
         $susp->mailflag($account['contactAllowed']);
         $susp->discount($discount);
         $susp->chargelimit($account['chargeLimit']);
         $susp->reasoncode($code);
         $susp->save();
         $cas_model->savedType($account['memberStatus']);
         $cas_model->savedMemType($account['customerTypeID']);
         $cas_model->savedDiscount($discount);
         $cas_model->savedChargeLimit($account['chargeLimit']);
         $cas_model->savedMailFlag($account['contactAllowed']);
         $cas_model->suspensionTypeID($status == 'TERM' ? 2 : 1);
         $cas_model->tdate(date('Y-m-d H:i:s'));
         $cas_model->username($this->current_user);
         $cas_model->reasonCode($code);
         $cas_model->active(1);
         $current_id = $cas_model->save();
         $history = new SuspensionHistoryModel($dbc);
         $history->username($this->current_user);
         $history->cardno($this->id);
         $history->reasoncode($code);
         $history->postdate(date('Y-m-d H:i:s'));
         $history->save();
         $json = array('cardNo' => $this->id, 'chargeLimit' => 0, 'activeStatus' => $status, 'customerTypeID' => 0, 'contactAllowed' => 0, 'customers' => array());
         foreach ($account['customers'] as $c) {
             $c['discount'] = 0;
             $json['customers'][] = $c;
         }
         \COREPOS\Fannie\API\member\MemberREST::post($this->id, $json);
     }
     // only one CustomerAccountSuspensions record should be active
     if ($current_id != 0) {
         $cas_model->reset();
         $cas_model->card_no($this->id);
         $cas_model->active(1);
         foreach ($cas_model->find() as $obj) {
             if ($obj->customerAccountSuspensionID() != $current_id) {
                 $obj->active(0);
                 $obj->save();
             }
         }
     }
     header('Location: PIMemberPage.php?id=' . $this->id);
     return False;
 }
コード例 #23
0
ファイル: MembersTest.php プロジェクト: phpsmith/IS4C
 public function testREST()
 {
     $account = \COREPOS\Fannie\API\member\MemberREST::get(-999);
     $this->assertEquals($account, false);
     /** get account and verify structure **/
     $TEST_ACCOUNT = 1;
     $account = \COREPOS\Fannie\API\member\MemberREST::get($TEST_ACCOUNT);
     $this->assertInternalType('array', $account);
     $all_fields = array('cardNo', 'memberStatus', 'activeStatus', 'customerTypeID', 'customerType', 'chargeBalance', 'chargeLimit', 'idCardUPC', 'startDate', 'endDate', 'addressFirstLine', 'addressSecondLine', 'city', 'state', 'zip', 'contactAllowed', 'contactMethod', 'modified', 'customers');
     foreach ($all_fields as $field) {
         $this->assertArrayHaskey($field, $account, 'Account missing field: ' . $field);
     }
     $this->assertInternalType('array', $account['customers']);
     $customer_fields = array('customerID', 'firstName', 'lastName', 'chargeAllowed', 'checksAllowed', 'discount', 'accountHolder', 'staff', 'phone', 'altPhone', 'email', 'memberPricingAllowed', 'memberCouponsAllowed', 'lowIncomeBenefits', 'modified');
     foreach ($account['customers'] as $customer) {
         foreach ($customer_fields as $field) {
             $this->assertArrayHasKey($field, $customer);
         }
     }
     $all = \COREPOS\Fannie\API\member\MemberREST::get();
     foreach ($all as $a) {
         $this->assertArrayHasKey('cardNo', $a);
         if ($a['cardNo'] == $TEST_ACCOUNT) {
             $this->assertEquals($a, $account, 'get single and get all must match');
             break;
         }
     }
     $account_changed = $account;
     $account_changed['idCardUPC'] = '12345';
     $account_changed['startDate'] = date('Y-m-d 00:00:00');
     $account_changed['endDate'] = date('Y-m-d 00:00:00', strtotime('+1 year'));
     $account_changed['addressFirstLine'] = '123 4th St';
     $account_changed['addressSecondLine'] = 'Apt. 5';
     $account_changed['city'] = 'somewhere';
     $account_changed['state'] = 'NY';
     $account_changed['zip'] = '12345';
     $account_changed['customers'][0]['firstName'] = 'Test';
     $account_changed['customers'][0]['lastName'] = 'User';
     /**
       POST the original account and verify the result,
       then POST a modified account and verify, then
       restore original and verify
     */
     $post_accounts = array($account, $account_changed, $account);
     foreach ($post_accounts as $a) {
         /** post account structure back and verify it did not change **/
         $resp = \COREPOS\Fannie\API\member\MemberREST::post($TEST_ACCOUNT, $a);
         $this->assertInternalType('array', $resp);
         $this->assertArrayHasKey('errors', $resp);
         $this->assertEquals(0, $resp['errors']);
         $this->assertArrayHasKey('account', $resp);
         foreach ($all_fields as $field) {
             if ($field == 'modified' || $field == 'customers') {
                 /**
                   modified timestamp expected to change.
                   Customers will be checked field by field
                 */
                 continue;
             }
             $this->assertArrayHasKey($field, $resp['account']);
             $this->assertEquals($a[$field], $resp['account'][$field], "Mismatch for field: {$field}");
         }
         for ($i = 0; $i < count($resp['account']['customers']); $i++) {
             $this->assertArrayHasKey($i, $a['customers']);
             foreach ($customer_fields as $field) {
                 if ($field == 'modified') {
                     $this->assertNotEquals($resp['account']['customers'][$i][$field], $a['customers'][$i][$field]);
                 } else {
                     $this->assertEquals($resp['account']['customers'][$i][$field], $a['customers'][$i][$field], "Mismatch for field: {$field}");
                 }
             }
         }
     }
 }
コード例 #24
0
ファイル: MemStatusEditor.php プロジェクト: phpsmith/IS4C
 protected function deactivate_account($cardno, $reason, $type)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $account = \COREPOS\Fannie\API\member\MemberREST::get($cardno);
     $cas_model = new CustomerAccountSuspensionsModel($dbc);
     $cas_model->card_no($cardno);
     $current_id = 0;
     $chkQ = $dbc->prepare_statement("SELECT cardno FROM suspensions WHERE cardno=?");
     $chkR = $dbc->exec_statement($chkQ, array($cardno));
     if ($dbc->num_rows($chkR) > 0) {
         // if account is already suspended, just update the reason
         $upQ = $dbc->prepare_statement("UPDATE suspensions SET reasoncode=?, type=?\n                WHERE cardno=?");
         $upR = $dbc->exec_statement($upQ, array($reason, substr($type, 0, 1), $cardno));
         $m_status = 0;
         if (substr($type, 0, 1) == 'T') {
             $m_status = 2;
         } else {
             $m_status = 1;
         }
         $cas_model->active(1);
         $changed = false;
         // find most recent active record
         $current = $cas_model->find('tdate', true);
         foreach ($current as $obj) {
             if ($obj->reasonCode() != $reason || $obj->suspensionTypeID() != $m_status) {
                 $changed = true;
             }
             $cas_model->savedType($obj->savedType());
             $cas_model->savedMemType($obj->savedMemType());
             $cas_model->savedDiscount($obj->savedDiscount());
             $cas_model->savedChargeLimit($obj->savedChargeLimit());
             $cas_model->savedMailFlag($obj->savedMailFlag());
             // copy "saved" values from current active
             // suspension record. should only be one
             break;
         }
         // only add a record if something changed.
         // count($current) of zero means there is no
         // record. once the migration to the new data
         // structure is complete, that check won't
         // be necessary
         if ($changed || count($current) == 0) {
             $cas_model->reasonCode($reason);
             $cas_model->username($this->current_user);
             $cas_model->tdate(date('Y-m-d H:i:s'));
             $cas_model->suspensionTypeID($m_status);
             $current_id = $cas_model->save();
         }
     } else {
         // new suspension
         // get current values and save them in suspensions table
         $discount = 0;
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $discount = $c['discount'];
                 break;
             }
         }
         $now = date('Y-m-d H:i:s');
         $insQ = $dbc->prepare("INSERT INTO suspensions \n                (cardno, type, memtype1, memtype2, reason, suspDate, mailflag, discount, chargelimit, reasoncode) \n                VALUES (?,?,?,?,''," . $dbc->now() . ",?,?,?,?)");
         $insArgs = array($cardno, substr($type, 0, 1), $account['customerTypeID'], $account['memberStatus'], $account['contactAllowed'], $discount, $account['chargeLimit'], $reason);
         $insR = $dbc->execute($insQ, $insArgs);
         // log action
         $username = $this->current_user;
         $histQ = $dbc->prepare_statement("INSERT INTO suspension_history (username, postdate,\n                post, cardno, reasoncode) VALUES (?," . $dbc->now() . ",'',?,?)");
         $histR = $dbc->exec_statement($histQ, array($username, $cardno, $reason));
         $cas_model->savedType($account['memberStatus']);
         $cas_model->savedMemType($account['customerTypeID']);
         $cas_model->savedDiscount($discount);
         $cas_model->savedChargeLimit($account['chargeLimit']);
         $cas_model->savedMailFlag($account['contactAllowed']);
         $cas_model->suspensionTypeID(substr($type, 0, 1) == 'T' ? 2 : 1);
         $cas_model->tdate(date('Y-m-d H:i:s'));
         $cas_model->username($this->current_user);
         $cas_model->reasonCode($reason);
         $cas_model->active(1);
         $current_id = $cas_model->save();
     }
     /**
       Clear privileges and save the account
     */
     $account['activeStatus'] = $type;
     $account['customerTypeID'] = 0;
     $account['chargeLimit'] = 0;
     $account['contactAllowed'] = 0;
     for ($i = 0; $i < count($account['customers']); $i++) {
         $account['customers'][$i]['discount'] = 0;
     }
     \COREPOS\Fannie\API\member\MemberREST::post($cardno, $account);
     // only one CustomerAccountSuspensions record should be active
     if ($current_id != 0) {
         $cas_model->reset();
         $cas_model->card_no($cardno);
         $cas_model->active(1);
         foreach ($cas_model->find() as $obj) {
             if ($obj->customerAccountSuspensionID() != $current_id) {
                 $obj->active(0);
                 $obj->save();
             }
         }
     }
 }
コード例 #25
0
 public function run()
 {
     $settings = $this->config->get('PLUGIN_SETTINGS');
     $dbc = FannieDB::get($settings['ScheduledEmailDB']);
     $sentP = $dbc->prepare('
         UPDATE ScheduledEmailQueue
         SET sentDate=' . $dbc->now() . ',
             sent=1,
             sentToEmail=?
         WHERE scheduledEmailQueueID=?');
     $failP = $dbc->prepare('
         UPDATE ScheduledEmailQueue
         SET sentDate=' . $dbc->now() . ',
             sent=2,
             sentToEmail=?
         WHERE scheduledEmailQueueID=?');
     // find messages due to be sent
     $query = '
         SELECT scheduledEmailQueueID,
             scheduledEmailTemplateID,
             cardNo,
             templateData
         FROM ScheduledEmailQueue
         WHERE sent=0
             AND sendDate <= ' . $dbc->now() . '
         ORDER BY scheduledEmailTemplateID';
     $result = $dbc->query($query);
     $template = new ScheduledEmailTemplatesModel($dbc);
     while ($row = $dbc->fetchRow($result)) {
         $template->scheduledEmailTemplateID($row['scheduledEmailTemplateID']);
         if (!$template->load()) {
             $this->cronMsg('Template does not exist: ' . $row['scheduledEmailTemplateID']);
             continue;
         }
         $member = \COREPOS\Fannie\API\member\MemberREST::get($row['cardNo']);
         $dbc->selectDB($settings['ScheduledEmailDB']);
         // reset current DB
         if ($member === false) {
             $this->cronMsg('Member does not exist: ' . $row['cardNo']);
             continue;
         }
         $email = false;
         foreach ($member['customers'] as $customer) {
             if ($customer['accountHolder']) {
                 $email = $customer['email'];
                 break;
             }
         }
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $this->cronMsg('Member does not have valid email address: ' . $row['cardNo']);
             $dbc->execute($failP, array('no email address', $row['scheduledEmailQueueID']));
             continue;
         }
         $data = json_decode($row['templateData'], true);
         if ($data === null && $row['templateData'] !== null) {
             $this->cronMsg('Invalid template data: ' . $row['data']);
             continue;
         } elseif (!is_array($data)) {
             $data = array();
         }
         if (self::sendEmail($template, $email, $data)) {
             $dbc->execute($sentP, array($email, $row['scheduledEmailQueueID']));
         } else {
             $dbc->execute($failP, array('error sending', $row['scheduledEmailQueueID']));
         }
     }
 }
コード例 #26
0
 public function post_id_handler()
 {
     global $FANNIE_OP_DB, $FANNIE_TRANS_DB, $FANNIE_ROOT, $FANNIE_ARCHIVE_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $cards = "(";
     $args = array();
     if (!is_array($this->id)) {
         $this->id = array($this->id);
     }
     foreach ($this->id as $c) {
         $cards .= "?,";
         $args[] = $c;
     }
     $cards = rtrim($cards, ",");
     $cards .= ")";
     $cardsClause = " AND m.card_no IN {$cards} ";
     if ($cards == "(") {
         $cardsClause = "";
     }
     /**
       Look up transactions involving AR over last 90 days
     */
     $transP = $dbc->prepare("\n            SELECT card_no, \n                CASE WHEN trans_subtype='MI' THEN -total ELSE 0 END AS charges,\n                CASE WHEN department=990 then total ELSE 0 END as payments, \n                tdate, \n                trans_num\n            FROM " . $FANNIE_TRANS_DB . $dbc->sep() . "dlog_90_view AS m \n            WHERE m.card_no IN " . $cards . "\n                AND (department=990 OR trans_subtype='MI')\n            ORDER BY card_no, \n                tdate, \n                trans_num");
     $transP = $dbc->prepare("\n            SELECT card_no,\n                charges,\n                payments,\n                tdate,\n                trans_num,\n                'OLD' as timespan\n            FROM " . $FANNIE_TRANS_DB . $dbc->sep() . "ar_history \n            WHERE card_no IN " . $cards . "\n                AND tdate >= ?\n            UNION ALL\n            SELECT card_no,\n                charges,\n                payments,\n                tdate,\n                trans_num,\n                'TODAY' as timespan\n            FROM " . $FANNIE_TRANS_DB . $dbc->sep() . "ar_history_today\n            WHERE card_no IN " . $cards . "\n            ORDER BY tdate");
     $date = date('Y-m-d', mktime(0, 0, 0, date('n'), date('j') - 90, date('Y')));
     $trans_args = $args;
     $trans_args[] = $date;
     foreach ($args as $a) {
         // need cards twice for the union
         $trans_args[] = $a;
     }
     $transR = $dbc->execute($transP, $trans_args);
     $arRows = array();
     while ($w = $dbc->fetch_row($transR)) {
         if (!isset($arRows[$w['card_no']])) {
             $arRows[$w['card_no']] = array();
         }
         $arRows[$w['card_no']][] = $w;
         $date = explode(' ', $w['tdate']);
         $date_id = date('Ymd', strtotime($date[0]));
     }
     /**
       Lookup details of AR related transactions
       Stucture is:
       * card_no
         => trans_num
            => line item description(s)
     */
     $detailsQ = '
         SELECT card_no,
             description,
             department,
             trans_num
         FROM ' . $FANNIE_ARCHIVE_DB . $dbc->sep() . 'dlogBig
         WHERE tdate BETWEEN ? AND ?
             AND trans_num=?
             AND card_no=?
             AND trans_type IN (\'I\', \'D\')
     ';
     $todayQ = str_replace($FANNIE_ARCHIVE_DB . $dbc->sep() . 'dlogBig', $FANNIE_TRANS_DB . $dbc->sep() . 'dlog', $detailsQ);
     $detailsP = $dbc->prepare($detailsQ);
     $todayP = $dbc->prepare($todayQ);
     $details = array();
     foreach ($arRows as $card_no => $trans) {
         $found_charge = false;
         foreach ($trans as $info) {
             if ($info['charges'] != 0) {
                 $found_charge = true;
             }
             $dt = strtotime($info['tdate']);
             $args = array(date('Y-m-d 00:00:00', $dt), date('Y-m-d 23:59:59', $dt), $info['trans_num'], $info['card_no']);
             if ($info['timespan'] == 'TODAY') {
                 $r = $dbc->execute($todayP, $args);
             } else {
                 $r = $dbc->execute($detailsP, $args);
             }
             while ($w = $dbc->fetch_row($r)) {
                 $tn = $w['trans_num'];
                 if (!isset($details[$w['card_no']])) {
                     $details[$w['card_no']] = array();
                 }
                 if (!isset($details[$w['card_no']][$tn])) {
                     $details[$w['card_no']][$tn] = array();
                 }
                 $details[$w['card_no']][$tn][] = $w['description'];
             }
         }
         if ($found_charge) {
             $actual = array();
             $i = 0;
             while ($arRows[$card_no][$i]['charges'] == 0) {
                 $i++;
             }
             for ($i; $i < count($arRows[$card_no]); $i++) {
                 $actual[] = $arRows[$card_no][$i];
             }
             $arRows[$card_no] = $actual;
         }
     }
     $today = date("d-F-Y");
     $month = date("n");
     $year = date("Y");
     $stateDate = date("d F, Y", mktime(0, 0, 0, date('n'), 0, date('Y')));
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     $pdf->SetAutoPageBreak(false);
     //Meat of the statement
     $balP = $dbc->prepare('
         SELECT balance
         FROM ' . $this->config->get('TRANS_DB') . $dbc->sep() . 'ar_live_balance
         WHERE card_no=?');
     $rowNum = 0;
     foreach ($this->id as $card_no) {
         $account = \COREPOS\Fannie\API\member\MemberREST::get($card_no);
         $primary = array();
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $primary = $c;
                 break;
             }
         }
         $balance = $dbc->getValue($balP, array($card_no));
         $pdf->AddPage();
         $pdf->Image('new_letterhead_horizontal.png', 5, 10, 200);
         $pdf->SetFont('Gill', '', '12');
         $pdf->Ln(45);
         $pdf->Cell(10, 5, sprintf("Invoice #: %s-%s", $card_no, date("ymd")), 0, 1, 'L');
         $pdf->Cell(10, 5, $stateDate, 0);
         $pdf->Ln(8);
         //Member address
         $name = $primary['lastName'];
         if (!empty($primary['firstName'])) {
             $name = $primary['firstName'] . ' ' . $name;
         }
         $pdf->Cell(50, 10, trim($card_no) . ' ' . trim($name), 0);
         $pdf->Ln(5);
         $pdf->Cell(80, 10, $account['addressFirstLine'], 0);
         $pdf->Ln(5);
         if ($account['addressSecondLine']) {
             $pdf->Cell(80, 10, $account['addressSecondLine'], 0);
             $pdf->Ln(5);
         }
         $pdf->Cell(90, 10, $account['city'] . ', ' . $account['state'] . '   ' . $account['zip'], 0);
         $pdf->Ln(25);
         $txt = "If payment has been made or sent, please ignore this invoice. If you have any questions about this invoice or would like to make arrangements to pay your balance, please write or call the Finance Department at the above address or (218) 728-0884.";
         $pdf->MultiCell(0, 5, $txt);
         $pdf->Ln(10);
         $priorQ = $dbc->prepare("\n                SELECT SUM(charges) - SUM(payments) AS priorBalance\n                FROM " . $FANNIE_TRANS_DB . $dbc->sep() . "ar_history\n                WHERE " . $dbc->datediff('tdate', $dbc->now()) . " < -90\n                    AND card_no = ?");
         $priorR = $dbc->execute($priorQ, array($card_no));
         $priorW = $dbc->fetch_row($priorR);
         $priorBalance = is_array($priorW) ? $priorW['priorBalance'] : 0;
         $indent = 10;
         $columns = array(75, 35, 30, 30);
         $pdf->Cell($indent, 8, '');
         $pdf->SetFillColor(200);
         $pdf->Cell(40, 8, 'Balance Forward', 0, 0, 'L', 1);
         $pdf->Cell(25, 8, '$ ' . sprintf("%.2f", $priorBalance), 0, 0, 'L');
         $pdf->Ln(8);
         $pdf->Cell(0, 8, "90-Day Billing History", 0, 1, 'C');
         $pdf->SetFillColor(200);
         $pdf->Cell($indent, 8, '', 0, 0, 'L');
         $pdf->Cell($columns[0], 8, 'Date', 0, 0, 'L', 1);
         $pdf->Cell($columns[1], 8, 'Receipt', 0, 0, 'L', 1);
         $pdf->Cell($columns[2], 8, '', 0, 0, 'L', 1);
         $pdf->Cell($columns[3], 8, 'Amount', 0, 1, 'L', 1);
         $gazette = false;
         if (!isset($arRows[$card_no])) {
             $arRows[$card_no] = array();
         }
         foreach ($arRows[$card_no] as $arRow) {
             $date = $arRow['tdate'];
             $trans = $arRow['trans_num'];
             $charges = $arRow['charges'];
             $payment = $arRow['payments'];
             $detail = $details[$card_no][$trans];
             if (strstr($detail[0], "Gazette Ad")) {
                 $gazette = true;
             }
             $lineitem = count($detail) == 1 ? $detail[0] : '(multiple items)';
             foreach ($detail as $line) {
                 if ($line == 'ARPAYMEN') {
                     $lineitem = 'Payment Received - Thank You';
                 }
             }
             $pdf->Cell($indent, 8, '', 0, 0, 'L');
             $pdf->Cell($columns[0], 8, $date, 0, 0, 'L');
             $pdf->Cell($columns[1], 8, $trans, 0, 0, 'L');
             $pdf->Cell($columns[2], 8, '', 0, 0, 'L');
             if ($payment > $charges) {
                 $pdf->Cell($columns[3], 8, '$ ' . sprintf('%.2f', $payment - $charges), 0, 0, 'L');
             } else {
                 $pdf->Cell($columns[3], 8, '$ ' . sprintf('(%.2f)', abs($payment - $charges)), 0, 0, 'L');
             }
             if ($pdf->GetY() > 245) {
                 $pdf->AddPage();
             } else {
                 $pdf->Ln(5);
             }
             if (!empty($lineitem)) {
                 $pdf->SetFontSize(10);
                 $pdf->Cell($indent + 10, 8, '', 0, 0, 'L');
                 $pdf->Cell(60, 8, $lineitem, 0, 0, 'L');
                 if ($pdf->GetY() > 245) {
                     $pdf->AddPage();
                 } else {
                     $pdf->Ln(5);
                 }
                 $pdf->SetFontSize(12);
             }
         }
         $pdf->Ln(15);
         $pdf->Cell($indent, 8, '');
         $pdf->SetFillColor(200);
         if ($balance >= 0) {
             $pdf->Cell(35, 8, 'Amount Due', 0, 0, 'L', 1);
         } else {
             $pdf->Cell(35, 8, 'Credit Balance', 0, 0, 'L', 1);
         }
         $pdf->Cell(25, 8, '$ ' . sprintf("%.2f", $balance), 0, 0, 'L');
         if ($gazette) {
             $pdf->SetLeftMargin(10);
             $pdf->Image('logo_bw.png', 85, 213, 25);
             $pdf->SetY(205);
             $pdf->Cell(0, 8, '', 'B', 1);
             $pdf->Ln(5);
             $pdf->Cell(30, 5, 'Whole Foods Co-op');
             $pdf->Cell(115, 5, '');
             $pdf->Cell(20, 5, 'Invoice Date:', 0, 0, 'R');
             $pdf->Cell(20, 5, date("m/d/Y"), 0, 1, 'L');
             $pdf->Cell(30, 5, '610 East 4th Street');
             $pdf->Cell(115, 5, '');
             $pdf->Cell(20, 5, 'Customer Number:', 0, 0, 'R');
             $pdf->Cell(20, 5, $card_no, 0, 1, 'L');
             $pdf->Cell(30, 5, 'Duluth, MN 55805');
             $pdf->Cell(115, 5, '');
             $pdf->Cell(20, 5, 'Invoice Total:', 0, 0, 'R');
             $pdf->Cell(20, 5, $balance, 0, 1, 'L');
             $pdf->Ln(5);
             $pdf->Cell(10, 10, trim($card_no), 0);
             $pdf->Ln(5);
             $pdf->Cell(50, 10, trim($primary['lastName']), 0);
             $pdf->Ln(5);
             $pdf->Cell(80, 10, $account['addressFirstLine'], 0);
             if ($account['addressSecondLine']) {
                 $pdf->Ln(5);
                 $pdf->Cell(80, 10, $account['addressSecondLine'], 0);
             }
             $pdf->Ln(5);
             $pdf->Cell(90, 10, $account['city'] . ', ' . $account['state'] . '   ' . $account['zip'], 0);
             $pdf->SetXY(80, 240);
             $pdf->SetFontSize(10);
             $pdf->MultiCell(110, 6, "( ) Please continue this ad in the next issue.\n( ) I would like to make some changes to my ad for the next issue.\n( ) I do not wish to continue an ad in the next issue.\n( ) I will contact you at a later date with my advertising decision.");
             $pdf->Ln(3);
             $pdf->SetFontSize(12);
             $pdf->Cell(0, 8, 'Please Return This Portion With Your Payment', 0, 0, 'C');
         }
     }
     $pdf->Output('makeStatement.pdf', 'D');
     return false;
 }
コード例 #27
0
 function saveFormData($memNum)
 {
     /**
       Use primary member for default column values
     */
     $account = self::getAccount();
     if (!$account) {
         return "Error: Problem saving household members<br />";
     }
     $json = array('cardNo' => $memNum, 'customerTypeID' => $account['customerTypeID'], 'memberStatus' => $account['memberStatus'], 'activeStatus' => $account['activeStatus'], 'customers' => array());
     $primary = array('discount' => 0, 'staff' => 0, 'lowIncomeBenefits' => 0, 'chargeAllowed' => 0, 'checksAllowed' => 0);
     foreach ($account['customers'] as $c) {
         if ($c['accountHolder']) {
             $primary = $c;
             break;
         }
     }
     $fns = FormLib::get('HouseholdSeparateDiscounts_fn', array());
     $lns = FormLib::get('HouseholdSeparateDiscounts_ln', array());
     $discs = FormLib::get('HouseholdSeparateDiscounts_discount', array());
     $checks = FormLib::get('HouseholdSeparateDiscounts_writeChecks', array());
     $ssi = FormLib::get('HouseholdSeparateDiscounts_SSI', array());
     $ids = FormLib::get('HouseholdMembers_ID', array());
     $pn = 2;
     for ($i = 0; $i < count($lns); $i++) {
         $json['customers'][] = array('customerID' => $ids[$i], 'firstName' => $fns[$i], 'lastName' => $lns[$i], 'accountHolder' => 0, 'discount' => $discs[$i], 'staff' => $primary['staff'], 'lowIncomeBenefits' => in_array($pn, $ssi) ? 1 : 0, 'chargeAllowed' => $primary['chargeAllowed'], 'checksAllowed' => in_array($pn, $checks) ? 1 : 0);
         $pn++;
     }
     $resp = \COREPOS\Fannie\API\member\MemberREST::post($memNum, $json);
     if ($resp['errors'] > 0) {
         return "Error: Problem saving household members<br />";
     }
     return '';
 }
コード例 #28
0
ファイル: FannieAutoComplete.php プロジェクト: phpsmith/IS4C
 /**
   Do whatever the service is supposed to do.
   Should override this.
   @param $args array of data
   @return an array of data
 */
 public function run($args = array())
 {
     $ret = array();
     if (!property_exists($args, 'field') || !property_exists($args, 'search')) {
         // missing required arguments
         $ret['error'] = array('code' => -32602, 'message' => 'Invalid parameters');
         return $ret;
     } else {
         if (strlen($args->search) < 1) {
             // search term is too short
             $ret['error'] = array('code' => -32602, 'message' => 'Invalid parameters');
             return $ret;
         }
     }
     $dbc = \FannieDB::getReadOnly(\FannieConfig::factory()->get('OP_DB'));
     switch (strtolower($args->field)) {
         case 'item':
             $res = false;
             if (!is_numeric($args->search)) {
                 $prep = $dbc->prepare('SELECT p.upc,
                                     p.description
                                    FROM products AS p
                                     LEFT JOIN productUser AS u ON u.upc=p.upc
                                    WHERE p.description LIKE ?
                                     OR p.brand LIKE ?
                                     OR u.description LIKE ?
                                     OR u.brand LIKE ?
                                    GROUP BY p.upc,
                                     p.description
                                    ORDER BY p.description');
                 $term = '%' . $args->search . '%';
                 $res = $dbc->execute($prep, array($term, $term, $term, $term));
             } elseif (ltrim($args->search, '0') != '') {
                 $prep = $dbc->prepare('
                 SELECT p.upc,
                     p.upc AS description
                 FROM products AS p
                 WHERE p.upc LIKE ?
                 GROUP BY p.upc');
                 $res = $dbc->execute($prep, array('%' . $args->search . '%'));
             }
             while ($res && ($row = $dbc->fetch_row($res))) {
                 $ret[] = array('label' => $row['description'], 'value' => $row['upc']);
             }
         case 'brand':
             $prep = $dbc->prepare('SELECT brand
                                FROM products
                                WHERE brand LIKE ?
                                GROUP BY brand
                                ORDER BY brand');
             $res = $dbc->execute($prep, array($args->search . '%'));
             while ($row = $dbc->fetch_row($res)) {
                 $ret[] = $row['brand'];
             }
             return $ret;
         case 'long_brand':
             $prep = $dbc->prepare('
             SELECT u.brand
             FROM productUser AS u
                 ' . DTrans::joinProducts('u', 'p', 'INNER') . '
             WHERE u.brand LIKE ?
             GROUP BY u.brand
             ORDER BY u.brand');
             $res = $dbc->execute($prep, array($args->search . '%'));
             while ($row = $dbc->fetch_row($res)) {
                 $ret[] = $row['brand'];
             }
             return $ret;
         case 'vendor':
             $prep = $dbc->prepare('SELECT vendorID,
                                 vendorName
                                FROM vendors
                                WHERE vendorName LIKE ?
                                ORDER BY vendorName');
             $res = $dbc->execute($prep, array($args->search . '%'));
             while ($row = $dbc->fetch_row($res)) {
                 $ret[] = $row['vendorName'];
             }
             if ($dbc->tableExists('prodExtra')) {
                 $prep = $dbc->prepare('SELECT distributor
                                    FROM prodExtra
                                    WHERE distributor LIKE ?
                                    GROUP BY distributor
                                    ORDER BY distributor');
                 $res = $dbc->execute($prep, array($args->search . '%'));
                 while ($row = $dbc->fetch_row($res)) {
                     if (!in_array($row['distributor'], $ret)) {
                         $ret[] = $row['distributor'];
                     }
                 }
             }
             return $ret;
         case 'mfirstname':
         case 'mlastname':
         case 'maddress':
         case 'mcity':
         case 'memail':
             return \COREPOS\Fannie\API\member\MemberREST::autoComplete($args->field, $args->search);
         case 'sku':
             $query = 'SELECT sku
                   FROM vendorItems
                   WHERE sku LIKE ? ';
             $param = array($args->search . '%');
             if (property_exists($args, 'vendor_id')) {
                 $query .= ' AND vendorID=? ';
                 $param[] = $args->vendor_id;
             }
             $query .= 'GROUP BY sku
                   ORDER BY sku';
             $prep = $dbc->prepare($query);
             $res = $dbc->execute($prep, $param);
             while ($row = $dbc->fetch_row($res)) {
                 $ret[] = $row['sku'];
                 if (count($ret) > 50) {
                     break;
                 }
             }
             return $ret;
         case 'unit':
             $query = '
             SELECT unitofmeasure
             FROM products
             WHERE unitofmeasure LIKE ?
             GROUP BY unitofmeasure
             ORDER BY unitofmeasure';
             $param = array($args->search . '%');
             $prep = $dbc->prepare($query);
             $res = $dbc->execute($prep, $param);
             while ($row = $dbc->fetchRow($res)) {
                 $ret[] = $row['unitofmeasure'];
                 if (count($ret) > 50) {
                     break;
                 }
             }
             return $ret;
         default:
             return $ret;
     }
 }
コード例 #29
0
 function process_file($linedata)
 {
     global $FANNIE_OP_DB, $FANNIE_NAMES_PER_MEM;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $mn_index = $this->get_column_index('memnum');
     $fn_index = $this->get_column_index('fn');
     $ln_index = $this->get_column_index('ln');
     $t_index = $this->get_column_index('memtype');
     $defaults_table = array();
     // get defaults directly from the memtype table if possible
     $mt = $dbc->tableDefinition('memtype');
     $defQ = $dbc->prepare_statement("SELECT memtype,custdataType,discount,staff,ssi from memtype");
     if ($dbc->tableExists('memdefaults') && (!isset($mt['custdataType']) || !isset($mt['discount']) || !isset($mt['staff']) || !isset($mt['ssi']))) {
         $defQ = $dbc->prepare_statement("SELECT memtype,cd_type as custdataType,discount,staff,SSI as ssi from memdefaults");
     }
     $defR = $dbc->exec_statement($defQ);
     while ($defW = $dbc->fetch_row($defR)) {
         $defaults_table[$defW['memtype']] = array('type' => $defW['custdataType'], 'discount' => $defW['discount'], 'staff' => $defW['staff'], 'SSI' => $defW['ssi']);
     }
     foreach ($linedata as $line) {
         // get info from file and member-type default settings
         // if applicable
         $cardno = $line[$mn_index];
         if (!is_numeric($cardno)) {
             continue;
             // skip bad record
         }
         $json = array('cardNo' => $cardno, 'customerTypeID' => $t_index !== false ? $line[$t_index] : 0, 'contactAllowed' => 1, 'chargeBalance' => 0, 'chargeLimit' => 0, 'customers' => array());
         $customer = array();
         $customer['firstName'] = $line[$fn_index];
         $customer['lastName'] = $line[$ln_index];
         $type = "PC";
         $discount = 0;
         $staff = 0;
         $SSI = 0;
         if ($t_index !== false) {
             if (isset($defaults_table[$mtype]['type'])) {
                 $type = $defaults_table[$mtype]['type'];
             }
             if (isset($defaults_table[$mtype]['discount'])) {
                 $discount = $defaults_table[$mtype]['discount'];
             }
             if (isset($defaults_table[$mtype]['staff'])) {
                 $staff = $defaults_table[$mtype]['staff'];
             }
             if (isset($defaults_table[$mtype]['SSI'])) {
                 $SSI = $defaults_table[$mtype]['SSI'];
             }
         }
         $json['memberStatus'] = $type;
         $customer['discount'] = $discount;
         $customer['staff'] = $staff;
         $customer['lowIncomeBenefits'] = $SSI;
         // determine person number
         if ($FANNIE_NAMES_PER_MEM == 1) {
             $customer['accountHolder'] = 1;
         } else {
             $account = \COREPOS\Fannie\API\member\MemberREST::get($cardno);
             if ($account) {
                 $customer['accountHolder'] = 0;
             } else {
                 $customer['accountHolder'] = 1;
             }
         }
         $json['customers'][] = $customer;
         $resp = \COREPOS\Fannie\API\member\MemberREST::post($cardno, $json);
         if ($resp['errors'] > 0) {
             $this->stats['errors'][] = "Error importing member {$cardno} ({$line[$fn_index]} {$line[$ln_index]})";
         } else {
             $this->stats['imported']++;
         }
     }
     return true;
 }
コード例 #30
-3
ファイル: CheckCouponMailing.php プロジェクト: phpsmith/IS4C
 public function post_id_upc_terms_handler()
 {
     $this->id = preg_split('/[^\\d]/', $this->id, 0, PREG_SPLIT_NO_EMPTY);
     $pdf = new FPDF('P', 'mm', 'Letter');
     $pdf->SetMargins(6.35, 6.35, 6.35);
     // quarter-inch margins
     $pdf->SetAutoPageBreak(false);
     $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
     $margins = $pdf->GetMargins();
     $margins['top'] = 0.0;
     $check_left_x = $margins['left'] > 3.175 ? $margins['right'] : 3.175 - $margins['left'];
     $real_check_top_y = 183.675 - $margins['top'];
     $check_right_x = 203.2 - $margins['left'];
     $real_check_bottom_y = 255.112 - $margins['top'];
     $line_height = 5;
     $envelope_window_tab = 15;
     $right_col1 = 130;
     $right_col2 = 170;
     $my_address = array('610 E 4th St', 'Duluth, MN 55805', 'Tel: 218.728.0884', 'www.wholefoods.coop');
     $check_date = date('F j, Y');
     $dbc = $this->connection;
     $dbc->setDefaultDB($this->config->get('OP_DB'));
     $signage = new COREPOS\Fannie\API\item\FannieSignage(array());
     foreach ($this->id as $card_no) {
         $pdf->AddPage();
         $account = \COREPOS\Fannie\API\member\MemberREST::get($card_no);
         $primary = array();
         foreach ($account['customers'] as $c) {
             if ($c['accountHolder']) {
                 $primary = $c;
                 break;
             }
         }
         $check_number = rand(100000, 999995);
         for ($i = 0; $i < 3; $i++) {
             $pdf->SetFont('Gill', '', 10);
             $check_top_y = $real_check_top_y - $i * 90;
             $check_bottom_y = $real_check_bottom_y - $i * 90;
             $pdf->SetXY($check_left_x, $check_top_y);
             $pdf->Ln($line_height * 4.25);
             foreach ($my_address as $line) {
                 $pdf->SetX($check_left_x + $envelope_window_tab + 20);
                 if ($line == 'www.wholefoods.coop') {
                     $pdf->SetFont('Gill', 'B', 9);
                 }
                 $pdf->Cell(0, $line_height, $line, 0, 1);
             }
             $pdf->SetFont('Gill', 'B', 10);
             $pdf->SetXY($check_left_x + $right_col1, $check_top_y);
             $pdf->Cell(30, $line_height, 'Check Number:', 0, 0, 'R');
             $pdf->SetFont('Gill', '', 10);
             $pdf->SetTextColor(0xff, 0x58, 0);
             $pdf->SetX($check_left_x + $right_col2);
             $pdf->Cell(30, $line_height, $check_number, 0, 0, 'R');
             $pdf->SetFont('Gill', 'B', 10);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetXY($check_left_x + $right_col1, $check_top_y + 1.5 * $line_height);
             $pdf->Cell(30, $line_height, 'Date:', 0, 0, 'R');
             $pdf->SetFont('Gill', '', 10);
             $pdf->SetTextColor(0xff, 0x58, 0);
             $pdf->SetX($check_left_x + $right_col2);
             $pdf->Cell(30, $line_height, $check_date, 0, 0, 'R');
             $pdf->SetXY($check_left_x + $right_col1, $check_top_y + 3 * $line_height);
             $pdf->SetFont('Gill', 'B', 10);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->Cell(30, $line_height, 'Amount:', 0, 0, 'R');
             $pdf->SetXY($check_left_x + $right_col1 + 30, $check_top_y + 3 * $line_height);
             $pdf->SetFont('Gill', '', 10);
             $pdf->SetTextColor(0xff, 0x58, 0);
             $pdf->MultiCell(40, $line_height, str_repeat(' ', 2) . $this->terms, 0, 'R');
             $pdf->SetTextColor(0, 0, 0);
             $their_address = array($primary['firstName'] . ' ' . $primary['lastName']);
             $their_address[] = $account['addressFirstLine'];
             if ($account['addressSecondLine']) {
                 $their_address[] = $account['addressSecondLine'];
             }
             $their_address[] = $account['city'] . ', ' . $account['state'] . ' ' . $account['zip'];
             $pdf->SetXY($check_left_x + $envelope_window_tab, $check_top_y + 11 * $line_height);
             $pdf->SetFont('Gill', 'B', 10);
             foreach ($their_address as $line) {
                 $pdf->SetX($check_left_x + $envelope_window_tab);
                 $pdf->Cell(0, $line_height, $line, 0, 1);
             }
             $pdf->SetFont('Gill', '', 10);
             $pdf->SetXY($check_left_x, $check_bottom_y + $line_height - 1);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFont('Gill', 'B', 10);
             $pdf->Cell(0, $line_height, 'Redeemable only at Whole Foods Co-op', 0, 0, 'C');
             $pdf->SetFont('Gill', '', 10);
             $pdf->SetXY($check_left_x + 145, $check_top_y + 6 * $line_height + 1);
             $pdf->SetFont('Gill', '', 8);
             $pdf->MultiCell(50, $line_height - 2, 'Limit one per day. Cannot be applied to previous purchases. No cash value.');
             $pdf->SetFont('Gill', '', 10);
             $pdf->SetFillColor(0xcc, 0xcc, 0xcc);
             $pdf->Rect($check_left_x + 84, $check_top_y + 28, 39, 15, 'F');
             $pdf->SetFillColor(0, 0, 0);
             $signage->drawBarcode(ltrim($this->upc, '0'), $pdf, $check_left_x + 87, $check_top_y + 30, array('height' => 11, 'fontsize' => 0));
             $pdf->Image('logo.rgb.noalpha.png', $check_left_x + $envelope_window_tab, $check_top_y + 20, 20);
             $pdf->SetFont('Gill', 'B', '31');
             $pdf->SetXY($check_left_x + $envelope_window_tab, $check_top_y + 0.5 * $line_height);
             $pdf->SetTextColor(0xff, 0x58, 0);
             $pdf->Cell(0, 3 * $line_height, 'We Appreciate You!');
             $pdf->SetFont('Gill', '', '10');
             $pdf->SetTextColor(0, 0, 0);
             $pdf->Image(dirname(__FILE__) . '/../GiveUsMoneyPlugin/img/sig.png', $check_right_x - 63.5, $check_top_y + 9 * $line_height, 63.5);
             $pdf->SetXY($check_right_x - 63.5, $check_top_y + 12 * $line_height);
             $pdf->Cell(63.5, $line_height, 'Authorized By Signature', 'T');
             $check_number++;
         }
     }
     $pdf->Output();
 }