Example #1
3
 public function drawPDF()
 {
     $pdf = new \FPDF('L', 'mm', 'Letter');
     $pdf->SetMargins(3.175, 3.175, 3.175);
     $pdf->SetAutoPageBreak(false);
     if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
         $this->font = 'Gill';
         $this->alt_font = 'GillBook';
         define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
     }
     $pdf->SetFont($this->font, '', 16);
     $data = $this->loadItems();
     $width = 136.52;
     $height = 105;
     $top = 90;
     $left = 15;
     $effective_width = $width - 2 * $left;
     foreach ($data as $item) {
         $pdf->AddPage();
         $column = 1;
         // right aligned
         $price = $this->printablePrice($item);
         $pdf->SetXY($left + $width * $column, $top);
         $pdf->SetFontSize($this->SMALL_FONT);
         $pdf->Cell($effective_width, 10, $item['brand'], 0, 1, 'C');
         $pdf->SetX($left + $width * $column);
         $pdf->SetFontSize($this->MED_FONT);
         $pdf->MultiCell($effective_width, 12, $item['description'], 0, 'C');
         $pdf->SetX($left + $width * $column);
         $pdf->SetFontSize($this->BIG_FONT);
         $pdf->Cell($effective_width, 25, $price, 0, 1, 'C');
         $y_pos = $pdf->GetY();
         if ($item['startDate'] != '' && $item['endDate'] != '') {
             // intl would be nice
             $datestr = $this->getDateString($item['startDate'], $item['endDate']);
             $pdf->SetXY($left + $width * $column, $top + ($height - 40));
             $pdf->SetFontSize($this->SMALL_FONT);
             $pdf->Cell($effective_width, 20, $datestr, 0, 1, 'R');
         }
         if ($item['originName'] != '') {
             $pdf->SetXY($left + $width * $column, $y_pos);
             $pdf->SetFontSize($this->SMALL_FONT);
             if (strlen($item['originName']) < 50) {
                 $pdf->Cell($effective_width, 20, $item['originName'], 0, 1, 'L');
             } else {
                 $pdf->Cell($effective_width, 20, $item['originShortName'], 0, 1, 'L');
             }
         }
     }
     $pdf->Output('WfcProdSingle.pdf', 'I');
 }
Example #2
0
 public function drawPDF()
 {
     $pdf = new \FPDF('P', 'mm', 'Letter');
     if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
         $this->font = 'Gill';
         $this->alt_font = 'GillBook';
         define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
         $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
     }
     $width = 52;
     // tag width in mm
     $height = 31;
     // tag height in mm
     $left = 6;
     // left margin
     $top = 16;
     // top margin
     $pdf->SetTopMargin($top);
     //Set top margin of the page
     $pdf->SetLeftMargin($left);
     //Set left margin of the page
     $pdf->SetRightMargin($left);
     //Set the right margin of the page
     $pdf->SetAutoPageBreak(False);
     // manage page breaks yourself
     $data = $this->loadItems();
     $num = 0;
     // count tags
     $x = $left;
     $y = $top;
     foreach ($data as $item) {
         // extract & format data
         $price = $item['normal_price'];
         $desc = strtoupper(substr($item['posDescription'], 0, 25));
         $brand = ucwords(strtolower(substr($item['brand'], 0, 13)));
         $pak = $item['units'];
         $size = $item['units'] . "-" . $item['size'];
         $sku = $item['sku'];
         $ppu = $item['pricePerUnit'];
         $vendor = substr($item['vendor'], 0, 7);
         $upc = $item['upc'];
         if ($num % 32 == 0) {
             $pdf->AddPage();
             $x = $left;
             $y = $top;
         } else {
             if ($num % 4 == 0) {
                 $x = $left;
                 $y += $height;
             }
         }
         $pdf->SetFont($this->font, '', 8);
         $pdf->SetXY($x, $y);
         // try normal wordwrap
         // but squeeze into two lines if needed
         $wrapped = wordwrap($desc, 12, "\n", true);
         if (count(explode("\n", $wrapped)) > 2) {
             $wrapped = substr($desc, 0, 12);
             if ($wrapped[11] != ' ') {
                 $wrapped .= '-';
             }
             $wrapped .= "\n";
             $wrapped .= trim(substr($desc, 12));
         }
         $pdf->MultiCell($width / 2, 3, $wrapped, 0, 'L');
         $pdf->SetX($x);
         $pdf->Cell($width / 2, 3, date('n/j/y ') . $size, 0, 1, 'L');
         $pdf->SetFont($this->font, 'B', 18);
         //change font for price
         $pdf->SetX($x);
         $pdf->Cell($width / 2, 8, $price, 0, 1, 'L');
         $args = array('height' => 7, 'align' => 'L', 'fontsize' => 8, 'width' => 0.23, 'font' => $this->font);
         $b_y = $pdf->GetY();
         $pdf = $this->drawBarcode($upc, $pdf, $x, $b_y, $args);
         // move right by tag width
         $x += $width;
         $num++;
     }
     $pdf->Output('Tags4x8P.pdf', 'I');
 }
