Example #1
0
 protected function getForm()
 {
     // Create object Snep_Form
     $form = new Snep_Form();
     // Set form action
     $form->setAction($this->getFrontController()->getBaseUrl() . '/ranking-report/index');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/ranking_report.xml');
     $config = Zend_Registry::get('config');
     $period = new Snep_Form_SubForm($this->view->translate("Period"), $form_xml->period);
     $locale = Snep_Locale::getInstance()->getLocale();
     $now = Zend_Date::now();
     if ($locale == 'en_US') {
         $now = $now->toString('YYYY-MM-dd HH:mm');
     } else {
         $now = $now->toString('dd/MM/YYYY HH:mm');
     }
     $yesterday = Zend_Date::now()->subDate(1);
     $initDay = $period->getElement('init_day');
     $initDay->setValue($now);
     $tillDay = $period->getElement('till_day');
     $tillDay->setValue($now);
     $form->addSubForm($period, "period");
     $rank = new Snep_Form_SubForm($this->view->translate("Ranking Options"), $form_xml->rank);
     $selectNumView = $rank->getElement('view');
     for ($index = 1; $index <= 30; $index++) {
         $selectNumView->addMultiOption($index, $index);
     }
     $form->addSubForm($rank, "rank");
     $form->getElement('submit')->setLabel($this->view->translate("Show Report"));
     $form->removeElement("cancel");
     return $form;
 }
 public function logAction()
 {
     $pageSize = 4096;
     $overlapSize = 128;
     $dir = APPLICATION_PATH . '/../data/logs/';
     $file = $this->_getParam('file', null);
     $this->view->page = $this->_getParam('page', 0);
     if ($file === null) {
         $file = sprintf('%s_application.log', Zend_Date::now()->toString('yyyy.MM.dd'));
     }
     $fp = fopen($dir . $file, 'r');
     fseek($fp, -$pageSize * ($this->view->page + 1) + $overlapSize, SEEK_END);
     $this->view->errorLog = fread($fp, $pageSize + $overlapSize * 2);
     fclose($fp);
     $iterator = new DirectoryIterator($dir);
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             if ($iterator->isFile()) {
                 $files[$iterator->getFilename()] = $iterator->getPathName();
             }
         }
         $iterator->next();
     }
     $this->view->itemCountPerPage = $pageSize;
     $this->view->totalItemCount = filesize($dir . $file);
     $this->view->files = $files;
 }
Example #3
0
 /**
  * Checks the legal age
  *
  * @param   array $data
  * @param   int $customerAddressId
  * @return  Mage_Checkout_Model_Type_Onepage
  */
 public function saveBilling($data, $customerAddressId)
 {
     $result = parent::saveBilling($data, $customerAddressId);
     if (isset($result['error'])) {
         return $result;
     }
     $dobIso = $this->getQuote()->getCustomerDob();
     $dob = new Zend_Date($dobIso, Zend_Date::ISO_8601);
     $legalBirthDay = $dob->add(self::LIMITED_AGE, Zend_Date::YEAR);
     $legal1 = Zend_Date::now()->isLater($legalBirthDay);
     if (!$legal1) {
         // not even limited legal
         $result['error'] = 1;
         $result['message'] = Mage::helper('n98legalage')->__('You are not yet limited contractually capable. You can ask your legal guardian to purchase.');
         return $result;
     }
     $dob = new Zend_Date($dobIso, Zend_Date::ISO_8601);
     $legalBirthDay = $dob->add(self::LEGAL_AGE, Zend_Date::YEAR);
     $legal2 = Zend_Date::now()->isLater($legalBirthDay);
     if (!$legal2) {
         $result['error'] = 1;
         $result['message'] = Mage::helper('n98legalage')->__('You are not yet contractually capable. You can ask your legal guardian to purchase on your behalf.');
         return $result;
     }
     return $result;
 }
Example #4
0
 /** Create the token for yahoo access and save to database.
  * 
  */
 public function access()
 {
     $config = array('siteUrl' => self::YAHOOTOKENGET, 'callbackUrl' => 'http://beta.finds.org.uk/admin/oauth/', 'consumerKey' => $this->_consumerKey, 'consumerSecret' => $this->_consumerSecret);
     $session = new Zend_Session_Namespace('yahoo_oauth');
     // build the token request based on the original token and secret
     $request = new Zend_Oauth_Token_Request();
     $request->setToken($session->token)->setTokenSecret($session->secret);
     unset($session->token);
     unset($session->secret);
     $now = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
     $date = new Zend_Date();
     $expires = $date->add('1', Zend_Date::HOUR)->toString('YYYY-MM-dd HH:mm:ss');
     $consumer = new Zend_Oauth_Consumer($config);
     $token = $consumer->getAccessToken($_GET, $request);
     $oauth_guid = $token->xoauth_yahoo_guid;
     $oauth_session = $token->oauth_session_handle;
     $oauth_token = $token->getToken();
     $oauth_token_secret = $token->getTokenSecret();
     $tokenRow = $this->createRow();
     $tokenRow->service = 'yahooAccess';
     $tokenRow->accessToken = serialize($oauth_token);
     $tokenRow->tokenSecret = serialize($oauth_token_secret);
     $tokenRow->guid = serialize($oauth_guid);
     $tokenRow->sessionHandle = serialize($oauth_session);
     $tokenRow->created = $now;
     $tokenRow->expires = $expires;
     $tokenRow->save();
 }
Example #5
0
 /**
  * @return \Application\Model\Bean\ProductLog
  */
 private function newLog(Product $product, $eventType)
 {
     $now = \Zend_Date::now();
     $log = ProductLogFactory::createFromArray(array('id_product' => $product->getItemCode(), 'id_user' => $this->getUser()->getIdUser(), 'date_log' => $now->get('yyyy-MM-dd HH:mm:ss'), 'event_type' => $eventType, 'note' => ''));
     $this->getCatalog('ProductLogCatalog')->create($log);
     return $log;
 }
Example #6
0
 /** This probably needs changing for construction methods.
  * @todo remove need for calling config
  * @todo pass variables to the constructor
  */
 public function __construct()
 {
     $this->_config = Zend_Registry::get('config');
     $this->_consumerKey = $this->_config->webservice->ydnkeys->consumerKey;
     $this->_consumerSecret = $this->_config->webservice->ydnkeys->consumerSecret;
     $this->_now = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
 }
 /**
  * Retrieves all active MOTDs.
  *
  * @return array
  * An associative array containing the details of the active MOTDs, or null
  * if there are no active MOTDs.
  */
 public function getActiveMotds()
 {
     $returnArray = array();
     //Retrieve all MOTDs.
     $motds = new Datasource_Cms_Connect_Motd();
     $motdsArray = $motds->getAll();
     foreach ($motdsArray as $currentMotd) {
         if ($currentMotd['active'] == 1) {
             //Ensure the today is captured in the MOTD date range.
             $displayFrom = new Zend_Date($currentMotd['displayFrom'], Zend_Date::ISO_8601);
             $displayTo = new Zend_Date($currentMotd['displayTo'], Zend_Date::ISO_8601);
             $now = Zend_Date::now();
             if ($displayFrom->isToday() || $displayTo->isToday()) {
                 $returnArray[] = $currentMotd;
             } else {
                 if ($now->isLater($displayFrom) && $now->isEarlier($displayTo)) {
                     $returnArray[] = $currentMotd;
                 }
             }
         }
     }
     //Clean up the return value consistent with this function's contract.
     if (empty($returnArray)) {
         $returnVal = null;
     } else {
         $returnVal = $returnArray;
     }
     return $returnVal;
 }
 /**
  * Get product collection.
  * @return array
  * @throws Exception
  */
 public function getLoadedProductCollection()
 {
     $mode = $this->getRequest()->getActionName();
     $limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
     $from = Mage::helper('ddg/recommended')->getTimeFromConfig($mode);
     $locale = Mage::app()->getLocale()->getLocale();
     $to = Zend_Date::now($locale)->toString(Zend_Date::ISO_8601);
     $productCollection = Mage::getResourceModel('reports/product_collection')->addAttributeToSelect('*')->addOrderedQty($from, $to)->setOrder('ordered_qty', 'desc')->setPageSize($limit);
     Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($productCollection);
     $productCollection->addAttributeToFilter('is_saleable', TRUE);
     //filter collection by category by category_id
     if ($cat_id = Mage::app()->getRequest()->getParam('category_id')) {
         $category = Mage::getModel('catalog/category')->load($cat_id);
         if ($category->getId()) {
             $productCollection->getSelect()->joinLeft(array("ccpi" => 'catalog_category_product_index'), "e.entity_id  = ccpi.product_id", array("category_id"))->where('ccpi.category_id =?', $cat_id);
         } else {
             Mage::helper('ddg')->log('Best seller. Category id ' . $cat_id . ' is invalid. It does not exist.');
         }
     }
     //filter collection by category by category_name
     if ($cat_name = Mage::app()->getRequest()->getParam('category_name')) {
         $category = Mage::getModel('catalog/category')->loadByAttribute('name', $cat_name);
         if ($category) {
             $productCollection->getSelect()->joinLeft(array("ccpi" => 'catalog_category_product_index'), "e.entity_id  = ccpi.product_id", array("category_id"))->where('ccpi.category_id =?', $category->getId());
         } else {
             Mage::helper('ddg')->log('Best seller. Category name ' . $cat_name . ' is invalid. It does not exist.');
         }
     }
     return $productCollection;
 }
