/**
  * Get the number of decimal places in the currency.
  *
  * @return integer
  */
 public function getCurrencyDecimalPlaces()
 {
     if ($currency = Currency::find($this->getCurrency())) {
         return $currency->getDecimals();
     }
     return 2;
 }
示例#2
0
 static function getSelectedCurrency($db)
 {
     if (!isset(Currency::$selected_currency_cache)) {
         $currencies = Currency::all($db);
         if (isset($_COOKIE['currency'])) {
             $selected_currency_id = $_COOKIE['currency'];
             $selected_currency = Currency::find($currencies, 'currency_id', $selected_currency_id);
         }
         if (!isset($selected_currency)) {
             $selected_currency = Currency::find($currencies, 'currency_value', 1);
         }
         Currency::$selected_currency_cache = $selected_currency;
     }
     return Currency::$selected_currency_cache;
 }
 /**
  * Shows the view to create (edit) engine
  */
 public function assignAction()
 {
     $id = $this->dispatcher->getParams()[0];
     // check "edit" or "new" action in use
     $engine = $id === null ? new Engines() : Engines::findFirst($id);
     if (!$engine instanceof Engines) {
         return $this->response->redirect(['for' => 'dashboard-full', 'controller' => $this->router->getControllerName(), 'action' => $this->router->getActionName()]);
     }
     try {
         // handling POST data
         if ($this->request->isPost()) {
             $engines = $engine->setName($this->request->getPost('name'))->setDescription($this->request->getPost('description'), null, '')->setHost($this->request->getPost('host'))->setCode($this->request->getPost('code'))->setCurrencyId($this->request->getPost('currency_id', null, 1))->setStatus($this->request->getPost('status', null, 0));
             if (!$engines->save()) {
                 // the store failed, the following message were produced
                 foreach ($engines->getMessages() as $message) {
                     $this->flashSession->error((string) $message);
                 }
                 // forward does not working correctly with this  action type
                 // by the way this handle need to remove in another action (
                 return $this->response->redirect(['for' => 'dashboard-full', 'controller' => $this->router->getControllerName(), 'action' => $this->router->getActionName()]);
             } else {
                 // saved successfully
                 if (!isset($id)) {
                     $this->flashSession->success('The engine was successfully added!');
                 } else {
                     $this->flashSession->success('The engine was successfully updated!');
                 }
                 // forward does not working correctly with this  action type
                 // by the way this handle need to remove in another action (
                 return $this->response->redirect(['for' => 'dashboard-full', 'controller' => $this->router->getControllerName()]);
             }
         }
         // build meta data
         $title = !isset($id) ? 'Add' : 'Edit';
         $this->tag->prependTitle($title . ' - ' . self::NAME);
         // add crumb to chain (name, link)
         $this->_breadcrumbs->add(self::NAME, $this->url->get(['for' => 'dashboard-controller', 'controller' => 'engines']))->add($title);
         // set variables output to view
         $this->view->setVars(['title' => $title, 'form' => new Forms\EngineForm(null, ['currency' => Currency::find(), 'default' => isset($id) ? $engine : null])]);
     } catch (\Phalcon\Exception $e) {
         echo $e->getMessage();
     }
 }
示例#4
0
 /**
  * Show the form for editing the specified currency.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $currency = Currency::find($id);
     return View::make('currencies.edit', compact('currency'));
 }
 public function getPayments()
 {
     $to = Input::get('to');
     $from = Input::get('from');
     if ($from == null || $to == null) {
         $today = LocationController::getTime();
         $todayFrom = $today['date'] . ' 00:00:00';
         $todayTo = $today['date'] . ' 23:59:59';
     } else {
         $todayFrom = $from . ' 00:00:00';
         $todayTo = $to . ' 23:59:59';
     }
     try {
         $results = Payment::where('created_at', '>', $todayFrom)->where('created_at', '<', $todayTo)->get()->toArray();
         if (!is_null($results)) {
             foreach ($results as $key => $payment) {
                 $driver = Driver::where('id', '=', $payment['driver_id'])->first()->toArray();
                 $currency = Currency::find($payment['currency'])->pluck('currency');
                 $results[$key]['driver_name'] = $driver['first'] . ' ' . $driver['last'];
                 $results[$key]['currency'] = $currency;
             }
         }
         $queries = DB::getQueryLog();
         $last_query = end($queries);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
     }
     //\Log::info(__METHOD__.print_r($results, 1));
     return json_encode($results);
 }
示例#6
0
 public function IndexAction()
 {
     $currentPage = (int) $_GET["page"];
     $this->view->setVar("page", $this->getPaginationWithModel(Currency::find(), $currentPage));
 }