Example #1
0
 public function __construct(SearchQuery $objSearchQuery, $objParentObject, $strControlId = null)
 {
     try {
         parent::__construct($objParentObject, $strControlId);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     $this->objSearchQuery = $objSearchQuery;
     $this->strTemplate = dirname(__FILE__) . '/SearchQueryPanel.tpl.php';
     $this->dtgConditions = new QDataGrid($this);
     $this->dtgConditions->AddColumn(new QDataGridColumn('Item', '<?= $_CONTROL->ParentControl->RenderItem($_ITEM); ?>', 'HtmlEntities=false', 'Width=160px'));
     $this->dtgConditions->AddColumn(new QDataGridColumn('Operation', '<?= $_CONTROL->ParentControl->RenderOperation($_ITEM); ?>', 'HtmlEntities=false', 'Width=180px'));
     $this->dtgConditions->AddColumn(new QDataGridColumn('Value', '<?= $_CONTROL->ParentControl->RenderValue($_ITEM); ?>', 'HtmlEntities=false', 'Width=390px'));
     $this->dtgConditions->SetDataBinder('dtgConditions_Bind', $this);
     $this->btnAddCondition = new QButton($this);
     $this->btnAddCondition->CssClass = 'primary';
     $this->btnAddCondition->Text = 'Add a Condition';
     $this->btnAddCondition->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnAddCondition_Click'));
     if ($this->objSearchQuery->Id) {
         $this->objQueryConditionArray = QueryCondition::LoadArrayBySearchQueryId($this->objSearchQuery->Id, QQ::OrderBy(QQN::QueryCondition()->Id));
         $this->objQueryConditionArray[] = new QueryCondition();
     } else {
         $this->objQueryConditionArray = array(new QueryCondition());
     }
     // Single Lookup of Node and Operations
     $this->objNodeArray = array();
     foreach (QueryNode::LoadAll(QQ::OrderBy(QQN::QueryNode()->Name)) as $objNode) {
         $this->objNodeArray[$objNode->Id] = $objNode;
     }
     $this->objOperationArray = array();
     foreach (QueryOperation::LoadAll(QQ::OrderBy(QQN::QueryOperation()->Name)) as $objOperation) {
         $this->objOperationArray[$objOperation->Id] = $objOperation;
     }
 }
Example #2
0
<?php

require_once 'logger/error_log.php';
//enables printing log messages to logger/error_log.txt
require_once 'Request.php';
//uses client data sent to make query calls to class in charge.
require_once 'QueryOperation.php';
//class in charge of query operations
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
error_log("type " . $request_method);
$query = new QueryOperation();
$result = new stdClass();
function get_url_id()
{
    $strip = basename($_SERVER['REQUEST_URI']);
    $strip = explode("?", $strip);
    if (count($strip) > 0) {
        return $strip[0];
    }
    return NULL;
}
switch ($request_method) {
    case 'get':
        $result = $query->getConsumo(new stdClass());
        break;
    case 'put':
        $put = file_get_contents("php://input", 'r');
        $params = json_decode($put);
        $result = $query->updateConsumo($params);
        break;
    case 'post':
Example #3
0
<?php

require_once 'logger/error_log.php';
//enables printing log messages to logger/error_log.txt
require_once 'Request.php';
//uses client data sent to make query calls to class in charge.
require_once 'QueryOperation.php';
//class in charge of query operations
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
error_log("type " . $request_method);
$query = new QueryOperation();
$result = new stdClass();
function get_url_id()
{
    $strip = basename($_SERVER['REQUEST_URI']);
    $strip = explode("?", $strip);
    if (count($strip) > 0) {
        return $strip[0];
    }
    return NULL;
}
switch ($request_method) {
    case 'get':
        $result = $query->getRichiesta(new stdClass());
        break;
    case 'put':
        $put = file_get_contents("php://input", 'r');
        $params = json_decode($put);
        $result = $query->updateRichiesta($params);
        break;
    case 'post':
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this QueryOperationMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing QueryOperation object creation - defaults to CreateOrEdit
  * @return QueryOperationMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objQueryOperation = QueryOperation::Load($intId);
         // QueryOperation was found -- return it!
         if ($objQueryOperation) {
             return new QueryOperationMetaControl($objParentObject, $objQueryOperation);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a QueryOperation object with PK arguments: ' . $intId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new QueryOperationMetaControl($objParentObject, new QueryOperation());
 }
Example #5
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objSearchQuery) {
         $objObject->objSearchQuery = SearchQuery::GetSoapObjectFromObject($objObject->objSearchQuery, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSearchQueryId = null;
         }
     }
     if ($objObject->objOrQueryCondition) {
         $objObject->objOrQueryCondition = QueryCondition::GetSoapObjectFromObject($objObject->objOrQueryCondition, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intOrQueryConditionId = null;
         }
     }
     if ($objObject->objQueryOperation) {
         $objObject->objQueryOperation = QueryOperation::GetSoapObjectFromObject($objObject->objQueryOperation, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intQueryOperationId = null;
         }
     }
     if ($objObject->objQueryNode) {
         $objObject->objQueryNode = QueryNode::GetSoapObjectFromObject($objObject->objQueryNode, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intQueryNodeId = null;
         }
     }
     return $objObject;
 }
Example #6
0
<?php

session_start();
require_once 'logger/error_log.php';
//enables printing log messages to logger/error_log.txt
require_once 'Request.php';
//uses client data sent to make query calls to class in charge.
require_once 'QueryOperation.php';
//class in charge of query operations
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
error_log("type " . $request_method);
$query = new QueryOperation();
$result = new stdClass();
function get_url_id()
{
    $strip = basename($_SERVER['REQUEST_URI']);
    $strip = explode("?", $strip);
    if (count($strip) > 0) {
        return $strip[0];
    }
    return NULL;
}
switch ($request_method) {
    case 'get':
        $result = $query->getResults(new stdClass(), $_SESSION['comune']);
        if (isset($_SESSION['comune'])) {
            unset($_SESSION['comune']);
        }
        break;
    case 'put':
        $put = file_get_contents("php://input", 'r');
Example #7
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, QueryOperation::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
 /**
  * Refresh this MetaControl with Data from the local QueryCondition object.
  * @param boolean $blnReload reload QueryCondition from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objQueryCondition->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objQueryCondition->Id;
         }
     }
     if ($this->lstSearchQuery) {
         $this->lstSearchQuery->RemoveAllItems();
         $this->lstSearchQuery->AddItem(QApplication::Translate('- Select One -'), null);
         $objSearchQueryArray = SearchQuery::LoadAll();
         if ($objSearchQueryArray) {
             foreach ($objSearchQueryArray as $objSearchQuery) {
                 $objListItem = new QListItem($objSearchQuery->__toString(), $objSearchQuery->Id);
                 if ($this->objQueryCondition->SearchQuery && $this->objQueryCondition->SearchQuery->Id == $objSearchQuery->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSearchQuery->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSearchQueryId) {
         $this->lblSearchQueryId->Text = $this->objQueryCondition->SearchQuery ? $this->objQueryCondition->SearchQuery->__toString() : null;
     }
     if ($this->lstOrQueryCondition) {
         $this->lstOrQueryCondition->RemoveAllItems();
         $this->lstOrQueryCondition->AddItem(QApplication::Translate('- Select One -'), null);
         $objOrQueryConditionArray = QueryCondition::LoadAll();
         if ($objOrQueryConditionArray) {
             foreach ($objOrQueryConditionArray as $objOrQueryCondition) {
                 $objListItem = new QListItem($objOrQueryCondition->__toString(), $objOrQueryCondition->Id);
                 if ($this->objQueryCondition->OrQueryCondition && $this->objQueryCondition->OrQueryCondition->Id == $objOrQueryCondition->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstOrQueryCondition->AddItem($objListItem);
             }
         }
     }
     if ($this->lblOrQueryConditionId) {
         $this->lblOrQueryConditionId->Text = $this->objQueryCondition->OrQueryCondition ? $this->objQueryCondition->OrQueryCondition->__toString() : null;
     }
     if ($this->lstQueryOperation) {
         $this->lstQueryOperation->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstQueryOperation->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objQueryOperationArray = QueryOperation::LoadAll();
         if ($objQueryOperationArray) {
             foreach ($objQueryOperationArray as $objQueryOperation) {
                 $objListItem = new QListItem($objQueryOperation->__toString(), $objQueryOperation->Id);
                 if ($this->objQueryCondition->QueryOperation && $this->objQueryCondition->QueryOperation->Id == $objQueryOperation->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstQueryOperation->AddItem($objListItem);
             }
         }
     }
     if ($this->lblQueryOperationId) {
         $this->lblQueryOperationId->Text = $this->objQueryCondition->QueryOperation ? $this->objQueryCondition->QueryOperation->__toString() : null;
     }
     if ($this->lstQueryNode) {
         $this->lstQueryNode->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstQueryNode->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objQueryNodeArray = QueryNode::LoadAll();
         if ($objQueryNodeArray) {
             foreach ($objQueryNodeArray as $objQueryNode) {
                 $objListItem = new QListItem($objQueryNode->__toString(), $objQueryNode->Id);
                 if ($this->objQueryCondition->QueryNode && $this->objQueryCondition->QueryNode->Id == $objQueryNode->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstQueryNode->AddItem($objListItem);
             }
         }
     }
     if ($this->lblQueryNodeId) {
         $this->lblQueryNodeId->Text = $this->objQueryCondition->QueryNode ? $this->objQueryCondition->QueryNode->__toString() : null;
     }
     if ($this->txtValue) {
         $this->txtValue->Text = $this->objQueryCondition->Value;
     }
     if ($this->lblValue) {
         $this->lblValue->Text = $this->objQueryCondition->Value;
     }
     if ($this->lstQueryConditionAsOr) {
         $this->lstQueryConditionAsOr->RemoveAllItems();
         $this->lstQueryConditionAsOr->AddItem(QApplication::Translate('- Select One -'), null);
         $objQueryConditionArray = QueryCondition::LoadAll();
         if ($objQueryConditionArray) {
             foreach ($objQueryConditionArray as $objQueryCondition) {
                 $objListItem = new QListItem($objQueryCondition->__toString(), $objQueryCondition->Id);
                 if ($objQueryCondition->OrQueryConditionId == $this->objQueryCondition->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstQueryConditionAsOr->AddItem($objListItem);
             }
         }
     }
     if ($this->lblQueryConditionAsOr) {
         $this->lblQueryConditionAsOr->Text = $this->objQueryCondition->QueryConditionAsOr ? $this->objQueryCondition->QueryConditionAsOr->__toString() : null;
     }
 }
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = QueryOperation::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from QueryOperation, given the clauses above
     $this->DataSource = QueryOperation::QueryArray($objCondition, $objClauses);
 }
Example #10
0
<?php

require_once 'logger/error_log.php';
//enables printing log messages to logger/error_log.txt
require_once 'Request.php';
//uses client data sent to make query calls to class in charge.
require_once 'QueryOperation.php';
//class in charge of query operations
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
error_log("type " . $request_method);
$query = new QueryOperation();
$result = new stdClass();
function get_url_id()
{
    $strip = basename($_SERVER['REQUEST_URI']);
    $strip = explode("?", $strip);
    if (count($strip) > 0) {
        return $strip[0];
    }
    return NULL;
}
switch ($request_method) {
    case 'get':
        $result = $query->getResults(new stdClass());
        break;
    case 'put':
        $put = file_get_contents("php://input", 'r');
        $params = json_decode($put);
        $result = $query->updateRecords($params);
        break;
    case 'post':