/** * 输出出仓数据 * * @param $data */ public function outPut($data, $dbconfig) { //无条码不用做 if (!$data["code"]) { return true; } $unicode = $dbconfig['unicode']; if (!$unicode) { $unicode = 'gb2312'; } $billtypedao = new BilltypeDao(); $billtype = $data["billType"]; $result = $billtypedao->find("billtypeDesc='{$billtype}'"); $result = $result->toArray(); if ($result["stype"] != 'OUT') { return true; } $dao = new Dao('', 'jk_dnb_hgk_send', '', false, $dbconfig); $dao->startTrans(); try { if ($data["memo"] == '电能表') { $sql = "insert into jk_dnb_hgk_recieve (fc_tm) values('" . $data["code"] . "')"; } else { $sql = "insert into jk_hgq_hgk_recieve (fc_tm) values('" . $data["code"] . "')"; } $sql = $this->auto_charset($sql, 'utf8', $unicode); $result = $dao->execute($sql); } catch (Exception $e) { $dao->rollback(); throw new Exception($e); } $dao->commit(); return true; }
/** * @covers Dao::getReference */ public function testGettingReferenceCachesTheReference() { $reference = $this->getMockForAbstractClass('BasicDaoReference', array(), '', false); $this->dao->expects($this->once())->method('getUserReference')->will($this->returnValue($reference)); self::assertEquals($reference, $this->dao->getReference('user')); self::assertEquals($reference, $this->dao->getReference('user')); }
public function exec($sql, $dbconfig, $unicode = 'gb2312') { $dao = new Dao('', 'jk_dnb_hgk_send', '', false, $dbconfig); $sql = $this->auto_charset($sql, 'utf8', $unicode); if (strpos($sql, 'select') !== false) { $result = $dao->query($sql)->toArray(); if ($result) { $result = $this->auto_charset($result, $unicode, 'utf8'); for ($i = 0; $i < count($result); $i++) { for ($j = count($result[$i]); $j >= 0; $j--) { unset($result[$i][$j]); } } $rtn["result"] = true; $rtn["value"] = $result; } else { $rtn["result"] = false; } } else { $result = $dao->execute($sql); if ($result) { $rtn["result"] = true; $rtn["value"] = $result; } else { $rtn["result"] = false; } } return $rtn; }
public function handle() { $dao = new \Dao(); $date = time(); $sql = "INSERT INTO `Group`.`groups` (`id`, `title`) VALUES (NULL, {$date});"; $dao->querySql($sql, 'default'); }
public function insert() { $sqlCommand = "INSERT INTO usuario_admin (nome)" . " VALUES (:nome)"; $paramters = array(); $paramters[':nome'] = $this->getNome(); $dao = new Dao(); return $dao->executeCommand($sqlCommand, $paramters); }
function __construct($owner, $delegate, Dao $dao, TableField $field) { $this->owner = $owner; $this->delegate = $delegate; $this->dao = $dao; $this->reflectionClass = new \ReflectionClass($dao->getEntityClass()); $this->field = $field; }
/** * @covers DaoToOneReference::getReferenced */ public function testReferenceGetsByIdIfPresentDataIsInt() { $this->getMockForAbstractClass('Dao', array('createDao'), 'BBB_NotAbstractDao2', false); $this->dao = $this->getMock('BBB_NotAbstractDao2', array('getRecordFromData'), array(), '', false); $this->record->expects($this->once())->method('getDirectly')->with('address')->will($this->returnValue(123)); $this->dao->expects($this->once())->method('getRecordFromData')->with(array('id' => 123), true, false)->will($this->returnValue('RECORD')); $reference = new DaoToOneReference($this->dao, 'localKey', 'foreignKey'); self::assertSame('RECORD', $reference->getReferenced($this->record, 'address')); }
public function testRecordCallsLoadIfAnAttributeWasNotSetYet() { $record = new Record(array('id' => 4), $this->dao, TRUE); $this->dao->expects($this->any())->method('getAttributes')->will($this->returnValue(array('id' => Dao::INT, 'name' => Dao::STRING))); $this->dao->expects($this->once())->method('getData')->with(array('id' => 4))->will($this->returnValue(array('id' => 4, 'name' => 'Test'))); self::assertEquals('Test', $record->get('name')); self::assertEquals('Test', $record->get('name')); // Checking it doesn't load twice }
function Entry() { $dao = new Dao(); $getIn = new Dao_GetRulesIn(); $getIn->user = LoginGetUser(); $getOut = new Dao_GetRulesOut(); $addIn->user = LoginGetUser(); $dao->GetRules($getIn, $getOut); CgiOutput($getOut->errorCode, $geeOut->errorMessage, $getOut->rules); }
public static function updateFaixaDescontoPermitido() { $FaixaDescontoPermitidoTO = new FaixaDescontoPermitidoTO(); $FaixaDescontoPermitidoDao = new FaixaDescontoPermitidoDao(); $validator = new DataValidator(); $FaixaDescontoPermitidoTO->id = isset($_POST["id"]) ? $_POST["id"] : null; $FaixaDescontoPermitidoTO->perc_desconto_max = isset($_POST["perc_desconto_max"]) ? $_POST["perc_desconto_max"] : null; $FaixaDescontoPermitidoTO->id_empreendimento = isset($_POST["id_empreendimento"]) ? $_POST["id_empreendimento"] : null; $usuarios = isset($_POST["usuarios"]) && count($_POST["usuarios"]) > 0 ? $_POST["usuarios"] : false; $delete_usuarios = isset($_POST["delete_usuarios"]) && count($_POST["delete_usuarios"]) > 0 ? $_POST["delete_usuarios"] : false; $validator->set_msg('O ID da faixa é obrigatório')->set('id', $FaixaDescontoPermitidoTO->id)->is_required(); $validator->set_msg('Informe o valor máximo de desconto desta faixa')->set('perc_desconto_max', $FaixaDescontoPermitidoTO->perc_desconto_max)->is_required(); $validator->set_msg('O id do empreendimento é obrigatório')->set('id_empreendimento', $FaixaDescontoPermitidoTO->id_empreendimento)->is_required(); if ($FaixaDescontoPermitidoDao->verificarFaixa($FaixaDescontoPermitidoTO->perc_desconto_max, $FaixaDescontoPermitidoTO->id_empreendimento, $FaixaDescontoPermitidoTO->id) && $FaixaDescontoPermitidoTO->perc_desconto_max > 0) { $validator->_errors['perc_desconto_max'][] = 'Já existe outra faixa com este valor máximo '; } if (!$validator->validate()) { Flight::response()->status(406)->header('Content-Type', 'application/json')->write(json_encode($validator->get_errors()))->send(); return; } $lastInsertId = $FaixaDescontoPermitidoDao->updateFaixaDescontoPermitido($FaixaDescontoPermitidoTO); if ($lastInsertId) { $UsuarioFaixaDescontoPermitidoDao = new UsuarioFaixaDescontoPermitidoDao(); $UsuarioFaixaDescontoPermitidoTO = new UsuarioFaixaDescontoPermitidoTO(); if ($usuarios) { $Dao = new Dao(); $Dao->setTimeZone($FaixaDescontoPermitidoTO->id_empreendimento); $UsuarioFaixaDescontoPermitidoTO->dta_entrada = date('Y-m-d H:i:s'); foreach ($usuarios as $usuario) { $UsuarioFaixaDescontoPermitidoTO->id_usuario = $usuario['id_usuario']; $UsuarioFaixaDescontoPermitidoTO->id_faixa_desconto_permitido = $FaixaDescontoPermitidoTO->id; $UsuarioFaixaDescontoPermitidoTO->flg_ativo = $usuario['flg_ativo']; $UsuarioFaixaDescontoPermitidoTO->id_responsavel_atv = $usuario['id_responsavel_atv']; if (!$UsuarioFaixaDescontoPermitidoDao->saveUsuarioFaixaDescontoPermitido($UsuarioFaixaDescontoPermitidoTO)) { Flight::halt(500, 'Erro ao vincular usuario a faixa '); } } } if ($delete_usuarios) { foreach ($delete_usuarios as $usuario) { if (!$UsuarioFaixaDescontoPermitidoDao->deleteUsuarioFaixaDescontoPermitido($usuario['id_rel'])) { Flight::halt(500, 'Erro ao deletar usuario'); } } } Flight::halt(201); } else { Flight::halt(500, 'Erro ao inserir Desconto'); } }
function Entry() { $ruleId = CgiInput("rule_id", ""); if ($ruleId == "") { CgiOutput(__LINE__, ""); } $dao = new Dao(); $delIn = new Dao_DeleteRuleIn(); $delOut = new Dao_DeleteRuleOut(); $delIn->user = LoginGetUser(); $delIn->ruleId = $ruleId; $dao->DeleteRule($delIn, $delOut); CgiOutput($delOut->errorCode, $delOut->errorMessage); }
public function updateSetting($sender, $param) { $result = $errors = array(); try { $result = $products = array(); $systemSetting = SystemSettings::getByType(SystemSettings::TYPE_SYSTEM_BUILD_PRODUCTS_ID); foreach ($param->CallbackParameter as $type => $ids) { $result[$type] = array(); $products[$type] = array(); foreach ($ids as $index => $id) { $id = intval(trim($id)); if (($product = Product::get($id)) instanceof Product) { $result[$type][] = $id; $products[$type][] = $product->getJson(); } } } Dao::beginTransaction(); $systemSetting->setValue(json_encode($result))->save(); Dao::commitTransaction(); } catch (Exception $ex) { // Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($products, $errors); }
public static function run() { try { Dao::beginTransaction(); $start = self::_logMsg("== START: processing Product Ageing ==", __CLASS__, __FUNCTION__); self::_emptyProductAgeingLog(); $productCount = 0; $products = self::_getProducts(); if (self::DEBUG === true) { self::_logMsg('ProductCount: ' . count($products), __CLASS__, __FUNCTION__); } foreach ($products as $product) { $productCount++; if (self::DEBUG === true) { self::_logMsg('ProductId: ' . $product->getId(), __CLASS__, __FUNCTION__); } $lastPurchase = self::_getLastPurchase($product); if ($lastPurchase instanceof ProductQtyLog) { self::_recordProductAgeingLog($lastPurchase); } } $end = new UDate(); self::_logMsg("== FINISHED: process product ageing, (productCount: " . $productCount . ", ProductAgeingLogCount: " . ProductAgeingLog::countByCriteria('active = 1') . ")", __CLASS__, __FUNCTION__); Dao::commitTransaction(); } catch (Exception $e) { Dao::rollbackTransaction(); echo "\n" . $e->getMessage() . "\n" . $e->getTraceAsString(); } }
protected function getOutput() { $id = $this->getArg('id', 0, true); if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) { return false; } $value = $this->getContextData()->getValue('value' . $id); if ($this->hasArg('isset') && $this->getArg('isset')) { return $value ? 'true' : 'false'; } if ($this->hasArg('widget') && $this->getArg('widget')) { if (!$this->environmentIs(self::ENV_INPUT)) { return false; } $select = new rex_category_select(); if ($this->hasArg('multiple') && $this->getArg('multiple')) { $select->setName('REX_INPUT_VALUE[' . $id . '][]'); $select->setMultiple(); $select->setSelected(rex_var::toArray($value)); } else { $select->setName('REX_INPUT_VALUE[' . $id . ']'); $select->setSelected($value); } if ($this->hasArg('root') && $this->getArg('root')) { $select->setRootId(explode(',', $this->getArg('root'))); } $widget = '<div class="rex-select-style">' . $select->get() . '</div>'; if ($this->hasArg('output') && $this->getArg('output')) { $label = $this->hasArg('label') ? $this->getArg('label') : ''; $widget = Dao::getForm($widget, $label, $this->getArg('output')); } return self::quote($widget); } return self::quote(htmlspecialchars($value)); }
public function __construct() { parent::__construct(); $this->load->model('funcionarios/usuariosModel'); $this->load->model('funcionarios/funcionariosModel'); $this->load->model('configuracoes/niveis_acesso/niveisAcessoModel'); }
/** * 根据 accountId 来查找账号信息 * @param integer $accountId * @return array */ public function getAccountByAccountId($accountId) { if (!$accountId) { return array(); } return Dao::factory('Account')->getAccountByAccountId($accountId); }
public function isFeriado(DateTime $pData) { try { $cont = 0; // separa mes e dia $dia = $pData->format("d"); $mes = $pData->format("m"); // se o feriado for fixo, ocorre todos os anos // portanto é necessário considerar somente // dia e mês da data $sql = "SELECT data, descricao, tipo, horas, fixo " . "FROM feriados " . "WHERE DAY(data) = {$dia} " . "AND MONTH(data) = {$mes} " . "AND fixo = 1;"; $rs = parent::obterRecordSet($sql); if ($rs) { $cont = 1; } else { $sql = "SELECT data, descricao, tipo, horas, fixo " . "FROM feriados " . "WHERE data = '" . $pData->format('Y-m-d') . "' " . "AND fixo = 0;"; $rs = parent::obterRecordSet($sql); if ($rs) { $cont = 1; } } // prepara retorno if ($cont == 1) { $this->setData($rs[0]["data"]); $this->setDescricao($rs[0]["descricao"]); $this->setTipo($rs[0]["tipo"]); $this->setHoras($rs[0]["horas"]); $this->setFixo($rs[0]["fixo"]); } return $cont; } catch (Exception $e) { throw new Exception($e->getTraceAsString()); } }
/** * Sending the email out * * @param unknown $sender * @param unknown $param * * @throws Exception */ public function sendEmail($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) { throw new Exception('System Error: invalid order provided!'); } if (!isset($param->CallbackParameter->emailAddress) || ($emailAddress = trim($param->CallbackParameter->emailAddress)) === '') { throw new Exception('System Error: invalid emaill address provided!'); } $emailBody = ''; if (isset($param->CallbackParameter->emailBody) && ($emailBody = trim($param->CallbackParameter->emailBody)) !== '') { $emailBody = str_replace("\n", "<br />", $emailBody); } $pdfFile = EntityToPDF::getPDF($order); $asset = Asset::registerAsset($order->getOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP); $type = $order->getType(); EmailSender::addEmail('*****@*****.**', $emailAddress, 'BudgetPC ' . $type . ':' . $order->getOrderNo(), (trim($emailBody) === '' ? '' : $emailBody . "<br /><br />") . 'Please find attached ' . $type . ' (' . $order->getOrderNo() . '.pdf) from Budget PC Pty Ltd.', array($asset)); $order->addComment('An email sent to "' . $emailAddress . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM); $results['item'] = $order->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
/** * * @param unknown $sender * @param unknown $params */ public function addComments($sender, $params) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($params->CallbackParameter->entityName) || ($entityName = trim($params->CallbackParameter->entityName)) === '') { throw new Exception('System Error: EntityName is not provided!'); } if (!isset($params->CallbackParameter->entityId) || ($entityId = trim($params->CallbackParameter->entityId)) === '') { throw new Exception('System Error: entityId is not provided!'); } if (!($entity = $entityName::get($entityId)) instanceof $entityName) { throw new Exception('System Error: no such a entity exisits!'); } if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') { throw new Exception('System Error: invalid comments passed in!'); } $comment = Comments::addComments($entity, $comments, Comments::TYPE_NORMAL); $results['item'] = $comment->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $params->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
/** * (non-PHPdoc) * @see DetailsPageAbstract::saveItem() */ public function saveItem($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($param->CallbackParameter->id)) { throw new Exception('Invalid supplier ID passed in!'); } $supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id); if (!$supplier instanceof Supplier) { throw new Exception('Invalid supplier passed in!'); } $contactName = trim($param->CallbackParameter->address->contactName); $contactNo = trim($param->CallbackParameter->address->contactNo); $street = trim($param->CallbackParameter->address->street); $city = trim($param->CallbackParameter->address->city); $region = trim($param->CallbackParameter->address->region); $postCode = trim($param->CallbackParameter->address->postCode); $country = trim($param->CallbackParameter->address->country); $address = $supplier->getAddress(); $supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save(); $results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : ''); $results['item'] = $supplier->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage() . $ex->getTraceAsString(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
public function initialize() { if (!$this->isInitialized() && !$this->initializing) { $this->initializing = true; $this->dao->setCache($this->owner); $table = $this->field->getTable(); $id = $table->getPropertyValue($this->owner, $table->getPrimaryKeyField()); $this->collection = array(); ProxyUtils::swap($this->owner, $this->collection, $this->field, $this->dao); $this->dao->__refreshByFK($this->collection, $id, $this->field->getForeignKeyConstraint()); $cacheCopy = $this->getArrayCopy(); ProxyUtils::swap($this->owner->{Dao::CACHE}, $cacheCopy, $this->field, $this->dao); $this->initialized = true; $this->initializing = false; } }
function affiche() { /* Si GET["ajout"] est possitionne, on affiche la vue pour ajouter/modifier une liste*/ if (isset($_GET["ajoutListe"])) { $this->vue->ajoutListe(); /* Sinon si la date et un groupe est possitionne on affiche la feuille d'absence associe*/ } else { if (isset($_POST["groupe"])) { /*On explose pour recuperer le groupe et la promo*/ if (strpos($_POST["groupe"], ':') !== FALSE) { $groupe = explode(":", $_POST["groupe"])[1]; $promo = explode(":", $_POST["groupe"])[0]; } else { $groupe = ""; $promo = $_POST["groupe"]; } } else { /*On explose pour recuperer le groupe et la promo*/ if (strpos($_GET["ics"], ':') !== FALSE) { $groupe = explode(":", $_GET["ics"])[1]; $promo = explode(":", $_GET["ics"])[0]; } else { $groupe = ""; $promo = $_GET["ics"]; } } } /* Si le groupe est NULL, c'est une promo, on utilise la vue associe. Sinon on redirige vers l'ajout de liste.*/ if ($groupe == NULL) { $dao = new Dao(); $dao->setICS($promo); $dao->getCours(); // $groupes = $dao->getGroupes2(); if ($this->dao->fichierPromoExist($promo)) { $groupes = $dao->getGroupeXLS($dao->getFeuilleAbsGroupe($promo)); $this->vue->head(); $this->vue->tableauPromo($promo, $groupes); } else { header('location:index.php?ajoutListe=true'); } } else { $this->vue->head(); $this->vue->tableau(); } }
public function listarEstados() { $query = "SELECT sigla_uf, nome FROM tbestados \n ORDER BY nome"; $sql = Dao::abreConexao()->prepare($query); $sql->execute(); $retorno = $sql->fetchAll(PDO::FETCH_ASSOC); Dao::fechaConexao(); return $retorno; }
function delete($report) { parent::delete($report, self::OBJECT_CLASS); $rs = $this->db->execute($s = Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::REPORT_ID), Operator::EQUAL, intval($report->getID())))), $this->table->getName(), $report); if ($this->db->affected_rows() != 1) { throw new Exception("Si è verificato un errore eliminando il dato. Riprovare."); } return $report; }
public function autentica($login, $senha, $isAdmin) { $query = "select * from funcionario where login = \$1 and senha = \$2 and admin = \$3"; $params = array($login, $senha, $isAdmin ? 't' : 'f'); print_r($params); $funcionarioArray = parent::daoFetchArray($query, $params); print_r($funcionarioArray); return !empty($funcionarioArray); }
public final function filterColumn() { $submitData = $this->setSubmitData(); $filter = $this->getColumnFilter(); $res = Dao::filterColumn($submitData, $filter); if (true !== $res) { throw new AcaciaException(AcaciaException::FILTER_COLUMN_FAIL, $res); } return $submitData; }
public function listarCidades() { $query = "SELECT cidade_id, nome, sigla_uf FROM tbcidades \n WHERE sigla_uf = ?' \n ORDER BY nome"; $sql = Dao::abreConexao()->prepare($query); $sql->bindValue(1, $this->getSiglaUf, PDO::PARAM_INT); $sql->execute(); $retorno = $sql->fetchAll(PDO::FETCH_ASSOC); Dao::fechaConexao(); return $retorno; }
function delete($author, $post) { parent::delete($author, "User"); parent::delete($author, "Post"); $rs = $this->db->execute($s = Query::generateDeleteStm($this->table, array(new WhereConstraint($this->table->getColumn(DB::VOTE_AUTHOR), Operator::EQUAL, intval($author->getID())), new WhereConstraint($this->table->getColumn(DB::VOTE_POST), Operator::EQUAL, intval($post->getID())))), $this->table->getName(), array("Vote", intval($author->getID()), intval($post->getID()))); if ($this->db->affected_rows() != 1) { throw new Exception("Si è verificato un errore eliminando l'oggetto. Riprovare."); } return true; }
public function buscaCaixa() { $query = "SELECT * FROM TCAIXA\n WHERE TICKET_ID = ?"; $sql = Dao::abreConexao()->prepare($query); $sql->bindValue(1, $this->getTicketId(), PDO::PARAM_INT); $sql->execute(); $retorno = $sql->fetch(PDO::FETCH_ASSOC); Dao::fechaConexao(); return $retorno; }
function Entry() { $url = CgiInput("url", ""); if ($url == "") { CgiOutput(__LINE__, ""); } $pattern = CgiInput("pattern", ""); if ($pattern == "") { CgiOutput(__LINE__, ""); } $dao = new Dao(); $addIn = new Dao_AddRuleIn(); $addOut = new Dao_AddRuleOut(); $addIn->creator = LoginGetUser(); $addIn->url = $url; $addIn->pattern = $pattern; $dao->AddRule($addIn, $addOut); CgiOutput($addOut->errorCode, $addOut->errorMessage); }