Example #9
0
 /**
  * @param Core_Dto_Entity
  * @throws Exception
  * */
 public function register(\Core_Dto_Entity $dto)
 {
     # @todo implementar regra de negocio que verifica se o comentario pode ser alterado
     # falta a definicao da estrutura tabela
     # recupera referencia da pessoa que está realizando operacao
     $pessoa = $this->_getRepository('app:VwPessoa')->find(\Core_Integration_Sica_User::getPersonId());
     # verifica o autor existe (usuario da sessao existe na base)
     # isso poderá ocorrer quando a sessao cair perando a realizacao
     # da operacao
     if (!count($pessoa)) {
         throw new \Exception(self::T_COMENTARIO_AUTHOR_NOT_FOUND);
     }
     $dto->setSqPessoa($pessoa);
     # recupera a unidade organizacional da pessoa que esta manipulando o comentario
     $dto->setSqUnidadeOrg($this->_getRepository('app:VwUnidadeOrg')->find(\Core_Integration_Sica_User::getUserUnit()));
     # verifica se o registro já existe
     $this->_alreadyExists($dto);
     # se o sq_comentario_artefato existir indica uma alteracao.
     # Devido a propriedade de tempo nunca será possível repedir um registro
     # se levar esta propriedade em consideracao
     if ($dto->getSqComentarioArtefato()) {
         $this->_update($dto);
         $this->getMessaging()->addSuccessMessage('MD002', 'User');
     } else {
         # define a hora de registro/alteracao
         $dto->setDtComentario(\Zend_Date::now());
         # delega a operação de salvar os dados para superclasse
         $this->_save($dto);
         $this->getMessaging()->addSuccessMessage('MD001', 'User');
     }
     $this->finish();
     $this->getMessaging()->dispatchPackets();
 }
Example #10
0
 private function logUpdate($eventType, $table, $oldValue, $newValue, $user)
 {
     $timestamp = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
     if ($this->trackFields != null) {
         // insert a log for each tracked field
         foreach ($this->trackFields as $field) {
             if (isset($oldValue[$field]) && isset($newValue[$field])) {
                 if ($oldValue[$field] != $newValue[$field]) {
                     $this->setColEventType(self::EVENT_TYPE_UPDATE);
                     $this->setColEventDate($timestamp);
                     $this->setColFieldName($field);
                     $this->setColRecordId($oldValue['id']);
                     $this->setColAppAccountId($user['appaccount_id']);
                     $this->setColUserId($user['user_id']);
                     $this->setColTableName($table);
                     $this->setColFieldTextType(false);
                     $this->setColValue($oldValue[$field]);
                     $this->log->log('UPDATE on database', Zend_Log::INFO);
                 }
             }
         }
     } else {
         throw new Agana_Exception('Track Fields for audit trail is not set');
     }
 }
Example #11
0
 /**
  * Initialize feedback, sets feedback_id from UUID value
  * This value can be provided via the url or a cookie and
  * will be stored in a session
  *
  * If no valid feedback code is found in the request string, the cookie
  * or in the session (also a cookie) then return false
  *
  * @return	integer		feeback_id
  */
 private function _init()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $conference = Zend_Registry::get('conference');
     $sessionNs = $conference['abbreviation'] . '_feedback';
     // check if feedback deadline has passed
     if (isset($conference['feedback_end'])) {
         if (Zend_Date::now()->isLater($conference['feedback_end'])) {
             return false;
         }
     }
     // check if session is set
     if (Zend_Session::namespaceIsset($sessionNs)) {
         $session = new Zend_Session_Namespace($sessionNs, true);
         return $this->_feedback_id = $session->feedback_id;
     }
     // for uuid parameter, first try Request value, if not available use Cookie value
     $uuid = $request->getParam('uuid', $request->getCookie('feedback_code'));
     // use parameter to set session and cookie
     if ($uuid) {
         if ($feedback = $this->getFeedbackByUuid($uuid)) {
             $session = new Zend_Session_Namespace($sessionNs, true);
             // cookie expires in 14 days
             if ($request->getParam('uuid')) {
                 // only set cookie if it is not already set
                 setcookie('feedback_code', $uuid, time() + 14 * 3600 * 24, '/', $conference['hostname']);
             }
             return $this->_feedback_id = $session->feedback_id = (int) $feedback->code_id;
         }
     }
     // If no UUID is found in Request, Cookie or Session then return
     return false;
 }
