Skip to content

Instantly share code, notes, and snippets.

@mountainskitime77
Created February 22, 2022 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mountainskitime77/8c974dcbd11522b149e2ce4af929c047 to your computer and use it in GitHub Desktop.
Save mountainskitime77/8c974dcbd11522b149e2ce4af929c047 to your computer and use it in GitHub Desktop.
Gridphp Issue
//CONSTRUCT GRIDPHP
$g = new jqgrid($db_conf);
//LIMIT ACTIONS
$g->set_actions(array(
"add"=>false,
"edit"=>false,
"delete"=>false,
// ...
"rowactions"=>false,
"export_pdf"=>true,
"export_excel"=>false,
"export_csv"=>true,
"export_html"=>false
)
);
//SET GRID PARAMETERS
$opt["caption"] = "My Appointments Purchased";
//STATIC
// to remove vertical scroll bar
$opt["height"] = "100%";
$opt["rowNum"] = 10;
$opt["resizable"] = true; // defaults to false
$opt["autoresize"] = true; // defaults to false
$opt["reloadedit"] = true;
$opt["globalsearch"] = false;
$opt["hotkeys"] = false;
$opt["tooltip"] = true;
$opt["responsive"] = true;
$opt["sortname"] = 'Original_Appt_Date';
$opt["sortorder"] = "desc";
// export PDF file params
$opt["export"] = array("filename"=>"AppointmentsPurchased", "heading"=>"Appointments Purchased", "orientation"=>"landscape", "paper"=>"a4");
// for excel, sheet header
$opt["export"]["sheetname"] = "Appointments Purchased";
// export filtered data or all data
$opt["export"]["range"] = "filtered"; // or "all"
// export PDF file
//$opt["export"] = array("format"=>"excel", "range"=>"filtered");
$g->set_options($opt);
//DEFINE COLUMNS
//Apppointment_ID
$col = array();
$col["name"] = "Appointment_ID";
$col["title"] = "ID";
$col["fixed"] = true;
$col["width"] = "50";
$col["hidden"] = true;
$col["export"] = false;
$col["editable"] = false; // this column is editable
$col["searchoptions"]["sopt"] = array("eq");
$cols[] = $col;
//Orignal_Appt_Datetime we are calling Billing Date
$col = array();
$col["name"] = "Original_Appt_Date";
$col["title"] = "Billing Dt";
$col["fixed"] = true;
$col["visible"] = "xs+";
$col["width"] = "95";
$col["formatter"] = "date"; // format as date
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Appt_Date
$col = array();
$col["name"] = "Appt_Date";
$col["title"] = "Appt Date";
$col["fixed"] = true;
$col["visible"] = "md+";
$col["width"] = "95";
$col["formatter"] = "date"; // format as date
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Appt_Starttime
$col = array();
$col["name"] = "Appt_Starttime";
$col["title"] = "Start Tm";
$col["fixed"] = true;
$col["visible"] = "md+";
$col["width"] = "75";
$col["sortable"] = false;
$col["editable"] = false; // this column is editable
//$col["datefmt"] = "Y-m-d";
$cols[] = $col;
//Appt_Endtime
$col = array();
$col["name"] = "Appt_Endtime";
$col["title"] = "End Tm";
$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "70";
$col["sortable"] = false;
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Timezone
$col = array();
$col["name"] = "Timezone";
$col["title"] = "Timezone";
//$col["fixed"] = true;
$col["visible"] = "md+";
$col["width"] = "85";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Name
$col = array();
$col["name"] = "Contact_Name";
$col["title"] = "Name";
//$col["fixed"] = true;
$col["visible"] = "sm+";
$col["width"] = "150";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Org
$col = array();
$col["name"] = "Contact_Organization";
$col["title"] = "Org";
//$col["fixed"] = true;
$col["visible"] = "md+";
$col["width"] = "150";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Email
$col = array();
$col["name"] = "Contact_Email";
$col["title"] = "Work Email";
$col["visible"] = "md+";
//$col["fixed"] = true;
$col["width"] = "150";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Personal_Email
$col = array();
$col["name"] = "Contact_Personal_Email";
$col["title"] = "Personal Email";
//$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "150";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Department
$col = array();
$col["name"] = "Contact_Department";
$col["title"] = "Dept";
//$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "75";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Title
$col = array();
$col["name"] = "Contact_Title";
$col["title"] = "Title";
//$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "75";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Phone
$col = array();
$col["name"] = "Contact_Phone";
$col["title"] = "Phone";
//$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "95";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Contact_Message
$col = array();
$col["name"] = "Contact_Message";
$col["title"] = "Message";
//$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "150";
$col["editable"] = false; // this column is editable
$cols[] = $col;
//Amount_Billed
$col = array();
$col["name"] = "AmountBilled";
$col["title"] = "Amt Billed";
$col["fixed"] = true;
$col["visible"] = "xs+";
$col["width"] = "125";
$col["editable"] = false; // this column is editable
$col["formatter"] = "currency";
$col["formatoptions"] = array("prefix" => "$",
"suffix" =>"",
"thousandsSeparator" => ",",
"decimalSeparator" => ".",
"decimalPlaces" => 2);
$cols[] = $col;
//Agent_ID
$col = array();
$col["name"] = "Agent_ID";
$col["title"] = "Agent ID";
//$col["fixed"] = true;
$col["visible"] = "lg+";
$col["width"] = "60";
$col["editable"] = true; // this column is editable
$col["isnull"] = true;
$col["searchoptions"]["sopt"] = array("eq");
$cols[] = $col;
//RENDER VIEW GRID
$g->select_command = 'Blank for security;
//$default_filter = "";
//if (!isset($_GET["filters"]))
// $default_filter = "WHERE status = 1";
// you can provide custom SQL query to display data
//$g->select_command = "SELECT id, `description`, `date`,`priority`,`attachment`,`status` from todos $default_filter";
//LOAD CUD FROM DB
$g->table = 'lg4."Appointment"';
//LOAD ALL COLUMNS
$g->set_columns($cols,false);
//RENDER GRID
$out = $g->render("appt_view");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment