/** * This function is used to save a record in log table. * @param Integer $menuID = id of menu name * @param Integer $actionflag = flag represents add,update,delete * @param Integer $loginUserId = id of logged user * @param Integer $recordId = id of changed record * @param String $childrecordId = if any child record exists it will concatenate as string * @param Array $defined_str = this is mainly used for employees/users active & inactive actions * @return Integer Id of saved record in log table. */ public static function logManager($menuID, $actionflag, $loginUserId, $recordId, $childrecordId = '', $defined_str = '') { $date = new Zend_Date(); // initializing Zend Date Object $logmanagermodel = new Default_Model_Logmanager(); $jsonlogDataArr = array(); if ($childrecordId != '') { $childrecordArr = explode(',', $childrecordId); for ($i = 0; $i < sizeof($childrecordArr); $i++) { $logarr[$i] = array('userid' => $loginUserId, 'recordid' => $recordId, 'childrecordid' => $childrecordArr[$i], 'date' => gmdate("Y-m-d H:i:s")); } $jsonlogarr = json_encode($logarr); $jsonlogarr = rtrim($jsonlogarr, "]"); $jsonlogarr = ltrim($jsonlogarr, "["); } else { $logarr = array('userid' => $loginUserId, 'recordid' => $recordId, 'date' => gmdate("Y-m-d H:i:s")); $jsonlogarr = json_encode($logarr); // Building Json String of loggedinUser,DatabaseID of UserAction,Date } if (is_array($defined_str) && count($defined_str) > 0) { $logarr = $defined_str; $jsonlogarr = json_encode($logarr); } //Saving Or Updating to DB using On Duplicate Key by setting menuID(ControllerID) and Useraction as Unique Fields In DB $id = $logmanagermodel->addOrUpdateLogManager($menuID, $actionflag, $jsonlogarr, $loginUserId, $recordId); return $id; }
/** * @name empnamewithidautoAction * * This method is used to send json output of employee names with ID for autocomplete field in activity log report * * @author Deepthi * @version 1.0 */ public function empnamewithidautoAction() { $logmanager_model = new Default_Model_Logmanager(); $term = $this->_getParam('term', null); $output = array(array('id' => '', 'value' => 'No records', 'label' => 'No records')); if ($term != '') { $emp_arr = $logmanager_model->getAutoReportEmpnameWithId($term); if (count($emp_arr) > 0) { $output = array(); foreach ($emp_arr as $emp) { $output[] = array('id' => $emp['id'], 'value' => $emp['emp_name'], 'label' => $emp['emp_name'], 'profile_img' => $emp['profileimg']); } } } $this->_helper->json($output); }
/** * This action is used to save update json in logmanager(removes 30 days before content and saves in logmanagercron) . */ public function logcronAction() { $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout()->disableLayout(); $logmanager_model = new Default_Model_Logmanager(); $logmanagercron_model = new Default_Model_Logmanagercron(); $logData = $logmanager_model->getLogManagerData(); $i = 0; if (count($logData) > 0) { foreach ($logData as $record) { if (isset($record['log_details']) && !empty($record['log_details'])) { $id = $record['id']; $menuId = $record['menuId']; $actionflag = $record['user_action']; $userid = $record['last_modifiedby']; $keyflag = $record['key_flag']; $date = $record['last_modifieddate']; $jsondetails = '{"testjson":[' . $record['log_details'] . ']}'; $jsonarr = @get_object_vars(json_decode($jsondetails)); $mainTableJson = ''; $cronTableJson = ''; if (!empty($jsonarr)) { $mainJsonArrayCount = count($jsonarr['testjson']); foreach ($jsonarr['testjson'] as $key => $json) { $jsonVal = @get_object_vars($json); if (!empty($jsonVal)) { $jsondate = explode(' ', $jsonVal['date']); $datetime1 = new DateTime($jsondate[0]); $datetime2 = new DateTime(); $interval = $datetime1->diff($datetime2); $interval = $interval->format('%a'); if ($interval > 30) { if ($cronTableJson == '') { $cronTableJson .= json_encode($jsonVal); } else { $cronTableJson .= ',' . json_encode($jsonVal); } if (isset($jsonVal['recordid']) && $jsonVal['recordid'] != '') { $keyflag = $jsonVal['recordid']; } } else { if ($mainTableJson == '') { $mainTableJson .= json_encode($jsonVal); } else { $mainTableJson .= ',' . json_encode($jsonVal); } } } if ($mainJsonArrayCount - 1 == $key) { // if all are greater than 30 days if ($mainTableJson == '') { $mainTableJson .= json_encode($jsonVal); } } } try { if ($cronTableJson != '' && $mainTableJson != '') { $result = $logmanager_model->UpdateLogManagerWhileCron($id, $mainTableJson); if ($result) { $InsertId = $logmanagercron_model->InsertLogManagerCron($menuId, $actionflag, $cronTableJson, $userid, $keyflag, $date); } $i++; } } catch (Exception $e) { echo $e->getMessage(); exit; } } } } } }
/** * This function is used to active/inactive employees. */ public function makeactiveinactiveAction() { Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $emp_id = $this->_getParam('emp_id', null); $status = trim($this->_getParam('status', null)); $hasteam = trim($this->_getParam('hasteam', null)); $employeeModal = new Default_Model_Employee(); $user_model = new Default_Model_Usermanagement(); $usermodel = new Default_Model_Users(); $role_model = new Default_Model_Roles(); $logmanagermodel = new Default_Model_Logmanager(); $menumodel = new Default_Model_Menu(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $empData = $employeeModal->getsingleEmployeeData($emp_id); if ($hasteam == 'true') { $employessunderEmpId = array(); $reportingmanagersList = array(); $employessunderEmpId = $employeeModal->getEmployeesUnderRM($emp_id); if ($empData[0]['is_orghead'] == 1) { $reportingmanagersList = $usermodel->getReportingManagerList_employees('', '', MANAGEMENT_GROUP); } else { $role_data = $role_model->getRoleDataById($empData[0]['emprole']); $reportingmanagersList = $usermodel->getReportingManagerList_employees($empData[0]['department_id'], $emp_id, $role_data['group_id']); } $reportingmanagersList = sapp_Global::removeElementWithValue($reportingmanagersList, 'id', $emp_id); $this->view->emp_id = $emp_id; $this->view->status = $status; $this->view->ishead = $empData[0]['is_orghead']; $this->view->empName = $empData[0]['userfullname']; $this->view->employessunderEmpId = $employessunderEmpId; $this->view->reportingmanagersList = $reportingmanagersList; } else { $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { if ($status == 'active') { $data = array('isactive' => 1, 'emptemplock' => 0); $empdata = array('isactive' => 1); $logarr = array('userid' => $loginUserId, 'recordid' => $emp_id, 'date' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); $jsonlogarr = json_encode($logarr); } else { if ($status == 'inactive') { $data = array('isactive' => 0, 'emptemplock' => 1); $empdata = array('isactive' => 0); $logarr = array('userid' => $loginUserId, 'recordid' => $emp_id, 'date' => gmdate("Y-m-d H:i:s"), 'isactive' => 0); $jsonlogarr = json_encode($logarr); } } $where = "id = " . $emp_id; $user_model->SaveorUpdateUserData($data, $where); $employeeModal->SaveorUpdateEmployeeData($empdata, "user_id =" . $emp_id); if ($empData[0]['is_orghead'] == '1') { $headData = array('is_orghead' => 0); $headWhere = "user_id = " . $emp_id; $employeeModal->SaveorUpdateEmployeeData($headData, $headWhere); } $menuidArr = $menumodel->getMenuObjID('/employee'); $menuID = $menuidArr[0]['id']; $id = $logmanagermodel->addOrUpdateLogManager($menuID, 4, $jsonlogarr, $loginUserId, $emp_id); $db->commit(); $result = 'update'; } catch (Exception $e) { $db->rollBack(); $result = 'failed'; } $this->_helper->json(array('result' => $result == 'update' ? "yes" : "no")); } }
public function activitylogreportAction() { try { $activitylog_model = new Default_Model_Activitylog(); $logmanager_model = new Default_Model_Logmanager(); $dashboardcall = $this->_getParam('dashboardcall'); if ($dashboardcall == 'Yes') { $perPage = DASHBOARD_PERPAGE; } else { $perPage = PERPAGE; } $selectFields = array('menuname' => 'Menu', 'username' => 'User Name', 'empId' => 'Employee ID', 'useraction' => 'Action', 'modifieddate' => 'Modified Date'); $selectColumns = array_keys($selectFields); $action = array('1' => 'Add', '2' => 'Edit', '3' => 'Delete', '5' => 'Cancel'); $activityLogData = array(); $splitArray = array(); $pageNo = 1; $order = $funorder = 'Desc'; $by = $sortby = 'last_modifieddate'; $searchData = ''; $lastpage = 0; if ($this->getRequest()->getPost()) { $this->_helper->layout->disableLayout(); } if ($this->_request->getParam('pageNo') != '') { $pageNo = intval($this->_request->getParam('pageNo')); } if ($this->_request->getParam('per_page') != '') { $perPage = intval($this->_request->getParam('per_page')); } if ($this->_request->getParam('fields') != '') { $selectColumns = explode(',', $this->_request->getParam('fields')); } $finalArray = array(); //POST with empty search fields if ($this->_request->getParam('hiddenusername') == '' && $this->_request->getParam('menu') == '' && $this->_request->getParam('useraction') == '' && $this->_request->getParam('modifieddate') == '') { if ($this->_request->getParam('sortby') != '') { $by = $sortby = $this->_request->getParam('sortby'); $order = $funorder = $this->_request->getParam('order'); if ($sortby == 'userfullname') { $by = ''; $usernameorder = $logmanager_model->getUsernameOrderForLog($order); if (!empty($usernameorder)) { $funorder = 'FIND_IN_SET(last_modifiedby,"' . $usernameorder . '")'; } } if ($sortby == 'employeeId') { $by = ''; $empidorder = $logmanager_model->getEmpidOrderForLog($order); if (!empty($empidorder)) { $funorder = 'FIND_IN_SET(last_modifiedby,"' . $empidorder . '")'; } } if ($sortby == 'menuname') { $by = ''; $menunameorder = $logmanager_model->getMenuOrderForLog($order); if (!empty($menunameorder)) { $funorder = 'FIND_IN_SET(menuId,"' . $menunameorder . '")'; } } } $activityLogData = $logmanager_model->getLogManagerDataReport($by, $funorder, $pageNo, $perPage, $searchData, array('*')); $activityLogCount = $activitylog_model->getLogManagerCount(); $menuArray = array(); $userArray = array(); if (count($activityLogData) > 0) { $lastpage = ceil($activityLogCount / $perPage); foreach ($activityLogData as $activitylog) { if (isset($activitylog['menuId'])) { if (!in_array($activitylog['menuId'], $menuArray)) { array_push($menuArray, $activitylog['menuId']); } } if (isset($activitylog['last_modifiedby'])) { if (!in_array($activitylog['last_modifiedby'], $userArray)) { array_push($userArray, $activitylog['last_modifiedby']); } } } } $menuNameArray = $activitylog_model->getMenuNamesByIds($menuArray); $userNameArray = $activitylog_model->getuserNamesByIds($userArray); if (count($activityLogData) > 0) { foreach ($activityLogData as $key => $activitylog) { if (in_array('menuname', $selectColumns)) { $finalArray[$key]['menuname'] = isset($menuNameArray[$activitylog['menuId']]) ? $menuNameArray[$activitylog['menuId']]['name'] : ''; } if (in_array('username', $selectColumns)) { $finalArray[$key]['username'] = isset($userNameArray[$activitylog['last_modifiedby']]) ? $userNameArray[$activitylog['last_modifiedby']]['userfullname'] : ''; } if (in_array('empId', $selectColumns)) { $finalArray[$key]['empId'] = isset($userNameArray[$activitylog['last_modifiedby']]) ? $userNameArray[$activitylog['last_modifiedby']]['employeeId'] : ''; } if (in_array('useraction', $selectColumns)) { $finalArray[$key]['useraction'] = $action[$activitylog['user_action']]; } if (in_array('modifieddate', $selectColumns)) { $finalArray[$key]['modifieddate'] = sapp_Global::getDisplayDate($activitylog['last_modifieddate']); } } } } else { // with search values from form $searchQuery = ''; if ($this->_request->getParam('menu') != '') { $searchQuery .= ' menuId =' . intval($this->_request->getParam('menu')) . ' AND'; } if ($this->_request->getParam('useraction') != '') { $searchQuery .= ' user_action =' . intval($this->_request->getParam('useraction')) . ' AND'; } if ($this->_request->getParam('hiddenusername') != '') { $username = $this->_request->getParam('hiddenusername'); //userid in request $searchQuery .= ' log_details Like \'%"userid":"' . $username . '"%\' AND'; } if ($this->_request->getParam('modifieddate') != '') { $date = sapp_Global::change_date($this->_request->getParam('modifieddate'), 'database'); $date1 = str_replace('-', '/', $date); $onedayafter = date('Y-m-d', strtotime($date1 . "+1 days")); $onedaybefore = date('Y-m-d', strtotime($date1 . "-1 days")); $searchQuery .= '(log_details Like "%' . $onedaybefore . '%" or log_details Like "%' . $date . '%" or log_details Like "%' . $onedayafter . '%")'; } if ($searchQuery != '') { $searchQuery = rtrim($searchQuery, " AND"); } $activityLogData = $logmanager_model->getLogManagerDataReport('last_modifieddate', 'Desc', '', '', $searchQuery, array('*')); /*looping jsonlogs */ if (count($activityLogData) > 0) { $userArray = array(); $menuArray = array(); $logJsonArray = array(); $jsonCount = 0; $index = 0; foreach ($activityLogData as $activitylog) { $logdetails = '{"testjson":[' . $activitylog['log_details'] . ']}'; $logarr = @get_object_vars(json_decode($logdetails)); if (!empty($logarr)) { $logarr['testjson'] = array_reverse($logarr['testjson']); $jsonCount = count($logarr['testjson']); } if ($jsonCount > 0 && isset($logarr['testjson']) && !empty($logarr['testjson'])) { foreach ($logarr['testjson'] as $key => $curr) { $currArray = @get_object_vars($curr); /*userid and date check with form and json values*/ $flag = false; if ($this->_request->getParam('modifieddate') != '') { $currArrayTemp = sapp_Global::getGMTformatdate($currArray['date']); $pos = strpos($currArrayTemp, $date); $flag = $pos !== false ? false : true; } if ($this->_request->getParam('hiddenusername') != '' && $username != $currArray['userid'] || $flag) { continue; } /*end userid and date check*/ $logJsonArray[$index]['userid'] = $currArray['userid'] != '' ? $currArray['userid'] : 1; $logJsonArray[$index]['date'] = $currArray['date']; $datesort[$index] = $currArray['date']; // to sort by date if (!in_array($currArray['userid'], $userArray)) { array_push($userArray, $currArray['userid']); } if (isset($activitylog['menuId'])) { if (!in_array($activitylog['menuId'], $menuArray)) { array_push($menuArray, $activitylog['menuId']); } } $logJsonArray[$index]['menu'] = $activitylog['menuId']; $logJsonArray[$index]['action'] = $action[(string) $activitylog['user_action']]; $actionsort[$index] = $action[(string) $activitylog['user_action']]; $index++; } } } $menuNameArray = $activitylog_model->getMenuNamesByIds($menuArray); $userNameArray = $activitylog_model->getuserNamesByIds($userArray); $lastpage = ceil(count($logJsonArray) / $perPage); $endIndex = intval($perPage); if ($pageNo != 1) { $startIndex = (intval($pageNo) - 1) * intval($perPage); } else { $startIndex = 0; } if (count($logJsonArray) > 0) { if ($this->_request->getParam('sortby') != '') { $sortby = $this->_request->getParam('sortby'); $order = $this->_request->getParam('order'); $orderby = $order == 'asc' ? SORT_ASC : SORT_DESC; if ($sortby == 'user_action' || $sortby == 'last_modifieddate') { // can sort by logJsonArray if ($sortby == 'user_action') { array_multisort($actionsort, $orderby, $logJsonArray); } if ($sortby == 'last_modifieddate') { array_multisort($datesort, $orderby, $logJsonArray); } /* only perpage no of rows */ $splitArray = array_slice($logJsonArray, $startIndex, $endIndex); foreach ($splitArray as $key => $logjson) { if (in_array('menuname', $selectColumns)) { $finalArray[$key]['menuname'] = isset($menuNameArray[(string) $logjson['menu']]) ? $menuNameArray[(string) $logjson['menu']]['name'] : ''; } if (in_array('username', $selectColumns)) { $finalArray[$key]['username'] = isset($userNameArray[(string) $logjson['userid']]) ? $userNameArray[(string) $logjson['userid']]['userfullname'] : ''; } if (in_array('empId', $selectColumns)) { $finalArray[$key]['empId'] = isset($userNameArray[(string) $logjson['userid']]) ? $userNameArray[(string) $logjson['userid']]['employeeId'] : ''; } if (in_array('useraction', $selectColumns)) { $finalArray[$key]['useraction'] = $logjson['action']; } if (in_array('modifieddate', $selectColumns)) { $finalArray[$key]['modifieddate'] = sapp_Global::getDisplayDate($logjson['date']); } } } else { $totalArray = array(); foreach ($logJsonArray as $key => $logjson) { if (in_array('menuname', $selectColumns)) { $totalArray[$key]['menuname'] = isset($menuNameArray[(string) $logjson['menu']]) ? $menuNameArray[(string) $logjson['menu']]['name'] : ''; } $menunameSort[$key] = $totalArray[$key]['menuname']; if (in_array('username', $selectColumns)) { $totalArray[$key]['username'] = isset($userNameArray[(string) $logjson['userid']]) ? $userNameArray[(string) $logjson['userid']]['userfullname'] : ''; } $usernameSort[$key] = $totalArray[$key]['username']; if (in_array('empId', $selectColumns)) { $totalArray[$key]['empId'] = isset($userNameArray[(string) $logjson['userid']]) ? $userNameArray[(string) $logjson['userid']]['employeeId'] : ''; } $empIdSort[$key] = $totalArray[$key]['empId']; if (in_array('useraction', $selectColumns)) { $totalArray[$key]['useraction'] = $logjson['action']; } if (in_array('modifieddate', $selectColumns)) { $totalArray[$key]['modifieddate'] = sapp_Global::getDisplayDate($logjson['date']); } } if ($sortby == 'userfullname') { array_multisort($usernameSort, $orderby, $totalArray); } if ($sortby == 'employeeId') { array_multisort($empIdSort, $orderby, $totalArray); } if ($sortby == 'menuname') { array_multisort($menunameSort, $orderby, $totalArray); } /* only perpage no of rows */ if (count($totalArray) >= intval($perPage)) { $finalArray = array_slice($totalArray, $startIndex, $endIndex); } else { $finalArray = $totalArray; } } } } } } if ($this->getRequest()->getPost()) { // To generate PDF START if ($this->_request->getParam('generatereport') == 'pdf') { $this->generateActivityLogPdf($finalArray, $selectColumns); } } if ($this->_request->getParam('generatereport') == 'xcel') { //xcel generation foreach ($selectFields as $key => $val) { foreach ($selectColumns as $column) { if ($column == $key) { $selectColumnLabels[$key] = $val; } } } sapp_Global::export_to_excel($finalArray, $selectColumnLabels, 'Activitylog Report.xlsx'); exit; } $activitylogreport_form = new Default_Form_activitylogreport(); $this->view->form = $activitylogreport_form; $this->view->totalselectfields = $selectFields; $this->view->tabkeys = implode(',', $selectColumns); $this->view->activitylogData = $finalArray; $this->view->pageNo = $pageNo; $this->view->perPage = $perPage; $this->view->sortBy = $sortby; $this->view->order = $order; $this->view->lastPageNo = $lastpage; } catch (Exception $e) { echo $e->getMessage(); } }
/** * This function is used to add/update data in database. * @param $user_form = all form data. * * @return JSON success/error messages in json format. */ public function saveupdateAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $agencylistmodel = new Default_Model_Agencylist(); $user_form = new Default_Form_Usermanagement(); $user_model = new Default_Model_Usermanagement(); $logmanagermodel = new Default_Model_Logmanager(); $menumodel = new Default_Model_Menu(); $messages = $user_form->getMessages(); $actionflag = ''; $tableid = ''; $agencyuser = '******'; if ($this->getRequest()->getPost()) { if ($user_form->isValid($this->_request->getPost())) { $id = $this->_request->getParam('id'); $employeeId = $this->_request->getParam('employeeId', null); //$userfullname = $this->_request->getParam('userfullname',null); $firstname = $this->_request->getParam('firstname', null); $lastname = $this->_request->getParam('lastname', null); $userfullname = $firstname . ' ' . $lastname; $entrycomments = $this->_request->getParam("entrycomments", null); $emailaddress = $this->_request->getParam("emailaddress", null); $emprole = $this->_request->getParam("emprole", null); $emplockeddate = $this->_request->getParam("emplockeddate", null); $act_inact = $this->_request->getParam("act_inact", null); $empreasonlocked = $this->_request->getParam("empreasonlocked", null); $emppassword = sapp_Global::generatePassword(); $data = array('emprole' => $emprole, 'firstname' => $firstname, 'lastname' => $lastname, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'entrycomments' => $entrycomments, 'userstatus' => 'old'); if ($emplockeddate == '') { unset($data['emplockeddate']); } if ($id != '') { if ($act_inact != '') { $data['isactive'] = $act_inact; $data['emptemplock'] = $act_inact == 0 ? "1" : "0"; $agencyroles = $agencylistmodel->getagencyrole(); $userData = $user_model->getUserDataById($id); $agencyuser = ''; $user_role = $userData['emprole']; foreach ($agencyroles as $agrole) { if ($agrole['id'] == $user_role) { $agencyuser = '******'; } } if ($agencyuser == 'yes') { $agencyData = $user_model->getAgencyData($id); if ($act_inact == '1') { $user_model->activateAllagencydetails($agencyData['agencyid'], $loginUserId); if ($agencyData['isactive'] != $act_inact) { $this->sendEMails($agencyData, 'activated'); } } else { $user_model->deleteAllagencydetails($agencyData['agencyid'], $loginUserId); if ($agencyData['isactive'] != $act_inact) { $this->sendEMails($agencyData, 'inactivated'); } } } } $where = array('id=?' => $id); unset($data['emppassword']); $messages['message'] = 'User updated successfully.'; $_SESSION['usermanagement_msg'] = $messages['message']; $actionflag = 2; } else { $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $messages['message'] = 'User added successfully.'; $_SESSION['usermanagement_msg'] = $messages['message']; $actionflag = 1; } $Id = $user_model->SaveorUpdateUserData($data, $where); if ($Id == 'update') { $tableid = $id; } else { $employeeId = $employeeId . str_pad($Id, 4, '0', STR_PAD_LEFT); $user_model->SaveorUpdateUserData(array('employeeId' => $employeeId), "id = " . $Id); $tableid = $Id; $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $userfullname; $this->view->password = $emppassword; $this->view->emp_id = $employeeId; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/newpassword.phtml'); $options['subject'] = APPLICATION_NAME . ' login credentials'; $options['header'] = 'Greetings from Sentrifugo'; $options['toEmail'] = $emailaddress; $options['toName'] = $this->view->emp_name; $options['message'] = $text; try { $result = sapp_Global::_sendEmail($options); } catch (Exception $e) { echo $e->getMessage(); } } $objidArr = $menumodel->getMenuObjID('/usermanagement'); $objID = $objidArr[0]['id']; $result = sapp_Global::logManager($objID, $actionflag, $loginUserId, $tableid); if ($act_inact != '') { if ($data['isactive'] == 1) { $logarr = array('userid' => $loginUserId, 'recordid' => $tableid, 'date' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); $jsonlogarr = json_encode($logarr); } else { $logarr = array('userid' => $loginUserId, 'recordid' => $tableid, 'date' => gmdate("Y-m-d H:i:s"), 'isactive' => 0); $jsonlogarr = json_encode($logarr); } $id = $logmanagermodel->addOrUpdateLogManager($objID, 4, $jsonlogarr, $loginUserId, $tableid); } $messages['result'] = 'saved'; $this->_helper->json($messages); } else { $messages = $user_form->getMessages(); $messages['result'] = 'error'; $this->_helper->json($messages); } } }