public function markattendanceAction() { $request = $this->getRequest(); $params = array_diff($request->getParams(), $request->getUserParams()); $this->_helper->viewRenderer->setNoRender(TRUE); $this->_helper->layout()->disableLayout(); foreach ($params as $colName => $value) { $value = is_array($value) ? $value : htmlentities(trim($value)); $this->applicant->{$colName} = $value; } $period_dateobj = new Zend_Date($request->getParam('period_date'), 'dd-MMM-yyyy'); $period_date = $period_dateobj->toString('YYYY-MM-dd HH:mm:ss'); $params['period_date'] = $period_date; $params['weekday_number'] = $period_dateobj->get(Zend_Date::WEEKDAY_DIGIT); $params['faculty_id'] = $this->identity; $model = new Acad_Model_Member_Student(); try { $insertId = $model->setAttendence($params); if ($insertId) { if (!isset($params['absentee'])) { echo "Hey, Nice class!! All are present.\n"; } echo 'Attendance marked successfully with period ID: ' . $insertId . ".\n Kindly note down this Id in case of any mistake."; } else { echo 'Attendance could not be submitted this time. Please try again.'; } } catch (Exception $e) { $this->_helper->logger->debug($e->getMessage()); switch ($e->getCode()) { case 23000: throw new Zend_Exception('Attendance has been already marked.', Zend_Log::ERR); break; default: throw new Zend_Exception('Sorry, unable to process the request', Zend_Log::ERR); break; } } }
public function markattendanceAction() { $request = $this->getRequest(); $params = array_diff($request->getParams(), $request->getUserParams()); $this->_helper->viewRenderer->setNoRender(TRUE); $this->_helper->layout()->disableLayout(); foreach ($params as $colName => $value) { $value = is_array($value) ? $value : htmlentities(trim($value)); $this->applicant->{$colName} = $value; } $period_dateobj = new Zend_Date($request->getParam('period_date'), 'dd-MMM-yyyy'); $period_date = $period_dateobj->toString('YYYY-MM-dd HH:mm:ss'); $params['period_date'] = $period_date; $params['weekday_number'] = $period_dateobj->get(Zend_Date::WEEKDAY_DIGIT); $params['faculty_id'] = $this->identity; $model = new Acad_Model_Member_Student(); try { $insertId = $model->setAttendence($params); echo 'Attendance successfully marked with period ID: ' . $insertId . ".\n Kindly note down this Id in case of any mistake."; } catch (Exception $e) { $this->_helper->logger->debug($e->getMessage()); switch ($e->getCode()) { case 23000: throw new Zend_Exception('Attendance has been already marked.', Zend_Log::ERR); break; default: throw new Zend_Exception('Sorry, unable to process the request', Zend_Log::ERR); break; } } /* echo 'Following information recieved:<br/>'; foreach ($params as $colName => $value) { $value = is_array($value)?var_export($value,true):htmlentities(trim($value)); echo '<b>'.ucwords(str_ireplace('_', ' ', $colName)).'</b> : '.$value.'<br/>'; }*/ }