Пример #1
0
 public static function GetDepartments()
 {
     // Составляем SQL-запрос
     $sql = 'CALL catalog_get_departments_list()';
     // Выполняем запрос и получаем результаты
     return DatabaseHandler::GetAll($sql);
 }
Пример #2
0
function getTeacherByid($teacherid)
{
    $sql = "SELECT * FROM teacher WHERE ID = :teacherid";
    $params = array(':teacherid' => $teacherid);
    $result = DatabaseHandler::GetAll($sql, $params);
    return $result[0]['Name'];
}
Пример #3
0
 public function getAllTag()
 {
     $sql = 'SELECT $this->table_name.*
             FROM $this->table_name
             ORDER BY pubdate DESC
             ';
     $arr = DatabaseHandler::GetAll($sql);
     return $arr;
 }
function adminauthenticate($username, $password)
{
    $passwordcrypt = ENCRYPT . $password;
    $passwordcrypt = SHA1($passwordcrypt);
    $sql = "SELECT * FROM admin_usr WHERE username = :username AND password = :password AND isactive = 1 AND isdeleted = 0";
    $params = array(':username' => $username, ':password' => $passwordcrypt);
    $result = DatabaseHandler::GetAll($sql, $params);
    if (count($result) > 0) {
        return 1;
    }
    return 0;
}
function isRegForEvent($username, $event_id)
{
    $acc = getAccountbyname($username);
    $user_id = $acc[0]['id'];
    $sql = "SELECT * FROM registrations WHERE user_id = :user_id AND event_id = :event_id AND isdeleted = 0";
    $params = array(':user_id' => $user_id, ':event_id' => $event_id);
    $result = DatabaseHandler::GetAll($sql, $params);
    if (count($result) > 0) {
        return 1;
    }
    return 0;
}
Пример #6
0
 public static function GetPLStatament($date, $period)
 {
     $ledgers = Ledger::GetPLLedgers();
     $today = date('d/m/Y');
     if ($date) {
         if ($date == $today) {
             foreach ($ledgers as &$ledger) {
                 $ledger->amount = $ledger->balance->amount;
             }
             return $ledgers;
         } else {
             $d1 = explode('/', $date);
             $stamp = $d1[2] . $d1[0] . $d1[1] . '000000' + 0;
             foreach ($ledgers as &$ledger) {
                 try {
                     $sql = 'SELECT * FROM general_ledger_entries WHERE ledger_id = ' . $ledger->id . ' AND stamp <= ' . $stamp . ' ORDER BY stamp DESC LIMIT 0,1';
                     $res = DatabaseHandler::GetRow($sql);
                     if ($res) {
                         $amount = $res['ledger_bal'];
                     } else {
                         $amount = 0;
                     }
                     $ledger->amount = $amount;
                 } catch (Exception $e) {
                 }
             }
             return $ledgers;
         }
     } else {
         $split = explode(' - ', $period);
         $d1 = explode('/', $split[0]);
         $d2 = explode('/', $split[1]);
         $lower = $d1[2] . $d1[1] . $d1[0] . '000000' + 0;
         $upper = $d2[2] . $d2[1] . $d2[0] . '999999' + 0;
         $sql = 'SELECT * FROM general_ledger_entries WHERE account_no = ' . intval($cid) . ' AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY id ASC';
         foreach ($ledgers as &$ledger) {
             try {
                 $sql = 'SELECT * FROM general_ledger_entries WHERE ledger_id = ' . $ledger->id . ' AND stamp BETWEEN ' . $lower . ' AND ' . $upper . ' ORDER BY stamp ASC';
                 $res = DatabaseHandler::GetAll($sql);
                 $amount = 0.0;
                 foreach ($res as $tx) {
                     $amount += $tx['amount'];
                 }
                 $ledger->amount = $amount;
             } catch (Exception $e) {
             }
         }
         return $ledgers;
     }
 }
 public static function checkBox($table, $idField, $titleField, $elementName, $whereClause = '', $cssClass = '', $onClick = '')
 {
     DatabaseHandler::Execute("SET NAMES UTF8;");
     $sql = "SELECT * FROM {$table} {$whereClause}";
     $records = DatabaseHandler::GetAll($sql);
     DatabaseHandler::Close();
     $checkBox = '';
     foreach ($records as $item) {
         $id = $item[$idField];
         $text = $item[$titleField];
         $checkBox .= "<label class='{$cssClass}'><input type='checkbox' name='{$elementName}' id='{$elementName}{$id}' value='{$id}' />{$text}</label>";
     }
     return $checkBox;
 }
