本文整理汇总了PHP中jqgrid::get_dropdown_values方法的典型用法代码示例。如果您正苦于以下问题:PHP jqgrid::get_dropdown_values方法的具体用法?PHP jqgrid::get_dropdown_values怎么用?PHP jqgrid::get_dropdown_values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jqgrid
的用法示例。
在下文中一共展示了jqgrid::get_dropdown_values方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$g->table = "cat";
$col = array();
$col["title"] = "Table";
// caption of column
$col["name"] = "TABLE_NAME";
$col["search"] = true;
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Type";
$col["name"] = "TABLE_TYPE";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
// render as select
$str = $g->get_dropdown_values("select distinct TABLE_TYPE as k, TABLE_TYPE as v from cat");
$col["editoptions"] = array("value" => $str);
$cols[] = $col;
$g->set_columns($cols);
// render grid
$out = $g->render("list1");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/redmond/jquery-ui.custom.css"></link>
<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>
<script src="../../lib/js/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="../../lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
示例2: 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"] = "cus.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");
$col["editoptions"] = array("value" => ":;" . $str);
$col["formatter"] = "select";
// display label, not value
$col["editrules"] = array("required" => true);
$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'] = "customers_name";
$col["editrules"] = array("required" => true);
$col["search"] = true;
$col['editable'] = true;
$cols[] = $col;
$col = array();
$col['title'] = $this->lang->line('car_number');
$col['name'] = "car_id";
$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;
//.........这里部分代码省略.........
示例3: array
$col["name"] = "id";
$col["width"] = "10";
$cols[] = $col;
$col = array();
$col["title"] = "Client";
$col["name"] = "client_id";
$col["dbname"] = "clients.name";
// 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 client_id as k, name as v from clients");
$col["editoptions"] = array("value" => $str);
$cols[] = $col;
$col = array();
$col["title"] = "Date";
$col["name"] = "invdate";
$col["width"] = "50";
$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);
// and is required
$col["formatter"] = "date";
// format as date
$col["search"] = false;
示例4: index
public function index()
{
if ($this->session->userdata('user_name')) {
$g = new jqgrid();
$g->select_command = "SELECT id,fac.factory_code as factory_id ,dis.distance_code as distance_id,cubic.cubic_value as cubic_id,pr.price, start_date,end_date FROM pricelist as pr \nLEFT JOIN transport_factory as fac ON(pr.factory_id=fac.factory_id)\nLEFT JOIN transport_cubiccode as cubic ON(pr.cubic_id = cubic.cubic_id)\nLEFT JOIN distancecode as dis ON(pr.distance_id=dis.distance_id)";
$g->table = "pricelist";
$col = array();
$col["title"] = "id";
$col["name"] = "id";
//$col["dbname"] = "pr.pricelist_id";
$col["width"] = "10";
$col["hidden"] = true;
$col["editable"] = false;
$cols[] = $col;
$col = array();
$col["title"] = $this->lang->line('factory_code');
// caption of column
$col["name"] = "factory_id";
$col["dbname"] = "pr.factory_id";
$col["width"] = "10";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["editrules"] = array("required" => 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_code AS v FROM transport_factory");
$col["editoptions"] = array("value" => ":;" . $str);
// multi-select in search filter
$col["stype"] = "select-multiple";
$col["searchoptions"]["value"] = $str;
$cols[] = $col;
$col = array();
$col["title"] = $this->lang->line('distance_code');
// caption of column
$col["name"] = "distance_id";
$col["dbname"] = "pr.distance_id";
$col["width"] = "10";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["editrules"] = array("required" => 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 distance_id AS k,distance_code AS v FROM distancecode WHERE distance_status=1");
$col["editoptions"] = array("value" => ":;" . $str);
// multi-select in search filter
$col["stype"] = "select-multiple";
$col["searchoptions"]["value"] = $str;
$cols[] = $col;
$col = array();
$col["title"] = $this->lang->line('cubic_value');
// caption of column
$col["name"] = "cubic_id";
$col["dbname"] = "pr.cubic_id";
$col["width"] = "10";
$col["align"] = "left";
$col["search"] = true;
$col["editable"] = true;
$col["editrules"] = array("required" => 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 cubic_id AS k,cubic_value AS v FROM transport_cubiccode WHERE cubic_status=1");
$col["editoptions"] = array("value" => ":;" . $str);
// multi-select in search filter
$col["stype"] = "select-multiple";
$col["searchoptions"]["value"] = $str;
$cols[] = $col;
$col = array();
$col["title"] = $this->lang->line('price');
// caption of column
$col["name"] = "price";
$col["editable"] = true;
$col["width"] = "10";
$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";
//.........这里部分代码省略.........
示例5: 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
//.........这里部分代码省略.........
示例6: index
//.........这里部分代码省略.........
$col2['name'] = 'stock_id';
$col2['hidden'] = true;
$col2['editable'] = true;
$cols2[] = $col2;
#stick date
$col2 = array();
$col2['title'] = $this->lang->line('date');
$col2['name'] = 'stock_date';
$col2['editable'] = true;
$col2["editrules"] = array("required" => true);
// and is required
//$col2["editoptions"] = array("size" => 20, "defaultValue" => date("d-m-Y H:i")); // with default display of textbox with size 20
$col2["searchoptions"]["sopt"] = array("cn");
// contains search for easy searching
# to make it date time
$col2["formatter"] = "datetime";
# opts array can have these options: http://trentrichardson.com/examples/timepicker/#tp-options
$col2["formatoptions"] = array("srcformat" => 'Y-m-d H:i:s', "newformat" => 'Y-m-d H:i', "opts" => array("timeFormat" => "HH:mm"));
$col2["show"] = array("list" => true, "add" => true, "edit" => true, "view" => true);
$cols2[] = $col2;
#Ref No.
$col2 = array();
$col2['title'] = $this->lang->line('reference_number');
$col2['name'] = 'ref_number';
$col2['editable'] = true;
$cols2[] = $col2;
$col2 = array();
$col2['title'] = $this->lang->line('customer_type');
$col2['name'] = "customer_type_id";
$col2['dbname'] = "oil.customer_type_id";
$col2["editable"] = true;
$col2["edittype"] = "select";
$col2["editrules"] = array("required" => true);
$str = $g2->get_dropdown_values("SELECT DISTINCT customer_type_id AS k,customer_type_title AS v FROM transport_customer_type WHERE customer_type_status = '2'");
$col2["editoptions"] = array("value" => ":;" . $str);
$col2["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers WHERE customer_type_id ='{customer_type_id}' ", "update_field" => "customer_id"));
$col2["formatter"] = "select";
// display label, not value
$col2["stype"] = "select";
// enable dropdown search
$col2["searchoptions"] = array("value" => ":;" . $str);
$cols2[] = $col2;
# Customer Name
$col2 = array();
$col2['title'] = $this->lang->line('customer_br');
$col2['name'] = "customer_id";
$col2['dbname'] = "oil.customer_id";
$col2["editable"] = true;
$col2["edittype"] = "select";
$col2["editrules"] = array("required" => true);
$str = $g2->get_dropdown_values("SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers ");
$col2["editoptions"] = array("value" => ":;" . $str);
$col2["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT car_id AS k,car_number AS v FROM `transport_oilcars` WHERE customer_id ='{customer_id}' AND `status`=1", "update_field" => "car_id"));
$col2["editoptions"]["onload"]["sql"] = "SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers WHERE customer_type_id ='{customer_type_id}' AND `status` =1";
$col2["formatter"] = "select";
// display label, not value
$col2["stype"] = "select";
// enable dropdown search
$col2["searchoptions"] = array("value" => ":;" . $str);
$cols2[] = $col2;
#Car Number
$col2 = array();
$col2['title'] = $this->lang->line('car_number');
$col2['name'] = "car_id";
$col2['dbname'] = "car.car_id";
$col2["editable"] = true;
示例7: array
$col["align"] = "center";
$cols[] = $col;
//Client
$col = array();
$col["title"] = "Client";
$col["name"] = "IDClient";
$col["dbname"] = "t_details.IDClient";
// 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 = $d_grid->get_dropdown_values("SELECT DISTINCT ID AS k, Nom AS v FROM t_clients ORDER BY Nom");
$col["editoptions"] = array("value" => $str, "required" => true);
$col["formatter"] = "select";
// display label, not value
$col["stype"] = "select";
// enable dropdown search
$col["searchoptions"] = array("value" => ":;" . $str);
$col["align"] = "center";
$cols[] = $col;
//test nom ne marche pas
/*
$col = array();
$col["title"] = "nom";
$col["name"] = "nom";
$col["dbname"] = "SELECT Nom FROM t_clients WHERE t_details.IDClient = t_clients.ID";
$col["hidden"] = true;
示例8: index
//.........这里部分代码省略.........
$col["fixed"] = true;
$col['width'] = "80";
$col["search"] = false;
$col['align'] = "center";
$col["editable"] = true;
$col["editrules"] = array("required" => true);
$col["edittype"] = "select";
// render as select
$str = $this->cus_drop->get_distancecode_dropdown();
$col["editoptions"] = array("value" => $str);
#$col["formatter"] = "select"; // display label, not value
// initially load 'note' of that client_id
$col["editoptions"]["onload"]["sql"] = "SELECT DISTINCT distance_id AS k,distance_code AS v FROM distancecode\nWHERE range_min <= '{real_distance}'\tAND range_max >='{real_distance}' ";
$col["formatter"] = "select";
// display label, not value
$col["stype"] = "select";
// enable dropdown search
$col["searchoptions"] = array("value" => ":;" . $str);
$cols[] = $col;
/*Cubic*/
$col = array();
$col['title'] = $this->lang->line('cubic_value');
$col["name"] = "cubic_id";
$col["dbname"] = "orders.cubic_id";
// this is required as we need to search in name field, not id
$col['width'] = "80";
$col["fixed"] = true;
$col["align"] = "center";
$col["search"] = false;
$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 cubic_id as k, cubic_value as v from transport_cubiccode where cubic_status=1");
//$str = $this->cus_drop->get_cubiccode_dropdown();
$col["editoptions"] = array("value" => ":;" . $str);
$col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ \$('select[name=cubic_id]').select2({width:'80%', dropdownCssClass: 'ui-widget ui-jqdialog'}); },200); }";
$cols[] = $col;
#price
$col = array();
$col['title'] = $this->lang->line('price');
$col['name'] = "price";
$col['align'] = "right";
$col["fixed"] = true;
$col['width'] = "80";
//$col["editrules"] = array("number" => true);
$col['editoptions'] = array("defaultValue" => "0", "readonly" => true);
#$col['hidden'] = true;
$col["show"] = array("list" => true, "add" => false, "edit" => false, "view" => true);
$col['editable'] = true;
$col['search'] = false;
$cols[] = $col;
/*End Cubic*/
#car
$col = array();
$col["title"] = $this->lang->line('car_number');
$col['name'] = "car_id";
$col['dbname'] = "car.car_number";
$col["fixed"] = true;
$col['align'] = "center";
$col['width'] = "85";
$col['search'] = true;
$col['editable'] = true;
$col["editrules"] = array("required" => true);
$col['edittype'] = "select";
$str = $this->cus_drop->get_car_dropdown();
示例9: array
// Client
$col = array();
$col["title"] = "Client";
$col["name"] = "IDClient";
$col["dbname"] = "t_clients.Nom";
// 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
$col["export"] = true;
# fetch data from database, with alias k for key, v for value
# on change, update other dropdown
$str = $detail_grid->get_dropdown_values("SELECT DISTINCT ID AS k, Nom AS v FROM t_clients ORDER BY Nom");
$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;
//Poids achat
$col = array();
$col["title"] = "Poids achat";
$col["name"] = "PoidsAchat";
$col["width"] = "100";
$col["search"] = true;
$col["editable"] = true;
$col["edittype"] = "select";
示例10: 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
//.........这里部分代码省略.........
示例11: array
$col["name"] = "NoVente";
$col["width"] = "10";
$cols[] = $col;
$col = array();
$col["title"] = "Client";
$col["name"] = "IDClient";
$col["dbname"] = "t_details.IDClient";
// 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 ID as k, Nom as v from t_clients");
$col["editoptions"] = array("value" => ":;" . $str);
$col["formatter"] = "select";
// display label, not value
$cols[] = $col;
$col = array();
$col["title"] = "Poids Achat";
$col["name"] = "PoidsAchat";
$col["width"] = "50";
$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);
// and is required
$col["search"] = false;