Example #12
0
 /**
  * 
  */
 public function indexAction()
 {
     $module = $this->_getParam('module');
     if (empty($module)) {
         $this->_helper->redirector->goToSimple('index', 'index', 'external');
     }
     $client = $this->view->session->client->id_perdata;
     $businessPlan = $this->_mapper->fetchBusinessPlanByClient($client, $module);
     if ($businessPlan) {
         $this->view->businessPlan = $businessPlan;
         $this->view->date_ini = $this->view->date($businessPlan->date_inserted);
         $this->view->hasBudgetCategory = $this->_mapper->hasBudgetCategory($businessPlan->id_businessplan);
         if (!$businessPlan->submitted) {
             $this->view->revision = $this->_mapper->getLastRevision($businessPlan->id_businessplan);
         }
         if (!empty($businessPlan->business_group)) {
             $this->view->is_group = true;
         }
         if (!empty($businessPlan->fk_id_fefop_contract)) {
             $mapperContract = new Fefop_Model_Mapper_Contract();
             $this->view->contract = $mapperContract->detail($businessPlan->fk_id_fefop_contract);
         }
     } else {
         $this->view->date_ini = Zend_Date::now()->toString('dd/MM/yyyy');
     }
     $this->view->can_create = $this->_mapper->canCreateBusinessPlan($client, $module);
     $this->view->module = $module;
 }
Example #13
0
 public function isVisible($identity = null)
 {
     if (!$this->isPublished()) {
         return false;
     }
     return $this->getDateObjectBy('published_at')->compare(Zend_Date::now()) < 0;
 }
Example #14
0
 /**
  * Check feed for modification
  *
  * @return Belvg_All_Model_Feed
  */
 public function checkUpdate()
 {
     $now = Zend_Date::now()->getTimestamp();
     if ($this->_helper->getFrequency() + $this->_helper->getLastUpdate() > $now) {
         return $this;
     }
     $this->_helper->setLastUpdate($now);
     if (!extension_loaded('curl')) {
         return $this;
     }
     $feed_data = array();
     $feed_xml = $this->getFeedData();
     $was_installed = gmdate('Y-m-d H:i:s', $this->_helper->getInstalledDate());
     if ($feed_xml && $feed_xml->channel && $feed_xml->channel->item) {
         foreach ($feed_xml->channel->item as $item) {
             $date = $this->getDate((string) $item->pubDate);
             if ($date < $was_installed) {
                 continue;
             }
             if (!$this->isInteresting($item)) {
                 continue;
             }
             $feed_data[] = array('severity' => 3, 'date_added' => $this->getDate($date), 'title' => (string) $item->title, 'description' => (string) $item->description, 'url' => (string) $item->link);
         }
         if ($feed_data) {
             Mage::getModel('adminnotification/inbox')->parse($feed_data);
         }
     }
 }
Example #15
0
 public function indexAction()
 {
     // Display the send_us_a_file.html page if the "Send us a file" feature is on and the user is not logged in.
     if (fz_config_get('app', 'send_us_a_file_feature') && false == $this->getUser()) {
         set('start_from', Zend_Date::now()->get(Zend_Date::DATE_SHORT));
         $maxUploadSize = min(Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('upload_max_filesize')), Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('post_max_size')));
         set('max_upload_size', $maxUploadSize);
         return html('send_us_a_file.html');
     }
     $this->secure();
     $user = $this->getUser();
     $freeSpaceLeft = max(0, Fz_Db::getTable('File')->getRemainingSpaceForUser($user));
     $maxUploadSize = min(Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('upload_max_filesize')), Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('post_max_size')), $freeSpaceLeft);
     $progressMonitor = fz_config_get('app', 'progress_monitor');
     $progressMonitor = new $progressMonitor();
     set('upload_id', md5(uniqid(mt_rand(), true)));
     set('start_from', Zend_Date::now()->get(Zend_Date::DATE_SHORT));
     set('refresh_rate', 1200);
     set('files', Fz_Db::getTable('File')->findByOwnerOrderByUploadDateDesc($user));
     set('use_progress_bar', $progressMonitor->isInstalled());
     set('upload_id_name', $progressMonitor->getUploadIdName());
     set('free_space_left', $freeSpaceLeft);
     set('max_upload_size', $maxUploadSize);
     set('sharing_destinations', fz_config_get('app', 'sharing_destinations', array()));
     set('disk_usage', array('space' => '<b id="disk-usage-value">' . bytesToShorthand(Fz_Db::getTable('File')->getTotalDiskSpaceByUser($user)) . '</b>', 'quota' => fz_config_get('app', 'user_quota')));
     return html('main/index.php');
 }
