Created
February 21, 2022 15:17
-
-
Save tmoore88/819a35a6272721cf5a2ae37a61106452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## | |
# EVENTS # | |
########## | |
$e["on_insert"] = array("add_edit_fk", null, true); | |
$e["on_update"] = array("add_edit_fk", null, true); | |
$g->set_events($e); | |
############################### | |
# RENDER EQ_LIST GRID (list1) # | |
############################### | |
$out = $g->render("list1"); | |
##################### | |
# ON EDIT/ADD EVENT # | |
##################### | |
function add_edit_fk($data) | |
{ | |
//////////////////////// | |
// GLOBAL VARIABLE(S) // | |
//////////////////////// | |
global $g; | |
//phpgrid_error("Error message"); | |
///////////////////////////////////// | |
// SET COLUMN TO UPPER CASE ON ADD // | |
///////////////////////////////////// | |
$data["params"]["First_name"] = strtoupper($data["params"]["First_name"]); //UPPER FIRST NAME | |
$data["params"]["Last_name"] = strtoupper($data["params"]["Last_name"]); //UPPER LAST NAME | |
$data["params"]["company_name"] = strtoupper($data["params"]["company_name"]); //UPPER COMPANY NAME | |
/////////////////////////////// | |
// AUTOCOMPLETE COMPANY NAME // | |
/////////////////////////////// | |
$n = $data["params"]["company_name"]; //SET COMPANY NAME TO N STRING | |
//CODE THAT IS NOT WORKING!! | |
//ERRORS OUT HERE WHEN LINE BELOW IS NOT REMARKED OUT | |
//$ss = $g->get_one("SELECT * FROM tbl_customer WHERE company_name=?",array($n)); //QUERY COMPANY NAME | |
if (empty($ss)) //IF QUERY EMPTY | |
{ | |
unset($data["params"]["fk_customer_id"]); //DISCARD CUSTOMER ID | |
// ERRORS OUT HERE WHEN TOP ONE IS REMARKED OUT AND NOT LINE BELOW REMARKED OUT | |
//$insert_id = $g->execute_query("INSERT INTO tbl_customer (company_name) VALUES (?)",array($n),"insert_id"); //INSERT CUSTOMER IN DATABASE | |
$data["params"]["fk_customer_id"] = $insert_id; //SET FK TO NEW CUSTOMER ID | |
} | |
///////////////////////////////////////////////////////////// | |
// UNSET ALL COLUMNS THAT DONOT BELONG TO DEFAULT DATABASE // | |
///////////////////////////////////////////////////////////// | |
unset($data["params"]["company_name"]); //UNSET COMPANY NAME | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment