本文整理汇总了PHP中Zend_Date类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Date类的具体用法?PHP Zend_Date怎么用?PHP Zend_Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Date类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUrl
/**
* 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));
}
示例2: timing
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 . '年前';
}
示例3: insert
public function insert(array $data)
{
$date = new Zend_Date();
$data['datebug'] = $date->toString('Y-MM-d');
$data['statut'] = "Non lu";
return parent::insert($data);
}
示例4: getLoadedProductCollection
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;
}
示例5: collectValidatedAttributes
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;
}
示例6: isValid
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;
}
示例7: isValid
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;
}
示例8: indexAction
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;
}
示例9: andamento
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;
}
示例10: getLastVideos
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;
}
示例11: getTransactionList
/**
* (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;
}
示例12: init
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');
}
示例13: createBackupFile
/**
* 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;
}
示例14: save
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;
}
示例15: returnItemToCustomer
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();
}
}