/** * Get limit from database for specified date. * * @param null|string $date date from which limit will be obtained, leave null for current day. * * @return double daily limit. */ function operations_ledcoin_daily_limit($date = NULL) { if ($date === NULL) { $date = date('Y-m-d'); } else { if (!preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $date)) { return 0.0; } list($year, $month, $day) = explode('-', $date); if (!checkdate($month, $day, $year)) { return 0.0; } } $limit = new Limit(); $limit->get_where(array('date' => $date)); if ($limit->exists()) { return (double) $limit->daily_limit; } return 0.0; }
public function delete_limit($limit_id = null) { if (is_null($limit_id)) { add_error_flash_message('Denný limit sa nenašiel.'); redirect(site_url('limits')); } $this->db->trans_begin(); $limit = new Limit(); $limit->get_by_id((int) $limit_id); if (!$limit->exists()) { $this->db->trans_rollback(); add_error_flash_message('Denný limit sa nenašiel.'); redirect(site_url('limits')); } if (date('Y-m-d') > $limit->date) { $this->db->trans_rollback(); add_error_flash_message('Nie je povolené vymazávať staršie limity ako dnešné.'); redirect(site_url('limits')); } $date = date('d. m. Y', strtotime($limit->date)); $daily_limit = $limit->daily_limit; if ($limit->delete() && $this->db->trans_status()) { $this->db->trans_commit(); add_success_flash_message('Limit s dátumom <strong>' . $date . '</strong> a hodnotou <strong>' . $daily_limit . '</strong> bol úspešne vymazaný.'); } else { $this->db->trans_rollback(); add_error_flash_message('Nepodarilo sa vymazať limit s dátumom <strong>' . $date . '</strong> a hodnotou <strong>' . $daily_limit . '</strong>!'); } redirect(site_url('limits')); }