PHP Zend_Date Code Examples

This page contains top rated real world PHP examples of Zend_Date extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: UrlCacheStatus.php Project: rickbakker/magento-turpentine
0
 /**
  * Update or insert $expireAt date for $url
  *
  * @param string $url
  * @param Zend_Date $expireAt
  */
 public function updateUrl($url, Zend_Date $expireAt)
 {
     /** @var Varien_Db_Adapter_Interface $writeAdapter */
     $writeAdapter = $this->_getWriteAdapter();
     $expireStr = $expireAt->toString('YYYY-MM-dd HH:mm:ss');
     $writeAdapter->insertOnDuplicate($this->getMainTable(), array('url' => $url, 'expire_at' => $expireStr));
 }
Example #2
Show file File: Timing.php Project: rickyfeng/wenda
0
 public function timing($time)
 {
     $date = new Zend_Date();
     $diffTime = $date->getTimestamp() - $time;
     $date = null;
     if ($diffTime < 60) {
         return ($diffTime <= 0 ? 1 : $diffTime) . '秒前';
     }
     $minute = ceil($diffTime / 60);
     if ($minute < 60) {
         return $minute . '分钟前';
     }
     $minute = ceil($diffTime / 3600);
     if ($minute < 24) {
         return $minute . '小时前';
     }
     $day = ceil($diffTime / 3600 / 24);
     if ($day < 30) {
         return $day . '天前';
     }
     $month = ceil($diffTime / 3600 / 24 / 30);
     if ($month < 12) {
         return $month . '月前';
     }
     $year = floor($diffTime / 3600 / 24 / 30 / 12);
     return $year . '年前';
 }
Example #3
Show file File: Bug.php Project: smehtaAA/projectlag
0
 public function insert(array $data)
 {
     $date = new Zend_Date();
     $data['datebug'] = $date->toString('Y-MM-d');
     $data['statut'] = "Non lu";
     return parent::insert($data);
 }
Example #4
Show file File: Bestsellers.php Project: dragonsword007008/magento2
0
 public function getLoadedProductCollection()
 {
     $collection = array();
     $mode = $this->getRequest()->getActionName();
     $limit = $this->recommnededHelper->getDisplayLimitByMode($mode);
     $from = $this->recommnededHelper->getTimeFromConfig($mode);
     $to = new \Zend_Date($this->_localeDate->date()->getTimestamp());
     $productCollection = $this->_productSoldFactory->create()->addAttributeToSelect('*')->addOrderedQty($from, $to->tostring(\Zend_Date::ISO_8601))->setOrder('ordered_qty', 'desc')->setPageSize($limit);
     //filter collection by category by category_id
     if ($cat_id = $this->getRequest()->getParam('category_id')) {
         $category = $this->_categoryFactory->create()->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 {
             $this->helper->log('Best seller. Category id ' . $cat_id . ' is invalid. It does not exist.');
         }
     }
     //filter collection by category by category_name
     if ($cat_name = $this->getRequest()->getParam('category_name')) {
         $category = $this->_categoryFactory->create()->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 {
             $this->helper->log('Best seller. Category name ' . $cat_name . ' is invalid. It does not exist.');
         }
     }
     if ($productCollection->getSize()) {
         foreach ($productCollection as $order) {
             foreach ($order->getAllVisibleItems() as $orderItem) {
                 $collection[] = $orderItem->getProduct();
             }
         }
     }
     return $collection;
 }
Example #5
Show file File: Performance.php Project: vinayshuklasourcefuse/sareez
0
 public function collectValidatedAttributes($productCollection)
 {
     $attribute = $this->getAttribute();
     $arr = explode('_', $attribute);
     $type = $arr[0];
     $period = $arr[1];
     $date = new Zend_Date();
     $date->sub($period * 24 * 60 * 60);
     $resource = Mage::getSingleton('core/resource');
     $connection = $resource->getConnection('core_read');
     switch ($type) {
         case 'clicks':
             $expr = new Zend_Db_Expr('SUM(clicks)');
             break;
         case 'orders':
             $expr = new Zend_Db_Expr('SUM(orders)');
             break;
         case 'revenue':
             $expr = new Zend_Db_Expr('SUM(revenue)');
             break;
         case 'cr':
             $expr = new Zend_Db_Expr('SUM(orders) / SUM(clicks) * 100');
             break;
     }
     $select = $connection->select();
     $select->from(array('ta' => $resource->getTableName('feedexport/performance_aggregated')), array($expr))->where('ta.product_id = e.entity_id')->where('ta.period >= ?', $date->toString('YYYY-MM-dd'));
     $select = $productCollection->getSelect()->columns(array($attribute => $select));
     return $this;
 }
Example #6
Show file File: Data.php Project: andrelsguerra/pequiambiental
0
 public function isValid($value)
 {
     $front = Zend_Controller_Front::getInstance()->getRequest();
     $action = $front->action;
     if ($action == "edit-evento") {
         return true;
     }
     if (!isset($value) or empty($value)) {
         return false;
     }
     //date_default_timezone_set( 'America/Sao_Paulo' );
     //  Zend_Registry::get('logger')->log("valor=", Zend_Log::INFO);
     // Zend_Registry::get('logger')->log($value, Zend_Log::INFO);
     $date = new Zend_Date();
     $data = new Zend_Date($date->toString('dd/MM/YYYY'));
     $data2 = new Zend_Date($value);
     $comparacao = $data->isLater($data2);
     $comparacao2 = $data->isEarlier($data2);
     $comparacao3 = $data->equals($data2);
     // Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO);
     //  Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO);
     // Zend_Registry::get('logger')->log($comparacao3, Zend_Log::INFO);
     if ($comparacao3 || $comparacao2) {
         Zend_Registry::get('logger')->log("data igual ou maior", Zend_Log::INFO);
     } else {
         $this->_setValue($value);
         //	Zend_Registry::get('logger')->log("data menor", Zend_Log::INFO);
         $this->_error(self::INVALID);
         return false;
     }
     // $comparacao= $data->compare($date2);
     // Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO);
     //  Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO);
     return true;
 }