Example #16
0
 /**
  * Обновить данные котирововк
  * 
  * @return string
  */
 public function updateQuotations()
 {
     $quotationMapper = new Application_Model_QuotationMapper();
     $quotationModel = new Application_Model_Quotation();
     $currencyMapper = new Application_Model_CurrencyMapper();
     $quotationMapper->clearCache();
     $currencyMapper->clearCache();
     $now = Zend_Date::now();
     $nowUnixFormated = $now->toString('Y-M-d H:m:s');
     $currenciesFetched = $currencyMapper->fetchAll();
     $currencyArray = [];
     foreach ($currenciesFetched as $currency) {
         $providerCurrencyId = $currency->getProviderCurrencyId();
         $currencyArray[$providerCurrencyId] = $currency;
     }
     $quotationMapper->delete();
     $quotations = $this->_prepareData();
     foreach ($currencyArray as $baseProviderCurrencyId => $baseCurrency) {
         foreach ($currencyArray as $quotatedProviderCurrencyId => $quotatedCurrency) {
             if ($baseProviderCurrencyId == $quotatedProviderCurrencyId) {
                 continue;
             }
             $quotation = round($quotations[$baseProviderCurrencyId]['quotation'] / $quotations[$quotatedProviderCurrencyId]['quotation'], 2);
             $data = ['baseCurrencyId' => $baseCurrency->getId(), 'quotatedCurrencyId' => $quotatedCurrency->getId(), 'quotation' => $quotation, 'updatedAt' => $nowUnixFormated];
             $quotationModel->setOptions($data);
             $quotationMapper->save($quotationModel);
         }
     }
     return 'success';
 }
Example #17
0
 public function indexAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Status"), $this->view->translate("System Logs")));
     $config = Zend_Registry::get('config');
     include $config->system->path->base . "/inspectors/Permissions.php";
     $test = new Permissions();
     $response = $test->getTests();
     $form = new Snep_Form(new Zend_Config_Xml('./modules/default/forms/logs.xml', 'general', true));
     $form->setAction($this->getFrontController()->getBaseUrl() . '/logs/view');
     $locale = Snep_Locale::getInstance()->getLocale();
     $now = Zend_Date::now();
     if ($locale == 'en_US') {
         $now = $now->toString('YYYY-MM-dd HH:mm');
     } else {
         $now = $now->toString('dd/MM/YYYY HH:mm');
     }
     $initDay = $form->getElement('init_day');
     $initDay->setValue($now);
     $endDay = $form->getElement('end_day');
     $endDay->setValue($now);
     $status = $form->getElement('status');
     $status->setValue('ALL');
     $realtime = $form->getElement('real_time');
     $realtime->setValue('no');
     $submit = $form->getElement("submit");
     $submit->setLabel("Log Search");
     $this->initLogFile();
     $this->view->form = $form;
 }
Example #18
0
 /**
  * 
  */
 public function init()
 {
     $this->setAttrib('class', 'horizontal-form')->setName('formstatement');
     $elements = array();
     $elements[] = $this->createElement('hidden', 'id_fefop_bank_statements')->setDecorators(array('ViewHelper'));
     $elements[] = $this->createElement('hidden', 'status')->setDecorators(array('ViewHelper'));
     $elements[] = $this->createElement('hidden', 'id_fefop_bank_contract')->setIsArray(true);
     $elements[] = $this->createElement('hidden', 'fk_id_fefop_contract')->setIsArray(true);
     $elements[] = $this->createElement('hidden', 'total_contract')->setIsArray(true);
     $elements[] = $this->createElement('hidden', 'total_expense')->setIsArray(true);
     $elements[] = $this->createElement('hidden', 'fk_id_budget_category')->setIsArray(true);
     $elements[] = $this->createElement('text', 'date_statement')->setDecorators($this->getDefaultElementDecorators())->setRequired(true)->setAttrib('class', 'm-wrap span12 date-mask')->setValue(Zend_Date::now()->toString('dd/MM/yyyy'))->setLabel('Data');
     $elements[] = $this->createElement('text', 'amount')->setDecorators($this->getDefaultElementDecorators())->setRequired(true)->setValue(0)->setAttrib('class', 'm-wrap span12 money-mask bold text-right')->setAttrib('style', 'font-size: 19px')->setLabel('Total');
     $dbTypeTransaction = App_Model_DbTable_Factory::get('FEFOPTypeTransaction');
     $rows = $dbTypeTransaction->fetchAll();
     $optTypeTransaction = array('' => '');
     foreach ($rows as $row) {
         $optTypeTransaction[$row['id_fefop_type_transaction']] = $row['acronym'] . ' - ' . $row['description'];
     }
     $elements[] = $this->createElement('select', 'fk_id_fefop_type_transaction')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->addMultiOptions($optTypeTransaction)->setRequired(true)->setLabel('Tipu Transasaun');
     $optOperation[Fefop_Model_Mapper_BankStatement::DEBIT] = 'Saída';
     $optOperation[Fefop_Model_Mapper_BankStatement::CREDIT] = 'Entrada';
     $elements[] = $this->createElement('select', 'operation')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->addMultiOptions($optOperation)->setRequired(true)->setLabel('Operasaun');
     $mapperFund = new Fefop_Model_Mapper_Fund();
     $funds = $mapperFund->fetchAll();
     $optFunds[''] = '';
     foreach ($funds as $fund) {
         $optFunds[$fund['id_fefopfund']] = $fund['name_fund'];
     }
     $elements[] = $this->createElement('select', 'fk_id_fefopfund')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optFunds)->setLabel('Fundu');
     $elements[] = $this->createElement('textarea', 'description')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setAttrib('rows', '2')->setRequired(true)->setLabel('Deskrisaun');
     $this->addElements($elements);
     App_Form_Toolbar::build($this, self::ID);
     $this->setDecorators($this->getDefaultFormDecorators());
 }
