/** * Sets the internal value to ISO date format. * * @param string|array $val String expects an ISO date format. Array notation with 'date' and 'time' * keys can contain localized strings. If the 'dmyfields' option is used for {@link DateField}, * the 'date' value may contain array notation was well (see {@link DateField->setValue()}). */ function setValue($val) { if (empty($val)) { $this->dateField->setValue(null); $this->timeField->setValue(null); } else { // String setting is only possible from the database, so we don't allow anything but ISO format if (is_string($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) { // split up in date and time string values. $valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'), $this->locale); // set date either as array, or as string if ($this->dateField->getConfig('dmyfields')) { $this->dateField->setValue($valueObj->toArray()); } else { $this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat'))); } // set time $this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat'))); } elseif (is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) { $this->dateField->setValue($val['date']); $this->timeField->setValue($val['time']); } else { $this->dateField->setValue($val); $this->timeField->setValue($val); } } }
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; }
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']); }
/** * @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); }
public function convertDateToStoreTimestamp($date, $store = null) { try { if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/disable_timestamp_timezone_adjustment')) { $dateObj = new Zend_Date(); $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT); return (int) $dateObj->get(null, Zend_Date::TIMESTAMP); } $dateObj = new Zend_Date(); $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); $dateObj->set($date, Varien_Date::DATETIME_INTERNAL_FORMAT); $dateObj->setLocale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $store)); $dateObj->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $store)); $gmtOffset = $dateObj->getGmtOffset(); if ($gmtOffset >= 0) { if (Mage::getStoreConfigFlag('xtcore/compatibility_fixes/zend_date_gmt_offset')) { // Note: Some Zend_Date versions always return a positive $gmtOffset. Thus, we replace + with - below if affected by this. return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset; } else { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) + $gmtOffset; } } else { return (int) $dateObj->get(null, Zend_Date::TIMESTAMP) - $gmtOffset; } } catch (Exception $e) { return null; } }
public function indexAction() { // numero da semana anterior $zendDate = new Zend_Date(); $semana = $zendDate->get(Zend_Date::WEEK) - 1; $dia_semana = $zendDate->get(Zend_Date::WEEKDAY_DIGIT); $zendDate->subDay(7); $dia_semana_inicio = $dia_semana - 1; $dia_semana_fim = 7 - $dia_semana; $periodo_inicial = $zendDate->subDay($dia_semana_inicio)->get("dd/MM/YYYY"); $periodo_final = $zendDate->addDay($dia_semana_fim)->get('dd/MM/YYYY'); $periodo = $periodo_inicial . ' à ' . $periodo_final; // busca as visualizacoes da semana $modelSalaoVisualizacao = new Model_DbTable_SalaoVisualizacao(); $visualizacoes = $modelSalaoVisualizacao->visualizacoes($semana); try { foreach ($visualizacoes as $visualizacao) { $pluginMail = new Plugin_Mail(); $pluginMail->setDataMail('visualizacao', $visualizacao); $pluginMail->setDataMail('periodo', $periodo); $pluginMail->send("salao-visualizacao.phtml", "Relatório de Visualizações", $visualizacao->salao_email); } echo 'emails enviados'; } catch (Zend_Mail_Exception $ex) { die('email'); } catch (Exception $ex) { Zend_Debug::dump($ex->getMessage()); } }
public static function date($date, $length = "", $locale = "") { global $config; $locale == "" ? $locale = new Zend_Locale($config->local->locale) : ($locale = $locale); $length == "" ? $length = "medium" : ($lenght = $length); /* * Length can be any of the Zend_Date lenghts - FULL, LONG, MEDIUM, SHORT */ $formatted_date = new Zend_Date($date, 'yyyy-MM-dd'); switch ($length) { case "full": return $formatted_date->get(Zend_Date::DATE_FULL, $locale); break; case "long": return $formatted_date->get(Zend_Date::DATE_LONG, $locale); break; case "medium": return $formatted_date->get(Zend_Date::DATE_MEDIUM, $locale); break; case "short": return $formatted_date->get(Zend_Date::DATE_SHORT, $locale); break; default: return $formatted_date->get(Zend_Date::DATE_SHORT, $locale); } }
/** * @see Document_Tag::getDataForResource * @return void */ public function getDataForResource() { $this->sanityCheck(); if ($this->date instanceof Zend_Date) { return $this->date->get(Zend_Date::TIMESTAMP); } return; }
/** * @see Document\Tag::getDataForResource * @return void */ public function getDataForResource() { $this->checkValidity(); if ($this->date instanceof \Zend_Date) { return $this->date->get(\Zend_Date::TIMESTAMP); } return; }
/** * this function returns the unique hits for the current week by the day * * @return zend_db_rowset */ public function getLogByDay() { $date = new Zend_Date(); $week = $date->get(Zend_Date::WEEK); $year = $date->get(Zend_Date::YEAR); $sql = "SELECT\r\n COUNT(id) AS unique_hits,\r\n traffic_log.day\r\n FROM\r\n traffic_log\r\n WHERE\r\n week = {$week}\r\n AND\r\n year = {$year}\r\n AND\r\n page NOT LIKE '/admin%'\r\n AND\r\n page NOT LIKE '/module%'\r\n GROUP BY\r\n traffic_log.`year`,\r\n traffic_log.`day`,\r\n traffic_log.`ip`\r\n ORDER BY\r\n year DESC, day DESC\r\n "; return $this->_db->fetchAll($sql); }
/** * Initialization. * @see PHPUnit_Framework_TestCase::setUp() */ protected function setUp() { $this->requested_at = new Zend_Date(); $this->received_at = new Zend_Date(); $this->received_at->addDay(14)->addHour(1)->addMinute(15); $this->history = new Blipoteka_Book_History(); $this->history->borrower_id = 1; $this->history->lender_id = 2; $this->history->book_id = 1; $this->history->requested_at = $this->requested_at->get(Zend_Date::W3C); $this->history->received_at = $this->received_at->get(Zend_Date::W3C); }
function data($timestamp, $format = Zend_Date::DATE_LONG, $idioma = 'pt_BR') { $date = new Zend_Date($timestamp, $idioma); if ($format == "ESPECIAL") { if (!$date->compareDate(date("d-m-Y"))) { return "Hoje, " . $date->get(Zend_Date::TIME_SHORT); } else { return date("d/m", $date->get()) . " - " . $date->get(Zend_Date::TIME_SHORT); } } return $date->get($format); }
/** * */ public function datformat($input, $format = 'short') { $vDate = new Zend_Date($input); if ($format == 'short') { return $vDate->get(Zend_Date::DATE_MEDIUM); } elseif ($format == 'long') { return $vDate->get(Zend_Date::DATE_LONG); } elseif ($format == 'timeshort') { return $vDate->get(Zend_Date::DATETIME_SHORT); } elseif ($format == 'timelong') { return $vDate->get(Zend_Date::DATETIME_LONG); } }
/** * @param string $date * @return Sgca_View_Helper_Date provides a fluent interface */ public function date($date = null, $part = 'yyyy-MM-dd', $output = 'dd/MM/yyyy') { if ($date instanceof Zend_Date) { return $date->get($output); } if (null !== $date && null !== $part) { $this->setDate(new Zend_Date($date, $part)); } if (null !== $output && null !== $date) { return $this->_date->get($output); } return $this; }
/** * getCheckoutFormFields * * Gera os campos para o formulário de redirecionamento ao Banco do Brasil * * @return array */ public function getCheckoutFormFields($order_id, $tpPagamento) { $order = $this->getOrder($order_id); $pedido = $order->getData(); // order details $customer_id = $order->getCustomerId(); $customerData = Mage::getModel('customer/customer')->load($customer_id); // then load customer by customer id $cliente = $customerData->getData(); // customer details $date = new Zend_Date(); $dataNascimento = new Zend_Date($cliente['dob'], 'YYYY-MM-dd HH:mm:ss'); // Utiliza endereço de cobrança caso produto seja virtual/para download $address = $order->getIsVirtual() ? $order->getBillingAddress() : $order->getShippingAddress(); $numCliente = $this->getConfigData('numCliente', $order->getStoreId()); $coopCartao = $this->getConfigData('coopCartao', $order->getStoreId()); $chaveAcessoWeb = $this->getConfigData('chaveAcessoWeb', $order->getStoreId()); $codMunicipio = $this->getConfigData('codMunicipio', $order->getStoreId()); $_read = Mage::getSingleton('core/resource')->getConnection('core_read'); $region = $_read->fetchRow('SELECT * FROM ' . Mage::getConfig()->getTablePrefix() . 'directory_country_region WHERE default_name = "' . $address->getRegion() . '"'); $telefoneCompleto = $this->limpaTelefone($cliente['telefone']); $dd = $telefoneCompleto[0] . $telefoneCompleto[1]; $telefone = str_replace($dd, "", $telefoneCompleto); // Monta os dados para o formulário $fields = array('numCliente' => $numCliente, 'coopCartao' => $coopCartao, 'chaveAcessoWeb' => $chaveAcessoWeb, 'numContaCorrente' => '', 'codMunicipio' => '', 'nomeSacado' => $address->getFirstname() . ' ' . $address->getLastname(), 'dataNascimento' => $dataNascimento->get('YYYYMMdd'), 'cpfCGC' => str_replace(".", "", $cliente['cpf']), 'endereco' => $address->getStreet1() . ', ' . $address->getStreet2(), 'bairro' => $address->getStreet3(), 'cidade' => $address->getCity(), 'cep' => str_replace('-', '', $address->getPostcode()), 'uf' => $region['code'], 'telefone' => $telefone, 'ddd' => $dd, 'ramal' => '', 'bolRecebeBoletoEletronico' => 1, 'email' => $cliente['email'], 'codEspDocumento' => 'DM', 'dataEmissao' => date('Ymd'), 'seuNumero' => '', 'nomeSacador' => '', 'numCGCCPFSacador' => '', 'qntMonetaria' => 1, 'valorTitulo' => number_format($order->getGrandTotal(), 2, '.', ','), 'codTipoVencimento' => '1', 'dataVencimentoTit' => date('Ymd', strtotime("+3 day")), 'valorAbatimento' => '0', 'valorIOF' => '0', 'bolAceite' => '1', 'percTaxaMulta' => '0', 'percTaxaMora' => '0', 'dataPrimDesconto' => NULL, 'valorSegDesconto' => NULL, 'descInstrucao1' => 'Pedido #' . $pedido["increment_id"] . '', 'descInstrucao2' => 'Pedido efetuado na loja seu-site.com.br.', 'descInstrucao3' => 'Em 2(dois) dias úteis para confirmação', 'descInstrucao4' => 'Não receber aṕos o vencimento', 'descInstrucao5' => 'Não receber pagamento em cheque'); return $fields; }
/** * Sets the internal value to ISO date format. * * @param String|Array $val */ function setValue($val) { // Fuzzy matching through strtotime() to support a wider range of times, // e.g. 11am. This means that validate() might not fire. // Note: Time formats are assumed to be less ambiguous than dates across locales. if ($this->getConfig('use_strtotime') && !empty($val)) { if ($parsedTimestamp = strtotime($val)) { $parsedObj = new Zend_Date($parsedTimestamp, Zend_Date::TIMESTAMP); $val = $parsedObj->get($this->getConfig('timeformat')); unset($parsedObj); } } if (empty($val)) { $this->value = null; $this->valueObj = null; } else { if (Zend_Date::isDate($val, $this->getConfig('datavalueformat'))) { $this->valueObj = new Zend_Date($val, $this->getConfig('datavalueformat')); $this->value = $this->valueObj->get($this->getConfig('timeformat')); } else { if (Zend_Date::isDate($val, $this->getConfig('timeformat'), $this->locale)) { $this->valueObj = new Zend_Date($val, $this->getConfig('timeformat'), $this->locale); $this->value = $this->valueObj->get($this->getConfig('timeformat')); } elseif (is_string($val)) { $this->value = $val; $this->valueObj = null; } else { $this->value = null; $this->valueObj = null; } } } return $this; }
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; }
/** * Generate Tracking URL including encoded parameters * * @return string */ public function getTrackingUrl() { $params = array(); switch (Mage::getStoreConfig('admin/germanstoreconfig/datatransfer')) { case IntegerNet_GermanStoreConfig_Model_Source_Datatransfer::DATATRANSFER_ADVANCED: $params['installation_date'] = Mage::getStoreConfig('germanstoreconfig/installation_date'); $params['installation_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); $params['gsc_version'] = (string) Mage::app()->getConfig()->getNode('modules/IntegerNet_GermanStoreConfig/version'); $params['magento_version'] = (string) Mage::getVersion(); $params['shop_name'] = Mage::getStoreConfig('general/imprint/shop_name'); $params['company_first'] = Mage::getStoreConfig('general/imprint/company_first'); $params['company_second'] = Mage::getStoreConfig('general/imprint/company_second'); $params['street'] = Mage::getStoreConfig('general/imprint/street'); $params['zip'] = Mage::getStoreConfig('general/imprint/zip'); $params['city'] = Mage::getStoreConfig('general/imprint/city'); $params['country'] = Mage::getStoreConfig('general/imprint/country'); $params['telephone'] = Mage::getStoreConfig('general/imprint/telephone'); $params['fax'] = Mage::getStoreConfig('general/imprint/fax'); $params['email'] = Mage::getStoreConfig('general/imprint/email'); $params['web'] = Mage::getStoreConfig('general/imprint/web'); $params['ceo'] = Mage::getStoreConfig('general/imprint/ceo'); $params['owner'] = Mage::getStoreConfig('general/imprint/owner'); // fallthrough intended // fallthrough intended case IntegerNet_GermanStoreConfig_Model_Source_Datatransfer::DATATRANSFER_BASIC: $params['installation_id'] = Mage::getStoreConfig('germanstoreconfig/installation_id'); $params['package_type'] = Mage::getStoreConfig('germanstoreconfig/module_code'); $params['server_ip'] = Mage::app()->getRequest()->getServer('SERVER_ADDR'); $params['transfer_type'] = Mage::getStoreConfig('admin/germanstoreconfig/datatransfer'); } // store current date in database $transferDate = new Zend_Date(); $this->_setConfigData('germanstoreconfig/transfer_date', $transferDate->get(Zend_Date::ISO_8601)); return Mage::getStoreConfig('germanstoreconfig/tracking_url') . '?data=' . base64_encode(serialize($params)); }
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'); } }
/** * this method returns the access for the last * 2 weeks. it automatically cleans itself (drops any records older than * 2 weeks.) * */ public function getLog() { $date = new Zend_Date(); $date->sub('2', Zend_Date::WEEK); $this->delete('date_time < ' . $date->get(Zend_Date::TIMESTAMP)); return $this->fetchAll(null, 'date_time DESC'); }
/** * Generate weeks of the month (use native PHP) */ protected function _generateWeeks() { $m = $this->_date->get(Zend_Date::MONTH); $Y = $this->_date->get(Zend_Date::YEAR); $daysInMonth = $this->_date->get(Zend_Date::MONTH_DAYS); $firstDay = date('w', strtotime(date($m . '/01/' . $Y))); // Add days from previous month to beginning $endOfDays = date('t', strtotime(date($m - 1 . '/01/' . $Y))); $prevMonth = $m == 1 ? $m = 12 : $m - 1; for ($i = 0; $i < $firstDay; $i++) { $this->_weeks[1][$i] = $this->getDay($endOfDays--, $m - 1); } // Current months weeks for ($i = 1, $j = $firstDay, $w = 1; $i <= $daysInMonth; $i++) { $this->_weeks[$w][$j] = $this->getDay($i); $j++; if ($j == 7) { $j = 0; $w++; } } // Add days from next month to end $lastIndex = count($this->_weeks); $nextMonth = $m == 12 ? $m = 1 : $m + 1; for ($i = $j; $i < 7; $i++) { $this->_weeks[$lastIndex][$i] = $this->getDay($i - $j + 1, $nextMonth); } }
public function generateInvoiceAction() { if ($this->getRequest()->isGet()) { $sessionid = $this->_getParam('id'); $config = new Zend_Config_Ini(APPLICATION_PATH . '/forms/session.ini', 'invoice'); $this->view->form = new Zend_Form($config->session); $this->view->form->sessionid->setValue($sessionid); } else { if ($this->getRequest()->isPost()) { $inv = new Model_Invoice(); $date = new Zend_Date(); $inv->generationdate = $date->get(Zend_Date::W3C); $duedate = $date->add($this->_getParam('daystopay'), Zend_Date::DAY); $inv->duedate = $duedate->get(Zend_Date::W3C); $inv->amount = $this->_getParam('amount'); $inv->save(); $session = Model_Session::findOneById($this->_getParam('id')); $session->invoiceid = $inv->id; $session->save(); $this->_redirect('/admin/'); } else { $this->_redirect('/admin/'); } } }
protected function setupStoreData() { // Using XMLWriter because SimpleXML namespaces on attribute names $this->doc = new XMLWriter(); $this->doc->openMemory(); $this->doc->setIndent(true); $this->doc->setIndentString(' '); $this->doc->startDocument('1.0', 'UTF-8'); $this->doc->startElement('feed'); $this->doc->writeAttribute('xmlns', 'http://www.w3.org/2005/Atom'); $this->doc->writeAttribute('xmlns:g', 'http://base.google.com/ns/1.0'); $this->doc->writeElement('title', $this->getConfig('title')); $this->doc->startElement('link'); $this->doc->writeAttribute('rel', 'self'); $this->doc->writeAttribute('href', $this->_store->getBaseUrl()); $this->doc->endElement(); $date = new Zend_Date(); $this->doc->writeElement('updated', $date->get(Zend_Date::ATOM)); $this->doc->startElement('author'); $this->doc->writeElement('name', $this->getConfig('author')); $this->doc->endElement(); $url = $this->_store->getBaseUrl(); $day = $date->toString('yyyy-MM-dd'); $path = $this->getConfig('output'); $filename = $path . '/' . str_replace('+', '-', strtolower(urlencode($this->_store->getName()))) . '-products.xml'; $this->doc->writeElement('id', 'tag:' . $url . ',' . $day . ':' . $filename); }
public function getNuSequencialProcesso() { $criteria = array('sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso(), 'sqTipoDocumento' => NULL, 'sqUnidadeOrg' => NULL); $seqProcesso = $this->findBy($criteria); if (!empty($seqProcesso[0])) { $sequencial = $seqProcesso[0]; } else { $data = new \Zend_Date(); $sequencial = new \Sgdoce\Model\Entity\SequencialArtefato(); $sequencial->setNuSequencial(0); $sequencial->setSqTipoArtefato($this->_getRepository('app:TipoArtefato')->find(\Core_Configuration::getSgdoceTipoArtefatoProcesso())); $sequencial->setNuAno($data->get('yyyy')); $this->getEntityManager()->persist($sequencial); $this->getEntityManager()->flush(); } $session = new \Core_Session_Namespace('Sequencial'); $session->__set('oldNuSequencial', $sequencial->getNuSequencial()); $disponivel = FALSE; $nuSequencial = (string) str_pad($sequencial->getNuSequencial(), 6, "0", STR_PAD_LEFT); do { $nuSequencial = $nuSequencial + 1; $nuSequencial = (string) str_pad($nuSequencial, 6, "0", STR_PAD_LEFT); $disponivel = $this->_getRepository('app:SequencialArtefato')->hasSequencialProcesso($nuSequencial); if (!$disponivel) { $nuSequencial + 1; } } while ($disponivel == FALSE); $sequencial->setNuSequencial($nuSequencial + 1); $this->getEntityManager()->persist($sequencial); $this->getEntityManager()->flush(); return $sequencial->getNuSequencial(); }
function fetchWithDateModified() { if (!$this->originalstmt->_stmt) { return false; } // fetch the next result $retval = $this->originalstmt->_stmt->fetch(); switch ($retval) { case null: // end of data // end of data case false: // error occurred $this->originalstmt->_stmt->reset(); return false; default: // fallthrough } $row = array(); foreach ($this->originalstmt->_values as $index => $val) { $key = $this->originalstmt->_keys[$index]; if (array_key_exists($key, $this->dateColumns) && $val) { //reformat date: $date = new Zend_Date($val, Zend_Date::ISO_8601); $row[$key] = $date->get(Zend_Date::ISO_8601); } else { $row[$key] = $val; } } return $row; }
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(); } }
public function monthAction() { // param handling $year = $this->_getParam('year'); $month = $this->_getParam('month'); if (!$year or !$month) { throw new Exception(''); } // start & stop date $startDate = new Zend_Date($year . '-' . $month . '-01', 'yyyy-M-dd'); $stopDate = new Zend_Date($startDate); $stopDate->addMonth(1)->addDay(-1); // spacings (start & end) $startSpace = $startDate->get(Zend_Date::WEEKDAY_8601) - 1; $stopSpace = 7 - $stopDate->get(Zend_Date::WEEKDAY_8601); // arrays $calendar = array(); $week = array(); for ($startSpace; $startSpace >= 1; $startSpace--) { $spaceDate = new Zend_Date($startDate); $spaceDate->addDay(-$startSpace); $day = array('date' => $spaceDate); $week[] = $day; } for ($currentDay = 1; $currentDay <= $stopDate->get('d'); $currentDay++) { $currentDate = new Zend_Date($startDate); $currentDate->setDay($currentDay); $day = array('date' => $currentDate); $week[] = $day; if (count($week) / 7 == 1) { $calendar[] = array('info' => $currentDate, 'columns' => $week); $week = array(); } } for ($stopSpace; $stopSpace >= 1; $stopSpace--) { $spaceDate = new Zend_Date($stopDate); $spaceDate->addDay(-$stopSpace); $day = array('date' => $spaceDate); $week[] = $day; if (count($week) / 7 == 1) { $calendar[] = array('info' => $currentDate, 'columns' => $week); $week = array(); } } // view $this->view->rows = $calendar; }
/** * Transforms DB timestamp to normal date * * @param string $value timestamp to transform * @param string $dateFormat format to transform the timestamp to * * @return object Zend_Date * @todo Made this a seperate method so I can call this from parent class */ protected function _isoToNormalDate($value, $dateFormat = null) { $zendDate = new Zend_Date($value, Zend_Date::ISO_8601, Zend_Registry::get('Zend_Locale')); if ($dateFormat) { return $zendDate->get($dateFormat); } return $zendDate; }
public static function getInvoiceNo() { //return strtoupper(uniqid()); $sub = substr(uniqid(rand(10, 1000), false), rand(0, 10), 5); $date = new Zend_Date(); $head = "W" . $date->get('YY-MM-d/ss'); return $head . $sub; }
public function setDtCadastro($dt_cadastro) { if (empty($dt_cadastro)) { return; } $date = new Zend_Date($dt_cadastro); $this->dt_cadastro = $date->get("yyyy-MM-dd HH:mm:ss"); }