Example #1
0
 public function addLog()
 {
     $data = $this->form_values;
     // App_Controller_Functions::pr($data);
     $name = $data['name'];
     $father_name = $data['father_name'];
     $age = $data['age'];
     $contact = $data['contact'];
     $address = $data['address'];
     $district = $data['district'];
     $uc = $data['uc'];
     $item_id = $data['item_id'];
     $dose_no = $data['dose_no'];
     $vaccination_date = $data['vaccination_date'];
     $reffers_to = $data['reffers_to'];
     $remarks = $data['remarks'];
     $user_id = $this->_user_id;
     $warehouse_id = $this->_identity->getWarehouseId();
     $date = date("Y-m-d h:i:s");
     foreach ($district as $key => $val) {
         if ($val != '' && $val >= 0) {
             $log_book = new LogBook();
             $log_book->setName($name[$key]);
             $log_book->setFatherName($father_name[$key]);
             $log_book->setAge($age[$key]);
             $log_book->setContact($contact[$key]);
             $log_book->setAddress($address[$key]);
             $districtId = $this->_em->getRepository('Locations')->find($district[$key]);
             $log_book->setDistrictId($districtId);
             $ucId = $this->_em->getRepository('Locations')->find($uc[$key]);
             $log_book->setUnionCouncilId($ucId);
             $log_book->setVaccinationDate(new \DateTime(App_Controller_Functions::dateToDbFormat($vaccination_date[$key])));
             $log_book->setRefferTo($reffers_to[$key]);
             $log_book->setRemarks($remarks[$key]);
             //
             $warehouse = $this->_em->getRepository('Warehouses')->find($warehouse_id);
             $log_book->setWarehouse($warehouse);
             $log_book->setCreatedDate(new \DateTime(App_Controller_Functions::dateToDbFormat($date)));
             $log_book->setCreatedBy($user_id);
             $this->_em->persist($log_book);
             $this->_em->flush();
             $log_book_id = $log_book->getPkId();
             foreach ($item_id as $key => $val) {
                 $log_book_item_doses = new LogBookItemDoses();
                 $logBook = $this->_em->getRepository('LogBook')->find($log_book_id);
                 $log_book_item_doses->setLogBookId($logBook);
                 $itemPack = $this->_em->getRepository('ItemPackSizes')->find($val);
                 $log_book_item_doses->setItemPackSize($itemPack);
                 $log_book_item_doses->setDoses($dose_no[$key]);
                 $this->_em->persist($log_book_item_doses);
                 $this->_em->flush();
             }
         }
     }
 }
Example #2
0
 public function addLogBook()
 {
     $data = $this->form_values;
     $dose_no = $this->form_values['dose_no_of'];
     $temp = $this->form_values['temp'];
     $temp = base64_decode(substr($temp, 1, strlen($temp) - 1));
     $temp = explode("|", $temp);
     $warehouse_id = $temp[0];
     //$loc_id = $temp[1];
     $rpt_date = $temp[1];
     $is_new_rpt = $temp[2];
     $tt = explode("-", $rpt_date);
     $yy = $tt[0];
     $mm = $tt[1];
     $dd = $tt[2];
     $date = date("Y-m-d h:i:s");
     $year_month = $yy . "-" . $mm;
     $vaccination_date = $yy . "-" . $mm . "-" . $this->form_values['day'];
     $user_id = $this->_user_id;
     $log_book = new LogBook();
     $log_book->setName($this->form_values['name']);
     $log_book->setFatherName($this->form_values['father_name']);
     $log_book->setAge($this->form_values['age']);
     $log_book->setGender($this->form_values['gender']);
     $log_book->setContact($this->form_values['contact']);
     $log_book->setAddress($this->form_values['address']);
     //$refer_to_warehouseId = $this->_em->getRepository('Warehouses')->find($this->form_values['refer_to']);
     //$log_book->setReferToWarehouse($refer_to_warehouseId);
     $districtId = $this->_em->getRepository('Locations')->find($this->form_values['district']);
     $log_book->setDistrict($districtId);
     if (!empty($this->form_values['uc'])) {
         $log_book->setUnionCouncilId($this->form_values['uc']);
     }
     $log_book->setVaccinationDate(new \DateTime($vaccination_date));
     //$log_book->setRefferTo(); //warehouseid from session
     $log_book->setRemarks($this->form_values['remarks']);
     $warehouse = $this->_em->getRepository('Warehouses')->find($warehouse_id);
     $log_book->setWarehouse($warehouse);
     $log_book->setCreatedDate(App_Tools_Time::now());
     $log_book->setModifiedDate(App_Tools_Time::now());
     $userId = $this->_em->getRepository('Users')->find($user_id);
     $log_book->setCreatedBy($userId);
     $log_book->setModifiedBy($userId);
     $this->_em->persist($log_book);
     $this->_em->flush();
     $log_book_id = $log_book->getPkId();
     foreach ($dose_no as $prodId => $value) {
         if ($value == "") {
             $value = NULL;
         }
         $log_book_item_doses = new LogBookItemDoses();
         $logBook = $this->_em->getRepository('LogBook')->find($log_book_id);
         $log_book_item_doses->setLogBook($logBook);
         $itemPack = $this->_em->getRepository('ItemPackSizes')->find($prodId);
         $log_book_item_doses->setItemPackSize($itemPack);
         $log_book_item_doses->setDoses($value);
         $user = $this->_em->getRepository('Users')->find($this->_user_id);
         $log_book_item_doses->setModifiedBy($user);
         $log_book_item_doses->setCreatedBy($user);
         $log_book_item_doses->setCreatedDate(App_Tools_Time::now());
         $log_book_item_doses->setModifiedDate(App_Tools_Time::now());
         $this->_em->persist($log_book_item_doses);
         $this->_em->flush();
     }
 }