Exemple #1
0
 //Update transaction
 $sql->query("\n\t\t \tUPDATE transactions\n\t\t\tSET description='" . $data['description'] . "',\n\t\t\t\tamount='" . $data['amount'] . "',\n\t\t\t\tdate='" . $data['date'] . "',\n\t\t\t\taccount_to_id='" . $data['accountTo'] . "',\n\t\t\t\taccount_from_id='" . $data['accountFrom'] . "',\n\t\t\t\ttransaction_type_id='" . $data['transType'] . "'\n\t\t\tWHERE transactions.id = '" . $data['transactionId'] . "'\n\t\t ");
 //Remove tags relationship
 $sql->query("\n\t\t \tDELETE FROM transactions_has_tags\n\t\t\tWHERE transaction_id='" . $data['transactionId'] . "'\n\t\t ");
 //Insert tags
 if ($data['tags'] != "" || $data['tags'] != NULL) {
     foreach ($tags->get() as $tag) {
         if (in_array(trim(strtolower(clearUTF($tag['name']))), $transactionTagsCompare)) {
             //IF have in BD
             $sql->query("\n\t\t\t\t\t\tINSERT INTO transactions_has_tags(transaction_id,tag_id)\n\t\t\t\t\t\tVALUES('" . $data['transactionId'] . "','" . $tag['id'] . "')\n\t\t\t\t\t");
         }
     }
     foreach ($transactionTags as $tag) {
         if (!in_array(strtolower(clearUTF(trim($tag))), $allTagsCompare)) {
             //IF DONT have in BD
             $sql->query("\n\t\t\t\t\t\tINSERT INTO tags(name, profile_id)\n\t\t\t\t\t\tVALUES ('" . trim(convertToUnicode($tag)) . "','" . CurrentUser::getId() . "')\n\t\t\t\t\t");
             $tagId = $sql->insertId;
             $sql->query("\n\t\t\t\t\t\tINSERT INTO transactions_has_tags(transaction_id,tag_id)\n\t\t\t\t\t\tVALUES('" . $data['transactionId'] . "','" . $tagId . "')\n\t\t\t\t\t");
         }
     }
 }
 //Add in Ammount
 if ($data['accountTo'] != '') {
     $balance = $accounts->get(1, $data['accountFrom'], 'balance');
     $balance += $oldData[0]['amount'];
     $balance += $data['amount'];
     $sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data['accountFrom'] . "'");
     $balance = $accounts->get(1, $data['accountTo'], 'balance');
     $balance -= $oldData[0]['amount'];
     $balance -= $data['amount'];
     $sql->query("UPDATE accounts SET balance='" . $balance . "' WHERE id = '" . $data['accountTo'] . "'");
