Example #1
0
 public function categoryAction()
 {
     $modelTransaction = new Application_Model_Transaction();
     $modelCategory = new Application_Model_Category();
     $this->view->categories = $modelCategory->getAll();
     if ($this->getRequest()->isPost()) {
         $category = $this->getRequest()->getPost('category', null);
         $this->view->category = $category;
         $this->view->sumCategory = $modelTransaction->getForGraphByCategory($category, date("Y"));
         $budgetCategory = $modelTransaction->getBudgetForGraphByCategory($category, date("Y"));
         $budgetCategoryFormated = array_fill(1, 12, 0);
         foreach ($budgetCategory as $category) {
             $budgetCategoryFormated[$category->month] = $category->maximum;
         }
         $this->view->budgetCategory = $budgetCategoryFormated;
         $this->view->months = array(1 => 'Janvier', 2 => 'Février', 3 => 'Mars', 4 => 'Avril', 5 => 'Mai', 6 => 'Juin', 7 => 'Juillet', 8 => 'Août', 9 => 'Septembre', 10 => 'Octobre', 11 => 'Novembre', 12 => 'Décembre');
     }
 }
 public function testPopulateTransactionData()
 {
     $transaction = new Application_Model_Transaction();
     $file_handle = fopen(APPLICATION_PATH . '/data/EXAMPLE.csv', "r");
     $field_names = fgetcsv($file_handle);
     //header row
     $entry = fgetcsv($file_handle);
     //first row
     fclose($file_handle);
     $feed_data = array_combine($field_names, $entry);
     $feed_data['depository'] = 'DTCC';
     $transaction->populateFromDescriptionData($feed_data);
     $this->assertSame($transaction->getAction(), 'NEW', 'transaction not set correctly');
     $trade_data = $transaction->getTradeData();
     $this->assertSame($trade_data['trade_id'], 1311449, 'trade data not set correctly');
     $this->assertSame($trade_data['inst_type'], 'IRSwap', 'categories not parsed correctly');
     $this->assertSame($trade_data['not_amount_1'], 250.0, 'size not calculated correctly');
     $this->assertSame($trade_data['term'], 10.0, 'term not calculated correctly');
 }
Example #3
0
 public function orderAction()
 {
     $request = $this->getRequest();
     $user_id = $request->getParam('user_id');
     if (empty($user_id)) {
         throw new Exception("empty user id");
     }
     if ($request->isPost()) {
         $payment_id = uniqid();
         $data = array('payment_number' => $payment_id, 'user_id' => $user_id);
         $trans_model = new Application_Model_Transaction();
         $trans_model->insert($data);
         $song_ids = $request->getParam('ids');
         $song_array = split("\n", $song_ids);
         $db = Zend_Registry::get("db");
         foreach ($song_array as $song_id) {
             $sql = "INSERT INTO `order` (payment_number, user_id, song_id) VALUES ('{$payment_id}', '{$user_id}','{$song_id}');";
             $db->query($sql);
         }
         $_SESSION['success'] = true;
         $_SESSION['message'] = "New Playlist was added to DB successfully.";
     }
     $this->view->user_id = $user_id;
 }
 /**
  * saves the data from a transaction instance to the database
  * when appropriate conditions are met
  * 
  * @param Application_Model_Transaction $transaction
  * 
  * @access protected
  */
 protected function _updateDatabase(Application_Model_Transaction $transaction)
 {
     $trade_data = $transaction->getTradeData();
     switch ($transaction->getAction()) {
         case 'NEW':
             $this->_saveIfTrade($trade_data);
             break;
         case 'CANCEL':
             $this->_getTradeMapper()->delete($trade_data['trade_id']);
             break;
         case 'CORRECT':
             $this->_getTradeMapper()->delete($trade_data['trade_id']);
             $this->_saveIfTrade($trade_data);
             break;
         default:
             break;
     }
 }
 public function categoryAction()
 {
     $session = new Zend_Session_Namespace('Zend_auth');
     $user = $session->user;
     $modelCategory = new Application_Model_Category();
     $this->view->categories = $modelCategory->getAll();
     $modelTransaction = new Application_Model_Transaction();
     $category = $this->getRequest()->getPost('category', null);
     if ($category != null) {
         $transactions = $modelTransaction->getByCategory($category, $user);
         $this->view->transactions = $transactions;
         $this->view->category = $category;
     }
 }