Пример #8
0
    public static function GetProductsInCategory($categoryId, $pageNo, &$rHowManyPages)
    {
        // Query that returns the number of products in the category
        $sql = 'CALL catalog_count_products_in_category(:category_id)';
        // Build the parameters array
        $params = array(':category_id' => $categoryId);
        // Calculate the number of pages required to display the products
        $rHowManyPages = Catalog::HowManyPages($sql, $params);
        // Calculate the start item
        $start_item = ($pageNo - 1) * PRODUCTS_PER_PAGE;
        // Retrieve the list of products
        $sql = 'CALL catalog_get_products_in_category(
				:category_id, :short_product_description_length,
				:products_per_page, :start_item)';
        // Build the parameters array
        $params = array(':category_id' => $categoryId, ':short_product_description_length' => SHORT_PRODUCT_DESCRIPTION_LENGTH, ':products_per_page' => PRODUCTS_PER_PAGE, ':start_item' => $start_item);
        // Execute the query and return the results
        return DatabaseHandler::GetAll($sql, $params);
    }
function getCategory($id)
{
    $sql = "SELECT * FROM event_categories WHERE id = :id AND isdeleted = 0";
    $params = array(':id' => $id);
    $result = DatabaseHandler::GetAll($sql, $params);
    return $result;
}
Пример #10
0
 public static function authors_SelectAll()
 {
     $sql = 'CALL `sp_authors_SelectAll`()';
     DatabaseHandler::Close();
     return DatabaseHandler::GetAll($sql);
 }
Пример #11
0
 public static function permissions_SelectAll()
 {
     $sql = 'CALL `sp_permissions_SelectAll`()';
     DatabaseHandler::Close();
     return DatabaseHandler::GetAll($sql);
 }
Пример #12
0
 public function GetAllComentsByUser($user_id)
 {
     $params[] = intval($user_id);
     $sql = 'SELECT *
             FROM coments
             WHERE user_id = ?';
     $arr = DatabaseHandler::GetAll($sql, $params);
     return $arr;
 }
Пример #13
0
        //                B_A::b_a_Insert($blog_id, $audience['1']);
        //            }
        //        }
        $result = '<div class="col-lg-12 col-md-6">
                        <div class="alert alert-success alert-dismissable">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                            ویرایش / افزودن بلاگ با موفقیت انجام شد. بلاگ مورد نظر غیر فعال بوده و برای فعال شدن از <a href="index.php?page=blog_list">لیست بلاگ ها</a> اقدام نمایید.
                            <br>
                            همچنین شما می توانید از <a href="../blog/detail.php?title=' . $title_en . '">این لینک</a> پیش نمایش بلاگ وارد شده را ببینید.
                        </div>
                    </div>';
    }
}
if (isset($_GET["id"])) {
    $update_blog = BLOGS::blogs_SelectRow($_GET["id"]);
    $keywords = DatabaseHandler::GetAll("SELECT * FROM blog_keywords WHERE blog_id = '{$_GET['id']}' ; ");
    foreach ($keywords as $keyword) {
        $keywords_input .= $keyword["keyword"] . ' , ';
    }
    $title_input = $update_blog['title'];
    $title_en_input = $update_blog['title_en'];
    $image_input = $update_blog["image"];
    $text_input = $update_blog['text'];
    $source_input = $update_blog['source'];
    $video_input = $update_blog['video'];
    $description_input = $update_blog['description'];
    $read_time_input = $update_blog['read_time'];
    $submit = "update";
    $page_title = "ویرایش بلاگ";
}
/**
Пример #14
0
 /**
  * Execute an SQL query on the database
  *
  * @param  resource $db  Database handler
  * @param  array    $bindings Array of PDO binding values from bind() to be
  *   used for safely escaping strings. Note that this can be given as the
  *   SQL query string if no bindings are required.
  * @param  string   $sql SQL query to execute.
  * @return array         Result from the query (all rows)
  */
 static function sql_exec($bindings, $sql = null)
 {
     // Argument shifting
     if ($sql === null) {
         $sql = $bindings;
     }
     //$stmt = $db->prepare( $sql );
     //echo $sql;
     $result = DatabaseHandler::Prepare($sql);
     // Bind parameters
     if (is_array($bindings)) {
         $result = DatabaseHandler::GetAllWithBinding($result, $bindings, PDO::FETCH_BOTH);
     } else {
         $result = DatabaseHandler::GetAll($result, null, PDO::FETCH_BOTH);
     }
     // Return all
     return $result;
 }
Пример #15
0
 public function excuteReadAll($params = null)
 {
     $result = DatabaseHandler::Prepare($this->sql);
     $result = DatabaseHandler::GetAll($result, $params);
     return $result;
 }
Пример #16
0
 public static function GetAllUsers()
 {
     $sql = 'SELECT * FROM users';
     return DatabaseHandler::GetAll($sql);
 }
