예제 #1
0
function update_balance($postdata, $xcrud)
{
    Xcrud_config::$dbname = 'bcspurchase_2015';
    Xcrud_config::$dbuser = '******';
    Xcrud_config::$dbpass = '';
    Xcrud_config::$dbhost = 'localhost';
    $db = Xcrud_db::get_instance();
    //$db->query("INSERT INTO test(test) values ('".$postdata->get('po_item_id')."')");
    $qty_lpb = $postdata->get('qty');
    $po_item_id = $postdata->get('po_item_id');
    $unit = $postdata->get('unit');
    $a = 'select po_item.qty from po_item where po_item_id="' . $po_item_id . '"';
    $db->query($a);
    $qty_po = $db->row()['qty'];
    $balance = $qty_po - $qty_lpb;
    $query = $db->query("UPDATE po_item SET lpb_balance ='" . $balance . "' WHERE po_item_id ='" . $po_item_id . "'");
    $db->query($query);
}
예제 #2
0
function update_price()
{
    //mengupdate field lpb_detail yang belum memiliki price HANYA UNTUK PR (cukup dijalankan sekali)
    Xcrud_config::$dbname = 'bcspurchase_2015';
    Xcrud_config::$dbuser = '******';
    Xcrud_config::$dbpass = '******';
    Xcrud_config::$dbhost = '10.2.2.32';
    $db = Xcrud_db::get_instance();
    $select = "select lpb_id from lpb_detail";
    $db->query($select);
    $arr = $db->result();
    $count = 0;
    //die("Arr :".$arr[0]['lpb_id']);
    foreach ($arr as $ar) {
        foreach ($ar as $a) {
            $count++;
        }
    }
    for ($x = 0; $x < $count; $x++) {
        $query = "select po_item_id from lpb_detail where lpb_id='" . $arr[$x]['lpb_id'] . "'";
        $db->query($query);
        $po_item_id = $db->row()['po_item_id'];
        //die("po item id : ".$po_item_id);
        if ($po_item_id != '') {
            $query2 = "select price from po_item  where po_item_id='{$po_item_id}'";
            $db->query($query2);
            $price = $db->row()['price'];
            //die("material id : ".$material_id);
            $query3 = "update lpb_detail set price='{$price}' where lpb_id='" . $arr[$x]['lpb_id'] . "'";
            $db->query($query3);
        }
    }
    die;
}
예제 #3
0
<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);
include '../inc/commons.php';
include BASE_URL . 'xcrud/xcrud.php';
if (!function_exists('xcrud_get_instance')) {
    function xcrud_get_instance($name = true)
    {
        return Xcrud::get_instance($name);
    }
}
Xcrud_config::$dbname = 'shop';
Xcrud_config::$dbuser = '******';
Xcrud_config::$dbpass = '******';
Xcrud_config::$dbhost = 'localhost';
$db = Xcrud_db::get_instance('shop');
$exec = $db->query("SELECT counter from counter");
$array = $db->result();
$counter = $array[0]['counter'];
$exec = $db->query("SELECT count(*),country from visitors group by country order by count(*) desc");
$array = $db->result();
$country = $array[0]['country'];
$exec = $db->query("SELECT count(*) as items from items");
$array = $db->result();
$items = $array[0]['items'];
$exec = $db->query("SELECT count(*) as count_category from (select distinct category from items group by category) as tbl1");
$array = $db->result();
$category = $array[0]['count_category'];
$exec = $db->query("SELECT count(*) as new from (select * from items where date_created+INTERVAL 1 WEEK > NOW()) as tbl1");
$array = $db->result();