v7‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT home/ajdemo/public_html/mempro/library/Am/Grid/Filter/Abstract.php000064400000013734152101646240021134 0ustar00varList; } public function initFilter(Am_Grid_ReadOnly $grid) { if (empty($this->title)) $this->title = ___("Filter"); if (empty($this->buttonTitle)) $this->buttonTitle = ___("Apply"); $this->grid = $grid; $this->vars = array(); foreach ($this->varList as $k) $this->vars[$k] = $this->grid->getRequest()->get($k); if ($this->isFiltered()) $this->applyFilter(); } /** apply filter using $this->vars array */ abstract protected function applyFilter(); public function isFiltered() { foreach ($this->vars as $k => $v) if (!empty($v)) return true; return false; } public function getTitle() { return $this->title; } protected function getParam($name, $default=null) { return isset($this->vars[$name]) ? $this->vars[$name] : $default; } public function getAllButFilterVars() { $ret = array(); $prefix = $this->grid->getId() . '_'; foreach ($this->grid->getCompleteRequest()->toArray() as $k => $v) { if (strpos($k, $prefix)!==false) { $kk = substr($k, strlen($prefix)); if (in_array($kk, $this->getVariablesList())) continue; if ($kk == 'p') continue; // skip page# too we do not want to see empty list } $ret[$k] = $v; } return $ret; } public function renderFilter() { $action = preg_replace('#\?.*#', '', $this->grid->getCompleteRequest()->REQUEST_URI); $action = htmlentities( $action, ENT_QUOTES, 'UTF-8'); $title = $this->getTitle(); $vars = $this->getAllButFilterVars(); $hiddenInputs = Am_Html::renderArrayAsInputHiddens($vars); $inputs = $this->renderInputs(); $button = $this->renderButton(); return <<
$button
$hiddenInputs $inputs
$title
CUT; } abstract function renderInputs(); protected function renderButton() { return sprintf('', htmlentities($this->buttonTitle, ENT_QUOTES, 'UTF-8')); } function renderStatic() {} function renderInputText($name = 'filter') { if (is_array($name)) { $attrs = $name; $name = isset($attrs['name']) ? $attrs['name'] : 'filter'; } else { $attrs = $this->attributes; } $attrs["name"] = $this->grid->getId() . '_' . $name; $attrs["type"] = "text"; if (!isset($attrs['value'])) $attrs["value"] = $this->vars[$name]; $out = " $v) $out .= ' ' . $k . '="' . htmlentities($v, ENT_QUOTES, 'UTF-8') . '"'; $out .= " />"; return $out ; } function renderInputCheckboxes($name, $options) { $attrs = $this->attributes; $attrs["name"] = $this->grid->getId() . '_' . $name . '[]'; $attrs["type"] = "checkbox"; $out = ''; foreach ($options as $k=>$title) { $attrs['value'] = $k; if (in_array($k, $this->getParam($name, array()))) { $attrs['checked'] = 'checked'; } else { unset($attrs['checked']); } $out .= sprintf(' ', $this->renderAttributes($attrs), htmlentities($title, ENT_QUOTES, 'UTF-8')); } return $out ; } function renderInputSelect($name, $options, $attributes = array()) { $out = ''; foreach ($options as $value => $title) { $out .= is_array($title) ? $this->_renderOptgroup($name, $value, $title) : $this->_renderOption($name, $value, $title); } $out = sprintf('', $this->grid->getId() . '_' . $name, $this->renderAttributes($attributes), $out ); return $out ; } protected function _renderOption($name, $value, $title) { return sprintf('', htmlentities($value, ENT_QUOTES, 'UTF-8'), (($value == $this->getParam($name)) ? ' selected="selected"' : ''), htmlentities($title, ENT_QUOTES, 'UTF-8') ); } protected function _renderOptgroup($name, $title, $options) { $out = ''; foreach ($options as $v => $t) { $out .= $this->_renderOption($name, $v, $t); } return sprintf('%s', htmlentities($title, ENT_QUOTES, 'UTF-8'), $out); } function renderAttributes($attributes) { $out = ''; foreach ($attributes as $k => $v) $out .= ' ' . $k . '="' . htmlentities($v, ENT_QUOTES, 'UTF-8') . '"'; return $out ; } } home/ajdemo/public_html/mempro/library/Am/Pdf/Invoice/Abstract.php000064400000014167152101701240021120 0ustar00di = $di; } /** * @return Am_Di */ function getDi() { return $this->di ? $this->di : Am_Di::getInstance(); } public function getPaperWidth() { return $this->getDi()->config->get('invoice_format', self::PAPER_FORMAT_LETTER) == self::PAPER_FORMAT_LETTER ? Am_Pdf_Page_Decorator::PAGE_LETTER_WIDTH : Am_Pdf_Page_Decorator::PAGE_A4_WIDTH; } public function getPaperHeight() { return $this->getDi()->config->get('invoice_format', self::PAPER_FORMAT_LETTER) == self::PAPER_FORMAT_LETTER ? Am_Pdf_Page_Decorator::PAGE_LETTER_HEIGHT : Am_Pdf_Page_Decorator::PAGE_A4_HEIGHT; } public function drawDefaultTemplate(Zend_Pdf $pdf) { $padd = 40; $pointer = $this->getPaperHeight() - $padd; $page = new Am_Pdf_Page_Decorator($pdf->pages[0]); if (!($ic = $this->getDi()->config->get('invoice_contacts'))) { $ic = $this->getDi()->config->get('site_title') . '
' . $this->getDi()->config->get('root_url'); } $page->setFont($this->getFontRegular(), 10); $invoice_logo_id = $this->getDi()->config->get('invoice_logo'); $yi = $pointer; if ($invoice_logo_id && ($upload = $this->getDi()->uploadTable->load($invoice_logo_id, false))) { if (file_exists($upload->getFullPath())) { $image = null; switch ($upload->getType()) { case 'image/png' : $image = new Zend_Pdf_Resource_Image_Png($upload->getFullPath()); break; case 'image/jpeg' : $image = new Zend_Pdf_Resource_Image_Jpeg($upload->getFullPath()); break; case 'image/tiff' : $image = new Zend_Pdf_Resource_Image_Tiff($upload->getFullPath()); break; } if ($image) { $gh = 100; $gw = 200; $h = $image->getPixelHeight(); $w = $image->getPixelWidth(); $nh = $gh; $nw = ceil($w * $gh / $h); if ($nw > $gw) { $nw = $gw; $nh = ceil($h * $gw / $w); } $page->drawImage($image, $padd, $pointer - $nh, $nw + $padd, $pointer); $yi = $pointer - $nh; } } } $yt = $page->drawTextWithFixedWidth($ic, $this->getPaperWidth() - $padd, $pointer, 400, 'UTF-8', Am_Pdf_Page_Decorator::ALIGN_RIGHT); $pointer = min($yt, $yi) - 10; $page->drawLine($padd, $pointer, $this->getPaperWidth() - $padd, $pointer); $page->nl($pointer); $page->nl($pointer); return $pointer; } /** * @return Zend_Pdf */ public function createPdfTemplate() { if ($this->getDi()->config->get('invoice_custom_template') && ($upload = $this->getDi()->uploadTable->load($this->getDi()->config->get('invoice_custom_template')))) { $pdf = Zend_Pdf::load($upload->getFullPath()); $this->pointer = $this->getPaperHeight() - $this->getDi()->config->get('invoice_skip', 150); } else { $pdf = new Zend_Pdf(); $pdf->pages[0] = $pdf->newPage($this->getDi()->config->get('invoice_format', Zend_Pdf_Page::SIZE_LETTER)); $this->pointer = $this->drawDefaultTemplate($pdf); } return $pdf; } //can be called only after createPdfTemplate public function getPointer() { return $this->pointer; } public function getFontRegular() { if ($this->getDi()->config->get('invoice_custom_ttf') && ($upload = $this->getDi()->uploadTable->load($this->getDi()->config->get('invoice_custom_ttf')))) { return Zend_Pdf_Font::fontWithPath($upload->getFullPath()); } else { return Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); } } public function getFontBold() { if ($this->getDi()->config->get('invoice_custom_ttfbold') && ($upload = $this->getDi()->uploadTable->load($this->getDi()->config->get('invoice_custom_ttfbold')))) { return Zend_Pdf_Font::fontWithPath($upload->getFullPath()); } else { return Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD); } } public function getFileName() { $filename = $this->getDi()->config->get('invoice_filename', 'amember-invoice-%public_id%.pdf'); $filename = str_replace('%payment.date%', date('Y-m-d', amstrtotime($this->payment->dattm)), $filename); $tmp = new Am_SimpleTemplate(); $tmp->assign('public_id', $this->invoice->public_id); $tmp->assign('receipt_id', $this->payment->receipt_id); $tmp->assign('display_id', $this->payment->display_invoice_id); $tmp->assign('payment', $this->payment); $tmp->assign('invoice', $this->invoice); $tmp->assign('user', $this->invoice->getUser()); return $tmp->render($filename); } abstract function render(); public function getState(Invoice $invoice) { $state = $this->getDi()->stateTable->findFirstByState($invoice->getState()); return $state ? $state->title : $invoice->getState(); } public function getCountry(Invoice $invoice) { $country = $this->getDi()->countryTable->findFirstByCountry($invoice->getCountry()); return $country ? $country->title : $invoice->getCountry(); } }