Beispiel #1
0
 public function testFannieSignage()
 {
     $dbc = FannieDB::get(FannieConfig::config('OP_DB'));
     $dbc->throwOnFailure(true);
     $signs = new \COREPOS\Fannie\API\item\FannieSignage(array(), 'shelftags', 1);
     $signs->setDB($dbc);
     $this->assertInternalType('array', $signs->loadItems());
     $signs = new \COREPOS\Fannie\API\item\FannieSignage(array(), 'batchbarcodes', 1);
     $signs->setDB($dbc);
     $this->assertInternalType('array', $signs->loadItems());
     $signs = new \COREPOS\Fannie\API\item\FannieSignage(array(), 'batch', 1);
     $signs->setDB($dbc);
     $this->assertInternalType('array', $signs->loadItems());
     foreach (range(0, 3) as $i) {
         $signs = new \COREPOS\Fannie\API\item\FannieSignage(array('0000000000111'), '', $i);
         $signs->setDB($dbc);
         $this->assertInternalType('array', $signs->loadItems());
     }
 }
Beispiel #2
0
 public function get_toIDs_handler()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $TRANS = $this->config->get('TRANS_DB') . $dbc->sep();
     define('FPDF_FONTPATH', 'font/');
     include dirname(__FILE__) . '/../src/fpdf/fpdf.php';
     $pdf = new FPDF('P', 'mm', 'Letter');
     //start new instance of PDF
     $pdf->Open();
     //open new PDF Document
     $count = 0;
     $x = 0;
     $y = 0;
     $date = date("m/d/Y");
     $infoP = $dbc->prepare_statement("SELECT ItemQtty,total,regPrice,p.card_no,description,department,\n            CASE WHEN p.card_no=0 THEN o.lastName ELSE c.LastName END as name,\n            CASE WHEN p.card_no=0 THEN o.firstName ELSE c.FirstName END as fname,\n            CASE WHEN o.phone is NULL THEN m.phone ELSE o.phone END as phone,\n            discounttype,quantity,\n            p.mixMatch AS vendorName\n            FROM {$TRANS}PendingSpecialOrder AS p\n            LEFT JOIN custdata AS c ON p.card_no=c.CardNo AND personNum=p.voided\n            LEFT JOIN meminfo AS m ON c.CardNo=m.card_no\n            LEFT JOIN {$TRANS}SpecialOrders AS o ON o.specialOrderID=p.order_id\n            WHERE trans_id=? AND p.order_id=?");
     $flagP = $dbc->prepare_statement("UPDATE {$TRANS}PendingSpecialOrder SET charflag='P'\n            WHERE trans_id=? AND order_id=?");
     $idP = $dbc->prepare_statement("SELECT trans_id FROM {$TRANS}PendingSpecialOrder WHERE\n            trans_id > 0 AND order_id=? ORDER BY trans_id");
     $signage = new \COREPOS\Fannie\API\item\FannieSignage(array());
     foreach ($this->toIDs as $toid) {
         if ($count % 4 == 0) {
             $pdf->AddPage();
             $pdf->SetDrawColor(0, 0, 0);
             $pdf->Line(108, 0, 108, 279);
             $pdf->Line(0, 135, 215, 135);
         }
         $x = $count % 2 == 0 ? 5 : 115;
         $y = $count / 2 % 2 == 0 ? 10 : 145;
         $pdf->SetXY($x, $y);
         $tmp = explode(":", $toid);
         $tid = $tmp[0];
         $oid = $tmp[1];
         $r = $dbc->exec_statement($infoP, array($tid, $oid));
         $w = $dbc->fetch_row($r);
         // flag item as "printed"
         $r2 = $dbc->exec_statement($flagP, array($tid, $oid));
         $r3 = $dbc->exec_statement($idP, array($oid));
         $o_count = 0;
         $rel_id = 1;
         while ($w3 = $dbc->fetch_row($r3)) {
             $o_count++;
             if ($w3['trans_id'] == $tid) {
                 $rel_id = $o_count;
             }
         }
         $pdf->SetFont('Arial', '', '12');
         $pdf->Text($x + 85, $y, "{$rel_id} / {$o_count}");
         $pdf->SetFont('Arial', 'B', '24');
         $pdf->Cell(100, 10, $w['name'], 0, 1, 'C');
         $pdf->SetFont('Arial', '', '12');
         $pdf->SetX($x);
         $pdf->Cell(100, 8, $w['fname'], 0, 1, 'C');
         $pdf->SetX($x);
         if ($w['card_no'] != 0) {
             $pdf->Cell(100, 8, "Owner #" . $w['card_no'], 0, 1, 'C');
             $pdf->SetX($x);
         }
         $pdf->SetFont('Arial', '', '16');
         $pdf->Cell(100, 9, $w['description'], 0, 1, 'C');
         $pdf->SetX($x);
         $pdf->Cell(100, 9, "Cases: " . $w['ItemQtty'] . ' - ' . $w['quantity'], 0, 1, 'C');
         $pdf->SetX($x);
         $pdf->SetFont('Arial', 'B', '16');
         $pdf->Cell(100, 9, sprintf("Total: \$%.2f", $w['total']), 0, 1, 'C');
         $pdf->SetFont('Arial', '', '12');
         $pdf->SetX($x);
         if ($w['discounttype'] == 1 || $w['discounttype'] == 2) {
             $pdf->Cell(100, 9, 'Sale Price', 0, 1, 'C');
             $pdf->SetX($x);
         } elseif ($w['regPrice'] - $w['total'] > 0) {
             $percent = round(100 * (($w['regPrice'] - $w['total']) / $w['regPrice']));
             $pdf->Cell(100, 9, sprintf("Owner Savings: \$%.2f (%d%%)", $w['regPrice'] - $w['total'], $percent), 0, 1, 'C');
             $pdf->SetX($x);
         }
         $pdf->Cell(100, 6, "Tag Date: " . $date, 0, 1, 'C');
         $pdf->SetX($x);
         $pdf->Cell(50, 6, "Dept #" . $w['department'], 0, 0, 'R');
         $pdf->SetFont('Arial', 'B', '12');
         $pdf->SetX($x + 50);
         $pdf->Cell(50, 6, $w['vendorName'], 0, 1, 'L');
         $pdf->SetFont('Arial', '', '12');
         $pdf->SetX($x);
         $pdf->Cell(100, 6, "Ph: " . $w['phone'], 0, 1, 'C');
         $pdf->SetXY($x, $y + 85);
         $pdf->Cell(160, 10, "Notes: _________________________________");
         $pdf->SetX($x);
         $upc = "454" . str_pad($oid, 6, '0', STR_PAD_LEFT) . str_pad($tid, 2, '0', STR_PAD_LEFT);
         $pdf = $signage->drawBarcode($upc, $pdf, $x + 30, $y + 95, array('height' => 14, 'fontsize' => 8));
         $count++;
     }
     $pdf->Output();
     return false;
 }
Beispiel #3
0
<?php

include dirname(__FILE__) . '/../../config.php';
if (!class_exists('FannieAPI')) {
    include dirname(__FILE__) . '/../../classlib2.0/FannieAPI.php';
}
$upc = FormLib::get('upc');
$name = FormLib::get('name');
if ($upc === '') {
    echo '<strong>Error</strong>: No UPC provided';
    return false;
}
if ($name === '') {
    $name = $upc;
}
if (!class_exists('FPDF')) {
    include dirname(__FILE__) . '/../../src/fpdf/fpdf.php';
}
$pdf = new FPDF('P', 'mm', 'Letter');
$pdf->AddPage();
$pdf->SetFont('Arial', '', 8);
$upc = ltrim($upc, '0');
// let library deal with check digits
$signage = new \COREPOS\Fannie\API\item\FannieSignage(array());
for ($i = 0; $i < 32; $i++) {
    $col = $i % 4;
    $row = floor($i / 4);
    $signage->drawBarcode($upc, $pdf, 50 * $col + 10, 32 * $row + 10);
}
$pdf->Output($name . '.pdf', 'I');
Beispiel #4
-3
 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();
 }