Example #19
0
 /**
  * @inheritdoc
  */
 protected function _makeLink()
 {
     $now = Zend_Date::now();
     $nowFormated = $now->toString('d/M/Y');
     $link = $this->_link . '?date_req=' . $nowFormated;
     return $link;
 }
Example #20
0
 public function updateTeacher($_data)
 {
     $db = $this->getAdapter();
     $db->beginTransaction();
     try {
         $_arr = array('teacher_code' => $_data['code'], 'teacher_name_en' => $_data['en_name'], 'teacher_name_kh' => $_data['kh_name'], 'sex' => $_data['sex'], 'phone' => $_data['phone'], 'dob' => $_data['dob'], 'pob' => $_data['pob'], 'address' => $_data['address'], 'email' => $_data['email'], 'degree' => $_data['degree'], 'note' => $_data['note'], 'date' => Zend_Date::now(), 'status' => $_data['status'], 'user_id' => $this->getUserId());
         $where = $this->getAdapter()->quoteInto("id=?", $_data["id"]);
         $this->update($_arr, $where);
         $this->_name = 'rms_teacher_subject';
         $ids = explode(',', $_data['record_row']);
         foreach ($ids as $i) {
             $arr = array('subject_id' => $_data['subject_id' . $i], 'teacher_id' => $_data["id"], 'status' => $_data['status' . $i], 'date' => Zend_Date::now(), 'user_id' => $this->getUserId());
             if (!empty($_data['subexist_id' . $i])) {
                 $where = $this->getAdapter()->quoteInto("id=?", $_data['subexist_id' . $i]);
                 $this->update($arr, $where);
             } else {
                 $this->insert($arr);
             }
         }
         return $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         echo $e->getMessage();
         exit;
     }
 }
 protected function _createEntry($item)
 {
     $entry = parent::_createEntry($item);
     $entry->setContentCreatedAt(Zend_Date::now());
     $entry->setContentUpdatedAt(Zend_Date::now());
     return $entry;
 }
Example #22
0
 public function AddNewStudent($_data)
 {
     try {
         print_r($_data);
         exit;
         $db = $this->getAdapter();
         $db->beginTransaction();
         $is_hold = 0;
         if (!empty($_data['is_hold'])) {
             $is_hold = $_data['is_hold'];
         }
         if (!empty($_data['is_new'])) {
             $_isnewstudent = $_data['is_new'];
         }
         $_arr = array('stu_type' => 1, 'stu_code' => 2222, 'fm_user' => 0, 'stu_card' => 'WU-001', 'mention' => $_data['metion'], 'stu_enname' => $_data['en_name'], 'stu_khname' => $_data['kh_name'], 'stu_card' => $_data['stu_id'], 'sex' => $_data['sex'], 'dob' => $_data['dob'], 'phone' => $_data['phone'], 'degree' => $_data['degree'], 'faculty_id' => $_data['dept'], 'year' => $_data['year'], 'batch' => $_data['batch'], 'session' => $_data['session'], 'create_date' => Zend_Date::now(), 'is_stu_new' => $_isnewstudent, 'is_hold' => $is_hold, 'is_subspend' => 1, 'is_exam' => 0, 'modify_date' => Zend_Date::now(), 'status' => 1, 'remark' => $_data['remark'], 'user_id' => $this->getUserId());
         $this->insert($_arr);
         $_name = 'rms_student_org';
         $this->insert($_arr);
         $stu_id = $db->lastInsertId();
         $is_new = 0;
         if (!empty($_data['is_new'])) {
             $is_new = $_data['is_new'];
         }
         $arr = array('stu_id' => $stu_id, 'is_new' => $is_new, 'payment_term' => $_data['payment_term'], 'amount' => $_data['tuitionfee'], 'discount_percent' => $_data['discount'], 'discount_fix' => $_data['discount'], 'scholarship' => $_data['remark'], 'net_tution_fee' => $_data['tuitionfee'], 'total' => $_data['tuitionfee'], 'paid_amount' => $_data['tuitionfee'], 'amount_in_khmer' => $_data['paid_kh'], 'forward_from_prev' => $_data['tuitionfee'], 'balance_due' => $_data['tuitionfee'], 'references' => $_data['remark'], 'user_id' => $this->getUserId(), 'create_date' => Zend_Date::now());
         $this->_name = 'rms_student_payment';
         $this->insert($arr);
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
     }
 }
