Example #1
0
 /**
  * 创建卡牌库
  * @author gentle
  */
 public function actionCreate()
 {
     $model = new CardDb("Create");
     if (isset($_POST['CardDb'])) {
         $model->attributes = $_POST['CardDb'];
         if ($model->save()) {
             $this->addLog('db', $model->id, '添加新库“' . $model->name . '”');
             Yii::app()->user->setFlash("success", "新建 <b>{$model->name}</b> 数据库成功!");
         } else {
             $errorMsg = '';
             $errorErr = $model->getErrors();
             foreach ($errorErr as $value) {
                 $errorMsg .= "\t" . $value[0];
             }
             $errorMsg = trim($errorMsg, ',');
             Yii::app()->user->setFlash("error", $errorMsg);
         }
         //$page = isset($_GET['CardDb_page']) ? $_GET['CardDb_page'] : 1;
         //$this->redirect(array('CardDb/index/CardDb_page/'.$page));
         $this->redirect(array('CardDb/index'));
     }
     //if (Yii::app()->request->isAjaxRequest) {
     //	$this->renderPartial('_form_db', array('model' => $model));
     //}
     $this->renderPartial('_form_db', array('model' => $model));
 }
Example #2
0
 /**
  * 左侧栏树形结构
  * @author gentle
  */
 public function dataTree()
 {
     $data = array();
     $databases = CardDb::model()->findAll();
     foreach ($databases as $key => $value) {
         $data[$key]['text'] = '<span>' . $value->name . '</span>';
         $data[$key]['expanded'] = false;
         $data[$key]['children'] = array();
         $datasets = CardDs::model()->findAllByAttributes(array('database_id' => (string) $value->id));
         if (empty($datasets)) {
             continue;
         }
         foreach ($datasets as $k => $v) {
             $data[$key]['children'][$k] = array('text' => '<a href="' . $this->createUrl('/CardDs/Index/id/' . $value->id) . '">' . $v->name . '</a>');
         }
     }
     return $data;
 }
Example #3
0
 /**
  * 左侧栏树形结构
  * @author gentle
  */
 public function dataTree($databaseId = 0, $action = 'cardItem/Index')
 {
     $data = array();
     $databases = CardDb::model()->findAll(User::model()->getScopeDbCriteria());
     foreach ($databases as $key => $value) {
         $data[$key]['text'] = '<span>' . $value->name . '</span>';
         if ($databaseId == $value->id) {
             $data[$key]['expanded'] = true;
         } else {
             $data[$key]['expanded'] = false;
         }
         $data[$key]['children'] = array();
         $dscriteria = User::model()->getScopeDsCriteria();
         $dscriteria->addCond('database_id', '==', (int) $value->id);
         $datasets = CardDs::model()->findAll($dscriteria);
         if (empty($datasets)) {
             continue;
         }
         foreach ($datasets as $k => $v) {
             $data[$key]['children'][$k] = array('text' => '<a href="' . $this->createUrl('/' . $action . '/id/' . $v->id) . '">' . $v->name . '</a>');
         }
     }
     return $data;
 }
Example #4
0
 /**
  * 根据表名得到真实的表和对应的查询条件
  * @param $tname	string	待解析表名
  * @return 真实表名和条件
  */
 public function parseRealTable($tname)
 {
     $rs = array('name' => $tname, 'criteria' => new EMongoCriteria());
     if (preg_match('/^(item_)/i', $tname)) {
         $tinfo = explode('_', $tname);
         if (count($tinfo) == 3) {
             $dbinfo = CardDb::model()->findByAttributes(array('en_name' => $tinfo[1]));
             if ($dbinfo) {
                 $dsinfo = CardDs::model()->findByAttributes(array('database_id' => $dbinfo->id, 'en_name' => $tinfo[2]));
                 if ($dsinfo) {
                     $rs['name'] = $tinfo[0];
                     $rs['criteria']->dataset_id = (int) $dsinfo['id'];
                 }
             }
         }
     }
     return $rs;
 }
	$card_number = $_SESSION['card-number'];

if(isset($_POST['points']))
	$points_to_add=$_POST['points'];
else
	$points_to_add=$_SESSION['points'];
	
/*skip serve per mostrare tutto nel caso in cui i punti siano positivi*/
$skip=false;
if($points_to_add < 0){
	$skip=true;
	?>
	<br/> <h2>ERRORE: Non puoi aggiungere punti negativi</h2>
	<h4>Se si vuole rimuovere dei punti usare lo strumento <a href="#editCard">Modifica Card</a>		
<?}
$sq = new CardDb();
$error=1; //if <0 error is enable
if(!$skip){
			$error = $sq -> addPoints($card_number, $points_to_add);
	
		if($error >= 0){ 
		$result = $sq -> getPoints($card_number)?>
		
		<h2>Punti aggiunti con successo. <br/>Situazione aggiornata Card <?php echo $card_number?>:</h2>
			<table class="rwd-table">
			  <tr>
				<th>Numero Card</th>
				<th>Saldo Punti</th>
				<th>Buono Utilizzabile</th>
				<th>Nome</th>
				<th>Telefono</th>
$card_number = $_SESSION['card-number'];
$mail = $_SESSION['mail'];
/*skip serve per mostrare tutto nel caso in cui i punti siano positivi*/
$skip = false;
if (filter_var($mail, FILTER_VALIDATE_EMAIL) == false) {
    $skip = true;
    ?>
	<br/> <h2>ERRORE: Mail inserita non valida</h2>
	<h4>Se si vuole inviare una email, settare un email valido: 
		<?php 
    $_SESSION['card-number'] = $card_number;
    ?>
	<a href="editCard.php"> Modifica Card</a>		
<?php 
}
$sq = new CardDb();
$result = $sq->getPoints($card_number);
if (!$skip) {
    ?>
		<h2>Situazione aggiornata Card <?php 
    echo $card_number;
    ?>
</h2>
		<table class="rwd-table">
		  <tr>
			<th>Numero Card</th>
			<th>Saldo Punti</th>
			<th>Buono Utilizzabile</th>
			<th>Nome</th>
			<th>Telefono</th>
			<th>Email</th>
<?php

session_start();
require "CardDb.php";
require "menu.html";
$sq = new CardDb();
$cleanAll = "No";
$cleanAll = $_SESSION['delete-all'];
if ($cleanAll == "Yes") {
    $sq->cleanAll();
    ?>
<h2> Tutto le card sono state rimosse </h2>
<?php 
}
Example #8
0
 /**
  * 获取库与实体对应关系表
  * @return unknown_type
  */
 public function getDBDSMap()
 {
     //添加统一前缀
     $cache_key = strtolower('db.admin' . __FUNCTION__);
     //调用,有缓存则用缓存
     if (($map = Yii::app()->cache->get($cache_key)) === false) {
         $dblist = CardDb::model()->findAll(User::model()->getScopeDbCriteria());
         $dslist = CardDs::model()->findAll(User::model()->getScopeDsCriteria());
         foreach ($dblist as $dv) {
             $map[$dv['id']] = array('en_name' => $dv['en_name'], 'name' => $dv['name'], 'list' => array());
         }
         foreach ($dslist as $tv) {
             if (isset($map[$tv['database_id']])) {
                 $map[$tv['database_id']]['list'][$tv['id']] = array('en_name' => $tv['en_name'], 'name' => $tv['name']);
             }
         }
         if (!Yii::app()->cache->set($cache_key, $map, Yii::app()->params['cache_expire'])) {
             Yii::log('设置缓存失败:key=' . $cache_key, CLogger::LEVEL_WARNING, 'system.cache');
         }
     }
     return $map;
 }
<?php

session_start();
require "CardDb.php";
require "menu.html";
$card_number = $_SESSION['card-number'];
$new_points = $_POST['points'];
$new_user = $_POST['name'];
$new_phone = $_POST['phone'];
$new_mail = $_POST['mail'];
$sq = new CardDb();
$sq->updateAll($card_number, $new_points, $new_user, $new_phone, $new_mail);
$values = $sq->getPoints($card_number);
?>
<h2>Valori aggiornati correttamente.</h2>
	<table class="rwd-table">
	  <tr>
		<th>Numero Card</th>
		<th>Saldo Punti</th>
		<th>Buono Utilizzabile</th>
		<th>Nome</th>
		<th>Telefono</th>
		<th>eMail</th>
		<th></th>
	  </tr>
	<?php 
while ($data = $values->fetchArray()) {
    ?>
		  <tr><form method="POST" action="saveEdit.php">
			<td data-th="Numero Card"><?php 
    echo $data['id'];
Example #10
0
<?php

session_start();
require "CardDb.php";
require "menu.html";
$sq = new CardDb();
$result = $sq->getAlls();
?>

<h1>Database FidelityCards</h1>
<table class="rwd-table">
  <tr>
	<th>Numero Card</th>
	<th>Saldo Punti</th>
	<th>Buono Utilizzabile</th>
	<th>Nome</th>
	<th>Telefono</th>
	<th>Email</th>
  </tr>

<?php 
while ($data = $result->fetchArray()) {
    ?>
	  <tr>
		<td data-th="Numero Card"><?php 
    echo $data['id'];
    ?>
</td>
		<td data-th="Saldo Punti"><?php 
    echo $data['points'];
    ?>
Example #11
0
 /**
  * 获取数据库列表
  */
 public function actionGetDbs()
 {
     $return['code'] = 0;
     $return['data'] = CardDb::model()->getList();
     echo CJSON::encode($return);
 }
Example #12
0
<?php

session_start();
require "CardDb.php";
require "menu.html";
$card_number = $_SESSION['card-number'];
$sq = new CardDb();
?>
	
	<h2>Lo sconto di <?php 
echo $_SESSION['money'];
$sq->setPoints($card_number, 0);
$result = $sq->getPoints($card_number);
?>
 € è stato usato:</h2>
		<table class="rwd-table">
		  <tr>
			<th>Numero Card</th>
			<th>Saldo Punti</th>
			<th>Buono Utilizzabile</th>
			<th>Nome</th>
			<th>Telefono</th>
			<th>Email</th>
		  </tr>
		<?php 
while ($data = $result->fetchArray()) {
    $_SESSION['card-number'] = $data['id'];
    $_SESSION['phone'] = $data['phone'];
    $_SESSION['mail'] = $data['mail'];
    ?>
			  <tr>
Example #13
0
<?php

session_start();
require "CardDb.php";
require "menu.html";
$card_number = $_POST['card-number'];
$_SESSION['card-number'] = $card_number;
$sq = new CardDb();
if (is_numeric($card_number)) {
    if ($sq->addCard($card_number)) {
        ?>
		<br/> <h2>Card Inserita con successo. Aggiungi altri dettagli:</h2>
		<?php 
        /*getPoints returns all fields with id=card_number */
        $values = $sq->getPoints($card_number);
        if ($values == FALSE) {
            echo "<h2>Card non trovata nel sistema</h2>";
        } else {
            ?>
			<table class="rwd-table">
			  <tr>
				<th>Numero Card</th>
				<th>Saldo Punti</th>
				<th>Buono Utilizzabile</th>
				<th>Nome</th>
				<th>Telefono</th>
				<th>eMail</th>
				<th></th>
			  </tr>
			<?php 
            while ($data = $values->fetchArray()) {
Example #14
0
<?php

session_start();
require "CardDb.php";
require "menu.html";
if (isset($_POST['card-number'])) {
    $card_number = $_POST['card-number'];
    $_SESSION['card-number'] = $card_number;
} else {
    $card_number = $_SESSION['card-number'];
}
$sq = new CardDb();
/*getPoints returns all fields with id=card_number */
$values = $sq->getPoints($card_number);
if ($values == FALSE) {
    echo "<h2>Card non trovata nel sistema</h2>";
} else {
    ?>
	<table class="rwd-table">
	  <tr>
		<th>Numero Card</th>
		<th>Saldo Punti</th>
		<th>Buono Utilizzabile</th>
		<th>Nome</th>
		<th>Telefono</th>
		<th>eMail</th>
		<th></th>
	  </tr>
	<?php 
    while ($data = $values->fetchArray()) {
        ?>