function showCupones() { $database = new DB(); echo "\n <table class=\"table table-striped table-bordered bootstrap-datatable datatable\">\n <thead>\n\t\t\t<tr>\n <th> </th>\n\t\t\t <th>Cupon</th>\n\t\t\t <th>Compra Minima</th>\n\n\t\t\t <th>Tipo</th>\n\t\t\t <th>Opciones</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>"; $query = "SELECT * from cupon,cupontipo\n where cupon.cupontipo_id=cupontipo.cupontipo_id"; $results = $database->get_results($query); $i = 0; foreach ($results as $row) { $i += 1; echo "<tr>\n\t\t\t <td align=right><font > {$i} </td>\n\t\t\t <td ><a href=\"/index.php?data=cupones&op=generados&bulk=" . $row['bulk'] . "\" >"; switch ($row['cupontipo_id']) { case 1: echo "\$ " . dinero($row['cantidad']) . " MX"; break; case 2: echo $row['cantidad'] . " %"; break; } echo "</b><a>\n\t\t\t </td>"; echo "<td><font >" . dinero($row['compra_minima']) . "</td>\n\n\t\t\t<td> <font >" . strtoupper($row['cupontipo']) . "</td>"; echo "<td><button class=\"btn-primary btn-setting hidden-print\" onclick=\"showData('myModal',\n 'view/cupones/cupones_agregar.inc.php',\n 'f=editar&cuid=" . $row['cupon_id'] . "')\">Editar</button>\n\n <button class=\"btn-info btn-setting hidden-print\" onclick=\"showData('myModal',\n 'view/cupones/cupones.php',\n 'f=generar&cuid=" . $row['cupon_id'] . "&cupon=" . $row['cupon'] . "&monto=" . $row['cantidad'] . "&compra_minima=" . $row['compra_minima'] . "')\">Generar</button></td>"; echo "</tr>"; } echo " </tbody>\n </table>"; }
function mostrar_transacciones($fecha_inicio, $fecha_fin, $user) { $database = new DB(); //$fecha=fechaplusweek($fecha); $total_pagos = ceil($total / $abono); echo "\n\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table class=\"table table-condensed striped\" width=100% >\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Id</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Fecha</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Movimiento</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Total</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Cliente</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead>\n\t\t\t\t\t\t\t <tbody>"; $fecha_inicio_bd = $fecha_inicio; $fecha_fin_bd = $fecha_fin; $query = "SELECT * from movimiento,tipomov,admin,cliente\n\t\twhere movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.admin_id=admin.admin_id AND (movimiento.tipomov_id=1 OR movimiento.tipomov_id=13 or movimiento.tipomov_id=14)\n AND movimiento.cliente_id=cliente.cliente_id AND cliente.empresa_id=0"; if ($fecha_inicio) { $query .= " AND fecha>='{$fecha_inicio_bd}' AND fecha<='{$fecha_fin_bd} 23:59:59' "; } if ($user) { $query .= " AND movimiento.admin_id={$user} "; } $query .= " ORDER BY fecha DESC"; $results = $database->get_results($query); foreach ($results as $item) { $vendedor = $item['nombre'] . " " . $item['apellidop']; echo "<tr><td style='text-align:right' width=30 >" . $item['movimiento_id'] . "</td>\n\t\t\t\t\t\t<td style='text-align:center'><span class='hidden-desktop'>" . fechamysqltous($item['fecha']) . "</span><a class='hidden-print' href=/index.php?data=estadisticas&op=ventas&fi=" . fechamysqltous($fecha_inicio) . "&hi={$hi}&ff=" . fechamysqltous($fecha_fin) . "&hf={$hf}&fid=" . $item['factura_id'] . ">" . fechamysqltomx($item['fecha'], "letra") . "</a></td>\n\t\t\t\t\t\t\t<td style='text-align:center'>" . $item['tipomov'] . "\n\t\t\t\t\t\t\t<br></td>\n\t\t\t\t\t\t\t<td style='text-align:right'>\$ " . dinero($item['cantidad'] + $item['iva']) . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $vendedor; echo " </td></tr>"; $n++; } echo " </tbody>\n\t\t</table> "; //echo "Pagos Atrazados: ".$pagos_atrazados; echo "</div>"; }
function catalogo($tid, $i) { $database = new DB(); $query = "SELECT categoria_id,categoria FROM categoria\n\t\twhere 1 "; $results = $database->get_results($query); foreach ($results as $row) { echo "<tr ><td colspan=3>" . $row['categoria'] . " </td></tr>"; $query = "SELECT descuento from temporada where temporada_Id={$tid}"; list($descuento) = $database->get_row($query); $query = "SELECT subcategoria_id,subcategoria FROM subcategoria where categoria_id=" . $row['categoria_id']; $subs = $database->get_results($query); foreach ($subs as $sub) { $query = "SELECT count(producto_id) as productos FROM producto\n\t\t\t\t\twhere producto.temporada_id={$tid} AND subcategoria_id=" . $sub['subcategoria_id']; if ($i) { $query .= " AND producto.descuento={$descuento}"; } else { $query .= " AND producto.descuento<>{$descuento}"; } list($productos) = $database->get_row($query); if ($productos) { echo "<tr><td></td><td align=right>\n\t\t\t\t\t\t<a href=/index.php?data=catalogo&subcat=" . $sub['subcategoria_id'] . "&tid={$tid}>" . $sub['subcategoria'] . "</a>\n </td>\n\t\t\t\t\t\t<td>{$productos}</td></tr>"; } } } }
public function filter_optimize_database($result, $paramarray) { $space_saved = 0; $tables = 0; switch (DB::get_driver_name()) { case 'mysql': $q = 'SHOW TABLE STATUS WHERE data_free > 0'; $tables = DB::get_results($q); if (count($tables) > 0) { foreach ($tables as $table) { $q2 = 'OPTIMIZE TABLE ' . $table->Name; if (DB::query($q2)) { $space_saved += $table->Data_free; $tables++; } } EventLog::log('Database Tables Optimized. ' . Utils::human_size($space_saved) . ' reclaimed from ' . HabariLocale::_n('table', 'tables', $tables) . '.'); } $result = true; break; case 'sqlite': if (DB::exec('VACUUM')) { $result = true; EventLog::log('SQLite database VACUUM\'ed successfully.'); } else { $result = false; } break; default: $result = false; break; } return $result; }
public function action_hconsole_debug() { if (isset($this->code['debug'])) { ob_start(); $res = eval($this->code['debug']); $dat = ob_get_contents(); ob_end_clean(); if ($res === false) { throw Error::raise($dat, E_COMPILE_ERROR); } else { echo $this->htmlspecial ? htmlspecialchars($dat) : $dat; } } if ($this->sql) { $itemlist = array(); if (preg_match('#^\\s*(select|show).*#i', $this->sql)) { $data = DB::get_results($this->sql); if (DB::has_errors()) { throw Error::raise(DB::get_last_error()); } if (is_array($data) && count($data)) { self::sql_dump($data); } else { echo 'empty set, nothing returned.'; } } else { $data = DB::query($this->sql); if (DB::has_errors()) { throw Error::raise(DB::get_last_error()); } echo 'Result: ' . (string) $data; } } }
public function testTimesAdded() { $sql = 'SELECT `flighttime` FROM ' . TABLE_PREFIX . 'pireps WHERE `accepted`=' . PIREP_ACCEPTED; $results = DB::get_results($sql); if (!$results) { $this->markTestSkipped('No PIREPs to test against'); } $this->added_time = 0; foreach ($results as $row) { $this->added_time = Util::AddTime($this->added_time, $row->flighttime); } $this->assertNotEqual(0, $this->added_time); // Now calculate by PIREP $allpilots = PilotData::GetAllPilots(); $total = 0; foreach ($allpilots as $pilot) { $p_hours = PilotData::getPilotHours($pilot->pilotid); $total = Util::AddTime($total, $p_hours); } $this->assertNotEqual(0, $total); $this->assertEqual($total, $this->added_time); StatsData::UpdateTotalHours(); $this->assertEqual($total, StatsData::TotalHours()); }
/** * Respond to Javascript callbacks * The name of this method is action_ajax_ followed by what you passed to the context parameter above. */ public function action_ajax_auto_tags( $handler ) { $selected = array(); if( isset( $handler->handler_vars['selected'] ) ) { $selected = Utils::single_array( $handler->handler_vars['selected'] ); } if( isset( $handler->handler_vars['term'] ) && MultiByte::strlen( $handler->handler_vars['term'] ) ) { $search = $handler->handler_vars['term'] . '%'; $tags = new Terms( DB::get_results( "SELECT * FROM {terms} WHERE vocabulary_id = :vid and LOWER(term_display) LIKE LOWER(:crit) ORDER BY term_display ASC", array( 'vid' => Tags::vocabulary()->id, 'crit' => $search ), 'Term' ) ); } else { $tags = Tags::vocabulary()->get_tree( 'term_display ASC' ); } $resp = array(); foreach ( $tags as $tag ) { $resp[] = MultiByte::strpos( $tag->term_display, ',' ) === false ? $tag->term_display : $tag->tag_text_searchable; } if( count( $selected ) ) { $resp = array_diff($resp, $selected ); } // Send the response // $ar = new AjaxResponse(); // $ar->data = $resp; // $ar->out(); echo json_encode( $resp ); }
/** * Populate the internal hashmap with the values from the DB. */ protected function _load() { if ($this->_loaded == true) { return; } if (empty($this->_key_value)) { $this->_loaded == true; return; } // This InfoRecord is read-only? if (empty($this->_table_name)) { $this->_loaded == true; return; } $result = DB::get_results(' SELECT name, value, type FROM ' . $this->_table_name . ' WHERE ' . $this->_key_name . ' = ?', array($this->_key_value)); foreach ($result as $result_element) { // XXX is this logic right? if ($result_element->type == 1) { $this->__inforecord_array[$result_element->name] = array('value' => unserialize($result_element->value)); } else { $this->__inforecord_array[$result_element->name] = array('value' => $result_element->value); } } $this->_loaded = true; }
public function testTimesAdded() { echo '<h3>Checking Times</h3>'; $sql = 'SELECT `flighttime` FROM ' . TABLE_PREFIX . 'pireps WHERE `accepted`=' . PIREP_ACCEPTED; $results = DB::get_results($sql); $this->added_time = 0; foreach ($results as $row) { $this->added_time = Util::AddTime($this->added_time, $row->flighttime); } heading('Time added, all PIREPS at once'); $this->assertNotEqual(0, $this->added_time); heading('Time added, pilot by pilot'); // Now calculate by PIREP $allpilots = PilotData::GetAllPilots(); $total = 0; foreach ($allpilots as $pilot) { $p_hours = PilotData::getPilotHours($pilot->pilotid); $total = Util::AddTime($total, $p_hours); } $this->assertNotEqual(0, $total); heading('Comparing pilot to pilot vs all PIREPS'); $this->assertEqual($total, $this->added_time); heading('Compare to STAT total hours'); StatsData::UpdateTotalHours(); $this->assertEqual($total, StatsData::TotalHours()); echo '<br />'; }
public function filter_rssblocks_update($success, $force = false) { EventLog::log('Running rrsblocks update'); $blocks = DB::get_results('SELECT b.* FROM {blocks} b WHERE b.type = ?', array('rssblock'), 'Block'); Plugins::act('get_blocks', $blocks); $success = true; foreach ($blocks as $block) { $cachename = array('rssblock', md5($block->feed_url)); if ($force || Cache::expired($cachename)) { $r = new RemoteRequest($block->feed_url); $r->set_timeout(10); $r->execute(); $feed = $r->get_response_body(); try { if (is_string($feed)) { new SimpleXMLElement($feed); // This throws an exception if the feed isn't valid Cache::set($cachename, $feed, 3600, true); } } catch (Exception $e) { $success = false; } } } Session::notice('ran rssblocks update'); return $success; }
/** * Get all of the custom fields that will show up * during the registration */ public static function GetCustomFields($getall = false) { $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'customfields'; if ($getall == false) { $sql .= ' WHERE showonregister=1'; } return DB::get_results($sql); }
/** * Return all of the custom fields data */ public static function getAllFields() { $all_fields = CodonCache::read('allfields'); if ($all_fields === false) { $all_fields = DB::get_results('SELECT * FROM ' . TABLE_PREFIX . 'customfields'); CodonCache::write('allfields', $all_fields, 'long'); } return $all_fields; }
/** * Get all of the downloads in a certain category * * @param int $categoryid the ID of the category * @return array Array of objects of all the downloads * */ public static function GetDownloads($categoryid) { if ($categoryid == '') { return false; } $categoryid = intval($categoryid); $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'downloads WHERE pid=' . $categoryid; return DB::get_results($sql); }
public static function optimizeTables() { $tables = Config::Get('TABLE_LIST'); foreach ($tables as $key => $name) { $tables[$key] = '`' . TABLE_PREFIX . $name . '`'; } $tables = implode(', ', $tables); $sql = 'OPTIMIZE TABLE ' . $tables; return DB::get_results($sql); }
/** * Returns an associative array of LogEntry types * * @param bool whether to force a refresh of the cached values * @return array An array of log entry type names => integer values */ public static function list_logentry_types($force = false) { if ($force || empty(self::$types)) { self::$types = array(); $res = DB::get_results('SELECT id, module, type FROM {log_types}'); foreach ($res as $x) { self::$types[$x->module][$x->type] = $x->id; } } return self::$types; }
function productos($proveedor_id, $subcat, $pid) { $database = new DB(); echo "<div class=\"box-header\">\n\t\t\t\t\t\t<h2><i class=\"halflings-icon align-justify\"></i><span class=\"break\"></span>Productos</h2>\n\t\t\t\t\t\t<div class=\"box-icon\">\n\t\t\t\t\t\t\t<a href=\"/index.php?data=productos&op=producto_form&f=agregar&pid={$pid}&subcat={$subcat}\" classe=\"btn-setting\"><i class=\"halflings-icon plus\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-minimize\"><i class=\"halflings-icon chevron-up\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-close\"><i class=\"halflings-icon remove\"></i></a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"box-content\">\n\t\t\t\t\t\t<table class=\"table table-striped table-bordered bootstrap-datatable datatable\">\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th>Id</th>\n\t\t\t\t\t\t\t\t\t <th>Producto</th>\n\t\t\t\t\t\t\t\t\t <th>P. Compra</th>\n\t\t\t\t\t\t\t\t\t <th>Stock</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead> \n\t\t\t\t\t\t\t <tbody>"; $query = "SELECT producto_id,producto,precio_compra,stock FROM producto where proveedor_id={$proveedor_id} AND subcategoria_id={$subcat}"; $subs = $database->get_results($query); foreach ($subs as $sub) { echo "<tr>\n\t\t\t\t\t\t\t<td>" . $sub['producto_id'] . "</td>\n\t\t\t\t\t\t\t<td>" . $sub['producto'] . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $sub['precio_compra'] . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $sub['stock'] . "</td>\n\t\t\t\t\t\t\t</tr>"; } echo "\t\t\t\t </tbody>\n\t\t\t\t\t\t </table> \n\t\t\t\t\t</div>\n\t\t\t\t"; }
/** * Returns all the ranks, and the total number of pilots * on each rank */ public static function getAllRanks() { $allranks = CodonCache::read('all_ranks'); if ($allranks === false) { $sql = 'SELECT r.*, (SELECT COUNT(*) FROM ' . TABLE_PREFIX . 'pilots WHERE rank=r.rank) as totalpilots FROM ' . TABLE_PREFIX . 'ranks r ORDER BY r.minhours ASC'; $allranks = DB::get_results($sql); CodonCache::write('all_ranks', $allranks, 'long'); } return $allranks; }
public static function get_categories($page, $page_size = 10, $order) { $ret = []; $db = new DB([]); $db->connect(); $total = $db->count('msf_article'); $total_page = 0; $total_page = ceil($total / $page_size); $start = ($page - 1) * $page_size; $limit = $page_size; //$page * $page_size - 1; $order_tag = explode('~', $order); $sql = "select * from msf_article order by `{$order_tag[0]}` {$order_tag[1]} limit {$start}, {$limit}"; $articles = $db->get_results($sql); $sql = "select id, name, alias from msf_category"; $cates = $db->get_results($sql); $cate = []; foreach ($cates as $idx => $data) { $cate[$data['id']] = [$data['name'], $data['alias']]; } $sql = "select id, name from msf_user"; $users = $db->get_results($sql); $user = []; foreach ($users as $idx => $data) { $user[$data['id']] = $data['name']; } foreach ($articles as $key => $article) { if (array_key_exists($article['category_id'], $cate)) { $articles[$key]['category_name'] = $cate[$article['category_id']][0]; $articles[$key]['category_alias'] = $cate[$article['category_id']][1]; } } foreach ($articles as $key => $value) { if (array_key_exists($value['create_user'], $user)) { $articles[$key]['create_user'] = $user[$value['create_user']]; } } $ret = ['page_info' => ['total_page' => $total_page, 'cur_page' => $page, 'page_size' => $page_size], 'articles' => $articles]; return $ret; }
/** * Return the active rewrite rules, both in the database and applied by plugins * * @return array Array of RewriteRule objects for active rewrite rules **/ public static function get_active() { static $system_rules; if (!isset($system_rules)) { $sql = "\n\t\t\t\tSELECT rr.rule_id, rr.name, rr.parse_regex, rr.build_str, rr.handler, rr.action, rr.priority, rr.parameters\n\t\t\t\tFROM {rewrite_rules} AS rr\n\t\t\t\tWHERE rr.is_active= 1\n\t\t\t\tORDER BY rr.priority"; $db_rules = DB::get_results($sql, array(), 'RewriteRule'); $system_rules = self::add_system_rules($db_rules); } $rewrite_rules = Plugins::filter('rewrite_rules', $system_rules); $rewrite_rules = self::sort_rules($rewrite_rules); $c = __CLASS__; return new $c($rewrite_rules); }
public function testSettings() { $settings = array('PHPVMS_VERSION', 'SITE_NAME', 'ADMIN_EMAIL', 'DATE_FORMAT', 'NOTIFY_UPDATE', 'CURRENT_SKIN', 'GOOGLE_KEY', 'DEFAULT_GROUP', 'PHPVMS_API_KEY'); $existing_settings = array(); $allsettings = DB::get_results("SELECT * FROM " . TABLE_PREFIX . "settings"); foreach ($allsettings as $setting) { $existing_settings[] = $setting->name; } foreach ($settings as $setting) { $this->assertTrue(in_array($setting, $existing_settings), $setting); } echo '<br />'; }
/** * Displays a list of all tags used on the site except those begining with "@" as a comma seperated linked list. **/ public function magic_site_tags() { $tagcount = 0; foreach (DB::get_results('SELECT * FROM ' . DB::table('tags') . ' ORDER BY tag_text ASC') as $tag) { if (substr($tag->tag_text, 0, 1) == "@") { continue; } if ($tagcount != 0) { echo ", "; } echo "<a href=\"" . URL::get('display_posts_by_tag', 'tag=' . $tag->tag_slug) . "\">{$tag->tag_text}</a>"; $tagcount++; } }
/** * Remove the admin token **/ public function action_plugin_deactivation($file) { // delete default access token ACL::destroy_token('manage_menus'); // delete menu vocabularies that were created $vocabs = DB::get_results('SELECT * FROM {vocabularies} WHERE name LIKE "menu_%"', array(), 'Vocabulary'); foreach ($vocabs as $vocab) { // This should only delete the ones that are menu vocabularies, unless others have been named 'menu_xxxxx' $vocab->delete(); } // delete blocks that were created $blocks = DB::get_results('SELECT * FROM {blocks} WHERE type = "menu"', array(), 'Block'); foreach ($blocks as $block) { $block->delete(); } }
/** * ActivityData::getActivity() * * @param integer $count * @return void */ public static function getActivity($where = '', $limit = 10, $start = '') { $sql = "SELECT p.*, a.*\r\n\t\t\t\tFROM `" . TABLE_PREFIX . "activityfeed` a\r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "pilots` p ON p.pilotid=a.pilotid "; if (is_array($where)) { $sql .= DB::build_where($where); } $sql .= ' ORDER BY `submitdate` DESC'; if (strlen($limit) != 0) { $sql .= ' LIMIT ' . $limit; } if (strlen($start) != 0) { $sql .= ' OFFSET ' . $start; } $ret = DB::get_results($sql); return $ret; }
function show_pedidos() { $database = new DB(); echo "<div class=\"box span8 hidden-print\">"; echo " <div class=\"box-header\">\n\t\t\t\t<h2><i class=\"halflings-icon align-justify\"></i><span class=\"break\"></span>Pedidos</h2>\n\t\t\t\t<div class=\"box-icon\">\n\t\t\t\t\t<a href=\"#\" class=\"btn-setting\"><i class=\"halflings-icon wrench\"></i></a>\n\t\t\t\t\t<a href=\"#\" class=\"btn-minimize\"><i class=\"halflings-icon chevron-up\"></i></a>\n\t\t\t\t\t<a href=\"#\" class=\"btn-close\"><i class=\"halflings-icon remove\"></i></a>\n\t\t\t </div>\n\t\t\t</div>\n\t\t\t<div class=\"box-content\">"; echo "<div id='pedidos'>"; echo "<table class=\"table table-striped table-bordered\"> <!-- bootstrap-datatable datatable -->\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n <th>Nombre</th>\n\t\t\t\t\t\t\t\t\t <th>Fecha de Orden</th>\n\t\t\t\t\t\t\t\t\t <th>Fecha de Entrega</th>\n <th>Status</th>\n\t\t\t\t\t\t\t\t\t <th>Total</th>\n <th>Anticipo</th>\n\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead>\n\t\t\t\t\t\t\t <tbody>"; $query = "SELECT * FROM pedido,status,pedido_nombre\n where pedido.pedido_nombre_id=pedido_nombre.pedido_nombre_id AND pedido.status_id=status.status_id"; $subs = $database->get_results($query); foreach ($subs as $sub) { $status_id = $sub['status_id']; echo "<tr>"; echo "<td>" . $sub['nombre'] . "</td>\n\t\t\t\t\t\t\t<td><a href=\"#\" onclick=\"showData('pedidos','view/pedidos/pedidos.php','case=pedidos')\"\n class=\"btn-setting\">" . $sub['fecha_orden'] . "</a> </td>\n\t\t\t\t\t\t\t<td style='text-align:left'>" . $sub['fecha_entrega'] . "</td>\n\t\t\t\t\t\t\t<td style='text-align:left'>" . $sub['status']; echo "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . dinero($sub['total']) . "</td>\n <td style='text-align:right'>" . dinero($sub['anticipo']) . "</td>\n\n\t\t\t\t\t\t\t</tr>"; } echo "\t\t\t\t </tbody>\n\t\t \t\t </table>\n </div> <!-- fin de la seccion -->\n \t </div>\n </div>\n\t\t\t\t"; }
public static function findLogs($params, $count = '', $start = '') { $sql = 'SELECT l.*, p.* FROM ' . TABLE_PREFIX . 'adminlog l INNER JOIN ' . TABLE_PREFIX . 'pilots p ON l.pilotid = p.pilotid '; /* Build the select "WHERE" based on the columns passed */ $sql .= DB::build_where($params); $sql .= ' ORDER BY l.datestamp DESC'; if (strlen($count) != 0) { $sql .= ' LIMIT ' . $count; } if (strlen($start) != 0) { $sql .= ' OFFSET ' . $start; } $ret = DB::get_results($sql); return $ret; }
function subcategorias($categoria_id) { $database = new DB(); $query = "SELECT categoria FROM categoria where categoria_id={$categoria_id} "; list($categoria) = $database->get_row($query); echo "<div class=\"box-header\">\n\t\t\t\t\t\t<h2><i class=\"halflings-icon align-justify\"></i><span class=\"break\"></span>Subcategorias de: " . strtoupper($categoria) . " </h2>\n\t\t\t\t\t\t<div class=\"box-icon\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-setting\"><i class=\"halflings-icon wrench\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-minimize\"><i class=\"halflings-icon chevron-up\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-close\"><i class=\"halflings-icon remove\"></i></a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"box-content\">"; echo "\t\t\t<form class=\"form-horizontal\" action=\"/functions/crud_proveedores.php\">\n\t\t\t\t\t\t\t<fieldset>\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<div class=\"control-group \">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<label class=\"control-label\" for=\"subcategoria\">SubCategoria</label>\n\t\t\t\t\t\t\t\t<div class=\"controls\">\n\t\t\t\t\t\t\t\t <input class=\"input-large\" id=\"subcategoria\" name=\"subcategoria\" type=\"text\" value=\"" . strtoupper($rfc) . "\"> \n\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"btn btn-primary\">Agregar SubCategoria</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t </div>\n\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t\t</form>"; echo "<table class=\"table table-striped table-bordered \">\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th>Subcategoria</th>\n\t\t\t\t\t\t\t\t\t <th>Productos</th>\n\t\t\t\t\t\t\t\t\t <th>Acciones</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead> \n\t\t\t\t\t\t\t <tbody>"; $query = "SELECT subcategoria_id,subcategoria FROM subcategoria where categoria_id=" . $categoria_id; $subs = $database->get_results($query); foreach ($subs as $sub) { $query = "SELECT count(producto_id) as productos FROM producto \n\t\t\t\t\twhere subcategoria_id=" . $sub['subcategoria_id']; list($productos) = $database->get_row($query); echo "<tr><td align=right> \n\t\t\t\t\t\t<a href=/index.php?data=catalogo&subcat=" . $sub['subcategoria_id'] . ">" . $sub['subcategoria'] . "</a> </td>\n\t\t\t\t\t\t<td>{$productos}</td></tr>"; } echo "\t\t\t\t </tbody>\n\t\t\t\t\t\t </table> \n\t\t\t\t\t</div>\n\t\t\t\t"; }
/** * function default_options * * returns defaults for the plugin * @return array default options array */ private static function default_options() { $home_keys = array(); // this is from the Tags::get() method, altered to return only the top ones $tags = DB::get_results(' SELECT t.id AS id, t.term_display AS term_display, t.term AS term, COUNT(tp.term_id) AS count FROM {terms} t LEFT JOIN {object_terms} tp ON t.id=tp.term_id WHERE t.vocabulary_id = ? GROUP BY id, term_display, term ORDER BY count DESC, term_display ASC LIMIT 0, 50', array(Tags::vocabulary()->id)); foreach ($tags as $tag) { $home_keys[] = Utils::htmlspecialchars(strip_tags($tag->term_display)); } return array('home_desc' => Utils::htmlspecialchars(strip_tags(Options::get('tagline'))), 'home_keywords' => $home_keys, 'home_index' => true, 'home_follow' => true, 'posts_index' => true, 'posts_follow' => true, 'archives_index' => false, 'archives_follow' => true); }
function mostrar_ventas() { $database = new DB(); //$fecha=fechaplusweek($fecha); $total_pagos = ceil($total / $abono); echo "\n\t\t\t\t\t<div class=\"box-header\">\n\t\t\t\t\t\t<h2></span>Ventas</h2>\n\t\t\t\t\t\t<div class=\"box-icon\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-setting\"><i class=\"halflings-icon wrench\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-minimize\"><i class=\"halflings-icon chevron-up\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-close\"><i class=\"halflings-icon remove\"></i></a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table class=\"table table-condensed striped\" width=100% >\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Id</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Fecha</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Cliente</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Tipo Venta</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Total</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Desc</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Vendedor</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead> \n\t\t\t\t\t\t\t <tbody>"; $query = "SELECT *, (notaventa+cupon+bono) as descuento from factura,tipomov,admin where factura.tipomov_id=tipomov.tipomov_id AND factura.admin_id=admin.admin_id ORDER BY factura_id DESC"; $results = $database->get_results($query); foreach ($results as $item) { $vendedor = $item['nombre'] . " " . $item['apellidop']; echo "<tr><td style='text-align:right'>" . $item['factura_id'] . "</td>\n\t\t\t\t\t\t<td style='text-align:right'>\n\t\t\t\t\t\t<a href=/index.php?data=estadisticas&op=ventas&fi={$fi}&hi={$hi}&ff={$ff}&hf={$hf}&fid=" . $item['factura_id'] . ">" . $item['fecha'] . "</a></td><td style='text-align:right'>" . $item['cliente_id'] . "</td>\n\t\t\t\t\t\t\t<td>" . $item['tipomov'] . "\n\t\t\t\t\t\t\t<br></td> \n\t\t\t\t\t\t\t<td style='text-align:right'>\$ " . dinero($item['total'] + $item['iva']) . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>\$ " . dinero($item['descuento']) . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $vendedor; echo " </td></tr>"; $n++; } echo " </tbody>\n\t\t</table> "; //echo "Pagos Atrazados: ".$pagos_atrazados; echo "</div>"; }
private function get_html() { set_time_limit(300); $q = "SELECT YEAR( FROM_UNIXTIME(pubdate) ) AS year, MONTH( FROM_UNIXTIME(pubdate) ) AS month, COUNT( id ) AS cnt\n\t\t\t\tFROM {posts}\n\t\t\t\tWHERE content_type = ? AND status = ?\n\t\t\t\tGROUP BY year, month\n\t\t\t\tORDER BY pubdate DESC"; $p[] = Post::type('entry'); $p[] = Post::status('published'); $results = DB::get_results($q, $p); $archives[] = '<ul id="compact-archives">'; if (empty($results)) { $archives[] = '<li>No Archives Found</li>'; } else { $grouping = array(); // group the results by year foreach ($results as $result) { if (!isset($grouping[$result->year])) { $grouping[$result->year] = array_fill(1, 12, 0); } $grouping[$result->year][$result->month] = $result->cnt; } // build the year lists $years = array_keys($grouping); for ($i = 0, $n = count($grouping); $i < $n; $i++) { $year = $years[$i]; $archives[] = '<li><span class="year">' . $year . '</span>'; $archives[] = '<ul class="months">'; for ($j = 1; $j <= count($grouping[$years[$i]]); $j++) { // make sure the month has a 0 on the front, if it doesn't $month = str_pad($j, 2, 0, STR_PAD_LEFT); $month_text = date('F', mktime(0, 0, 0, $month)); $archives[] = '<li>'; if ($grouping[$years[$i]][$j] == 0) { $archives[] = $month; } else { $archives[] = '<a href="' . URL::get('display_entries_by_date', array('year' => $year, 'month' => $month)) . '" title="View entries in ' . $month_text . ' ' . $year . '">' . $month . '</a>'; } $archives[] = '</li>'; } $archives[] = '</ul>'; $archives[] = '</li>'; } } $archives[] = '</ul>'; return implode('', $archives); }
public function ShowNewsFront($count = 5) { $sql = 'SELECT id, subject, body, postedby, UNIX_TIMESTAMP(postdate) AS postdate FROM ' . TABLE_PREFIX . 'news ORDER BY postdate DESC LIMIT ' . $count; $res = DB::get_results($sql); if (!$res) { return; } foreach ($res as $row) { //TODO: change the date format to a setting in panel $this->set('subject', $row->subject); $this->set('body', $row->body); $this->set('postedby', $row->postedby); $this->set('postdate', date(DATE_FORMAT, $row->postdate)); $this->show('news_newsitem.tpl'); } }