Example #3
0
 /**
   Get a list of all available classes implementing a given
   base class
   @param $base_class [string] name of base class
   @param $include_base [boolean] include base class name in the result set
     [optional, default false]
   @return [array] of [string] class names
 */
 public static function listModules($base_class, $include_base = false)
 {
     $directories = array();
     $directories[] = dirname(__FILE__) . '/../modules/plugins2.0/';
     switch ($base_class) {
         case 'ItemModule':
             $directories[] = dirname(__FILE__) . '/../item/modules/';
             break;
         case 'MemberModule':
         case '\\COREPOS\\Fannie\\API\\member\\MemberModule':
             $directories[] = dirname(__FILE__) . '/../mem/modules/';
             break;
         case 'FannieTask':
             $directories[] = dirname(__FILE__) . '/../cron/tasks/';
             break;
         case 'BasicModel':
             $directories[] = dirname(__FILE__) . '/data/models/';
             break;
         case 'BasicModelHook':
         case '\\COREPOS\\Fannie\\API\\data\\hooks\\BasicModelHook':
             $directories[] = dirname(__FILE__) . '/data/hooks/';
             break;
         case 'FannieReportPage':
             $directories[] = dirname(__FILE__) . '/../reports/';
             $directories[] = dirname(__FILE__) . '/../purchasing/reports/';
             break;
         case 'FannieReportTool':
         case '\\COREPOS\\Fannie\\API\\FannieReportTool':
             $directories[] = dirname(__FILE__) . '/../reports/';
             break;
         case 'FannieSignage':
         case '\\COREPOS\\Fannie\\API\\item\\FannieSignage':
             $directories[] = dirname(__FILE__) . '/item/signage/';
             break;
         case 'FanniePage':
             $directories[] = dirname(__FILE__) . '/../admin/';
             $directories[] = dirname(__FILE__) . '/../batches/';
             $directories[] = dirname(__FILE__) . '/../cron/management/';
             $directories[] = dirname(__FILE__) . '/../item/';
             $directories[] = dirname(__FILE__) . '/../logs/';
             $directories[] = dirname(__FILE__) . '/../reports/';
             $directories[] = dirname(__FILE__) . '/../mem/';
             $directories[] = dirname(__FILE__) . '/../purchasing/';
             /*
             $directories[] = dirname(__FILE__).'/../install/';
             $directories[] = dirname(__FILE__).'/../ordering/';
             */
             break;
     }
     // recursive search
     $search = function ($path) use(&$search) {
         if (is_file($path) && substr($path, -4) == '.php') {
             return array($path);
         } elseif (is_dir($path)) {
             $dh = opendir($path);
             $ret = array();
             while (($file = readdir($dh)) !== false) {
                 if ($file == '.' || $file == '..') {
                     continue;
                 }
                 if ($file == 'noauto') {
                     continue;
                 }
                 if ($file == 'index.php') {
                     continue;
                 }
                 if ($file == 'Store-Specific') {
                     continue;
                 }
                 $ret = array_merge($ret, $search($path . '/' . $file));
             }
             return $ret;
         }
         return array();
     };
     $files = array_reduce($directories, function ($carry, $dir) use($search) {
         return array_merge($carry, $search($dir));
     }, array());
     $ret = array();
     foreach ($files as $file) {
         $class = substr(basename($file), 0, strlen(basename($file)) - 4);
         // matched base class
         if ($class === $base_class) {
             if ($include_base) {
                 $ret[] = $class;
             }
             continue;
         }
         // almost certainly not a class definition
         if ($class == 'index') {
             continue;
         }
         // if the file is part of a plugin, make sure
         // the plugin is enabled. The exception is when requesting
         // a list of plugin classes
         if (strstr($file, 'plugins2.0') && $base_class != 'FanniePlugin' && $base_class != '\\COREPOS\\Fannie\\API\\FanniePlugin') {
             $parent = \COREPOS\Fannie\API\FanniePlugin::memberOf($file);
             if ($parent === false || !\COREPOS\Fannie\API\FanniePlugin::isEnabled($parent)) {
                 continue;
             }
         }
         // verify class exists
         ob_start();
         include_once $file;
         ob_end_clean();
         $namespaced_class = self::pathToClass($file);
         if (!class_exists($class, false) && !class_exists($namespaced_class, false)) {
             continue;
         }
         if (class_exists($class, false) && is_subclass_of($class, $base_class)) {
             $ret[] = $class;
         } elseif (class_exists($namespaced_class, false) && is_subclass_of($namespaced_class, $base_class)) {
             $ret[] = $namespaced_class;
         }
     }
     return $ret;
 }
