public function detailsAction() { $userId = null; $auth = Zend_Auth::getInstance(); $authAccount = $auth->getStorage()->read(); if (null != $authAccount) { if (null != $authAccount->getId()) { $this->view->userlogat = $authAccount; } } $id = (int) $this->getRequest()->getParam('id'); if ($id) { // BEGIN: Find model $model = new Default_Model_RecurrentExpenses(); if ($model->find($id)) { $this->view->result = $model; } $select = $model->getMapper()->getDbTable()->select()->where('NOT deleted')->order(array('created DESC')); $result = $model->fetchAll($select); // END: Find model //START: Adaugare comment $form_comments = new Default_Form_Comments(); $form_comments->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/comments.phtml')))); $this->view->plugin_form_comments = $form_comments; if ($this->getRequest()->isPost()) { $model = new Default_Model_Comments(); $action = $this->getRequest()->getPost('action'); if ($form_comments->isValid($this->getRequest()->getPost())) { $model->setOptions($form_comments->getValues()); $model->setIdProject($id); $saved_comment = $model->save(); if ($saved_comment) { $admins = Needs_Tools::findAdmins(); $adminIds = Needs_Tools::findAdmins('id'); foreach ($adminIds as $adminId) { $emailTemplate = new Default_Model_EmailTemplates(); } $auth = Zend_Auth::getInstance(); $authAccount = $auth->getStorage()->read(); if (null != $authAccount) { if (null != $authAccount->getId()) { $user = new Default_Model_Users(); $user->find($authAccount->getId()); } } $select = $emailTemplate->getMapper()->getDbTable()->select()->where('const = ?', 'adaugare_comentariu_admin')->limit(1); $emailTemplate->fetchRow($select); if (NULL != $emailTemplate->getContent()) { $emailArray = array(); $name = $user->name . ' ' . $user->surname; $message = $emailTemplate->getContent(); $message = str_replace("{" . "\$" . "name}", $name, $message); $notification = new Default_Model_NotificationMessages(); $notification->setIdUser($authAccount->getId()); $notification->setIdProject($id); $notification->setSubject($emailTemplate->getSubject()); $notification->setMessage($message); if ($idNotification = $notification->save()) { $notify = new Default_Model_NotificationTo(); $notify->setIdNotification($idNotification); $notify->setStatus('1'); foreach ($adminIds as $adminId) { $notify->setIdUserTo($adminId); $notify->save(); } } else { $this->_flashMessenger->addMessage("<div class='failure canhide'><p>Notificarile nu au fost salvate cu succes<a href='javascript:;'></a></p></div>"); } $emailArray['subject'] = $emailTemplate->getSubject(); $emailArray['content'] = $message; $emailArray['toEmail'] = $admins; $emailArray['toName'] = $name; $emailArray['fromEmail'] = EMAIL; $emailArray['fromName'] = FROM_NAME; $emailArray['SMTP_USERNAME'] = SMTP_USERNAME; $emailArray['SMTP_PASSWORD'] = SMTP_PASSWORD; $emailArray['SMTP_PORT'] = SMTP_PORT; $emailArray['SMTP_URL'] = SMTP_URL; Needs_Tools::sendEmail($emailArray); } $this->_flashMessenger->addMessage("<div class='success canhide'><p>The comment was added successfully!<a href='javascript:;'></a></p></div>"); } else { $this->_flashMessenger->addMessage("<div class='failure canhide'><p>The comment was not added successfully!<a href='javascript:;'></a></p></div>"); } $this->_redirect(WEBROOT . '/recurrent-expenses/details/id/' . $id); } } //end adaugare comment //$modelc = new Default_Model_Comments(); // $select = $modelc->getMapper()->getDbTable()->select() // ->from(array('c' => 'comment'), array('c.*')) // ->where("NOT c.deleted") // ->where("c.idParent IS NULL") // ->where("c.idProduct=?",$model->getId()) // ->order(array('c.created DESC')); // $resultc = $modelc->fetchAll($select); // // if(NULL != $resultc) // { // $paginator = Zend_Paginator::factory($resultc); // $paginator->setItemCountPerPage(25); // $paginator->setCurrentPageNumber($this->_getParam('page')); // $paginator->setPageRange(5); // $this->view->resultc = $paginator; // $this->view->itemCountPerPage = $paginator->getItemCountPerPage(); // $this->view->totalItemCount = $paginator->getTotalItemCount(); // // Zend_Paginator::setDefaultScrollingStyle('Sliding'); // Zend_View_Helper_PaginationControl::setDefaultViewPartial('_pagination.phtml'); // } } }
public static function notifications($id) { $notification = new Default_Model_NotificationTo(); $select = $notification->getMapper()->getDbTable()->select()->from(array('n' => 'notification_to'), array('n.*'))->where("NOT n.deleted")->where("n.status=?", '1')->where("n.idUserTo=?", $id); $result = $notification->fetchAll($select); $notifications = count($result) != 0 ? count($result) : 0; $notification = new Default_Model_NotificationMessages(); $select = $notification->getMapper()->getDbTable()->select()->from(array('n' => 'notification_to'), array('n.*'))->joinLeft(array('nm' => 'notification_messages'), 'n.`idNotification` = nm.`id`', array('nm.*'))->where("NOT n.deleted")->where("n.status=?", '1')->where("n.idUserTo=?", $id)->limit(3)->setIntegrityCheck(false); $result = $notification->fetchAll($select); $res_notificari = '<ul>'; foreach ($result as $rez) { $res_notificari .= "<li><a href='" . WEBROOT . "notifications/details/id/" . $rez->getId() . "'>" . $rez->getSubject() . "</a></li>"; } if ($notifications > 0) { $res_notificari .= "<a href=\"" . WEBROOT . "notifications\" class=\"notificari\">Toate Notificarile</a>"; } else { $res_notificari .= "<li>Nu aveti notificari</li>"; } $res_notificari .= "</ul>"; $result_array = array($res_notificari, $notifications); return $result_array; }
public function delete(Default_Model_NotificationTo $value) { $id = $value->getId(); $data = array('deleted' => '1'); $this->getDbTable()->update($data, array('id = ?' => $id)); return $id; }
public function deleteAction() { $id = $this->getRequest()->getParam('id'); $idProject = $this->getRequest()->getParam('idProject'); if ($id) { $model = new Default_Model_NotificationTo(); if ($model->find($id)) { if ($model->delete()) { $this->_flashMessenger->addMessage("<div class='success canhide'><p>" . Zend_Registry::get('translate')->_('Notificare stearsa cu succes') . "</p><a href='javascript:;'></a></div>"); } else { $this->_flashMessenger->addMessage("<div class='failure canhide'><p>" . Zend_Registry::get('translate')->_('Notificarea nu a fost stearsa') . "</p><a href='javascript:;'></a></div>"); } } else { $this->_flashMessenger->addMessage("<div class='failure canhide'><p>" . Zend_Registry::get('translate')->_('Eroare stergere notificare') . "!</p><a href='javascript:;'></a></div>"); } } $this->_redirect('/notifications'); }