/** * @return json */ public function getListResultsAction() { $params = $this->getRequest()->getParams(); $params['name'] = "%" . $params['name'] . "%"; $paymentTermQuery = PaymentTermQuery::create()->filter($params)->page($params['page'], $this->getMaxPerPage())->find(); $paymentTerms = array(); while ($paymentTerm = $paymentTermQuery->read()) { $paymentTerms[$paymentTerm->getIndex()] = $paymentTerm->toArray(); $paymentTerms[$paymentTerm->getIndex()]['name'] = utf8_encode($paymentTerm->getName()); $paymentTerms[$paymentTerm->getIndex()]['events'] = PaymentTermQuery::create()->addColumns(array('PaymentTerm.*', 'PaymentTerm2Event.*', 'Event.name'))->innerJoinEvent()->whereAdd('PaymentTerm.' . PaymentTerm::ID_PAYMENT_TERM, $paymentTerm->getIdPaymentTerm())->fetchAll(); } die(json_encode($paymentTerms)); }
/** * */ public function exportToExcelAction() { $params = $this->getRequest()->getParams(); // if (!empty($params['rfc'])) // $params['rfc'] = '%'.$params['rfc'].'%'; // $params['id_approval_status'] = $params['status']; // unset($params['status']); $params = $this->getRequest()->getParams(); $query = SapSupplierQuery::create(); $queryCount = SapSupplierQuery::create(); if (!empty($params['name'])) { $query = $query->whereAdd(SapSupplier::CARDNAME, "%" . $params['name'] . "%", SapSupplierQuery::LIKE); $queryCount = $queryCount->whereAdd(SapSupplier::CARDNAME, "%" . $params['name'] . "%", SapSupplierQuery::LIKE); } if (!empty($params['sap_id_bussiness_associate'])) { $query = $query->whereAdd(SapSupplier::CARDCODE, '%' . $params['sap_id_bussiness_associate'] . '%', SapSupplierQuery::LIKE); $queryCount = $queryCount->whereAdd(SapSupplier::CARDCODE, '%' . $params['sap_id_bussiness_associate'] . '%', SapSupplierQuery::LIKE); } if (isset($params['status'])) { $query = $query->whereAdd(SapSupplier::ID_APPROVAL_STATUS, $params['status'], SapSupplierQuery::LIKE); $queryCount = $queryCount->whereAdd(SapSupplier::ID_APPROVAL_STATUS, $params['status'], SapSupplierQuery::LIKE); } $total = $queryCount->count(); $query = $query->whereAdd(SapSupplier::CARDTYPE, SapSupplier::$CardTypes['Supplier'])->find(); $headers = array('Name', 'Payment Term', 'RFC', 'Approval Status'); $content = array(); foreach ($query as $key => $object) { $content[$key][] = utf8_encode($object->getName()); if (PaymentTermQuery::create()->whereAdd(\Application\Model\Bean\PaymentTerm::ID_PAYMENT_TERM, $object->getIdPaymentTerm())->count()) { $content[$key][] = PaymentTermQuery::create()->findByPK($object->getIdPaymentTerm())->getName(); } else { $content[$key][] = $this->i18n->_('Not Available'); } $content[$key][] = $object->getRfc(); $approvalStatus = array_flip(SapSupplier::$IdApprovalStatus); $content[$key][] = $approvalStatus[$object->getIdApprovalStatus()]; } $title = $this->i18n->_('Suppliers Report'); $filename = 'suppliers_report'; $report = new SimpleListReport(); $report->setTableHeaders($headers); $report->setTableContent($content); $report->setTableTitle($title); $report->setFilename($filename); $report->createSpreadsheet(); }