本文整理汇总了PHP中jqgrid::set_events方法的典型用法代码示例。如果您正苦于以下问题:PHP jqgrid::set_events方法的具体用法?PHP jqgrid::set_events怎么用?PHP jqgrid::set_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jqgrid
的用法示例。
在下文中一共展示了jqgrid::set_events方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
//.........这里部分代码省略.........
$col['dbname'] = "cus.car_id";
$col["width"] = "100";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
// render as select
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("SELECT DISTINCT car_id AS k,car_number AS v FROM transport_cars;");
$col["editoptions"] = array("value" => ":;" . $str);
$col["formatter"] = "select";
// display label, not value
$cols[] = $col;
#remark
$col = array();
$col['title'] = $this->lang->line('car_license');
$col['name'] = "car_license";
$col['editable'] = true;
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => "2", "cols" => "20");
$cols[] = $col;
#Address
$col = array();
$col['title'] = $this->lang->line('Address1');
$col['name'] = "address1";
$col['editable'] = true;
$col["search"] = false;
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => "2", "cols" => "20");
$cols[] = $col;
#Contact Person
$col = array();
$col['title'] = $this->lang->line('contact_person');
$col['name'] = "contact_person";
$col['editable'] = true;
$cols[] = $col;
# Tel
/*
$col = array();
$col['title'] = $this->lang->line('tel');
$col['name'] = "mobile_number";
$col['editable'] = true;
$col["editrules"] = array("number" => true);
$cols[] = $col;
*/
#remark
$col = array();
$col['title'] = $this->lang->line('note');
$col['name'] = "remark";
$col['editable'] = true;
$col['edittype'] = "textarea";
$col["viewable"] = false;
$col['editoptions'] = array("rows" => "2", "cols" => "20");
$cols[] = $col;
$e["on_insert"] = array("add_client", null, true);
#$e["on_delete"] = array("del_client", null, true);
$g->set_events($e);
$g->select_command = "SELECT\n\tcustomer_id,\n\tcus.customer_type_id,\n\tcus_type.customer_type_title,\n\tcus.factory_id,\n\tcustomers_name,\n\tcus.car_id,\n\tcus.car_license,\n\taddress1,\n\tcontact_person,\n\tmobile_number,\n\tremark\nFROM\n\ttransport_customers AS cus\nLEFT JOIN transport_factory AS fac ON (\n\tcus.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customer_type AS cus_type ON (\n\tcus.customer_type_id = cus_type.customer_type_id\n)\nLEFT JOIN transport_cars AS car ON (cus.car_id=car.car_id)\nWHERE\n\tcus. STATUS = 1\nAND cus_type.customer_type_status != 1";
function add_client(&$data)
{
$check_sql = "SELECT count(*) as c from transport_customers where LOWER(`customers_name`) = '" . strtolower($data["params"]["customers_name"]) . "'";
$rs = mysql_fetch_assoc(mysql_query($check_sql));
if ($rs["c"] > 0) {
phpgrid_error("ข้อมูลลูกค้าซ้ำ");
}
}
// end of sub function
function del_client(&$data)
{
$check_sql = "UPDATE `transport_customers` SET `status`='0' WHERE (`customer_id`='{$data["id"]}')";
mysql_query($check_sql);
}
//Use Table
$g->table = "transport_customers";
// pass the cooked columns to grid
$g->set_columns($cols);
$opt["sortname"] = 'customer_id';
$opt["sortorder"] = "desc";
$opt["rowList"] = array(10, 20, 30);
$opt["caption"] = $this->lang->line('customer');
$opt["autowidth"] = true;
$opt["multiselect"] = false;
$opt["autowidth"] = true;
$opt["view_options"]['width'] = '520';
$opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
$g->set_options($opt);
$g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'customer', 'add_customer'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'customer', 'edit_customer'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'customer', 'del_customer'), "export" => false, "autofilter" => true, "search" => "advance"));
// set database table for CRUD operations
// render grid and get html/js output
$out_index = $g->render("list1");
$h2_title = $this->lang->line('customeroils');
//display
$this->_example_output((object) array('output' => '', 'out' => $out_index, 'h2_title' => $h2_title, 'js_files' => array(), 'css_files' => array()));
} else {
//If no session, redirect to login page
redirect('login', 'refresh');
}
}
示例2: index
public function index()
{
if ($this->session->userdata('user_name')) {
$g = new jqgrid();
$dispyPrice = $this->price->dispalyPrice();
$titke_cubic = $this->price->header_cubic();
$row_distance = $this->price->row_distance();
$i = 0;
foreach ($row_distance as $key => $val) {
// $i = $val['distance_id'];
foreach ($titke_cubic as $row) {
$data[$i]["id"] = $i;
$data[$i]["distacne"] = $dispyPrice[$i]['distance'];
$data[$i]['cubic'][$row->cubic_id] = 2 + $i;
//$dispyPrice[$i][$row->cubic_id];
$data[$i]["pricelist_id"] = $dispyPrice[$row->id];
}
$i = $val['distance_id'];
}
$g->table = $data;
// ห$g->table = $pricelist;
$col = array();
$col["title"] = "id";
// caption of column
$col["name"] = "id";
$col["width"] = "250";
$col["sorttype"] = int;
$col['editable'] = true;
$col['hidden'] = true;
$cols[] = $col;
$col = array();
$col["title"] = "pricelist_id";
// caption of column
$col["name"] = "pricelist_id";
$col["width"] = "250";
$col["sorttype"] = int;
$col['editable'] = true;
#$col['hidden'] = true;
//$cols[] = $col;
$col = array();
$col["title"] = "Cubic /<br/> Distance";
// caption of column
$col["name"] = "distacne";
$col["width"] = "350";
$cols[] = $col;
foreach ($titke_cubic as $row) {
$col = array();
$col['title'] = "{$row->cubic_value}";
$col['name'] = "cubic[{$row->cubic_id}]";
$col['editable'] = true;
$col['search'] = false;
$cols[] = $col;
}
$g->set_columns($cols);
$e["js_on_select_row"] = "do_onselect";
$e["on_update"] = array("do_update", null, true);
$e["on_data_display"] = array("filter_display", null, true);
$g->set_events($e);
function filter_display($data)
{
/*
These comments are just to show the input param format
Array
(
[params] => Array
(
[0] => Array
(
[client_id] => 1
[name] => Client 1
[gender] => My custom malea
[company] => My custom Client 1 Company 1
)
[1] => Array
(
[client_id] => 2
[name] => Client 2
[gender] => male
[company] => Client 2 Com2pany 11
)
.......
*/
foreach ($data["params"] as &$d) {
foreach ($d as $k => $v) {
$d[$k] = strtoupper($d[$k]);
}
}
}
function do_update(&$data)
{
// $obj = &get_instance();
print_r($data);
$id = intval($_REQUEST["id"]);
}
$g->set_actions(array("add" => false, "edit" => true, "bulkedit" => true, "delete" => true, "rowactions" => true, "autofilter" => true, "search" => "simple"));
$opt['caption'] = "d";
$opt["sortname"] = 'id';
// by default sort grid by this field
//.........这里部分代码省略.........
示例3: update_client
## ------------------ ##
## SERVER SIDE EVENTS ##
## ------------------ ##
// params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
// if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid
$e["on_insert"] = array("add_client", null, false);
$e["on_update"] = array("update_client", null, false);
$e["on_delete"] = array("delete_client", null, true);
# $e["on_after_insert"] = array("after_insert", null, true); // return last inserted id for further working
$e["on_data_display"] = array("filter_display", null, true);
## ------------------ ##
## CLIENT SIDE EVENTS ##
## ------------------ ##
// just set the JS function name (should exist)
$e["js_on_select_row"] = "do_onselect";
$grid->set_events($e);
function update_client($data)
{
/*
These comments are just to show the input param format
$data => Array
(
[client_id] => 2
[params] => Array
(
[client_id] => 2
[name] => Client 2
[gender] => male
[company] => Client 2 Company
)
示例4: index
public function index()
{
//check login
if ($this->session->userdata('user_name')) {
$i_rule = $this->session->userdata('user_cizacl_role_id');
$g = new jqgrid();
$col = array();
$col["title"] = "Id";
// caption of column
$col["name"] = "tax_id";
$col["width"] = "10";
/*$col["fixed"] = true;*/
$col["search"] = false;
$col["editable"] = false;
$col["hidden"] = true;
$cols[] = $col;
#tax date
$col = array();
$col['title'] = $this->lang->line('date');
$col['name'] = "tax_date";
$col["width"] = "170";
$col["editable"] = true;
// this column is editable
$col["editoptions"] = array("size" => 20, "defaultValue" => date("d-m-Y"));
// with default display of textbox with size 20
$col["editrules"] = array("required" => true);
// and is required
$col["formatter"] = "date";
// format as date
$col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
$cols[] = $col;
#ref_number
$col = array();
$col['title'] = $this->lang->line('ref_no');
$col['name'] = "ref_number";
$col["editable"] = true;
// this column is editable
$cols[] = $col;
#tax Datail
$col = array();
$col['title'] = $this->lang->line('tax_detail');
$col['name'] = "tax_details";
$col["width"] = "170";
$col["editable"] = true;
// this column is editable
$col['edittype'] = "textarea";
$col["editoptions"] = array("rows" => "2", "cols" => "20");
$col["editrules"] = array("required" => true);
$col["formatter"] = "autocomplete";
// autocomplete
$col["formatoptions"] = array("sql" => "SELECT DISTINCT tax_details as k, tax_details as v FROM taxbuy", "search_on" => "tax_details", "update_field" => "tax_details");
$cols[] = $col;
#Price
$col = array();
$col['title'] = $this->lang->line('total_price');
$col['name'] = "total_price";
$col["editable"] = true;
$col["editrules"] = array("number" => true, "required" => true);
$col["editoptions"] = array("onblur" => "update_vat()");
$col["align"] = "right";
$col["formatter"] = "number";
$col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col["search"] = false;
$cols[] = $col;
#vat
$col = array();
$col['title'] = $this->lang->line('vat');
$col['name'] = "total_vat";
$col["editable"] = true;
$col["editrules"] = array("number" => true, "required" => true);
#$col["editoptions"] = array("onblur" => "update_vat()");
$col["formatter"] = "number";
$col["align"] = "right";
$col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col["search"] = false;
$cols[] = $col;
#Total
$col = array();
$col['title'] = $this->lang->line('total_amount');
$col["align"] = "right";
$col['name'] = "total_amount";
$col["editrules"] = array("number" => true, "required" => true);
$col["editable"] = true;
$col["formatter"] = "number";
$col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col["search"] = false;
$cols[] = $col;
#Note
$col = array();
$col["title"] = $this->lang->line('remark');
$col["name"] = "note";
$col["width"] = "150";
$col['editable'] = true;
$col["edittype"] = "textarea";
$col["editoptions"] = array("rows" => "2", "cols" => "20");
$cols[] = $col;
//$g->set_options($opt);
$e["js_on_load_complete"] = "grid1_onload";
$g->set_events($e);
//Use Table
//.........这里部分代码省略.........
示例5: index
//.........这里部分代码省略.........
$g2->select_command = "SELECT
stock_id,
stock_date,
ref_number,
oil.customer_type_id,
cus_type.customer_type_title,
oil.customer_id,
cus.customers_name,
oil.car_id,
car.car_number,
stock_details,
receive_oil,
receive_price,
receive_amount
FROM
oilstock AS oil
LEFT JOIN transport_cars AS car ON (oil.car_id = car.car_id)
LEFT JOIN transport_customers AS cus ON (
oil.customer_id = cus.customer_id
)
LEFT JOIN transport_customer_type AS cus_type ON (
cus.customer_type_id = cus_type.customer_type_id
)
WHERE
oil.factory_id = '$fac_id'
AND oil_type = 1";
*/
$g2->select_command = "SELECT\n\tstock_id,\n\tstock_date,\n\tref_number,\n\toil.customer_type_id,\n\tcus_type.customer_type_title,\n\toil.customer_id,\n\tcus.customer_name,\n\toil.car_id,\n\tcar.car_number,\t\n stock_details,\n\t\n\treceive_oil,\n\treceive_price,\n\treceive_amount\nFROM\n\toilstock AS oil\nLEFT JOIN transport_cars AS car ON (oil.car_id = car.car_id)\nLEFT JOIN transport_oilcustomers AS cus ON (\n\toil.customer_id = cus.customer_id\n)\nLEFT JOIN transport_customer_type AS cus_type ON (\n\tcus.customer_type_id = cus_type.customer_type_id\n)\nWHERE\n\toil.factory_id = '{$fac_id}'\nAND oil_type = 1";
#select table
$g2->table = "oilstock";
#$g2->table = "oil_receive";
$e["on_insert"] = array("add_client", null, true);
$g2->set_events($e);
function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["factory_id"] = $id;
$data["params"]["oil_type"] = 1;
}
$g2->set_actions(array("add" => true, "edit" => true, "delete" => true, "view" => false, "rowactions" => false, "autofilter" => true, "search" => "advance", "inlineadd" => false, "showhidecolumns" => false));
$g2->set_columns($cols2);
#display Grid2
$out_list2 = $g2->render("list2");
/*Grid3 รายการจ่ายน้ำมัน*/
$g3 = new jqgrid();
/*Option*/
$opt3["caption"] = $this->lang->line('sell_oil_list');
$opt3["sortname"] = 'stock_id';
$opt3["sortorder"] = "desc";
$opt3["height"] = "250";
$opt3['rowNum'] = 10;
$opt3['rowList'] = array(10, 20, 30);
$opt3["width"] = "979";
//$opt3["autowidth"] = true;
//$opt3['hidegrid'] = true;
$opt3["form"]["position"] = "center";
$opt3["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt3["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
/*
$opt3["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('จำเป็นต้องเลือกโรงงาน'); return false; } }";
$opt3["add_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
$opt3["edit_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
$opt3["delete_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
$opt3["add_options"]["afterShowForm"] =
'function(formid) { jQuery("#ref_number").focus(); }';
示例6: index
//.........这里部分代码省略.........
$col["editrules"] = array("required" => true);
$cols[] = $col;
$col = array();
$col["title"] = $this->lang->line('start_date');
// caption of column
$col["name"] = "start_date";
$col["formatter"] = "date";
// format as date
$col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd/m/Y');
// http://docs.jquery.com/UI/Datepicker/formatDate
$col["width"] = "10";
$col["editrules"] = array("required" => true);
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = $this->lang->line('end_date');
// caption of column
$col["name"] = "end_date";
$col["formatter"] = "date";
// format as date
$col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd/m/Y');
// http://docs.jquery.com/UI/Datepicker/formatDate
$col["width"] = "10";
$col["editrules"] = array("required" => true);
$col["editable"] = true;
$cols[] = $col;
$g->set_columns($cols);
$g->set_actions(array("add" => true, "edit" => true, "delete" => true, "clone" => true, "rowactions" => true, "search" => "advance", "showhidecolumns" => false));
// $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
$grid["rowNum"] = 50;
// by default 20
$grid["sortname"] = 'id';
// by default sort grid by this field
$grid["sortorder"] = "desc";
// ASC or DESC
$grid["caption"] = $this->lang->line('pricelist');
// caption of grid
$grid["autowidth"] = true;
// expand grid to screen width
$grid["multiselect"] = true;
// allow you to multi-select through checkboxes
$grid["form"]["position"] = "center";
$grid["altRows"] = true;
$grid["altclass"] = "myAltRowClass";
$grid["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$grid["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$g->set_options($grid);
$e["on_update"] = array("update_price", null, true);
$e["on_insert"] = array("add_price", null, true);
$g->set_events($e);
function add_price(&$data)
{
$factory_id = $data["params"]["factory_id"];
$distance_id = $data["params"]["distance_id"];
$cubic_id = $data["params"]["cubic_id"];
$start_date = $data["params"]["start_date"];
$end_date = $data["params"]["end_date"];
$check_sql = "SELECT COUNT(*) AS c\nFROM\n\tpricelist\nWHERE\n\tfactory_id = '{$factory_id}'\nAND distance_id = '{$distance_id}'\nAND cubic_id = '{$cubic_id}'\nAND ( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$start_date}','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$start_date}','%Y-%m-%d'))) \nAND ( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$end_date} ','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$end_date}','%Y-%m-%d')))";
$rs = mysql_fetch_assoc(mysql_query($check_sql));
if ($rs["c"] > 0) {
phpgrid_error("ข้อมูลราคาซ้ำ ไม่สามารถบันทึกได้");
}
}
// end of sub function
function update_price(&$data)
{
//print_r($data);
$obj =& get_instance();
$obj->load->model("price_model", "price");
$obj->load->library('conv_date');
$price_id = $data["params"]["id"];
//$startdate = date('Y-m-d',strtotime($data['params']['start_date']));
$startdate = $data['params']['start_date'];
$enddate = $data['params']['start_date'];
$c_stdate = $obj->price->check_before_update_price($price_id);
//$c_endate = $obj->price->check_before_update_price($price_id,$en);
$st_date = $c_stdate['start_date'];
$en_date = $c_stdate['end_date'];
//$ed_date = $c_endate;
$m_date = $obj->conv_date->compareDate($startdate, $st_date);
$e_date = $obj->conv_date->compareDate($enddate, $st_date);
//$m_date ="E";
if ($m_date !== "E" && $e_date !== "E") {
$check_sql = "SELECT COUNT(*) as c\n\nFROM\n\tpricelist\nWHERE\n\tfactory_id = '{$data["params"]["factory_id"]}'\nAND cubic_id = '{$data["params"]["cubic_id"]}'\nAND distance_id = '{$data["params"]["distance_id"]}'\nAND ( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$data["params"]["start_date"]}','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$data["params"]["start_date"]}','%Y-%m-%d'))) \nOR\n( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$data["params"]["end_date"]}','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$data["params"]["end_date"]}','%Y-%m-%d'))) LIMIT 1";
$rs = mysql_fetch_assoc(mysql_query($check_sql));
if ($rs["c"] > 0) {
phpgrid_error("ข้อมูลราคาซ้ำ ไม่สามารถบันทึกได้");
}
}
}
// End of function update_price
//Display
$pricetable = $g->render("list1");
$h2_title = "Price Setting";
$this->_example_output((object) array('output' => '', 'out' => $out, 'dispyPrice' => $dispyPrice, 'h2_title' => $h2_title, 'list_row' => $num_row, 'pricelist' => $pricelist, 'pricetable' => $pricetable));
} else {
//If no session, redirect to login page
redirect('login', 'refresh');
}
}
示例7: index
public function index()
{
if ($this->session->userdata('user_name')) {
$i_rule = $this->session->userdata('user_cizacl_role_id');
$this->load->model('income_model', 'dropdrown');
$this->load->model('dropdown_model', 'cus_drop');
$g = new jqgrid();
$col = array();
$col["title"] = "Id";
// caption of column
$col["name"] = "id";
$col["width"] = "10";
$col["fixed"] = true;
$col["search"] = false;
$col["editable"] = false;
$col["export"] = false;
$col["hidden"] = true;
$cols[] = $col;
$col = array();
$col['title'] = "cubic value";
$col['name'] = "cubic_id";
$col['dbname'] = "orders.cubic_id";
$col["editable"] = true;
$col["formatter"] = "select";
$col["editable"] = true;
$col["edittype"] = "select";
$str = $g->get_dropdown_values("SELECT DISTINCT cubic_id AS k, cubic_value AS v FROM transport_cubiccode WHERE cubic_status=1");
//$col["editoptions"] = array("value"=>":;".$str);
$col["editoptions"] = array("value" => $str);
$col["formatter"] = "select";
// display label, not value
$cols[] = $col;
/**Option Form */
$opt["sortname"] = 'id';
$opt["sortorder"] = "desc";
$opt["caption"] = $this->lang->line('Order_Transportation');
$opt['rowNum'] = 10;
$opt['rowList'] = array(10, 20, 30);
$opt['height'] = "300";
$opt["autowidth"] = true;
$opt["multiselect"] = false;
$opt["scroll"] = true;
$opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#dp_number").focus(); }';
$opt["altRows"] = true;
$opt["altclass"] = "myAltRowClass";
$g->set_options($opt);
$g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'add'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'edit'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'delete'), "rowactions" => true, "export" => true, "autofilter" => true, "search" => "advance"));
$g->select_command = "SELECT\n\tid,\n\tdp_number,\n\torders.customer_id,\n cus.customers_name AS cid,\n orders.factory_id,\n\tfac.factory_code,\n\treal_distance,\n\torders.distance_id,\n\tdis.distance_code,\n\torders.cubic_id,\n cubic.cubic_value,\n orders.price AS price,\n\torders.use_oil,\n orders.car_id,\n\tcar.car_number,\n\torders.driver_id,\n\tdri.driver_name,\n order_date,\n orders.delivery_datetime,\n orders.remark\n\nFROM\n\t`orders` AS orders\nLEFT JOIN transport_factory AS fac ON (\n\torders.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customers AS cus ON (\n\torders.customer_id = cus.customer_id\n)\nLEFT JOIN transport_cubiccode AS cubic ON (\n\torders.cubic_id = cubic.cubic_id\n)\nLEFT JOIN distancecode AS dis ON (\n\torders.distance_id = dis.distance_id\n)\nLEFT JOIN transport_cars AS car ON (\norders.car_id = car.car_id\n)\nLEFT JOIN driver AS dri ON (\n\torders.driver_id = dri.driver_id\n)";
// this db table will be used for add,edit,delete
$g->table = "orders";
$e["on_after_insert"] = array("after_insert", null, true);
$e["on_update"] = array("do_update", null, true);
/*
$e["on_insert"] = array(
"add_order",
null,
true);
*/
$e["on_data_display"] = array("filter_display", null, true);
$g->set_events($e);
function add_order(&$data)
{
//print_r($data);
$obj =& get_instance();
$obj->load->model("price_model", "pricelist");
//$id = intval($_REQUEST["id"]);
$factory_id = $data["params"]["factory_id"];
$distance_id = $data["params"]["distance_id"];
$cubid_id = $data["params"]["cubic_id"];
$order_date = $data["params"]["order_date"];
#get price
$order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
if ($order_price == null) {
$str = ob_get_clean();
$str = "ไม่มีการกำหนดราคาค่าขนส่ง";
phpgrid_error($str);
}
/*check DP NUmber*/
$check_sql = "SELECT count(*) as c from orders where LOWER(`dp_number`) = '" . strtolower($data["params"]["dp_number"]) . "'";
$rs = mysql_fetch_assoc(mysql_query($check_sql));
if ($rs["c"] > 0) {
phpgrid_error("หมายเลข DP Number ซ้ำ");
}
/*End Check DP Number*/
//$str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
//mysql_query($str);
}
function do_update(&$data)
{
//print_r($data);
$obj =& get_instance();
$obj->load->model("price_model", "pricelist");
$id = intval($_REQUEST["id"]);
$factory_id = $data["params"]["factory_id"];
$distance_id = $data["params"]["distance_id"];
$cubid_id = $data["params"]["cubic_id"];
$order_date = $data["params"]["order_date"];
#get price
//.........这里部分代码省略.........
示例8: index
//.........这里部分代码省略.........
$cols2[] = $col;
#Expanse date
$col = array();
$col["title"] = $this->lang->line('date');
$col["name"] = "expense_date";
$col["width"] = "20";
$col["editable"] = true;
// this column is editable
//$col["editoptions"] = array("size" => 20, "defaultValue" => date('d-m-Y')); // with default display of textbox with size 20
$col["editoptions"] = array("size" => 20);
// with default display of textbox with size 20
$col["editrules"] = array("required" => true);
// and is required
# format as date
$col["formatter"] = "date";
# opts array can have these options: http://api.jqueryui.com/datepicker/
$col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
$cols2[] = $col;
/*
$col = array();
$col["title"] = $this->lang->line('reference_number'); // caption of column
$col["name"] = "ref_number"; // field name, must be exactly same as with SQL prefix or db field
$col["width"] = "30";
$col["editable"] = true;
$cols2[] = $col;
*/
# Descriptionns
$col = array();
$col["title"] = $this->lang->line('desc');
// caption of column
$col["name"] = "expense_details";
// field name, must be exactly same as with SQL prefix or db field
$col["width"] = "100";
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => '2', "cols" => '60');
$col["editrules"] = array("required" => true);
#$col["formatter"] = "autocomplete"; // autocomplete
/*
$col["formatoptions"] = array(
"sql" => "SELECT DISTINCT expense_details as k, expense_details as v FROM expense",
"search_on" => "expense_details",
"update_field" => "expense_details");
*/
$col["editable"] = true;
$cols2[] = $col;
$col = array();
$col["title"] = $this->lang->line('amount');
$col["name"] = "total_amount";
$col["width"] = "30";
$col['align'] = "right";
$col['formatter'] = "currency";
$col["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col["editable"] = true;
// this column is editable
$col["editoptions"] = array("size" => 20);
// with default display of textbox with size 20
$col["editrules"] = array("required" => true, "number" => true);
// and is required
$cols2[] = $col;
#Not Remarl
$col = array();
$col["title"] = $this->lang->line('note');
// caption of column
$col["name"] = "note";
// field name, must be exactly same as with SQL prefix or db field
$col["width"] = "40";
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => '2', "cols" => '20');
$col["editable"] = true;
/*
$col["formatter"] = "autocomplete"; // autocomplete
$col["formatoptions"] = array(
"sql" => "SELECT DISTINCT note as k, note as v FROM expense",
"search_on" => "note",
"update_field" => "note");
*/
$cols2[] = $col;
$grid->set_columns($cols2);
$e["js_on_load_complete"] = "grid2_onload";
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);
function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["factory_id"] = $id;
$data["params"]["car_id"] = 0;
}
// generate grid output, with unique grid name as 'list1'
$out_detail = $grid->render("list2");
// Head Title
$h2_title = $this->lang->line('expense');
$this->_example_output((object) array('output' => '', 'out_detail' => $out_detail, 'out_master' => $out_master, 'js_files' => array(), 'css_files' => array(), 'h2_title' => $h2_title));
} else {
$this->_example_output();
}
//end if
} else {
redirect('login', 'refresh');
}
}
示例9: index
//.........这里部分代码省略.........
$col["fixed"] = true;
$col['width'] = "120";
$col["edittype"] = "textarea";
$col["editoptions"] = array("rows" => 2, "cols" => 20);
$col['editable'] = true;
$cols[] = $col;
/*Grid Option*/
$opt["sortname"] = 'id';
$opt["sortorder"] = "desc";
$opt["caption"] = $this->lang->line('Order_Transportation');
$opt['rowNum'] = 10;
$opt['rowList'] = array(10, 20, 30);
$opt['height'] = "360";
$opt["autowidth"] = true;
$opt["multiselect"] = true;
$opt["scroll"] = true;
$opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
$opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#dp_number").focus();}';
$opt["edit_options"]["afterShowForm"] = 'function(formid) { jQuery("#dp_number").focus();}';
$opt["altRows"] = true;
$opt["altclass"] = "myAltRowClass";
$opt["form"]["position"] = "center";
// or "all"
$g->set_options($opt);
$g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'add'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'edit'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'delete'), "rowactions" => false, "export" => true, "autofilter" => true, "search" => "advance"));
$g->select_command = "SELECT\n\tid,\n\tdp_number,\n\torders.customer_id,\n cus.customers_name AS cid,\n orders.factory_id,\n\tfac.factory_code,\n\treal_distance,\n\torders.distance_id,\n\tdis.distance_code,\t\n cubic.cubic_value as cubic_id,\n orders.price AS price,\n\torders.use_oil,\n orders.car_id,\n\tcar.car_number,\n\torders.driver_id,\n\tdri.driver_name,\n order_date,\n orders.delivery_datetime,\n orders.remark\n\nFROM\n\t`orders` AS orders\nLEFT JOIN transport_factory AS fac ON (\n\torders.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customers AS cus ON (\n\torders.customer_id = cus.customer_id\n)\nLEFT JOIN transport_cubiccode AS cubic ON (\n\torders.cubic_id = cubic.cubic_id\n)\nLEFT JOIN distancecode AS dis ON (\n\torders.distance_id = dis.distance_id\n)\nLEFT JOIN transport_cars AS car ON (\norders.car_id = car.car_id\n)\nLEFT JOIN driver AS dri ON (\n\torders.driver_id = dri.driver_id\n)";
// this db table will be used for add,edit,delete
$g->table = "orders";
$e["on_insert"] = array("add_order", null, true);
$e["on_after_insert"] = array("after_insert", null, true);
$e["on_update"] = array("do_update", null, true);
$e["on_data_display"] = array("filter_display", null, true);
$g->set_events($e);
function add_order(&$data)
{
//print_r($data);
$obj =& get_instance();
$obj->load->model("price_model", "pricelist");
//$id = intval($_REQUEST["id"]);
$factory_id = $data["params"]["factory_id"];
$distance_id = $data["params"]["distance_id"];
$cubid_id = $data["params"]["cubic_id"];
$order_date = $data["params"]["order_date"];
#get price
$order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
if ($order_price == null) {
$str = ob_get_clean();
$str = "ยังไม่มีการกำหนดราคาค่าขนส่ง";
phpgrid_error($str);
}
/*check DP NUmber*/
$check_sql = "SELECT count(*) as c from orders where LOWER(`dp_number`) = '" . strtolower($data["params"]["dp_number"]) . "'";
$rs = mysql_fetch_assoc(mysql_query($check_sql));
if ($rs["c"] > 0) {
phpgrid_error("หมายเลข DP Number ซ้ำ");
}
/*End Check DP Number*/
//$str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
//mysql_query($str);
}
function do_update(&$data)
{
//print_r($data);
$obj =& get_instance();
$obj->load->model("price_model", "pricelist");
示例10: jqgrid
mysql_select_db(PHPGRID_DBNAME);
// include and create object
include PHPGRID_LIBPATH . "inc/jqgrid_dist.php";
$g = new jqgrid();
// set database table for CRUD operations
$g->table = "t_clients";
// set few params
$grid["caption"] = "Clients vente directe";
$grid["export"] = array("format" => "pdf", "filename" => "my-file", "heading" => "Clients vente directe ", "orientation" => "landscape", "paper" => "a4");
$grid["export"]["render_type"] = "html";
// export filtered data or all data
$grid["export"]["range"] = "all";
// or "all"
// params are array(<function-name>,<class-object> or <null-if-global-func>)
$e["on_render_pdf"] = array("set_pdf_format", null);
$g->set_events($e);
function set_pdf_format($param)
{
$grid = $param["grid"];
$arr = $param["data"];
//$grid->SetFont('helvetica', '', 11);
$html .= "<h1>" . $grid->options["export"]["heading"] . "</h1>";
$html .= '<table border="1" cellpadding="2" cellspacing="1">';
$i = 0;
foreach ($arr as $v) {
$shade = $i++ % 2 ? 'bgcolor="#efefef"' : '';
$html .= "<tr>";
foreach ($v as $d) {
// bold header
if ($i == 1) {
$html .= "<td bgcolor=\"lightgrey\"><strong>{$d}</strong></td>";
示例11: index
//.........这里部分代码省略.........
$cols[] = $col;
foreach ($titke_cubic as $row) {
$col = array();
$col['title'] = "{$row->cubic_value}";
$col['name'] = "cubic[{$row->cubic_id}]";
$col['editable'] = true;
$col["editrules"] = array("number" => true);
$col["formatter"] = "number";
$col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col['search'] = false;
$cols[] = $col;
}
$g->set_columns($cols);
$g->set_actions(array("add" => false, "edit" => true, "bulkedit" => false, "delete" => true, "rowactions" => false, "autofilter" => true, "search" => "simple"));
$opt['caption'] = "{$head_title}";
$opt["sortname"] = 'id';
// by default sort grid by this field
$opt["sortorder"] = "asc";
// ASC or DESC
$opt['rowNum'] = 30;
$opt["autowidth"] = true;
$opt["cellEdit"] = true;
// excel visual params
$opt["cellEdit"] = true;
// inline cell editing, like spreadsheet
$opt["rownumbers"] = true;
$opt["rownumWidth"] = 30;
$g->set_options($opt);
//$e["on_insert"] = array("add_client", null, true);
$e["on_update"] = array("update_prices", null, true);
//$e["on_delete"] = array("delete_client", null, true);
//$e["on_after_insert"] = array("after_insert", null, true); // return last inserted id for further working
//$e["on_data_display"] = array("filter_display", null, true);
$g->set_events($e);
function update_prices(&$data)
{
global $_SESSION;
/*
These comments are just to show the input param format
$data => Array
(
[client_id] => 2
[params] => Array
(
[client_id] => 2
[name] => Client 2
[gender] => male
[company] => Client 2 Company
)
)
*/
/*
Array
(
[id] => 1
[params] => Array
(
[cubic] => Array
(
[3] => 50
)
[id] => 1
)
示例12: index
//.........这里部分代码省略.........
# format as date
$col["formatter"] = "date";
# opts array can have these options: http://api.jqueryui.com/datepicker/
$col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
$cols2[] = $col;
//car
$col = array();
$col["title"] = $this->lang->line('car_number');
$col["name"] = "car_id";
$col["dbname"] = "transport_cars.car_number";
// this is required as we need to search in name field, not id
$col["width"] = "20";
$col["align"] = "center";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
// render as select
# fetch data from database, with alias k for key, v for value
//$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
$str = $this->getdrop->grid_dropdown("SELECT distinct car_id AS k,car_number AS v FROM `transport_cars`");
$col["editoptions"] = array("value" => $str);
$col["formatter"] = "select";
// display label, not value
$cols2[] = $col;
#ref_number
/*
$col = array();
$col["title"] = $this->lang->line('reference_number'); // caption of column
$col["name"] = "ref_number"; // field name, must be exactly same as with SQL prefix or db field
$col["width"] = "30";
$col["editable"] = true;
$cols2[] = $col;
*/
# Detail
$col = array();
$col["title"] = $this->lang->line('desc');
// caption of column
$col["name"] = "expense_details";
// field name, must be exactly same as with SQL prefix or db field
$col["width"] = "70";
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => '2', "cols" => '50');
$col["editrules"] = array("required" => true);
$col["editable"] = true;
$col["formatter"] = "autocomplete";
// autocomplete
$col["formatoptions"] = array("sql" => "SELECT DISTINCT expense_details as k, expense_details as v FROM expense", "search_on" => "expense_details", "update_field" => "expense_details");
$cols2[] = $col;
# Total Amount
$col = array();
$col["title"] = $this->lang->line('amount');
$col["name"] = "total_amount";
$col["width"] = "20";
$col['align'] = "right";
$col['formatter'] = "currency";
$col["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col["editable"] = true;
// this column is editable
$col["editoptions"] = array("size" => 20);
// with default display of textbox with size 20
$col["editrules"] = array("required" => true, "number" => true);
// and is required
$cols2[] = $col;
#Note Remark
$col = array();
$col["title"] = $this->lang->line('note');
// caption of column
$col["name"] = "note";
// field name, must be exactly same as with SQL prefix or db field
$col["width"] = "30";
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => '2', "cols" => '20');
$col["editable"] = true;
$col["formatter"] = "autocomplete";
// autocomplete
$col["formatoptions"] = array("sql" => "SELECT DISTINCT note as k, note as v FROM expense", "search_on" => "note", "update_field" => "note");
$cols2[] = $col;
# Render set columns
$grid->set_columns($cols2);
$e["js_on_load_complete"] = "grid2_onload";
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);
function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["factory_id"] = $id;
}
// generate grid output, with unique grid name as 'list1'
$out_detail = $grid->render("list2");
// Head Title
$h2_title = $this->lang->line('car_service');
$this->_example_output((object) array('output' => '', 'out_detail' => $out_detail, 'out_master' => $out_master, 'js_files' => array(), 'css_files' => array(), 'h2_title' => $h2_title));
} else {
$this->_example_output();
}
//end if
} else {
redirect('login', 'refresh');
}
}
示例13: index
//.........这里部分代码省略.........
$col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
$cols2[] = $col;
# Reference Number
$col = array();
$col["title"] = $this->lang->line('reference_number');
// caption of column
$col["name"] = "ref_number";
// field name, must be exactly same as with SQL prefix or db field
$col["width"] = "30";
$col["editable"] = true;
$col['hidden'] = true;
$cols2[] = $col;
# Detail
$col = array();
$col["title"] = $this->lang->line('desc');
// caption of column
$col["name"] = "income_details";
// field name, must be exactly same as with SQL prefix or db field
$col["editrules"] = array("required" => true);
// and is required
$col["width"] = "60";
$col["editable"] = true;
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => '2', "cols" => '50', "defaultValue" => ' ');
$col["formatter"] = "autocomplete";
// autocomplete
$col["formatoptions"] = array("sql" => "SELECT DISTINCT income_details as k, income_details as v FROM income", "search_on" => "income_details", "update_field" => "income_details");
$cols2[] = $col;
#total Amount
$col = array();
$col["title"] = $this->lang->line('amount');
$col["name"] = "total_amount";
$col["width"] = "40";
$col['align'] = "right";
$col['formatter'] = "currency";
$col["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
$col["editable"] = true;
// this column is editable
$col["editoptions"] = array("size" => 20);
// with default display of textbox with size 20
$col["editrules"] = array("required" => true, "number" => true);
// and is required
$cols2[] = $col;
# Remark
$col = array();
$col["title"] = $this->lang->line('note');
// caption of column
$col["name"] = "note";
// field name, must be exactly same as with SQL prefix or db field
$col["width"] = "40";
$col["editable"] = true;
$col['edittype'] = "textarea";
$col['editoptions'] = array("rows" => '2', "cols" => '20', "defaultValue" => ' ');
$col["formatter"] = "autocomplete";
// autocomplete
$col["formatoptions"] = array("sql" => "SELECT DISTINCT note as k, note as v FROM income", "search_on" => "note", "update_field" => "note");
$cols2[] = $col;
// virtual column for grand total
$col = array();
$col["title"] = "table_total";
$col["name"] = "table_total";
$col["width"] = "100";
$col["hidden"] = true;
$cols2[] = $col;
// virtual column for running total
$col = array();
$col["title"] = "running_total";
$col["name"] = "running_total";
$col["width"] = "100";
$col["hidden"] = true;
$cols[] = $col;
$grid->set_columns($cols2);
$e["js_on_load_complete"] = "grid2_onload";
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);
function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["factory_id"] = $id;
}
// generate grid output, with unique grid name as 'list1'
$out_detail = $grid->render("list2");
// Head Title
$h2_title = $this->lang->line('income');
$js_script = $this->income_model->income_fect_assoc($data);
// Used JS Script
//$id2 = intval($_GET["jqgrid_page"]);
$id3 = intval($_GET['jqgrid_page']);
//$data["params"]["factory_id"] = $id2;
$js_script = $id3;
//display
$this->_example_output((object) array('output' => '', 'out_detail' => $out_detail, 'out_master' => $out_master, 'js_files' => array(), 'css_files' => array(), 'js_script' => $js_script, 'h2_title' => $h2_title));
} else {
$this->_example_output();
}
//end if
} else {
redirect('login', 'refresh');
}
}
示例14: index
public function index()
{
//check login
if ($this->session->userdata('user_name')) {
$i_rule = $this->session->userdata('user_cizacl_role_id');
$g = new jqgrid();
#ID
$col = array();
$col['title'] = "ID";
$col['name'] = "customer_id";
$col['hidden'] = true;
$col['isnull'] = true;
$cols[] = $col;
#Factory
$col = array();
$col["title"] = $this->lang->line("factory_name");
$col["name"] = "factory_id";
$col["dbname"] = "fac.factory_id";
// this is required as we need to search in name field, not id
$col["width"] = "100";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
// render as select
# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select distinct factory_id as k, factory_name as v from transport_factory where factory_status =1");
$col["editoptions"] = array("value" => ":;" . $str);
$col["formatter"] = "select";
// display label, not value
$col["editrules"] = array("required" => true);
$col["editoptions"] = array("value" => $str);
$col["formatter"] = "select";
// display label, not value
$col["stype"] = "select";
// enable dropdown search
$col["searchoptions"] = array("value" => ":;" . $str);
$cols[] = $col;
#Customer_Type
$col = array();
$col["title"] = $this->lang->line('customer_type');
$col["name"] = "customer_type_id";
$col["dbname"] = "cus_type.customer_type_title";
// this is required as we need to search in name field, not id
$col["fixed"] = true;
//$col["width"] = "65";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
// render as select
# fetch data from database, with alias k for key, v for value
//$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
$str = $g->get_dropdown_values("SELECT DISTINCT customer_type_id AS k, customer_type_title AS v FROM `transport_customer_type` WHERE customer_type_status ='2'");
#$str = $this->dropdrown->get_customer_type();
$col["editoptions"] = array("value" => $str);
$col["formatter"] = "select";
// display label, not value
$cols[] = $col;
#Customer name
$col = array();
$col['title'] = $this->lang->line('customer_agancy');
$col['name'] = "customer_name";
$col["editrules"] = array("required" => true);
$col["search"] = true;
$col['editable'] = true;
$cols[] = $col;
#remark
$col = array();
$col['title'] = $this->lang->line('note');
$col['name'] = "remark";
$col['editable'] = true;
$col['edittype'] = "textarea";
$col["viewable"] = false;
$col['editoptions'] = array("rows" => "2", "cols" => "20");
$cols[] = $col;
// $cols[] = $col;
$e["on_insert"] = array("add_client", null, true);
$e["on_delete"] = array("delete_client", null, true);
#$e["on_delete"] = array("del_client", null, true);
$g->set_events($e);
$g->select_command = "SELECT\n\tcustomer_id,\n\tcustomer_name,\n\to_c.factory_id,\n\to_c.customer_type_id,\n\tcustomer_type_title,\n o_c.remark as remark\nFROM\n\ttransport_oilcustomers AS o_c\nLEFT JOIN transport_factory AS fac ON (\n\to_c.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customer_type AS cus_type ON (\n\to_c.customer_type_id = cus_type.customer_type_id\n)\nWHERE\n\to_c.`status` = 1";
function add_client(&$data)
{
$check_sql = "SELECT count(*) as c from transport_oilcustomers where factory_id =" . $data["params"]["factory_id"] . " AND LOWER(`customer_name`) = '" . strtolower($data["params"]["customer_name"]) . "'";
$rs = mysql_fetch_assoc(mysql_query($check_sql));
if ($rs["c"] > 0) {
phpgrid_error("ข้อมูลลูกค้าซ้ำ");
}
}
// end of sub function
function delete_client(&$data)
{
ob_start();
print_r($data);
$str = ob_get_clean();
$str = "UPDATE `transport_oilcustomers` SET `status`='0' WHERE (`customer_id`='{$data["id"]}')";
mysql_query($str);
}
//Use Table
//.........这里部分代码省略.........
示例15: index
public function index()
{
//check login
if ($this->session->userdata('user_name')) {
// Grid
$this->load->library("jqgridnow_lib");
$g = new jqgrid();
$col = array();
$col["title"] = $this->lang->line('id');
// caption of column
$col["name"] = "factory_id";
$col["width"] = "10";
$col["search"] = false;
$col["editable"] = false;
$col["hidden"] = true;
$cols[] = $col;
$col = array();
$col['title'] = $this->lang->line('factory_name');
$col['name'] = "factory_name";
$col['width'] = "40";
$col['search'] = true;
$col['editable'] = true;
$col["editrules"] = array("required" => true);
$cols[] = $col;
$col = array();
$col['title'] = $this->lang->line('factory_code');
$col['name'] = "factory_code";
$col['width'] = "40";
$col['search'] = true;
$col['editable'] = true;
$col["editrules"] = array("required" => true);
$cols[] = $col;
$col = array();
$col['title'] = $this->lang->line('factory_note');
$col['name'] = "factory_note";
$col['width'] = "40";
$col["sortable"] = false;
// this column is not sortable
$col["search"] = false;
// this column is not searchable
$col["editable"] = true;
$col["edittype"] = "textarea";
// render as textarea on edit
$col["editoptions"] = array("rows" => 2, "cols" => 30);
// with these attributes
$cols[] = $col;
//properties grid
$grid["sortname"] = 'factory_id';
$grid["sortorder"] = "desc";
$grid["caption"] = $this->lang->line('factory_setting');
$grid["autowidth"] = true;
$grid["multiselect"] = false;
$grid["rownumbers"] = true;
$g->set_options($grid);
$g->select_command = "SELECT\n\tfactory_id,\n\tfactory_name,\n\tfactory_code,\n\tfactory_note,\n\tfactory_status,\n\tstatus_name\nFROM\n\ttransport_factory AS fac\nLEFT JOIN allstatus AS st ON (fac.factory_status = st.id)\nWHERE\n\tfactory_status = 1";
$g->set_columns($cols);
$e["on_delete"] = array("delete_factory", null, true);
$g->set_events($e);
function delete_factory($data)
{
$str_ch = "UPDATE transport_factory SET factory_status ='0' WHERE (factory_id ='{$data["factory_id"]}')";
phpgrid_error($str_ch);
//mysql_query($str_ch);
}
$g->table = "transport_factory";
// render grid and get html/js output
$out_index = $g->render("list1");
//display
$this->_example_output((object) array('output' => '', 'out' => $out_index));
} else {
//If no session, redirect to login page
redirect('login', 'refresh');
}
// end if
}