Example #4
0
 protected function loadPluginFonts($pdf)
 {
     if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
         $this->font = 'Gill';
         $this->alt_font = 'GillBook';
         define('FPDF_FONTPATH', dirname(__FILE__) . '/../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
         $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
         $pdf->AddFont('GillBook', '', 'GillSansMTPro-Book.php');
     }
     return $pdf;
 }
Example #5
0
 private function listHouseCoupons()
 {
     $FANNIE_URL = $this->config->get('URL');
     $this->add_script($FANNIE_URL . 'src/javascript/fancybox/jquery.fancybox-1.3.4.js?v=1');
     $this->add_css_file($FANNIE_URL . 'src/javascript/fancybox/jquery.fancybox-1.3.4.css');
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $ret = '<form action="HouseCouponEditor.php" method="get">';
     $ret .= '<p>';
     $ret .= '<button type="submit" name="new_coupon_submit" 
         class="btn btn-default" value="New Coupon">New Coupon</button>';
     $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     $ret .= '<button type="button" class="fancybox-btn btn btn-default"
         href="explainify.html">Explanation of Settings</button>';
     $this->add_onload_command('$(\'.fancybox-btn\').fancybox();');
     $ret .= '</p>';
     $ret .= '</form>';
     $ret .= '<table class="table">';
     $ret .= '<tr><th>ID</th><th>Name</th><th>Value</th><th>Expires</th></tr>';
     $model = new HouseCouponsModel($dbc);
     foreach ($model->find('coupID') as $obj) {
         if (strstr($obj->endDate(), ' ')) {
             $tmp = explode(' ', $obj->endDate());
             $obj->endDate($tmp[0]);
         }
         $report_dates = array(date('Y-m-d', strtotime($obj->startDate())), date('Y-m-d', strtotime($obj->endDate())));
         /**
           If coupon period is more than 45 days, use the current month
           as a reporting period
         */
         if (strtotime($report_dates[1]) - strtotime($report_dates[0]) > 86400 * 45) {
             $report_dates = array(date('Y-m-01'), date('Y-m-t'));
         }
         $ret .= sprintf('<tr><td>#%d <a href="HouseCouponEditor.php?edit_id=%d">Edit</a></td>
                 <td>%s</td><td>%.2f%s</td><td>%s</td>
                 <td>
                     <a href="%sws/barcode-pdf/?upc=%s&name=%s"
                     class="btn btn-default">Print Barcode</a>
                     <a href="%sreports/ProductMovement/ProductMovementModular.php?upc=%s&date1=%s&date2=%s"
                     class="btn btn-default">Usage Report</a>
                     <a href="%smodules/plugins2.0/CoreWarehouse/reports/CWCouponReport.php?coupon-id=%d&date1=%s&date2=%s"
                     class="btn btn-default %s">Member Baskets</a>
                 </tr>', $obj->coupID(), $obj->coupID(), $obj->description(), $obj->discountValue(), $obj->discountType(), $obj->endDate(), $FANNIE_URL, '499999' . str_pad($obj->coupID(), 5, '0', STR_PAD_LEFT), urlencode($obj->description()), $FANNIE_URL, '499999' . str_pad($obj->coupID(), 5, '0', STR_PAD_LEFT), $report_dates[0], $report_dates[1], $FANNIE_URL, $obj->coupID(), $report_dates[0], $report_dates[1], \COREPOS\Fannie\API\FanniePlugin::isEnabled('CoreWarehouse') ? '' : 'collapse');
     }
     $ret .= '</table>';
     $dbc->close();
     return $ret;
 }
Example #6
0
 public function drawPDF()
 {
     $pdf = new \FPDF('P', 'mm', 'Letter');
     if (\COREPOS\Fannie\API\FanniePlugin::isEnabled('CoopDealsSigns')) {
         $this->font = 'Gill';
         $this->alt_font = 'GillBook';
         define('FPDF_FONTPATH', dirname(__FILE__) . '/../../../modules/plugins2.0/CoopDealsSigns/noauto/fonts/');
         $pdf->AddFont('Gill', '', 'GillSansMTPro-Medium.php');
         $pdf->AddFont('Gill', 'B', 'GillSansMTPro-Heavy.php');
     }
     $width = 52;
     // tag width in mm
     $bar_width = 50;
     $height = 31;
     // tag height in mm
     $left = 5.5;
     // left margin
     $top = 15;
     // top margin
     $pdf->SetTopMargin($top);
     //Set top margin of the page
     $pdf->SetLeftMargin($left);
     //Set left margin of the page
     $pdf->SetRightMargin($left);
     //Set the right margin of the page
     $pdf->SetAutoPageBreak(False);
     // manage page breaks yourself
     $data = $this->loadItems();
     $num = 0;
     // count tags
     $x = $left;
     $y = $top;
     $sign = 0;
     foreach ($data as $item) {
         // extract & format data
         $price = $item['normal_price'];
         $desc = $item['description'];
         $brand = strtoupper($item['brand']);
         $price = $item['normal_price'];
         if ($item['scale']) {
             if (substr($price, 0, 1) != '$') {
                 $price = sprintf('$%.2f', $price);
             }
             $price .= ' /lb.';
         } else {
             $price = $this->formatPrice($item['normal_price']);
         }
         if ($num % 32 == 0) {
             $pdf->AddPage();
             $x = $left;
             $y = $top;
             $sign = 0;
         } else {
             if ($num % 4 == 0) {
                 $x = $left;
                 $y += $height;
             }
         }
         $row = floor($sign / 4);
         $column = $sign % 4;
         $pdf->SetFillColor(86, 90, 92);
         $pdf->Rect($left + $width * $column, $top + $row * $height, $bar_width, 5, 'F');
         $pdf->Rect($left + $width * $column, $top + $row * $height + 25, $bar_width, 2, 'F');
         $pdf->SetXY($left + $width * $column, $top + $row * $height + 6);
         $pdf->SetFont($this->font, 'B', $this->SMALL_FONT);
         $pdf->MultiCell($width, 5, $brand, 0, 'C');
         $pdf->SetX($left + $width * $column);
         $pdf->SetFont($this->font, '', $this->MED_FONT);
         $pdf->MultiCell($width, 5, $item['description'], 0, 'C');
         $pdf->SetX($left + $width * $column);
         $pdf->SetFont($this->font, '', $this->BIG_FONT);
         $pdf->Cell($width, 8, $price, 0, 1, 'C');
         // move right by tag width
         $x += $width;
         $num++;
         $sign++;
     }
     $pdf->Output('Tags4x8P.pdf', 'I');
 }