Example #7
Show file File: Search.php Project: knatorski/SMS
0
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     if (empty($data['phone_number']) && empty($data['sms_id']) && (empty($data['date_until']) || empty($data['date_from']))) {
         $this->addErrorMessage('"Data do" i "Data od" sa wymagane jeżeli nie podasz "SMS ID" lub Numeru telefonu');
         return false;
     }
     if (empty($data['sms_id']) && empty($data['phone_number'])) {
         try {
             $dateCheck = new Zend_Date($data['date_from']);
             if (!$dateCheck->isEarlier($data['date_until']) and 0 != strcmp($data['date_from'], $data['date_until'])) {
                 $isValid = false;
                 $this->addErrorMessage('"Data do" nie może być wcześniejsza niż "Data od"!');
             }
             $dateSub = new Zend_Date($data['date_until']);
             $config = Zend_Registry::get('config');
             if ($dateSub->sub($dateCheck)->toValue('DD') > $config['search']['mail']['filter']['interval']) {
                 $isValid = false;
                 $this->addErrorMessage('Maksymalny okres z jakiego można wyszukiwać dane to ' . $config['search']['sms']['filter']['interval'] . ' dni');
             }
         } catch (Exception $ex) {
             $this->addErrorMessage($ex->getMessage());
             $isValid = false;
         }
     }
     return $isValid;
 }
Example #8
Show file File: ThongkethangController.php Project: rongandat/phanloaicanbo
0
 public function indexAction()
 {
     $translate = Zend_Registry::get('Zend_Translate');
     $this->view->title = 'Thống kê tháng - ' . $translate->_('TEXT_DEFAULT_TITLE');
     $this->view->headTitle($this->view->title);
     $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED;
     $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath);
     Zend_Layout::startMvc($option);
     $date = new Zend_Date();
     $date->subMonth(1);
     $thang = $this->_getParam('thang', $date->toString("M"));
     $nam = $this->_getParam('nam', $date->toString("Y"));
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     $em_id = $identity->em_id;
     $holidaysModel = new Front_Model_Holidays();
     $list_holidays = $holidaysModel->fetchData(array(), 'hld_order ASC');
     $xinnghiphepModel = new Front_Model_XinNghiPhep();
     $list_nghi_phep = $xinnghiphepModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $chamcongModel = new Front_Model_ChamCong();
     $cham_cong = $chamcongModel->fetchOneData(array('c_em_id' => $em_id, 'c_thang' => $thang, 'c_nam' => $nam));
     $khenthuongModel = new Front_Model_KhenThuong();
     $khen_thuong = $khenthuongModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $kyluatModel = new Front_Model_KyLuat();
     $ky_luat = $kyluatModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $this->view->cham_cong = $cham_cong;
     $this->view->thang = $thang;
     $this->view->nam = $nam;
     $this->view->list_holidays = $list_holidays;
     $this->view->list_nghi_phep = $list_nghi_phep;
     $this->view->khen_thuong = $khen_thuong;
     $this->view->ky_luat = $ky_luat;
 }
Example #9
Show file File: Andamento.php Project: nandorodpires2/intranet
0
 public function andamento($projeto_id)
 {
     $porcentagem = 0;
     $trabalhados = 0;
     $horas_projeto = 0;
     $horas_trabalhadas = 0;
     // dados do projeto
     $modelProjeto = new Model_DbTable_Projeto();
     $projeto = $modelProjeto->getById($projeto_id);
     $horas_projeto = $projeto->projeto_horas;
     $modelControleHoras = new Model_DbTable_ControleHoras();
     $horas = $modelControleHoras->fetchAll("projeto_id = {$projeto_id}");
     foreach ($horas as $hora) {
         $zendDateInicio = new Zend_Date($hora->controle_horas_data_inicio);
         $zendDateFim = new Zend_Date($hora->controle_horas_data_fim);
         $trabalhados += $zendDateFim->sub($zendDateInicio)->get(Zend_Date::TIMESTAMP);
     }
     // converte horas trabalhadas para horas
     $horas_trabalhadas = $trabalhados / 3600;
     if ($horas_trabalhadas < 1) {
         return 0;
     }
     if ($horas_projeto == 0) {
         return 100;
     }
     $porcentagem = number_format($horas_trabalhadas * 100 / $horas_projeto, 2, '.', '');
     return $porcentagem;
 }
Example #10
Show file File: Video.php Project: alissonpirola/site-drandre
0
 public function getLastVideos($limit = 5)
 {
     $ytUser = $this->_usr;
     $array = array();
     try {
         $gdata = new Zend_Gdata_YouTube();
         $feed = $gdata->getUserUploads($ytUser);
         if ($feed) {
             $i = 1;
             foreach ($feed as $entry) {
                 $thumb = max($entry->getVideoThumbnails());
                 $image = min($entry->getVideoThumbnails());
                 $date = new Zend_Date($entry->getVideoDuration(), Zend_Date::SECOND);
                 $array[] = array("id" => $entry->getVideoId(), "title" => $entry->getVideoTitle(), "thumb" => $thumb["url"], "time" => $date->get("mm:ss"), "image" => $image["url"]);
                 if ($i == $limit) {
                     break;
                     /* Sai */
                 }
                 $i++;
             }
         }
     } catch (Zend_Exception $e) {
     }
     return $array;
 }