Exemple #2
0
    //Inclui página de conta
    exit;
}
$transactions = $api->getTransactions(20);
//Últimas 20 transações
$tags = $api->getTags(10, '', 'most_expensive', 'asc', date('Y-m-01'), date('Y-m-31'));
//As 10 tags mais caras
$balances = $api->getAccountBalance();
//Balanço por conta
/* Monta QUERY para execução de gráfico */
$seriesGraph = '[';
$i = 0;
foreach ($accounts as $acc) {
    $i++;
    $seriesGraph .= '{';
    $seriesGraph .= 'name: "' . convertToUnicode($acc->name) . '",';
    $seriesGraph .= 'data: [';
    $monthsLeft = 12 - date('m');
    //Meses que faltam para o fim do ano
    $invertedCount = 0;
    //Contador invertido para meses dos anos passados
    $year = date('Y');
    $monthCount = date('m');
    for ($o = 0; $o <= 12; $o++) {
        $year = date("Y", strtotime('-' . (12 - $o) . ' months', strtotime(date('Y') . '-' . date('m') . '-01')));
        $toMonth = date("m", strtotime('-' . (12 - $o) . ' months', strtotime(date('Y') . '-' . date('m') . '-01')));
        $generatedDate = 1000 * strtotime($year . '-' . $toMonth . '-01');
        $seriesGraph .= '[';
        $seriesGraph .= 'Date.UTC(' . $year . ',' . ($toMonth - 1) . ',1),';
        //Base zero para javascript (0 - 11)
        $TodayDiff = $monthsLeft + $o;
Exemple #3
0
		 	chart: {
		 		renderTo: 'monthBalanceGraph', 
		 		type: 'column'
		 	},
		 	legend: {enabled: false},
			colors: ['#ce6a6a'],
			xAxis: {
				categories: <?php 
    echo $categories;
    ?>
				
			},
			series: [
				{
					name: '<?php 
    echo convertToUnicode($myTag[0]->name);
    ?>
',
					data: [<?php 
    echo $graphData;
    ?>
]
				}
			]
	 });

	<?php 
}
?>
	 
})(jQuery);
Exemple #4
0
function clearUTF($t)
{
    return replaceSpecialChars(convertToUnicode($t));
}
Exemple #5
0
      * ======================================
      */
 /*
  * ======================================
  * POST method
  * ======================================
  */
 case 'post':
     //Set DATA
     $var['dateExploded'] = explode('-', str_replace('/', '-', $_DATA['birthday']));
     if (count($var['dateExploded']) == 3) {
         $var['date'] = $var['dateExploded'][2] . '-' . $var['dateExploded'][1] . '-' . $var['dateExploded'][0];
     } else {
         $var['date'] = '';
     }
     $data = array('name' => trim(convertToUnicode($_DATA['name'])), 'birthday' => $var['date'], 'gender' => trim(convertToUnicode($_DATA['gender'])), 'email' => trim(convertToUnicode($_DATA['email'])), 'password' => trim(convertToUnicode($_DATA['password'])), 'newPassword' => trim(convertToUnicode($_DATA['newPassword'])));
     //Return
     if ($userInfo->updateUser($data)) {
         RestUtils::sendResponse('200');
     }
     break;
     /*
      * ======================================
      * Default
      * ======================================
      */
 /*
  * ======================================
  * Default
  * ======================================
  */
Exemple #6
0
     RestUtils::sendResponse('201', $transactionId);
     exit;
     break;
     /*
      * ======================================
      * POST method
      * ======================================
      */
 /*
  * ======================================
  * POST method
  * ======================================
  */
 case 'post':
     //Set variables
     $data = array('name' => trim(convertToUnicode($_DATA['accountName'])), 'initialBalance' => number_format(str_replace(',', '.', str_replace('.', '', $_DATA['initialBalance'])), 2, '.', ''), 'accountType' => intval($_DATA['accountType']), 'accountId' => trim($_DATA['accountId']));
     //Verify basic inputs
     if ($data['name'] == '' || count($data['name']) > 28) {
         //Name
         RestUtils::sendResponse('406', array('data' => 'name', 'message' => 'Por favor, verifique o nome.'));
         exit;
     } elseif ($data['initialBalance'] == '') {
         //Initial Balance
         RestUtils::sendResponse('406', array('data' => 'initialBalance', 'message' => 'Por favor, verifique o valor inicial.'));
         exit;
     } elseif ($data['accountType'] == '') {
         //Account type
         RestUtils::sendResponse('406', array('data' => 'accountType', 'message' => 'Por favor, verifique a conta escolhida.'));
         exit;
     }
     //Verify type
Exemple #7
0
     $sql->close();
     RestUtils::sendResponse('201');
     break;
     /*
      * ======================================
      * POST method
      * ======================================
      */
 /*
  * ======================================
  * POST method
  * ======================================
  */
 case 'post':
     //Set variables
     $data = array('name' => trim(convertToUnicode($_DATA['tagName'])), 'id' => trim($_DATA['id']));
     //Verify if exists
     $tr = $tags->getUnique($data['id']);
     if (count($tr) == 0) {
         RestUtils::sendResponse('406', array('data' => 'tagId', 'message' => 'Essa tag n&atilde;o existe.'));
     }
     if ($tr[0]['profile_id'] != CurrentUser::getId()) {
         RestUtils::sendResponse('406', array('data' => 'tagId', 'message' => 'Essa tag n&atilde;o pertence ao perfil.'));
     }
     //Connect
     $sql = new DataBase();
     $sql->connect();
     //Update
     $sql->query("\r\n\t\t\tUPDATE tags\r\n\t\t\tSET name='" . $data['name'] . "'\r\n\t\t\tWHERE id = '" . $data['id'] . "'\r\n\t\t");
     //Close Connection
     $sql->close();