Ejemplo n.º 1
0
 public function addProcurements()
 {
     $data = $this->form_values;
     //  App_Controller_Functions::pr($data);
     $shipments = new Shipments();
     $shipmentHistory = new ShipmentHistory();
     $shipments->setReferenceNumber($data['transaction_reference']);
     $item_id = $this->_em->getRepository('ItemPackSizes')->find($data['item_id']);
     $shipments->setItemPackSize($item_id);
     $shipments->setShipmentDate(new \DateTime(App_Controller_Functions::dateToDbFormat($data['shipment_date'])));
     $shipments->setShipmentQuantity($data['quantity']);
     $funding_source_id = $this->_em->getRepository('Warehouses')->find($data['from_warehouse_id']);
     $shipments->setFundingSource($funding_source_id);
     $activity_id = $this->_em->getRepository('StakeholderActivities')->find($data['activity_id']);
     $shipments->setStakeholderActivity($activity_id);
     $warhouse_id = $this->_em->getRepository('Warehouses')->find($this->_identity->getWarehouseId());
     $shipments->setWarehouse($warhouse_id);
     $shipments->setCreatedDate(new \DateTime(date("Y-m-d")));
     $created_by = $this->_em->getRepository('Users')->find($this->_user_id);
     $shipments->setCreatedBy($created_by);
     $this->_em->persist($shipments);
     $this->_em->flush();
     $id = $shipments->getPkId();
     $shipment_id = $this->_em->getRepository('Shipments')->find($id);
     $shipmentHistory->setShipment($shipment_id);
     $shipmentHistory->setStatus($data['status']);
     $shipmentHistory->setReferenceNumber($data['transaction_reference']);
     $shipmentHistory->setCreatedDate(new \DateTime(date("Y-m-d")));
     $created_by = $this->_em->getRepository('Users')->find($this->_user_id);
     $shipmentHistory->setCreatedBy($created_by);
     $this->_em->persist($shipmentHistory);
     $this->_em->flush();
     $shipment_history_id = $shipmentHistory->getPkId();
     return $shipment_history_id;
 }