Example #11
Show file File: Belboon.php Project: netzkind/php-oara
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Base#getTransactionList($merchantId,$dStartDate,$dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $result = $this->_client->getEventList(null, null, null, null, null, $dStartDate->toString("YYYY-MM-dd"), $dEndDate->toString("YYYY-MM-dd"), null, null, null, null, 0);
     foreach ($result->handler->events as $event) {
         if (in_array($event["programid"], $merchantList)) {
             $transaction = array();
             $transaction['unique_id'] = $event["eventid"];
             $transaction['merchantId'] = $event["programid"];
             $transaction['date'] = $event["eventdate"];
             if ($event["subid"] != null) {
                 $transaction['custom_id'] = $event["subid"];
                 if (preg_match("/subid1=/", $transaction['custom_id'])) {
                     $transaction['custom_id'] = str_replace("subid1=", "", $transaction['custom_id']);
                 }
             }
             if ($event["eventstatus"] == 'APPROVED') {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
             } else {
                 if ($event["eventstatus"] == 'PENDING') {
                     $transaction['status'] = Oara_Utilities::STATUS_PENDING;
                 } else {
                     if ($event["eventstatus"] == 'REJECTED') {
                         $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                     }
                 }
             }
             $transaction['amount'] = $event["netvalue"];
             $transaction['commission'] = $event["eventcommission"];
             $totalTransactions[] = $transaction;
         }
     }
     return $totalTransactions;
 }
