Ejemplo n.º 1
0
## note: many functions below are commented out (with //). note which ones are and which are not
#i can define a relationship to another table
#the 1st field is the fk in the table, the 2nd is the second table, the 3rd is the pk in the second table, the 4th is field i want to retrieve as the dropdown value
#http://ajaxcrud.com/api/index.php?id=defineRelationship
//$tblDemo->defineRelationship("fkID", "tblDemoRelationship", "pkID", "fldName", "fldSort DESC"); //use your own table - this table (tblDemoRelationship) not included in the installation script
#i don't want to visually show the primary key in the table
$tblDemo->omitPrimaryKey();
#the table fields have prefixes; i want to give the heading titles something more meaningful
$tblDemo->displayAs("fldField1", "Field1");
$tblDemo->displayAs("fldField2", "Field2");
$tblDemo->displayAs("fldCertainFields", "Valid Value Field");
$tblDemo->displayAs("fldLongField", "Long Field");
$tblDemo->displayAs("fldCheckbox", "Is Selected?");
#set the textarea height of the longer field (for editing/adding)
#http://ajaxcrud.com/api/index.php?id=setTextareaHeight
$tblDemo->setTextareaHeight('fldLongField', 150);
#i could omit a field if I wanted
#http://ajaxcrud.com/api/index.php?id=omitField
//$tblDemo->omitField("fldField2");
#i could omit a field from being on the add form if I wanted
//$tblDemo->omitAddField("fldField2");
#i could disallow editing for certain, individual fields
//$tblDemo->disallowEdit('fldField2');
#i could set a field to accept file uploads (the filename is stored) if wanted
//$tblDemo->setFileUpload("fldField2", "uploads/");
#i can have a field automatically populate with a certain value (eg the current timestamp)
//$tblDemo->addValueOnInsert("fldField1", "NOW()");
#i can use a where field to better-filter my table
//$tblDemo->addWhereClause("WHERE (fldField1 = 'test')");
#i can order my table by whatever i want
//$tblDemo->addOrderBy("ORDER BY fldField1 ASC");
Ejemplo n.º 2
0
$tblEventAttendee->validateUpdateWithFunction("canRowBeModifiedOrDeleted");
$tblEventAttendee->defineCheckbox("fldWillBeLate");
$tblEventAttendee->addOrderBy("ORDER BY fldFirstName ASC");
#Add WHERE clause so we only display information specific to the event that was selected
$tblEventAttendee->addWhereClause("WHERE fkEventID = {$eventID}");
#I could add filter boxes to the top, but have chosen not to do so; commenting these out
//$tblEventAttendee->addAjaxFilterBox("fldFirstName");
//$tblEventAttendee->addAjaxFilterBox("fldLastName");
//$tblEventAttendee->addAjaxFilterBox("fldAttending");
//using addValueOnInsert so when someone signs up it will automatically add them to this event
$tblEventAttendee->addValueOnInsert("fkEventID", $eventID);
//using addValueOnInsert to track their IP address
$tblEventAttendee->addValueOnInsert("fldIPAddress", $_SERVER["REMOTE_ADDR"]);
$tblEventAttendee->setTextboxWidth("fldTimeArriving", 8);
$tblEventAttendee->setTextboxWidth("fldLastName", 25);
$tblEventAttendee->setTextareaHeight("fldComments", 70);
//comment field should be a bit wider height
#set the number of rows to display (per page)
$tblEventAttendee->setLimit(25);
//after 25 people, the resultset will paginate
$tblEventAttendee->setAddPlaceholderText("fldTimeArriving", $fldTime);
$tblEventAttendee->setAddFieldNote("fldTimeArriving", "Leave blank if you'll be on time.");
$tblEventAttendee->setAddFieldNote("fldWillBeLate", "If you will be arriving late, please enter the time in the next box.");
$tblEventAttendee->modifyFieldWithClass("fldTimeArriving", "time");
$tblEventAttendee->modifyFieldWithClass("fldLastName", "required");
$tblEventAttendee->modifyFieldWithClass("fldFirstName", "required");
$tblEventAttendee->formatFieldWithFunction("fldWillBeLate", "displayWillBeLate");
$tblEventAttendee->formatFieldWithFunctionAdvanced("fldTimeArriving", "displayArrivalTime");
$tblEventAttendee->emptyTableMessage = "No one has signed up yet! Press the '<b>Add Person</b>' button below to sign up for this event.";
$tblEventAttendee->addMessage = "You have been added to this event.";
$tblEventAttendee->setCSSFile("cuscosky.css");
Ejemplo n.º 3
0
//$tblEvent->addAjaxFilterBox("fldLastName");
//$tblEvent->addAjaxFilterBox("fldAttending");
$today = date("Y-m-d");
if (!$viewPastEvents) {
    #Add Where clause - only show future events
    $tblEvent->addWhereClause("WHERE (fldDate >= \"{$today}\") OR fldDate = \"0000-00-00\"");
    $signupText = "Sign up for Event";
    $tblEvent->setFileUpload("fldImage", "uploads/", "uploads/");
} else {
    #Add Where clause - only show past events
    $tblEvent->addWhereClause("WHERE (fldDate < \"{$today}\") AND fldDate != \"0000-00-00\"");
    $signupText = "View Who Signed Up";
    $tblEvent->turnOffAjaxEditing();
}
$tblEvent->addButtonToRow($signupText, "index.php");
$tblEvent->setTextareaHeight("fldAdditionalInformation", 70);
#set the number of rows to display (per page)
//$tblEvent->setLimit(25);
$tblEvent->setAddPlaceholderText("fldDate", "YYYY-mm-dd");
$tblEvent->setAddPlaceholderText("fldTime", "7:00pm");
$tblEvent->setAddFieldNote("fldDate", "Make sure to enter in format <b>YYYY-mm-dd</b>.");
$tblEvent->setAddFieldNote("fldImage", "If you want to add an image to the event (optional).");
$tblEvent->setAddFieldNote("fldType", "Public means anyone can come; Private means you want this event to be exclusive.");
//$tblEvent->addButtonToRowWindowOpen = "same"; //this is default behavior so i have it commented out
$tblEvent->formatFieldWithFunction("fldDate", "highlightDate");
$tblEvent->formatFieldWithFunction("fldImage", "showImage");
$tblEvent->modifyFieldWithClass("fldDate", "datepicker");
$tblEvent->showTable();
include 'footer.php';
function highlightDate($date)
{
<?php

require_once 'include/preheader.php';
// <-- this include file MUST go first before any HTML/output
include 'include/ajaxCRUD.class.php';
// <-- this include file MUST go first before any HTML/output
$tblDemo = new ajaxCRUD("Autos", "autos", "id_autos", "");
$tblDemo->defineRelationship("id_tipo", "tipo", "id_tipo", "desc_tipo");
$tblDemo->defineRelationship("id_modelo", "modelo", "id_modelo", "desc_modelo");
$tblDemo->defineRelationship("id_marca", "marca", "id_marca", "desc_marca");
$tblDemo->omitPrimaryKey();
$tblDemo->displayAs("nombre_autos", "Nombre");
$tblDemo->displayAs("desc_autos", "Descripcion");
$tblDemo->displayAs("detalle_autos", "Especificaciones");
$tblDemo->displayAs("precio_autos", "Precio");
$tblDemo->displayAs("id_marca", "Marca");
$tblDemo->displayAs("id_tipo", "Tipo");
$tblDemo->displayAs("id_modelo", "Modelo");
$tblDemo->setTextareaHeight('detalle_autos', 150);
$tblDemo->addWhereClause("WHERE id_marca = 2 and id_tipo = 41");
$tblDemo->setLimit(30);
$tblDemo->showTable();
Ejemplo n.º 5
0
$tblDemo->displayAs("fldField2", "Field2");
$tblDemo->displayAs("fldCertainFields", "Certain Fields");
$tblDemo->displayAs("fldLongField", "Long Field");
$tblDemo->setTextareaHeight('fldLongField', 200);
$allowableValues = array("Allowable Value 1", "Allowable Value2", "Dropdown Value", "CRUD");
$tblDemo->defineAllowableValues("fldCertainFields", $allowableValues);
$tblDemo->setLimit(3);
$tblDemo->addAjaxFilterBox('fldField1');
$tblDemo->formatFieldWithFunction('fldField1', 'makeBlue');
$tblDemo->formatFieldWithFunction('fldField2', 'makeBold');
$tblDemo->showTable();
$tblDemo2 = new ajaxCRUD("Item", "tblDemo2", "pkID");
$tblDemo2->omitPrimaryKey();
$tblDemo2->displayAs("fldField1", "Field1");
$tblDemo2->displayAs("fldField2", "Field2");
$tblDemo2->displayAs("fldCertainFields", "Certain Fields");
$tblDemo2->displayAs("fldLongField", "Long Field");
$tblDemo2->setTextareaHeight('fldLongField', 200);
$tblDemo2->setLimit(20);
$tblDemo2->addAjaxFilterBox('fldField1');
$tblDemo2->formatFieldWithFunction('fldField2', 'makeBlue');
$tblDemo2->formatFieldWithFunction('fldField1', 'makeBold');
$tblDemo2->showTable();
function makeBold($val)
{
    return "<b>{$val}</b>";
}
function makeBlue($val)
{
    return "{$val}";
}