public function ajaxCheckLogbookNameAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $name = $this->_request->name; $fname = $this->_request->fname; $do = $this->_request->do; $log_book = new Model_LogBook(); $log_book->form_values = array('name' => $name, 'fname' => $fname, 'do' => $do); return $log_book->checkLogbookName(); }
public function lastLog3months2() { $wh_Id = $this->form_values['wh_id']; $loc_Id = $this->form_values['loc_id']; $last_report_date = $this->getLogLastReportDate2(); $last_3months = $this->getLogLast3Months2(); //$last_3months = array_reverse($last_3months); for ($i = 0; $i < sizeof($last_3months); $i++) { $L3M_dt = new DateTime($last_3months[$i]['MaxDate']); $dataMonthArr[] = $L3M_dt->format('Y-m-d'); } // // if (isset($dataMonthArr)) { // foreach ($dataMonthArr as $mon) { // //$mon = $date->format( "Y-m-d" ); // $L3M_dt = new DateTime($mon); // $do3Months = "Z" . base64_encode($wh_Id . '|' . $mon . '|0'); // $rows = $this->_em->getRepository('LogBook')->findBy(array('warehouse' => $wh_Id, 'vaccinationDate' => $L3M_dt->format("Y-m-d"))); // if (count($rows) > 0) { // $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs green'>" . $L3M_dt->format('M-y') . "</a>"; // } else { // $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs green'>" . $L3M_dt->format('M-y') . "</a>"; // } // } // $months = array_reverse($months); // } // // $L3M_dt = new DateTime(); // // $curr_date = date("Y-m-d"); // /// echo $curr_date; // echo $L3M_dt->format('Y-m'); // echo substr($last_report_date, 0, 7); // exit; // // if (substr($last_report_date, 0, 7) < $L3M_dt->format('Y-m')) { // $L3M_dt = new DateTime($last_report_date . "-01"); // $L3M_dt->modify("+1 month"); // // // Check if exist in draft // $rows = $this->_em->getRepository('LogBook')->findBy(array('warehouse' => $wh_Id, 'vaccinationDate' => $L3M_dt->format("Y-m-d"))); // if (count($rows) > 0) { // $do3Months = "Z" . base64_encode($wh_Id . '|' . $L3M_dt->format("Y-m-d") . '|0'); // It should be 0 in case of new report as well // $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs blue' >Add " . $L3M_dt->format('M-y') . " </a>"; // } else { // $do3Months = "Z" . base64_encode($wh_Id . '|' . $L3M_dt->format("Y-m-d") . '|1'); // $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs blue' >Add " . $L3M_dt->format('M-y') . " </a>"; // } // } // echo implode('', $months); $end_date = date('Y') . '-' . date('m') . '-01'; //exit; $end_date = date('Y-m-d', strtotime("-1 days", strtotime("+1 month", strtotime($end_date)))); // $start_date = date('Y-m-d', strtotime("-364 days", strtotime($end_date))); $start_date = '2015-05-01'; // Start date and End date $begin = new DateTime($start_date); $end = new DateTime($end_date); $diff = $begin->diff($end); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($begin, $interval, $end); foreach ($period as $date) { //echo $log_book = new Model_LogBook(); $rows = $log_book->getLogBook($wh_Id, $date->format("Y-m")); if (count($rows) > 0) { // echo $wh_Id; // echo $date->format("Y-m-d"); $do3Months = "Z" . base64_encode($wh_Id . '|' . $date->format("Y-m-d") . '|0'); $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs green'>" . $date->format('M-y') . "</a>"; } else { // echo $wh_Id; // echo $date->format("Y-m-d"); $do3Months = "Z" . base64_encode($wh_Id . '|' . $date->format("Y-m-d") . '|1'); $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs blue' >Add " . $date->format('M-y') . " </a>"; } // $str_date = $date->format("Y-m"); } echo implode('', $months); }
public function lastLog3months2() { $wh_Id = $this->form_values['wh_id']; $loc_Id = $this->form_values['loc_id']; $last_report_date = $this->getLogLastReportDate2(); $last_3months = $this->getLogLast3Months2(); //$last_3months = array_reverse($last_3months); for ($i = 0; $i < sizeof($last_3months); $i++) { $L3M_dt = new DateTime($last_3months[$i]['MaxDate']); $dataMonthArr[] = $L3M_dt->format('Y-m-d'); } $end_date = date('Y') . '-' . date('m') . '-01'; $end_date = date('Y-m-d', strtotime("-1 days", strtotime("+1 month", strtotime($end_date)))); $start_date = '2015-05-01'; // Start date and End date $begin = new DateTime($start_date); $end = new DateTime($end_date); $diff = $begin->diff($end); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($begin, $interval, $end); foreach ($period as $date) { //echo $log_book = new Model_LogBook(); $rows = $log_book->getLogBook($wh_Id, $date->format("Y-m")); if (count($rows) > 0) { // echo $wh_Id; // echo $date->format("Y-m-d"); $do3Months = "Z" . base64_encode($wh_Id . '|' . $date->format("Y-m-d") . '|0'); $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs green'>" . $date->format('M-y') . "</a>"; } else { // echo $wh_Id; // echo $date->format("Y-m-d"); $do3Months = "Z" . base64_encode($wh_Id . '|' . $date->format("Y-m-d") . '|1'); $months[] = "<a href=log-book-add?do=" . $do3Months . " class='btn btn-xs blue' >Add " . $date->format('M-y') . " </a>"; } // $str_date = $date->format("Y-m"); } echo implode('', $months); }