Example #12
Show file File: CadastroCliente.php Project: Dinookys/zend_app
0
 public function init()
 {
     // Verifica se o campo select esta com o valor null
     $required = new Zend_Validate_NotEmpty();
     $required->setType($required->getType() | Zend_Validate_NotEmpty::STRING | Zend_Validate_NotEmpty::ZERO);
     $data_now = new Zend_Date();
     $options_estado_civil = array('-- Selecione --', 'casado' => 'Casado', 'solteiro' => 'Solteiro', 'divorciado' => 'Divorciado', 'viuvo' => 'Viuvo');
     $options_empty = array('-- Selecione --');
     $options_meio_comunicacao = array('-- Selecione --', 'Telefone' => 'Telefone', 'Tv' => 'TV', 'Local' => 'Pass. no Local', 'Radio' => 'Rádio', 'Faixas' => 'Faixas', 'Email' => 'Email', 'Panfletagem' => 'Panfletagem', 'Mala direta' => 'Mala direta', 'Indicação' => 'Indicação', 'Internet' => 'Internet', 'Jornal' => 'Jornal', 'Outdoor' => 'Outdoor', 'Outros' => 'Outros');
     $options_renda = array('-- Selecione --', 'formal' => 'Formal', 'informal' => 'Informal', 'mista' => 'Mista');
     $options_sim_nao = array('Não', 'Sim');
     $this->addElement('hidden', 'data', array('value' => $data_now->toString('YYYY-MM-dd'), 'decorators' => $this->setColSize(12)));
     // Adicionando tag HTML usando description do elemento
     $this->addElement('hidden', 'data_desc', array('ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-2 pull-right")))));
     // Adicionando tag HTML usando description do elemento
     $this->addElement('hidden', 'header3', array('description' => '<h3>FICHA DE ATENDIMENTO AO CLIENTE</h3>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
     $this->addElement('text', 'nome', array('label' => 'Nome', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('text', 'cpf', array('label' => 'CPF', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
     $this->addElement('select', 'estado_civil', array('label' => 'Estado Civil', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_estado_civil, 'validators' => array($required), 'decorators' => $this->setColSize(3)));
     $this->addElement('text', 'email', array('label' => 'E-mail', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('text', 'data_nasc', array('label' => 'Data de Nascimento', 'required' => false, 'description' => '<span class="glyphicon glyphicon-calendar"></span>', 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3, true, true)));
     // Adicionando tag HTML usando description do elemento
     $this->addElement('hidden', 'hr_filiacao', array('description' => '<h3>FILIAÇÃO</h3>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
     $this->addElement('text', 'filiacao_pai', array('label' => 'Pai', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('text', 'filiacao_mae', array('label' => 'Mãe', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     // Adicionando tag HTML usando description do elemento
     $this->addElement('hidden', 'hr_end', array('description' => '<hr/>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
     $this->addElement('text', 'cep', array('label' => 'CEP', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
     $this->addElement('text', 'endereco', array('label' => 'Endereço', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(9)));
     $this->addElement('text', 'bairro', array('label' => 'Bairro', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('select', 'estado', array('label' => 'Estado', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_empty, 'validators' => array($required), 'decorators' => $this->setColSize(6)));
     $this->addElement('select', 'cidade', array('label' => 'Cidade', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_empty, 'validators' => array($required), 'decorators' => $this->setColSize(6)));
     $this->addElement('text', 'fone_resid', array('label' => 'Fone Resid.', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(4)));
     $this->addElement('text', 'fone_com', array('label' => 'Fone Com.', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(4)));
     $this->addElement('text', 'fone_cel', array('label' => 'Celular', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(4)));
     // Adicionando tag HTML usando description do elemento
     $this->addElement('hidden', 'hr_contato', array('description' => '<hr/>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
     $this->addElement('text', 'empresa_trabalha', array('label' => 'Empresa na qual trabalha', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize()));
     $this->addElement('text', 'profissao', array('label' => 'Profissão', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('text', 'cargo', array('label' => 'Cargo', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('text', 'renda_familiar', array('label' => 'Renda Familiar', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(6)));
     $this->addElement('select', 'renda', array('label' => 'Renda', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_renda, 'validators' => array($required), 'decorators' => $this->setColSize(6)));
     $this->addElement('select', 'fgts', array('label' => 'FGTS', 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_sim_nao, 'decorators' => $this->setColSize(3)));
     $this->addElement('select', 'fgts_tres_anos', array('label' => 'Mais de 3 anos', 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_sim_nao, 'decorators' => $this->setColSize(3)));
     $this->addElement('text', 'saldo_fgts', array('label' => 'Saldo FGTS', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
     $this->addElement('text', 'valor_entrada', array('label' => 'Valor de entrada', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'decorators' => $this->setColSize(3)));
     // Adicionando tag HTML usando description do elemento
     $this->addElement('hidden', 'header3_atendimento', array('description' => '<h3>SOBRE O ATENDIEMENTO</h3>', 'ignore' => true, 'decorators' => array(array('Description', array('escape' => false, 'tag' => 'div', 'class' => "col-xs-12")))));
     $this->addElement('select', 'meio_comunicacao', array('label' => 'Meio de Comunicação', 'required' => true, 'filters' => array('StringTrim'), 'class' => 'form-control', 'multiOptions' => $options_meio_comunicacao, 'validators' => array($required), 'decorators' => $this->setColSize()));
     $this->addElement('textarea', 'observacoes', array('label' => 'Observações', 'required' => false, 'filters' => array('StringTrim'), 'class' => 'form-control', 'cols' => 80, 'rows' => 5, 'decorators' => $this->setColSize()));
     $this->addElement('hidden', 'created_user_id', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
     $this->addElement('hidden', 'last_user_id', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
     $this->addElement('hidden', 'locked', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
     $this->addElement('hidden', 'locked_by', array('value' => CURRENT_USER_ID, 'decorators' => $this->setColSize(12)));
     $this->addElement('submit', 'Enviar', array('label' => 'Enviar', 'ignore' => 'true', 'class' => 'btn btn-success pull-right', 'decorators' => $this->setColSize(12, false)));
     $this->setDecorators(array('FormElements', array(array('in' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row')), 'Form', array('HtmlTag', array('tag' => 'div', 'class' => 'panel panel-body panel-default'))));
     $this->setAttrib('class', 'form');
     $this->setAttrib('id', 'ficha-atendimento');
     $this->setMethod('post');
 }
Example #13
Show file File: Logger.php Project: protechhelp/gamamba
0
 /**
  * Set the backup file content
  *
  * @param string $content
  * @return AW_Lib_Model_Log_Logger
  */
 public function createBackupFile($content)
 {
     if (!extension_loaded("zlib") || !$content) {
         return $this;
     }
     $date = new Zend_Date();
     $fileName = $date->toString(Varien_Date::DATE_INTERNAL_FORMAT) . self::BACKUP_DEFAULT_FILE_NAME;
     $pathToBackupDir = Mage::getBaseDir() . self::PATH_TO_BACKUP_DIR;
     $pathToBackupFile = $pathToBackupDir . $fileName;
     $backupFile = fopen($pathToBackupFile, 'w');
     if (!$backupFile) {
         return $this;
     }
     $fwrite = fwrite($backupFile, $content);
     if (!$fwrite) {
         fclose($backupFile);
         unlink($pathToBackupFile);
         return $this;
     }
     $archiveName = $date->toString(Varien_Date::DATE_INTERNAL_FORMAT) . self::BACKUP_DEFAULT_ARCHIVE_NAME;
     $pathToBackupArchive = $pathToBackupDir . $archiveName;
     $zipArchive = new ZipArchive();
     $zipArchive->open($pathToBackupArchive, ZIPARCHIVE::CREATE);
     $zipArchive->addFile($pathToBackupFile, $fileName);
     $zipArchive->close();
     fclose($backupFile);
     unlink($pathToBackupFile);
     return $this;
 }
Example #14
Show file File: PastebinMapper.php Project: sebflipper/zf-pastebin
0
 public function save(Default_Model_Pastebin $pastebin)
 {
     $shortId = $pastebin->getShortId();
     if (empty($shortId)) {
         $shortId = $this->_getShortId();
         $pastebin->setShortId($shortId);
     }
     $name = $pastebin->getName();
     $expiresTime = $pastebin->getExpires();
     $expires = null;
     if ($expiresTime != 'never') {
         $expires = new Zend_Date();
         if ($expiresTime == 'hour') {
             $expires->addHour(1);
         }
         if ($expiresTime == 'day') {
             $expires->addDay(1);
         }
         if ($expiresTime == 'week') {
             $expires->addWeek(1);
         }
         if ($expiresTime == 'month') {
             $expires->addMonth(1);
         }
         $expires = $expires->get('yyyy-MM-dd HH:mm:ss');
     }
     $data = array('short_id' => $shortId, 'name' => !empty($name) ? $name : 'Anonymous', 'code' => $pastebin->getCode(), 'language' => $pastebin->getLanguage(), 'expires' => $expires, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'created' => date('Y-m-d H:i:s'));
     if (null === ($id = $pastebin->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
     return $shortId;
 }
Example #15
Show file File: DbReturnItem.php Project: pingitgroup/stockpingitgroup
0
 public function returnItemToCustomer($post)
 {
     $db_global = new Application_Model_DbTable_DbGlobal();
     $db = $this->getAdapter();
     $db->beginTransaction();
     try {
         $session_user = new Zend_Session_Namespace('auth');
         $userName = $session_user->user_name;
         $GetUserId = $session_user->user_id;
         if ($post["invoice_no"] == "") {
             $date = new Zend_Date();
             $returnout_no = "RCO" . $date->get('hh-mm-ss');
         } else {
             $returnout_no = $post['invoice_no'];
         }
         $data_return = array("returnin_id" => $post["return_id"], "returnout_no" => $returnout_no, "location_id" => $post["LocationId"], "date_return" => $post["return_date"], "remark" => $post["remark_return"], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "all_total" => $post["all_total"]);
         $returnout_id = $db_global->addRecord($data_return, "tb_return_customer_out");
         unset($data_update);
         $ids = explode(',', $post['identity']);
         foreach ($ids as $i) {
             $add_data = array("return_id" => $returnout_id, "pro_id" => $post["item_id_" . $i], "qty_return" => $post["qty_return_" . $i], "price" => $post["price_" . $i], "sub_total" => $post["sub_total_" . $i], "return_remark" => $post["remark_" . $i]);
             $db->insert("tb_return_customer_item_out", $add_data);
             $rows = $db_global->inventoryLocation($post["LocationId"], $post["item_id_" . $i]);
             if ($rows) {
                 $updatedata = array('qty' => $rows["qty"] - $post["qty_return_" . $i], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                 //update stock product location
                 $db_global->updateRecord($updatedata, $rows["ProLocationID"], "ProLocationID", "tb_prolocation");
                 unset($updatedata);
                 $qty_on_return = array("QuantityOnHand" => $rows["QuantityOnHand"] - $post["qty_return_" . $i], "QuantityAvailable" => $rows["QuantityAvailable"] - $post["qty_return_" . $i], "Timestamp" => new zend_date());
                 //update total stock
                 $db_global->updateRecord($qty_on_return, $post["item_id_" . $i], "ProdId", "tb_inventorytotal");
                 unset($qty_on_return);
                 $data_history = array('transaction_type' => 6, 'pro_id' => $post["item_id_" . $i], 'date' => new Zend_Date(), 'location_id' => $post["LocationId"], 'Remark' => $returnout_no, 'qty_edit' => $post["qty_return_" . $i], 'qty_before' => $rows["qty"], 'qty_after' => $rows["qty"] - $post["qty_return_" . $i], 'user_mod' => $GetUserId);
                 $db->insert("tb_move_history", $data_history);
                 unset($data_history);
             } else {
                 $insertdata = array('pro_id' => $post["item_id_" . $i], 'LocationId' => $post["LocationId"], 'qty' => -$post["qty_return_" . $i]);
                 //update stock product location
                 $db->insert("tb_prolocation", $insertdata);
                 unset($insertdata);
                 $data_history = array('transaction_type' => 6, 'pro_id' => $post["item_id_" . $i], 'date' => new Zend_Date(), 'location_id' => $post["LocationId"], 'Remark' => $returnout_no, 'qty_edit' => $post["qty_return_" . $i], 'qty_before' => 0, 'qty_after' => -$post["qty_return_" . $i], 'user_mod' => $GetUserId);
                 $db->insert("tb_move_history", $data_history);
                 unset($data_history);
                 $rows_stock = $db_global->InventoryExist($post["item_id_" . $i]);
                 if ($rows_stock) {
                     $dataInventory = array('QuantityOnHand' => $rows_stock["QuantityOnHand"] - $post["qty_return_" . $i], 'QuantityAvailable' => $rows_stock["QuantityAvailable"] - $post["qty_return_" . $i], 'Timestamp' => new Zend_date());
                     $db_global->updateRecord($dataInventory, $rows_stock["ProdId"], "ProdId", "tb_inventorytotal");
                     unset($dataInventory);
                 } else {
                     $addInventory = array('ProdId' => $post["item_id_" . $i], 'QuantityOnHand' => -$post["qty_return_" . $i], 'QuantityAvailable' => -$post["qty_return_" . $i], 'Timestamp' => new Zend_date());
                     $db->insert("tb_inventorytotal", $addInventory);
                     unset($addInventory);
                 }
             }
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
     }
 }
Example #16
Show file File: PartnerUsageFilter.php Project: richhl/kalturaCE
0
 public function init()
 {
     $this->setMethod('post');
     $this->setDecorators(array('FormElements', 'Form', array('HtmlTag', array('tag' => 'fieldset'))));
     // filter type
     $this->addElement('select', 'filter_type', array('required' => true, 'multiOptions' => array('none' => 'None', 'byid' => 'Publisher ID', 'byname' => 'Publisher Name', 'free' => 'Free-form text'), 'decorators' => array('ViewHelper', 'Label')));
     // search input
     $this->addElement('text', 'filter_input', array('required' => true, 'filters' => array('StringTrim'), 'decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'id' => 'filter_text')))));
     // active status
     $this->addElement('checkbox', 'include_active', array('label' => 'partner-usage filter active', 'checked' => true, 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')))));
     // blocked status
     $this->addElement('checkbox', 'include_blocked', array('label' => 'partner-usage filter blocked', 'checked' => true, 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')))));
     // removed status
     $this->addElement('checkbox', 'include_removed', array('label' => 'partner-usage filter removed', 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')))));
     // from
     $from = new Zend_Date(time() - 60 * 60 * 24 * 30);
     $this->addElement('text', 'from_date', array('value' => $from->toString(self::getDefaultTranslator()->translate('datepicker format')), 'filters' => array('StringTrim'), 'decorators' => array('ViewHelper')));
     // from - to separator
     $this->addElement('text', 'dates_separator', array('description' => '&nbsp;-&nbsp;', 'filters' => array('StringTrim'), 'decorators' => array(array('Description', array('escape' => false, 'tag' => '')))));
     // to
     $to = new Zend_Date(time());
     $this->addElement('text', 'to_date', array('value' => $to->toString(self::getDefaultTranslator()->translate('datepicker format')), 'filters' => array('StringTrim'), 'decorators' => array('ViewHelper')));
     $this->addElement('text', 'clear_dates', array('description' => 'partner-usage filter clear dates', 'decorators' => array(array('Description', array('tag' => 'a', 'id' => 'clear_dates')))));
     $this->addElement('text', 'filter_input_help', array('decorators' => array(array('HtmlTag', array('tag' => 'div', 'class' => 'help', 'placement' => 'append')))));
     $this->addDisplayGroup(array('filter_type', 'filter_input', 'filter_input_help'), 'filter_type_group', array('description' => 'partner-usage filter by', 'decorators' => array(array('Description', array('tag' => 'legend')), 'FormElements', 'Fieldset')));
     $this->addDisplayGroup(array('include_active', 'include_blocked', 'include_removed'), 'statuses', array('description' => 'partner-usage filter status types', 'decorators' => array(array('Description', array('tag' => 'legend')), 'FormElements', 'Fieldset')));
     $this->addDisplayGroup(array('from_date', 'dates_separator', 'to_date', 'clear_dates'), 'dates', array('description' => 'partner-usage filter range limit', 'decorators' => array(array('Description', array('tag' => 'legend')), 'FormElements', 'Fieldset')));
     // submit button
     $this->addElement('button', 'submit', array('type' => 'submit', 'id' => 'do_filter', 'label' => 'partner-usage filter search', 'decorators' => array('ViewHelper')));
 }
Example #17
Show file File: Bootstrap.php Project: uskumar33/DeltaONE
0
 protected function _initView()
 {
     $theme = 'default';
     $templatePath = APPLICATION_PATH . '/../public/themes/' . $theme . '/templates';
     Zend_Registry::set('user_date_format', 'm-d-Y');
     Zend_Registry::set('calendar_date_format', 'mm-dd-yy');
     Zend_Registry::set('db_date_format', 'Y-m-d');
     Zend_Registry::set('perpage', 10);
     Zend_Registry::set('menu', 'home');
     Zend_Registry::set('eventid', '');
     $dir_name = $_SERVER['DOCUMENT_ROOT'] . rtrim(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']), '/');
     Zend_Registry::set('acess_file_path', $dir_name . SEPARATOR . "application" . SEPARATOR . "modules" . SEPARATOR . "default" . SEPARATOR . "plugins" . SEPARATOR . "AccessControl.php");
     Zend_Registry::set('siteconstant_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "site_constants.php");
     Zend_Registry::set('emailconstant_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "email_constants.php");
     Zend_Registry::set('emptab_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "emptabconfigure.php");
     Zend_Registry::set('emailconfig_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "mail_settings_constants.php");
     Zend_Registry::set('application_file_path', $dir_name . SEPARATOR . "public" . SEPARATOR . "application_constants.php");
     $date = new Zend_Date();
     Zend_Registry::set('currentdate', $date->get('yyyy-MM-dd HH:mm:ss'));
     Zend_Registry::set('currenttime', $date->get('HH:mm:ss'));
     Zend_Registry::set('logo_url', '/public/images/landing_header.jpg');
     $view = new Zend_View();
     $view->setEscape('stripslashes');
     $view->setBasePath($templatePath);
     $view->setScriptPath(APPLICATION_PATH);
     $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
     $viewRenderer->setView($view);
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     return $this;
 }
Example #18
Show file File: Aviso.php Project: fredcido/cenbrap
0
 /**
  * 
  */
 public function listAvisos($curso)
 {
     try {
         $auth = Zend_Auth::getInstance();
         $parameters = array('usuario' => $auth->getIdentity()->codigo, 'curso' => $curso);
         // Cria hash de comunicacao
         $parameters['hash'] = App_Util_Cenbrap::getHash($parameters, array('usuario', 'curso'));
         // Faz requisição para API
         $response = App_Util_Cenbrap::request('MuralAvisos', $parameters);
         if (empty($response['status'])) {
             throw new Exception('Erro ao listar mural de avisos');
         }
         $avisos = array();
         $date = new Zend_Date();
         foreach ($response['avisos'] as $aviso) {
             if (!empty($aviso['data'])) {
                 $date->setDate($aviso['data'], 'dd/MM/yyyy');
                 $avisos[$date->toString('yyyy-MM-dd')][] = $aviso;
             }
         }
         ksort($avisos);
         $avisos = array_reverse($avisos);
         return $avisos;
     } catch (Exception $e) {
         $this->_message->addMessage($e->getMessage(), App_Message::WARNING);
         return array();
     }
 }
Example #19
Show file File: ModelTest.php Project: rom1git/Centurion
0
 public function testDateFormatForDatePicker()
 {
     //Without time
     $date = new Zend_Date('1/12/2009', 'dd/MM/YYYY');
     $form = new Cms_Form_Model_Flatpage();
     $form->setDateFormat('dd/MM/yy');
     $row = Centurion_Db::getSingleton('cms/flatpage')->createRow();
     $row->published_at = $date->get(Centurion_Date::MYSQL_DATETIME);
     $form->setInstance($row);
     $expected = $date->get('dd/MM/yy');
     $value = $form->getElement('published_at')->getValue();
     $this->assertEquals($expected, $value);
     $values = $form->processValues($form->getValues());
     $this->assertEquals($date->get(Centurion_Date::MYSQL_DATETIME), $values['published_at']);
     //With Time
     $date = new Zend_Date('1/12/2009 11:32', 'dd/MM/YYYY HH:mm');
     $form = new Cms_Form_Model_Flatpage();
     $form->setDateFormat('dd/MM/yy', 'hh:mm');
     $row = Centurion_Db::getSingleton('cms/flatpage')->createRow();
     $row->published_at = $date->get(Centurion_Date::MYSQL_DATETIME);
     $form->setInstance($row);
     $expected = $date->get('dd/MM/yy hh:mm');
     $value = $form->getElement('published_at')->getValue();
     $this->assertEquals($expected, $value);
     $values = $form->processValues($form->getValues());
     $this->assertEquals($date->get(Centurion_Date::MYSQL_DATETIME), $values['published_at']);
 }
Example #20
Show file File: RelativeDateTime.php Project: hausdesign/zf-library
0
 public function relativeDateTime(Zend_Date $date = null)
 {
     if (null === $date) {
         return $this;
     }
     $todayDate = new Zend_Date();
     $diff = $todayDate->sub($date);
     $mt = new Zend_Measure_Time($diff);
     $units = $mt->getConversionList();
     $chunks = array(Zend_Measure_Time::YEAR, Zend_Measure_Time::MONTH, Zend_Measure_Time::WEEK, Zend_Measure_Time::DAY, Zend_Measure_Time::HOUR, Zend_Measure_Time::MINUTE, Zend_Measure_Time::SECOND);
     for ($i = 0, $count = count($chunks); $i < $count; ++$i) {
         $seconds = $units[$chunks[$i]][0];
         $unitKey = $chunks[$i];
         if (0.0 !== ($result = floor($diff->get(Zend_Date::TIMESTAMP) / $seconds))) {
             break;
         }
     }
     $translateHelper = new Zend_View_Helper_Translate();
     if ($result === (double) 1) {
         $formatedString = $translateHelper->translate($this->getUnitTemplate($unitKey));
     } else {
         $formatedString = $translateHelper->translate($this->getUnitTemplate($unitKey . 'S'));
     }
     $formatedString = str_replace('%value%', (string) $result, $formatedString);
     return $formatedString;
 }
Example #21
Show file File: SamplereceivingController.php Project: robertsonmello/projetos
0
 public function selectedrequestcovenantAction()
 {
     $responce = new stdClass();
     $cdrequest = $_POST["idrequest"];
     $requestModel = new RequestModel();
     $clientCovenant = $requestModel->fetchRow($requestModel->getClientCovenantForward($cdrequest));
     if ($clientCovenant['dtbirth'] != '') {
         $dtbirth = new Zend_Date($clientCovenant['dtbirth'], 'dd-MM-YYYY');
         $year = $dtbirth->toString('YYYY');
         $month = $dtbirth->toString('MM');
         $day = $dtbirth->toString('dd');
         $today = new Zend_Date();
         $tdYear = $today->toString('YYYY');
         $tdMonth = $today->toString('MM');
         $tdDay = $today->toString('dd');
         $nrage = 0;
         $nrage = GslabUtils::calcAgeDifferenceShort($clientCovenant['dtbirth']);
         if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
             $nrage--;
         }
     } else {
         $nrage = " ";
     }
     $responce->forward = $clientCovenant['nmforward'];
     $responce->covenant = $clientCovenant['nmcovenant'];
     $responce->client = $clientCovenant['nmclient'];
     $responce->fgsex = $clientCovenant['fgsex'];
     $responce->age = $nrage;
     $responce = json_encode($responce);
     print_r($responce);
     return $responce;
 }
Example #22
Show file File: Grid.php Project: digitalpianism/customreports
0
 /**
     * @return $this
     * @throws Zend_Date_Exception
     */
 protected function _prepareCollection()
 {
     // Get the session
     $session = Mage::getSingleton('core/session');
     // Dates for one week
     $store = Mage_Core_Model_App::ADMIN_STORE_ID;
     $timezone = Mage::app()->getStore($store)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
     date_default_timezone_set($timezone);
     // Automatic -30 days if no dates provided
     if ($session->getWishlistFrom()) {
         $sDate = $session->getWishlistFrom();
     } else {
         $sDate = date('Y-m-d 00:00:00', Mage::getModel('core/date')->timestamp(strtotime('-30 days')));
     }
     if ($session->getWishlistTo()) {
         $eDate = $session->getWishlistTo();
     } else {
         $eDate = date('Y-m-d 23:59:59', Mage::getModel('core/date')->timestamp(time()));
     }
     ###############################################################################
     $start = new Zend_Date($sDate);
     $start->setTimeZone("UTC");
     $end = new Zend_Date($eDate);
     $end->setTimeZone("UTC");
     ###############################################################################
     $from = $start->toString("Y-MM-dd HH:mm:ss");
     $to = $end->toString("Y-MM-dd HH:mm:ss");
     $collection = Mage::getModel('wishlist/wishlist')->getCollection()->addFieldToFilter('wishlist_id', array('in' => $this->getFilterWishlistWithItems()))->addFieldToFilter('main_table.updated_at', array('gt' => $from))->addFieldToFilter('main_table.updated_at', array('lt' => $to));
     $collection->getSelect()->joinLeft(array('customer' => Mage::getSingleton("core/resource")->getTableName('customer_entity')), 'main_table.customer_id=customer.entity_id', array('email'));
     $this->setCollection($collection);
     parent::_prepareCollection();
     return $this;
 }
Example #23
Show file File: Trip.php Project: rizkioa/etak6
0
 /**
  * Get trip paginator adapter
  * @param string $filtingField
  * @param string $filtingCriteria
  * @param string $sortingField
  * @return Zend_Paginator_Adapter_DbSelect|Zend_Paginator_Adapter_DbTableSelect
  */
 public function getTripPaginatorAdapter($filtingField, $filtingCriteria, $sortingField)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
     if (!empty($filtingField)) {
         // switch filting field
         switch ($filtingField) {
             case 'departure_time':
             case 'arrival_time':
                 if (!empty($filtingCriteria)) {
                     $dateFormat = new Zend_Date($filtingCriteria, 'dd-MM-y HH:mm:ss');
                     $filtingCriteria = $dateFormat->toString('y-MM-dd HH:mm:ss');
                 }
                 break;
             case 'from_city':
             case 'to_city':
                 $db = Zend_Db_Table::getDefaultAdapter();
                 $select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
                 break;
             default:
                 break;
         }
         // add filting criteria
         $select->where($filtingField . ' = ?', $filtingCriteria);
     }
     // add sorting criteria
     if (!empty($sortingField)) {
         $select->order($sortingField);
     }
     $adapter = new Zend_Paginator_Adapter_DbSelect($select);
     return $adapter;
 }
Example #24
Show file File: Date.php Project: sgdoc/sgdoce-codigo
0
 /**
  * @return string
  */
 public function __toString()
 {
     if ($this->_date instanceof Zend_Date) {
         return $this->_date->__toString();
     }
     return '';
 }
Example #25
Show file File: Onepage.php Project: netz98/N98_LegalAge
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 #26
Show file File: GetDays.php Project: realejo/library-zf1
0
 /**
  * @param date $d data a ser comparada
  */
 public function getDays($d)
 {
     $now = time();
     $date = new Zend_Date($d, Zend_Date::ISO_8601);
     $time = $now - $date->getTimestamp();
     if ($time < 86400) {
         //60*60*24
         $time = 'hoje';
     } elseif ($time < 172800) {
         //60*60*24*2
         $time = 'ontem';
         //mostrar quantidade de dias até 14 dias
     } elseif ($time < 604800) {
         //60*60*24*30
         $time = 'há ' . round(floatval($time) / 86400) . ' dias';
         //mostrar quantidades de semanas apartir da 2 semana até 1 mes
     } elseif ($time > 1209600 && $time <= 2592000) {
         //60*60*24*(7*4)
         $time = 'há ' . round(floatval($time) / 604800) . ' semanas';
     } elseif ($time > 2592000 && $time <= 5184000) {
         //60*60*24*30 && 60*60*24*30*2
         $time = 'há ' . round(floatval($time) / 2592000) . ' mês';
     } elseif ($time > 5184000 && $time < 31104000) {
         //60*60*24*30*2  && 60*60*24*30*12
         $time = 'há ' . round(floatval($time) / 2592000) . ' meses';
     } else {
         //if ($time < 31104000) { //60*60*24*30*12
         $time = 'há mais de um ano (' . $date->toString() . ')';
     }
     return $time;
 }
Example #27
Show file File: Search.php Project: knatorski/SMS
0
 protected function _filterSql()
 {
     $date = new Zend_Date();
     if (isset($this->filterdata['created_by']) && !empty($this->filterdata['created_by'])) {
         $this->_select->where("p.created_by = (?)", new Zend_Db_Expr("SELECT id FROM public.user WHERE upper(login) ilike '" . strtoupper($this->filterdata['created_by'] . "'")));
     }
     if (isset($this->filterdata['name']) && !empty($this->filterdata['name'])) {
         $this->_select->where("p.name ilike ?", $this->filterdata['name']);
     }
     if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) {
         $this->filterdata['date_for'] = $date->setDate($this->filterdata['date_for'], 'YYYY-MM-dd')->toString(Zend_Date::ISO_8601);
     }
     if (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
         $this->filterdata['date_to'] = $date->setDate($this->filterdata['date_to'], 'YYYY-MM-dd')->toString(Zend_Date::ISO_8601);
     }
     if (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for']) && isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
         $this->_select->where('created_at BETWEEN \'' . $this->filterdata['date_for'] . '\' AND \'' . $this->filterdata['date_to'] . '\'');
     } elseif (isset($this->filterdata['date_for']) && !empty($this->filterdata['date_for'])) {
         $this->_select->where('created_at > ?', $this->filterdata['date_for']);
     } elseif (isset($this->filterdata['date_to']) && !empty($this->filterdata['date_to'])) {
         $this->_select->where('created_at < ?', $this->filterdata['date_to']);
     }
     if (isset($this->filterdata['ws_service_set_id']) && !empty($this->filterdata['ws_service_set_id'])) {
         $this->_select->where("ws_service_set_id = ?", $this->filterdata['ws_service_set_id']);
     }
     if (isset($this->filterdata['ws_service_group_id']) && !empty($this->filterdata['ws_service_group_id'])) {
         $this->_select->where("ws_service_group_id = ?", $this->filterdata['ws_service_group_id']);
     }
 }
Example #28
Show file File: Data.php Project: NatashaOlut/Mage_Test
0
 public function testFormatTime()
 {
     $this->assertEquals($this->_dateTime->format(self::TIME_FORMAT_SHORT), $this->_helper->formatTime());
     $this->assertEquals($this->_dateTime->format(self::DATETIME_FORMAT_SHORT), $this->_helper->formatTime(null, 'short', true));
     $zendDate = new Zend_Date($this->_dateTime->format('U'));
     $this->assertEquals($zendDate->toString(self::TIME_FORMAT_SHORT_ISO), $this->_helper->formatTime($zendDate, 'short'));
 }
Example #29
Show file File: Update.php Project: siite/choose-sa-cloud
0
 /**
  * @param null $currentRev
  * @return array
  * @throws \Exception
  */
 public static function getAvailableUpdates($currentRev = null)
 {
     if (!$currentRev) {
         $currentRev = Version::$revision;
     }
     self::cleanup();
     if (PIMCORE_DEVMODE) {
         $xmlRaw = Tool::getHttpData("http://" . self::$updateHost . "/v2/getUpdateInfo.php?devmode=1&revision=" . $currentRev);
     } else {
         $xmlRaw = Tool::getHttpData("http://" . self::$updateHost . "/v2/getUpdateInfo.php?revision=" . $currentRev);
     }
     $xml = simplexml_load_string($xmlRaw, null, LIBXML_NOCDATA);
     $revisions = array();
     $releases = array();
     if ($xml instanceof \SimpleXMLElement) {
         if (isset($xml->revision)) {
             foreach ($xml->revision as $r) {
                 $date = new \Zend_Date($r->date);
                 if (strlen(strval($r->version)) > 0) {
                     $releases[] = array("id" => strval($r->id), "date" => strval($r->date), "version" => strval($r->version), "text" => strval($r->id) . " - " . $date->get(\Zend_Date::DATETIME_MEDIUM));
                 } else {
                     $revisions[] = array("id" => strval($r->id), "date" => strval($r->date), "text" => strval($r->id) . " - " . $date->get(\Zend_Date::DATETIME_MEDIUM));
                 }
             }
         }
     } else {
         throw new \Exception("Unable to retrieve response from update server. Please ensure that your server is allowed to connect to update.pimcore.org:80");
     }
     return array("revisions" => $revisions, "releases" => $releases);
 }
Example #30
Show file File: Acl.php Project: KasaiDot/FansubCMS
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $this->_initAcl();
     if ($this->_auth->hasIdentity()) {
         $ident = $this->_auth->getIdentity();
         $date = new Zend_Date();
         $ident->last_login = $date->get(DATABASE_DATE_FORMAT);
         $ident->save();
     }
     if ($request->getControllerName() != 'admin' && $request->getModuleName() != 'admin') {
         return;
     }
     // if this is not admin skip the rest
     if (!$this->_auth->hasIdentity() && !($request->getControllerName() == 'auth' && $request->getActionName() == 'login' && $request->getModuleName() == 'admin')) {
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         $redirect->gotoSimple('login', 'auth', 'admin');
     }
     if ($request->getModuleName() == 'user' && $request->getControllerName() == 'admin' && $request->getActionName() == 'profile') {
         return;
     }
     // the profile is a free resource
     $resource = $request->getModuleName() . '_' . $request->getControllerName();
     $hasResource = $this->_acl->has($resource);
     if ($hasResource && !$this->_acl->isAllowed('fansubcms_user_custom_role_logged_in_user', $resource, $request->getActionName())) {
         throw new FansubCMS_Exception_Denied('The user is not allowd to do this');
     }
 }
Frequently Used Methods