Example #23
0
 public function rssAction()
 {
     // build the feed array
     $feedArray = array();
     // the title and link are required
     $feedArray['title'] = 'Recent Pages';
     $feedArray['link'] = 'http://localhost';
     // the published timestamp is optional
     $feedArray['published'] = Zend_Date::now()->toString(Zend_Date::TIMESTAMP);
     // the charset is required
     $feedArray['charset'] = 'UTF8';
     // first get the most recent pages
     $mdlPage = new Model_Page();
     $recentPages = $mdlPage->getRecentPages();
     //add the entries
     if (is_array($recentPages) && count($recentPages) > 0) {
         foreach ($recentPages as $page) {
             // create the entry
             $entry = array();
             $entry['guid'] = $page->id;
             $entry['title'] = $page->headline;
             $entry['link'] = 'http://localhost/page/open/title/' . $page->name;
             $entry['description'] = $page->description;
             $entry['content'] = $page->content;
             // add it to the feed
             $feedArray['entries'][] = $entry;
         }
     }
     // create an RSS feed from the array
     $feed = Zend_Feed::importArray($feedArray, 'rss');
     // now send the feed
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $feed->send();
 }
 public function subscribeAction()
 {
     $this->enableLayout();
     $newsletter = new Newsletter("person");
     // replace "crm" with the class name you have used for your class above (mailing list)
     $params = $this->getAllParams();
     $this->view->success = false;
     if ($newsletter->checkParams($params)) {
         try {
             $params["parentId"] = 1;
             // default folder (home) where we want to save our subscribers
             $newsletterFolder = Model\Object::getByPath("/crm/newsletter");
             if ($newsletterFolder) {
                 $params["parentId"] = $newsletterFolder->getId();
             }
             $user = $newsletter->subscribe($params);
             // user and email document
             // parameters available in the email: gender, firstname, lastname, email, token, object
             // ==> see mailing framework
             $newsletter->sendConfirmationMail($user, Model\Document::getByPath("/en/advanced-examples/newsletter/confirmation-email"), array("additional" => "parameters"));
             // do some other stuff with the new user
             $user->setDateRegister(\Zend_Date::now());
             $user->save();
             $this->view->success = true;
         } catch (\Exception $e) {
             echo $e->getMessage();
         }
     }
 }