Пример #17
0
 public static function blog_audience_SelectAll()
 {
     $sql = 'CALL `sp_blog_audience_SelectAll`()';
     DatabaseHandler::Close();
     return DatabaseHandler::GetAll($sql);
 }
Пример #18
0
 public function GetAllPostByAuthor($author_id)
 {
     $params[] = $author_id;
     $sql = 'SELECT posts.*, COUNT(coments.coment_id) as coments, authors.author_id, authors.login, authors.logo, authors.name
             FROM posts
             LEFT JOIN coments ON posts.post_id = coments.post_id
             LEFT JOIN authors ON posts.author_id = authors.author_id
             WHERE posts.author_id = ?
             GROUP BY posts.post_id
             ORDER BY pubdate DESC;
             ';
     $arr = DatabaseHandler::GetAll($sql, $params);
     return $arr;
 }
Пример #19
0
     $audience_statement = "AND b_a.audience_id IN ( {$audience_statement} )";
 }
 if (strpos($audience_statement, 'all') === false) {
     $audience_statement_final = $audience_statement;
 }
 $query = 'SELECT blogs.id,blogs.title,blogs.video,blogs.add_time,blogs.source,blogs.title_en,blogs.hit_count,blogs.description,blogs.read_time, blogs.image, b_a.blog_id, b_a.audience_id, b_s.blog_id, b_s.subject_id, b_t.blog_id, b_t.type_id
                 FROM blogs
                 INNER JOIN b_a ON blogs.id = b_a.blog_id
                 INNER JOIN b_s ON blogs.id = b_s.blog_id
                 INNER JOIN b_t ON blogs.id = b_t.blog_id
                 WHERE 1=1
                 ' . $type_statement_final . '
                 ' . $subject_statement_final . '
                 ' . $audience_statement_final . '
                 GROUP BY (blogs.id)';
 $blogs = DatabaseHandler::GetAll($query);
 $output = "";
 $clearfix = 1;
 $clearfixOutput = '';
 foreach ($blogs as $blog) {
     if ($clearfix % 3 == 0) {
         # code...
         $clearfixOutput = "<div class='clearfix'></div>";
     } else {
         $clearfixOutput = "";
     }
     $clearfix++;
     $blog["description"] = mb_substr($blog["description"], 0, 170, 'UTF-8') . " ... ";
     $blog["add_time"] = jdate("d/m/Y", $blog["add_time"]);
     if ($blog["source"] != "") {
         $blog["source"] = "منبع : " . $blog["source"];
Пример #20
0
 private function processLatestEnquiries()
 {
     try {
         $sql = 'SELECT stamp FROM enquiries WHERE status = 0 ORDER BY stamp DESC LIMIT 0,5';
         $res = DatabaseHandler::GetAll($sql);
         $sql2 = 'SELECT count(*) FROM enquiries WHERE status = 0';
         $res2 = DatabaseHandler::GetOne($sql2);
         $enquiries = [];
         foreach ($res as $enquiry) {
             $enquiries[] = Enquiry::GetEnquiry($enquiry['stamp']);
         }
         $obj = new stdClass();
         $obj->enquiries = $enquiries;
         $obj->total = $res2;
         $this->latestEnquiries = $obj;
     } catch (Exception $e) {
     }
 }
Пример #21
0
 public static function GetInvoices()
 {
     try {
         $sql = 'SELECT * FROM invoices ORDER BY stamp DESC LIMIT 0,30';
         $res = DatabaseHandler::GetAll($sql);
         $invoice = [];
         foreach ($res as $inv) {
             $invoice = new Invoice($inv['id'], $inv['order_id'], $inv['date'], $inv['amount'], $inv['balance'], $inv['status']);
             $invoice->loadPayments();
             $invoices[] = $invoice;
         }
         return $invoices;
     } catch (Exception $e) {
     }
 }
Пример #22
0
 public static function GetUnsettledVouchers($prid)
 {
     try {
         $sql = 'SELECT * FROM expense_vouchers WHERE status = 0';
         $res = DatabaseHandler::GetAll($sql);
         $vouchers = array();
         foreach ($res as $act) {
             $vouchers[] = self::initialize($act);
         }
         return $vouchers;
     } catch (Exception $e) {
     }
 }
function getTeamId($team)
{
    $sql = "SELECT * FROM mad_team WHERE team_name=:team";
    $parms = array(':team' => $team);
    $result = DatabaseHandler::GetAll($sql, $parms);
    return $result[0]['id'];
}
function getInactiveUsers()
{
    $sql = "SELECT * FROM `users` WHERE isactive=0 AND isdeleted=0 ORDER BY `added_on` DESC LIMIT 151,200";
    $result = DatabaseHandler::GetAll($sql);
    return $result;
}
Пример #25
0
 public static function GetPreferredJournalsOauth($id)
 {
     $userId = self::GetUserIdOauth($id);
     $sql = 'SELECT journal_id FROM user_journal WHERE user_id = ' . $userId;
     // Execute the query and return the results
     return DatabaseHandler::GetAll($sql);
 }
Пример #26
0
 public static function GetLatestItems($number)
 {
     //$sql = 'UPDATE products SET pack_size = '.$packsize.', featured = '.$featured.', availability = '.$availability.', catalog_bal = '.$openstock.', stock_bal = '.$openstock.', optimum_bal = '.$optstock.', low_bal = '.$lowstock.' WHERE id = '.$item->itemId;
     $stock_accounts = array();
     $sql = 'SELECT * FROM stock_accounts ORDER BY tstamp DESC LIMIT 0,' . intval($number);
     $stocks = DatabaseHandler::GetAll($sql);
     foreach ($stocks as $stock) {
         $sql = 'SELECT * FROM products WHERE resource_id = ' . $stock['resource_id'];
         $sqlf = 'SELECT * FROM features WHERE resource_id = ' . $stock['resource_id'];
         $product = DatabaseHandler::GetRow($sql);
         $features = DatabaseHandler::GetAll($sqlf);
         //$sqlf = 'SELECT * FROM item_features WHERE item_id = '.$product['id'];
         $typedata = ResourceType::GetTypeData($product['type_id']);
         $unit = Unit::GetUnitById($typedata['unit_id']);
         $item = new Product($product['resource_id'], $product['type_id'], $typedata['type'], $product['name'], $product['reference'], $unit, $product['description'], $features, $product['manufacturer'], $product['retail_price'], $product['wholesale_price'], $product['tax_code'], $product['img_url'], $product['plength'], $product['pwidth'], $product['pheight'], $product['pweight'], $product['pshape']);
         $stockAccount = new StockAccount($stock['account_id'], $item, $stock['pack_size'], $stock['featured'], $stock['availability'], $stock['catalog_bal'], $stock['stock_bal'], $stock['optimum_bal'], $stock['low_bal'], $stock['cost_price'], $stock['retail_price'], $stock['wholesale_price'], $stock['vat_code'], $stock['date_added'], $stock['tstamp']);
         $stock_accounts[] = $stockAccount;
     }
     //do something as an inventory objects
     return $stock_accounts;
 }
Пример #27
0
 public static function GetAttributesNotAssignedToProduct($productId)
 {
     // Build the SQL query
     $sql = 'CALL catalog_get_attributes_not_assigned_to_product(:product_id)';
     // Build the parameters array
     $params = array(':product_id' => $productId);
     // Execute the query and return the results
     return DatabaseHandler::GetAll($sql, $params);
 }
Пример #28
0
 public static function GetClientDocuments($cid)
 {
     try {
         $sql = 'SELECT * FROM land_docs WHERE client_id =' . intval($cid);
         $res = DatabaseHandler::GetAll($sql);
         $land_docs = [];
         foreach ($res as $document) {
             $land_docs[] = self::initialize($document);
         }
         return $land_docs;
     } catch (Exception $e) {
         return false;
     }
 }
Пример #29
0
 public static function GetCartProducts($cartProductsType)
 {
     $sql = '';
     // При получении списка товаров для немедленной оплаты
     if ($cartProductsType == GET_CART_PRODUCTS) {
         // Составляем SQL - запрос
         $sql = 'CALL shopping_cart_get_products(:cart_id)';
     } elseif ($cartProductsType == GET_CART_SAVED_PRODUCTS) {
         // Составляем SQL - запрос
         $sql = 'CALL shopping_cart_get_saved_products(:cart_id)';
     } else {
         trigger_error($cartProductsType . 'value unknown', E_USER_ERROR);
     }
     // Создаем массив параметров
     $params = array(':cart_id' => self::GetCartId());
     // Выполняем запрос и возвращаем результат
     return DatabaseHandler::GetAll($sql, $params);
 }
Пример #30
0
 public static function GetAllInvoices($dates, $all)
 {
     if ($all == 'true') {
         $sql = 'SELECT * FROM purchase_invoices';
     } else {
         $split = explode(' - ', $dates);
         $d1 = explode('/', $split[0]);
         $d2 = explode('/', $split[1]);
         $lower = $d1[2] . $d1[1] . $d1[0] . '000000' + 0;
         $upper = $d2[2] . $d2[1] . $d2[0] . '999999' + 0;
         $sql = 'SELECT * FROM purchase_invoices WHERE stamp BETWEEN ' . $lower . ' AND ' . $upper . '';
     }
     try {
         $res = DatabaseHandler::GetAll($sql);
         return $res;
     } catch (Exception $e) {
         Logger::Log('Purchase Invoice', 'Exception', $e->getMessage());
         return null;
     }
 }