コード例 #1
0
ファイル: LogsController.php プロジェクト: valizr/MMA
 public function indexAction()
 {
     $params = array();
     $modul = $this->getRequest()->getParam('modul');
     $action = $this->getRequest()->getParam('actionType');
     $data_inceput = $this->getRequest()->getParam('data_inceput');
     $data_sfarsit = $this->getRequest()->getParam('data_sfarsit');
     //form cautare dupa modul/tip de actiune/data
     $form = new Default_Form_SearchLogs();
     $form->modul->setValue($modul);
     $form->actionType->setValue($action);
     $form->data_inceput->setValue($data_inceput);
     $form->data_sfarsit->setValue($data_sfarsit);
     $form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/logs/search.phtml'))));
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $post = $this->getRequest()->getPost();
             $model = new Default_Model_Logs();
             $model->setOptions($form->getValues());
         }
     }
     //end form
     //fetch loguri
     $logs = new Default_Model_Logs();
     $select = $logs->getMapper()->getDbTable()->select();
     if (!empty($action)) {
         $params['actionType'] = $action;
         $select->where('actionType = ?', $action);
     }
     if (!empty($modul)) {
         $params['modul'] = $modul;
         $select->where('modul = ?', $modul);
     }
     if (!empty($data_inceput)) {
         $params['data_inceput'] = $data_inceput;
         $select->where("DATE(created) >= ?", $data_inceput);
     }
     if (!empty($data_sfarsit)) {
         $params['data_sfarsit'] = $data_sfarsit;
         $select->where("DATE(created) <= ?", $data_sfarsit);
     }
     $select->order('created DESC');
     $result = $logs->fetchAll($select);
     if (NULL != $result) {
         $paginator = Zend_Paginator::factory($result);
         $paginator->setItemCountPerPage(10);
         $paginator->setCurrentPageNumber($this->_getParam('page'));
         $paginator->setPageRange(5);
         $this->view->result = $paginator;
         $this->view->itemCountPerPage = $paginator->getItemCountPerPage();
         $this->view->totalItemCount = $paginator->getTotalItemCount();
         Zend_Paginator::setDefaultScrollingStyle('Sliding');
         Zend_View_Helper_PaginationControl::setDefaultViewPartial(array('_pagination.phtml', $params));
     }
 }
コード例 #2
0
ファイル: SearchLogs.php プロジェクト: valizr/MMA
 function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setAction(WEBROOT . 'logs');
     $this->addAttribs(array('id' => 'searchLogs', 'class' => ''));
     $this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
     //BEGIN:Module
     $id = new Zend_Form_Element_Select('modul');
     $options = array('' => 'Selectati modulul');
     $module = new Default_Model_Logs();
     $select = $module->getMapper()->getDbTable()->select()->group('modul')->order('created DESC');
     $result = $module->fetchAll($select);
     if (NULL != $result) {
         foreach ($result as $value) {
             $options[$value->getModul()] = $value->getModul();
         }
     }
     $id->addMultiOptions($options);
     $this->addElement($id);
     //END:Module
     //BEGIN:ActionType
     $id = new Zend_Form_Element_Select('actionType');
     $options = array('' => 'Selectati tipul actiunii');
     $module = new Default_Model_Logs();
     $select = $module->getMapper()->getDbTable()->select()->group('actionType')->order('created DESC');
     $result = $module->fetchAll($select);
     if (NULL != $result) {
         foreach ($result as $value) {
             $options[$value->getActionType()] = $value->getActionType();
         }
     }
     $id->addMultiOptions($options);
     $this->addElement($id);
     //END:ActionType
     // BEGIN: data
     $data_inceput = new Zend_Form_Element_Text('data_inceput');
     $data_inceput->setAttribs(array('class' => 'data_inceput', 'placeholder' => 'Data inceput'));
     $this->addElement($data_inceput);
     $data_sfarsit = new Zend_Form_Element_Text('data_sfarsit');
     $data_sfarsit->setAttribs(array('class' => 'data_sfarsit', 'placeholder' => 'Data sfarsit'));
     $this->addElement($data_sfarsit);
     // END: data
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setValue('Cauta');
     $submit->setAttribs(array('class' => 'submit'));
     $submit->setIgnore(true);
     $this->addElement($submit);
 }
コード例 #3
0
ファイル: Logs.php プロジェクト: valizr/MMA
 /**
  * Face scriere in baza de date la o actiune de tip tracking
  * 
  * @param int $userId	Id-ul userului care a facut actiunea
  * @param string $modul		Modulul in care s-a facut actiunea
  * @param string $actionType	Tipul actiunii
  * @param string $actionDone	Text ce arata ce s-a modificat, obligatoriu sa contina tag-ul @userId@, optional @targetId@
  * @param int $targetId		Id-ul persoanei,obiectului asupra care s-a facut modificarea
  */
 public function DbLogTracking($userId, $targetId, $modul, $actionType, $actionDone)
 {
     $logs = new Default_Model_Logs();
     $logs->setIdUser($userId);
     $logs->setIdTarget($targetId);
     $logs->setModul($modul);
     $logs->setActionType($actionType);
     $logs->setActionDone($actionDone);
     $id = $logs->save();
     return $id;
 }
コード例 #4
0
ファイル: Logs.php プロジェクト: valizr/MMA
 public function save(Default_Model_Logs $value)
 {
     $data = array('id' => $value->getId(), 'idUser' => $value->getIdUser(), 'idTarget' => $value->getIdTarget(), 'modul' => $value->getModul(), 'actionType' => $value->getActionType(), 'actionDone' => $value->getActionDone());
     if (null === ($id = $value->getId())) {
         $data['created'] = new Zend_Db_Expr('NOW()');
         $id = $this->getDbTable()->insert($data);
     }
     return $id;
 }