Example #1
0
 /**
  * @param $filterFields FilterField[]
  */
 function __construct($filterFields)
 {
     $this->filterFields = $filterFields;
     // handle filterResults Request
     global $curPage;
     if (isset($_POST['filter'])) {
         $curPage->saveConfig('filter', $_POST['filter']);
     }
     // get page config from session and build condition array
     if ($filterConfig = $curPage->getConfig('filter')) {
         //$curPage->pr();
         //prses();
         foreach ($filterConfig as $key => $value) {
             if (!empty($value)) {
                 if (is_array($value) && areSet(array('start', 'end'), $value)) {
                     // its a bw filter field
                     $this->condArray[$key] = "{$key} >= '{$value['start']}' AND {$key} < '{$value['end']}'";
                     foreach ($value as $k => $v) {
                         $filterFields[$key]->bwValues[$k] = $v;
                     }
                 } else {
                     $this->condArray[$key] = "{$key} = '{$value}'";
                     $filterFields[$key]->val = $value;
                 }
             }
         }
     }
 }
Example #2
0
/**
 * Created by EngrNaveed
 * Date: 28-Dec-14
 * Time: 5:20 PM
 */
require_once "../initialize.php";
// expected input pattern:
//Array
//(
//    [classname] => Guardian
//    [fieldname] => id
//    [currentValue] => n
//)
//prpost();
if (areSet(array('classname', 'fieldname', 'currentValue'), $_POST) && !empty($_POST['currentValue'])) {
    // extract variables from the info
    $classname = $_POST['classname'];
    $tableName = $_POST['classname']::tablename();
    $columnName = $_POST['fieldname'];
    $displayColumnsArr = $_POST['classname']::$displayFields;
    $displayColumns = join(",", $displayColumnsArr);
    // find data
    foreach ($displayColumnsArr as $col) {
        $conditionArr[] = "{$col} LIKE '%" . $_POST['currentValue'] . "%'";
    }
    $condition = join(" OR ", $conditionArr);
    $condition .= " OR {$tableName}.{$columnName} = '" . $_POST['currentValue'] . "'";
    $data = $classname::findByCondition($condition);
    //    pr($data,"received data");
    //    prlq();
Example #3
0
<?php

/**
 * Created by EngrNaveed.
 * Date: 10-01-15
 * Time: 2:05 PM
 */
require_once "../initialize.php";
// expected data: Array(
//    [parentField] => class_id
//    [targetField] => section
//    [parentFieldValue] => 1
//    [classname] => Student
//)
if (areSet(array('parentField', 'targetField', 'parentFieldValue', 'classname'), $_POST)) {
    $fields = $_POST['classname']::getColumns();
    $fClass = $fields->{$_POST}['targetField']->fkeyInfo->fClass;
    $fField = $fields->{$_POST}['targetField']->fkeyInfo->fField;
    // find records
    $condition = $_POST['parentField'] . "=" . $_POST['parentFieldValue'];
    $records = $fClass::findByCondition($condition);
    if ($records) {
        // show options
        foreach ($records as $object) {
            echo "<option value='" . $object->{$fField} . "'>" . $object->title() . "</option>";
        }
    } else {
        echo "<option></option>";
    }
}
Example #4
0
File: login.php Project: nveeed/ems
<?php

require_once 'html_components/require_comps_start.php';
if (isset($_GET['logout'])) {
    $user->logout();
    $session->setMessage("You are now logged out.", "info");
    redirect('login.php');
}
//if the user is already logged in, no need to ask him again for the credentials, take him to the admin area:
if ($user->isLoggedIn()) {
    redirect('index.php');
}
// else check to see if the form is submitted. If yes, authenticate...
if (areSet(array('username', 'password'), $_POST)) {
    if (User::authenticate($_POST['username'], $_POST['password'])) {
        redirect('index.php');
    } else {
        $session->setMessage("Incorrect Username and / or Password.", 'danger');
        redirect("login.php");
    }
}
// page starts here:
?>
<div class="modalBackdrop"></div>
	<div class='row'>
	<div class='col-sm-12 col-lg-4 col-lg-offset-4'>
        <form id="loginForm" class="form-horizontal gridBkg" role="form" method="post">
            <div class="input-group">
                <label for="username" class="input-group-addon"><?php 
echo icon('user');
?>
Example #5
0
<?php

/**
 * Created by EngrNaveed.
 * Date: 04-Jan-15
 * Time: 5:07 PM
 */
require_once __DIR__ . "/" . "../initialize.php";
// we need: $tablename, record_id and a delete request
if (areSet(array('del_class', 'record_to_del', 'delete'), $_GET) && $_GET['delete'] == 'true') {
    //    pr($classname);
    $response = $_GET['del_class']::dbDelete($_GET['record_to_del']);
    if ($response->succeeded) {
        $msgType = 'info';
    } else {
        $msgType = 'danger';
    }
    $session->setMessage($response->detail, $msgType);
    $uri = preg_replace("/&delete=true.*/", "", $_SERVER['REQUEST_URI']);
    redirect($uri);
}
Example #6
0
/**
 * Created by EngrNaveed
 * Date: 12/26/2014
 * Time: 8:42 PM
 */
require_once __DIR__ . "/" . "../initialize.php";
// we require $classname and an $objToSave in order to save data
$formErrors = array();
$objToSave = null;
if ($objToSave instanceof TableObject) {
}
$classname = "";
$arrayToSave = null;
$msg = "Successfully Saved to Database.";
$msgType = 'success';
$autoInsertFormIsSubmitted = areSet(array('autoInsertForm', 'classname'), $_POST);
$recordIsBeingEdited = isAjax() && isset($_POST['recordInfo']) && isset($_POST['valueToSave']);
$newRecFormIsSubmitted = isset($_POST['submit']);
$anyFormIsSubmitted = $autoInsertFormIsSubmitted || $recordIsBeingEdited || $newRecFormIsSubmitted;
if ($recordIsBeingEdited) {
    $info = explode('-', decrypt($_POST['recordInfo']));
    //    $info: Array
    //    (
    //        [0] => persons    // table
    //        [1] => cnic       // field
    //        [2] => 13         // id
    //    )
    $classname = tbl2cls($info[0]);
    $objToSave = $classname::findById($info[2]);
    $objToSave->{$info}[1]->val = $_POST['valueToSave'];
} elseif ($newRecFormIsSubmitted) {
Example #7
0
/**
 * Created by EngrNaveed
 * Date: 28-Dec-14
 * Time: 5:20 PM
 */
require_once "../initialize.php";
// expected input pattern:
//Array
//(
//    [classname] => Person
//    [fieldname] => id
//    [currentValue] => n
//)
//prpost();
if (areSet(array('classname', 'fieldname', 'currentValue'), $_POST)) {
    // extract variables from the info
    $classname = $_POST['classname'];
    $tableName = $_POST['classname']::tablename();
    $columnName = $_POST['fieldname'];
    $displayColumnsArr = $_POST['classname']::$displayFields;
    $displayColumns = join(",", $displayColumnsArr);
    // find data
    $condition = "MATCH ({$displayColumns}) AGAINST ('" . $_POST['currentValue'] . "*' IN BOOLEAN MODE) OR {$tableName}.{$columnName} = '" . $_POST['currentValue'] . "'";
    $data = $classname::findByCondition($condition);
    //    pr($data,"received data");
    //    prlq();
    echo "<div class='list-group fkeyHints'>";
    if ($data && !$data[0]->isEmpty()) {
        foreach ($data as $object) {
            $href = "recordDetail.php?classname=" . $_POST['classname'] . "&recordId=" . $object->id;