Example #25
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkCeop($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('CEOP iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_dec'])) {
             $history = 'INSERE CEOP-DEC: %s- INSERIDO NOVO CEOP-DEC COM SUCESSO';
             $this->_data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $this->_data['registry_date'] = Zend_Date::now()->toString('yyyy-MM-dd');
         } else {
             $history = 'ALTERA CEOP-DEC: %s DADUS PRINCIPAL - ALTERA CEOP-DEC';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
Example #26
0
 /**
  * Login function authentication system 
  * @param Zend_Db_Table_Row $account
  * @return boolean
  */
 function Login(Zend_Db_Table_Row $account)
 {
     $select = $this->select()->where('email=?', $account->email)->limit(1);
     $row = $this->fetchRow($select);
     // set up the auth adapter
     $db = Acl_Model_Account::getDefaultAdapter();
     $authAdapter = new OS_Application_Adapter_Auth($account->email, $account->password);
     $authAdapter = new Zend_Auth_Adapter_DbTable($db);
     $authAdapter->setTableName($this->_name)->setIdentityColumn('email')->setCredentialColumn('password')->setCredentialTreatment('block = 0');
     #->setCredentialTreatment('MD5(?) and block = 0');
     $authAdapter->setIdentity($account->email);
     $authAdapter->setCredential(crypt($account->password, $row->password));
     $result = $authAdapter->authenticate();
     Zend_Session::regenerateId();
     if ($result->isValid()) {
         $auth = Zend_Auth::getInstance();
         $storage = $auth->getStorage();
         $storage->write($authAdapter->getResultRowObject(array('id', 'email', 'registerdate', 'lastvisitdate', 'role_id', 'fullname', 'email_alternative')));
         $account = $this->find($authAdapter->getResultRowObject()->id)->current();
         #$account = $this->createRow( $account->toArray() );
         $account->lastvisitdate = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss');
         $account->save();
         return true;
     }
     return false;
 }
Example #27
0
 /**
  *
  * @param $entity
  * @param \Core_Dto $dto
  */
 public function preInsert($entity, $dto = NULL)
 {
     $dtoDuplicado = \Core_Dto::factoryFromData(array('sqArtefato' => $dto->getSqArtefato(), 'sqTipoAssuntoSolicitacao' => $dto->getSqTipoAssuntoSolicitacao(), 'sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidadeOrg' => \Core_Integration_Sica_User::getUserUnit()), 'search');
     $listResult = $this->_getRepository()->getSolicitacaoDuplicado($dtoDuplicado);
     if (count($listResult)) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN206'));
     }
     # artefatos inconsistêntes não podem abrir solicitação de alguns tipos de solicitação
     $isInconsistent = $this->getServiceLocator()->getService('Artefato')->isInconsistent($dtoDuplicado);
     if ($isInconsistent && in_array($dto->getSqTipoAssuntoSolicitacao(), $this->getTipoAssuntoSolcOnlyConsistent())) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN205'));
     }
     # se for exclusão de volume e só houver um volume cadastrado, não permite a criação
     if ($dto->getSqTipoAssuntoSolicitacao() == \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoVolumeDeProcesso() && !$this->_getRepository('app:ProcessoVolume')->notTheOnlyVolume($dto->getSqArtefato())) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN207'));
     }
     //Tira os Espaços do 'enter' para salvar com 500 caracteres
     $dsSolicitacao = $this->getServiceLocator()->getService('MinutaEletronica')->fixNewlines($entity->getDsSolicitacao());
     $entity->setDsSolicitacao(!$dsSolicitacao ? NULL : $dsSolicitacao);
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $entSqPessoa = $this->getEntityManager()->getPartialReference('app:VwPessoa', \Core_Integration_Sica_User::getPersonId());
         $entSqUnidadeOrg = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit());
         $entTipoAssuntoSolicitacao = $this->_getRepository('app:TipoAssuntoSolicitacao')->find($dto->getSqTipoAssuntoSolicitacao());
         $entity->setDtSolicitacao(\Zend_Date::now());
         $entity->setSqPessoa($entSqPessoa);
         $entity->setSqUnidadeOrg($entSqUnidadeOrg);
         $entity->setSqTipoAssuntoSolicitacao($entTipoAssuntoSolicitacao);
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
 }
 /**
  * Inserts a Tat invitation flag into the datasource.
  *
  * @param string $enquiryId
  * The unique Enquiry identifier (external).
  *
  * @return void
  */
 public function insertInvitation($enquiryId)
 {
     $dateSent = Zend_Date::now();
     $dateSent = $dateSent->toString(Zend_Date::ISO_8601);
     $data = array('refno' => $enquiryId, 'date_sent' => $dateSent);
     $this->insert($data);
 }
 public function sendAction()
 {
     $message = new Push_Model_Message();
     $now = Zend_Date::now()->toString('y-MM-dd HH:mm:ss');
     $errors = array();
     if ($id = $this->getRequest()->getParam('message_id')) {
         $message->find($id);
         $messages = array();
         if ($message->getId() and $message->getStatus() == "queued") {
             $messages[] = $message;
         }
     } else {
         $messages = $message->findAll(array('status IN (?)' => array('queued'), 'send_at IS NULL OR send_at <= ?' => $now, 'send_until IS NULL OR send_until >= ?' => $now), 'created_at DESC');
     }
     if (count($messages) > 0) {
         foreach ($messages as $message) {
             try {
                 // Envoi et sauvegarde du message
                 $message->push();
                 if ($message->getErrors()) {
                     $errors[$message->getId()] = $message->getErrors();
                 }
             } catch (Exception $e) {
                 $message->updateStatus('failed');
                 $errors[$message->getId()] = $e;
             }
         }
     }
     Zend_Debug::dump('Erreurs :');
     Zend_Debug::dump($errors);
     die('done');
 }
Example #30
0
 public function updateStudentINfo($_data, $by_id)
 {
     //echo $_data['major_id'];
     $_arr = array('stu_enname' => $_data['en_name'], 'stu_khname' => $_data['kh_name'], 'stu_card' => $_data['stu_card'], 'sex' => $_data['sex'], 'dob' => $_data['dob'], 'pob' => $_data['pob'], 'phone' => $_data['phone'], 'degree' => $_data['degree'], 'batch' => $_data['batch'], 'session' => $_data['session'], 'year' => $_data['year'], 'father_phone' => $_data['father_phone'], 'mother_phone' => $_data['mother_phone'], 'situation' => $_data['situation'], 'finish_bacc' => $_data['finish_bacc'], 'certificate_code' => $_data['certificate_code'], 'bacc_score' => $_data['bacc_score'], 'mention' => $_data['mention'], 'from_school' => $_data['from_school'], 'mention' => $_data['mention'], 'student_add' => $_data['student_add'], 'certificate_code' => $_data['certificate_code'], 'from_school' => $_data['from_school'], 'modify_date' => Zend_Date::now(), 'remark' => $_data['remark'], 'status' => $_data['status'], 'user_id' => $this->getUserId());
     $where = $this->getAdapter()->quoteInto("stu_id=?", $by_id);
     $this->update($_arr, $where);
 }