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'); }
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'); }
/** 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; }
/** Define any javascript needed @return a javascript string function javascript_content(){ $js =""; return $js; //js_content() } */ function body_content() { //Should this really be done with global? global $FANNIE_PLUGIN_LIST, $FANNIE_PLUGIN_SETTINGS; ob_start(); echo showInstallTabs('Plugins'); ?> <form action=InstallPluginsPage.php method=post> <h1 class="install"> <?php if (!$this->themed) { echo "<h1 class='install'>{$this->header}</h1>"; } ?> </h1> <?php if (is_writable('../config.php')) { echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>"; } else { echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>"; } ?> <h4 class="install">Available plugins</h4> <?php if (!isset($FANNIE_PLUGIN_LIST)) { $FANNIE_PLUGIN_LIST = array(); } if (!is_array($FANNIE_PLUGIN_LIST)) { $FANNIE_PLUGIN_LIST = array(); } if (!isset($FANNIE_PLUGIN_SETTINGS)) { $FANNIE_PLUGIN_SETTINGS = array(); } if (!is_array($FANNIE_PLUGIN_SETTINGS)) { $FANNIE_PLUGIN_SETTINGS = array(); } $mods = FannieAPI::ListModules('FanniePlugin'); $others = FannieAPI::listModules('\\COREPOS\\Fannie\\API\\FanniePlugin'); foreach ($others as $o) { if (!in_array($o, $mods)) { $mods[] = $o; } } sort($mods); if (isset($_REQUEST['PLUGINLIST']) || isset($_REQUEST['psubmit'])) { $oldset = $FANNIE_PLUGIN_LIST; if (!is_array($oldset)) { $oldset = array(); } $newset = isset($_REQUEST['PLUGINLIST']) ? $_REQUEST['PLUGINLIST'] : array(); foreach ($newset as $plugin_class) { if (!\COREPOS\Fannie\API\FanniePlugin::IsEnabled($plugin_class)) { $obj = new $plugin_class(); $obj->pluginEnable(); } } foreach ($oldset as $plugin_class) { if (!class_exists($plugin_class)) { continue; } if (!in_array($plugin_class, $newset)) { $obj = new $plugin_class(); $obj->pluginDisable(); } } $FANNIE_PLUGIN_LIST = $_REQUEST['PLUGINLIST']; } echo '<table id="install" class="table">'; $count = 0; foreach ($mods as $m) { $enabled = False; $instance = new $m(); foreach ($FANNIE_PLUGIN_LIST as $r) { if ($r == $m) { $enabled = True; break; } } /* 17Jun13 Under Fannie Admin CSS the spacing is cramped. The slider overlaps the text. Want it higher and to the right. Not obvious why or how to fix. Jiggered the CSS a little here and above but isn't really a fix. */ echo '<tr ' . ($count % 2 == 0 ? 'class="info"' : '') . '> <td style="width:10em;"> </td> <td style="width:25em;">' . "\n"; echo '<fieldset class="toggle">' . "\n"; printf('<input name="PLUGINLIST[]" id="plugin_%s" type="checkbox" %s value="%s" onchange="$(\'#settings_%s\').toggle();" class="checkbox-inline" /> <label onclick="" for="plugin_%s">%s</label>', $m, $enabled ? 'checked' : '', $m, $m, $m, $m); echo "\n" . '<span class="toggle-button"></span></fieldset>' . "\n"; // 17Jun13 EL Added <br /> for overlap problem. printf('<br /><span class="noteTxt">%s</span>', $instance->plugin_description); echo '</td></tr>' . "\n"; if (empty($instance->plugin_settings)) { echo '<tr ' . ($count % 2 == 0 ? 'class="info"' : '') . '> <td colspan="2"><i>No settings required</i></td></tr>'; } else { echo '<tr ' . ($count % 2 == 0 ? 'class="info"' : '') . '> <td colspan="2" style="margin-bottom: 0px; height:auto;">'; printf('<div id="settings_%s" %s>', $m, !$enabled ? 'class="collapse"' : ''); foreach ($instance->plugin_settings as $field => $info) { $form_id = $m . '_' . $field; // ignore submitted values if plugin was not enabled if ($enabled && isset($_REQUEST[$form_id])) { $FANNIE_PLUGIN_SETTINGS[$field] = $_REQUEST[$form_id]; } if (!isset($FANNIE_PLUGIN_SETTINGS[$field])) { $FANNIE_PLUGIN_SETTINGS[$field] = isset($info['default']) ? $info['default'] : ''; } echo '<b>' . (isset($info['label']) ? $info['label'] : $field) . '</b>: '; if (isset($info['options'])) { echo '<select name="' . $form_id . '" class="form-control">'; foreach ($info['options'] as $key => $val) { printf('<option %s value="%s">%s</option>', $FANNIE_PLUGIN_SETTINGS[$field] == $val ? 'selected' : '', $val, $key); } echo '</select>'; } else { printf('<input type="text" name="%s" value="%s" class="form-control" />', $form_id, $FANNIE_PLUGIN_SETTINGS[$field]); } // show the default if plugin isn't enabled, but // unset so that it isn't saved in the configuration if (!$enabled) { unset($FANNIE_PLUGIN_SETTINGS[$field]); } // 17Jun13 EL Added <br /> for crampedness problem. if (isset($info['description'])) { echo '<br /><span class="noteTxt">' . $info['description'] . '</span>'; } echo '<br />'; //confset($field,"'".$CORE_LOCAL->get($field)."'"); } if ($enabled && isset($_REQUEST['psubmit'])) { $instance->settingChange(); } echo '</div>'; echo '</td></tr>'; } $count++; } echo '</table>'; $saveStr = "array("; foreach ($FANNIE_PLUGIN_LIST as $r) { $saveStr .= "'" . $r . "',"; } $saveStr = rtrim($saveStr, ",") . ")"; confset('FANNIE_PLUGIN_LIST', $saveStr); $saveStr = "array("; foreach ($FANNIE_PLUGIN_SETTINGS as $key => $val) { $saveStr .= "'" . $key . "'=>'" . $val . "',"; } $saveStr = rtrim($saveStr, ",") . ")"; confset('FANNIE_PLUGIN_SETTINGS', $saveStr); ?> <hr /> <p> <button type="submit" name="psubmit" value="1" class="btn btn-default">Save Configuration</button> </p> </form> <?php return ob_get_clean(); // body_content }
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; }
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 .= ' '; $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; }
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'); }