/** * * @param NpdSheet $npd * @param SapSupplier $supplier * @param Color $color * @return array */ public function toArrayForList() { if (!empty($this->idNpdSheet)) { $npd = NpdSheetQuery::create()->findByPK($this->getIdNpdSheet()); } if (!$npd instanceof NpdSheet) { $npd = new NpdSheet(); } if (!empty($this->idSupplier)) { $supplier = SapSupplierQuery::create()->findByPK($this->getIdSupplier()); } if (!$supplier instanceof SapSupplier) { $supplier = new SapSupplier(); } if (!empty($this->idColor)) { $color = ColorQuery::create()->findByPK($this->getIdColor()); } if (!$color instanceof Color) { $color = new Color(); } return array('npd_status' => $npd->getStatusName(), 'name' => utf8_encode($npd->getName()), 'reference' => utf8_encode($npd->getReference()), 'supplier' => utf8_encode($supplier->getName()), 'color' => utf8_encode($color->getName()), 'id_sample' => $this->getIdSample(), 'id_npd_sheet' => $this->getIdNpdSheet(), 'quantity' => $this->getQuantity(), 'folio' => $this->getFolio(), 'notes' => utf8_encode($this->getNotes()), 'status' => $this->getStatus(), 'status_name' => $this->getStatusName(), 'deadline' => $this->getDeadline(), 'shipped_quantity' => $this->getShippedQuantity(), 'is_ordered' => $this->isOrdered(), 'is_requested_to_supplier' => $this->isRequestedToSupplier(), 'is_sent' => $this->isSent()); }
/** * */ public function exportToExcelSentSamplesAction() { $params = $this->getRequest()->getParams(); $sampleShipmentQuery = SampleShipmentQuery::create()->addDescendingOrderBy(SampleShipment::ID_SAMPLE_SHIPMENT)->filter($params)->find(); $i = 1; while ($sampleShipment = $sampleShipmentQuery->read()) { $content[$i] = array('Guide', $sampleShipment->getGuide(), '', '', '', '', ''); $i++; $content[$i] = array('Courier', $sampleShipment->getCourier(), '', '', '', '', ''); $i++; $content[$i] = array('Shipment Date', $sampleShipment->getShipmentDate(), '', '', '', '', ''); $i++; $content[$i] = array('Notes', $sampleShipment->getNote(), '', '', '', '', ''); $i++; $content[$i] = array('', '', '', '', '', '', ''); $i++; $content[$i] = array('Id Npd Sheet', 'Description', 'Supplier', 'Color', 'Quantity', 'Cost', 'Ammount'); $i++; $sampleQuery = SampleQuery::create()->whereAdd(Sample::ID_SAMPLE_SHIPMENT, $sampleShipment->getIdSampleShipment())->find(); while ($sample = $sampleQuery->read()) { $npd = NpdSheetQuery::create()->findByPK($sample->getIdNpdSheet()); if (ColorQuery::create()->whereAdd(Color::ID_COLOR, $sample->getIdColor())->count()) { $color = ColorQuery::create()->findByPK($sample->getIdColor()); } else { $color = new Color(); $color->setName('Any'); } $content[$i] = array($sample->getIdNpdSheet(), $npd->getDescription(), $sample->getIdSupplier(), $color->getName(), $sample->getQuantity(), '$' . number_format($sample->getCost(), 4) . $npd->getIdCurrency(), '$' . number_format($sample->getTotalAmmount(), 4) . $npd->getIdCurrency()); $i++; } $content[$i] = array('', '', '', '', '', 'Total', '$' . number_format($sampleQuery->getTotalAmmount(), 4) . $npd->getIdCurrency()); $i++; $content[$i] = array('', '', '', '', '', '', ''); $i++; $content[$i] = array('', '', '', '', '', '', ''); $i++; } $header = array('', '', '', '', '', '', ''); $tableColumnsWidth = array('small', 'medium', 'small', 'small', 'small', 'medium', 'medium'); // $content $title = $this->i18n->_('Sent Samples Report'); $fileName = $this->i18n->_('sent_samples_report'); $report = new SimpleListReport(); $report->setTableTitle($title); $report->setTableHeaders($header); $report->setTableContent($content); $report->setTableColumnsWidth($tableColumnsWidth); $report->setFilename($fileName); $report->createSpreadsheet(); }
private function getSamplesInformation() { $this->SetFillColor(245, 245, 245); $this->SetLineWidth(0.1); $fill = true; $this->Cell(25, 10, 'Id Npd Sheet', 'TB', 0, 'C', $fill); $this->Cell(25, 10, 'Description', 'TB', 0, 'L', $fill); $this->Cell(25, 10, 'Supplier', 'TB', 0, 'R', $fill); $this->Cell(25, 10, 'Color', 'TB', 0, 'R', $fill); $this->Cell(25, 10, 'Quantity', 'TB', 0, 'R', $fill); $this->Cell(35, 10, 'Cost', 'TB', 0, 'R', $fill); $this->Cell(30, 10, 'Ammount', 'TB', 0, 'R', $fill); $this->Ln(); $fill = false; $this->SetFillColor(225, 225, 225); $borders = 'T'; $height = 6; while ($sample = $this->samples->read()) { if (NpdSheetQuery::create()->whereAdd(NpdSheet::ID_NPD_SHEET, $sample->getIdNpdSheet())->count()) { $npd = NpdSheetQuery::create()->findByPK($sample->getIdNpdSheet()); } else { $npd = new NpdSheet(); } if (ColorQuery::create()->whereAdd(Color::ID_COLOR, $sample->getIdColor())->count()) { $color = ColorQuery::create()->findByPK($sample->getIdColor()); } else { $color = new Color(); $color->setName('Any'); } $rowHeight = 0; $x = $this->GetX(); $y = $this->GetY(); $this->MultiCell(25, $height, $npd->getIdNpdSheet(), $borders, 'R', $fill, 0); $x += 25; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(30, $height, $npd->getName(), $borders, 'R', $fill, 0); $x += 30; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(20, $height, $sample->getIdSupplier(), $borders, 'R', $fill); $x += 20; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(25, $height, $color->getName(), $borders, 'R', $fill); $x += 25; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(25, $height, $sample->getQuantity(), $borders, 'R', $fill); $x += 25; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(35, $height, "\$" . number_format($sample->getCost(), 4) . $npd->getIdCurrency(), $borders, 'R', $fill); $x += 35; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->MultiCell(30, $height, "\$" . number_format($sample->getTotalAmmount(), 4) . $npd->getIdCurrency(), $borders, 'R', $fill); $x += 30; $y2 = $this->GetY(); $this->SetXY($x, $y); $currentCellHeight = $y2 - $y; if ($rowHeight < $currentCellHeight) { $rowHeight = $currentCellHeight; } $this->Ln($rowHeight); } $this->samples->rewind(); $this->Cell(25, $height, ' ', 'TB', 0, 'C', $fill); $this->Cell(25, $height, '', 'TB', 0, 'L', $fill); $this->Cell(25, $height, '', 'TB', 0, 'R', $fill); $this->Cell(25, $height, '', 'TB', 0, 'R', $fill); $this->Cell(25, $height, '', 'TB', 0, 'R', $fill); $this->Cell(35, $height, 'Total', 'TB', 0, 'R', $fill); $this->Cell(30, $height, "\$" . number_format($this->samples->getTotalAmmount(), 4) . $npd->getIdCurrency(), 'TB', 0, 'R', $fill); $this->Ln(); }