Example #1
0
 protected function genericSampleNPDNotification(NPDEvent $event, $notificationTypeId, $status)
 {
     $npd = $event->getNPD();
     $sampleObjects = SampleQuery::create()->whereAdd(Sample::ID_NPD_SHEET, $npd->getIdNpdSheet())->whereAdd(Sample::STATUS, $status)->addAscendingOrderBy(Sample::DEADLINE)->find();
     $npdSupplierIds = NpdSheetSupplierQuery::create()->addColumn(NpdSheetSupplier::ID_SUPPLIER)->whereAdd(NpdSheetSupplier::ID_NPD_SHEET, $npd->getIdNpdSheet())->fetchCol();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $npdSupplierIds, SupplierQuery::IN)->find()->toCombo();
     $colors = \Application\Query\ColorQuery::create()->find()->toCombo();
     $samples = array();
     foreach ($sampleObjects as $sample) {
         if (!$sample instanceof Sample) {
             $sample = new Sample();
         }
         $samples[] = array('Supplier' => utf8_decode($suppliers[$sample->getIdSupplier()]), 'Quantity' => $sample->getQuantity(), 'Color' => $colors[$sample->getIdColor()], 'Remarks' => utf8_decode($sample->getNotes()), 'Deadline' => $sample->getDeadline(), 'Cost' => $sample->getCost(), 'ShippedQuantity' => $sample->getShippedQuantity());
     }
     $vars = array('id_npd_sheet' => $npd->getIdNpdSheet(), 'creation_date' => $npd->getCreationDateAsZendDate()->get("dd-MM-yyyy HH:mm"), 'name' => utf8_decode($npd->getName()), 'description' => utf8_decode($npd->getDescription()), 'samples' => $samples);
     $this->createNotification($notificationTypeId, $vars);
 }