/** * @param $name * @param $type * @param Datagrid $parent * @param array $options */ public function __construct($name, Datagrid $parent, array $options = []) { $this->name = $name; $this->parent = $parent; $this->datagridHelper = $this->parent->getDatagridHelper(); $this->setDefaultOptions($options); }
public function index() { $grid = new Datagrid('testgrid'); $dataSource = DataList::create("DatagridTest_Person")->sort("Name"); $grid->setDataSource($dataSource); $form = new Form($this, 'gridform', new FieldList($grid), new FieldList(new FormAction('rerender', 'rerender'))); return array('Form' => $form); }
public static function listUser() { $allUser = Admin_User::all(); $datagrid = new Datagrid(); $datagrid->setFields(array('userprofile/fullname' => 'Fullname')); $datagrid->setFields(array('userprofile/emel' => 'Email')); $datagrid->setFields(array('userprofile/icno' => 'IC Number')); $datagrid->setFields(array('status' => 'Status')); $datagrid->setAction('view', 'deleteRole', true, array('userid')); $datagrid->setAction('reset', 'deleteRole', true, array('userid')); $datagrid->setTable('users', 'table table-bordered table-hover table-striped table-condensed'); $datagrid->build($allUser, 'userid'); return $datagrid->render(); }
/** * Load a single DatagridColumnPreference object, * by DatagridId, DatagridColumnId, UserAccountId Index(es) * @param integer $intDatagridId * @param integer $intDatagridColumnId * @param integer $intUserAccountId * @return DatagridColumnPreference */ public static function LoadByDatagridShortDescriptionColumnNameUserAccountId($strDatagridShortDescription, $strColumnName, $intUserAccountId) { $objDatagrid = Datagrid::LoadByShortDescription($strDatagridShortDescription); if ($objDatagrid) { return DatagridColumnPreference::LoadByDatagridIdColumnNameUserAccountId($objDatagrid->DatagridId, $strColumnName, $intUserAccountId); } else { throw new Exception(sprintf('The datagrid %s is not represented in the datagrid table in the database', $strDatagridShortDescription)); } }
function filteredgrid() { $this->rapyd->load("datafilter", "datagrid"); function rtrunc($forma) { $pos = strpos($forma, "\r\n"); return substr($forma, 0, $pos); } $filter = new DataFilter("Filtro de Busqueda"); $filter->db->select(array("forma", 'nombre')); $filter->db->from("formatos"); $filter->db->orderby("nombre"); //$filter->db->where("forma LIKE"); $filter->nombre = new inputField("Nombre", "nombre"); $filter->nombre->size = 20; $filter->forma = new inputField("Forma", "forma"); $filter->forma->size = 20; $filter->buttons("reset", "search"); $filter->build(); $form = new DataForm("supervisor/puertosdir/filteredgrid/process"); $form->puerto = new inputField("Nuevo Puerto", "puerto"); $form->puerto->rule = "required"; $form->submit("btnsubmit", "Cambiar"); $form->build_form(); if ($form->on_success()) { echo 'pasamos'; } $grid = new Datagrid("Resultados"); $grid->use_function('rtrunc'); $link = site_url('/supervisor/acdatasis/activar'); $grid->per_page = 15; $grid->column("Nombre", "nombre"); $grid->column("Dirigido", "<rtrunc><#forma#></rtrunc>", 'align="center"'); $grid->build(); //echo $grid->db->last_query(); $ssql = json_encode($grid->db->last_query()); $data['script'] = "<script type='text/javascript'>\n\t\t\t\$(document).ready(function() {\n\t\t\t\tsql={$ssql};\n\t\t\t\t\n\t\t\t});\n\t\t\t</script>"; $data['content'] = $filter->output . $form->output . $grid->output; $data['title'] = "<h1>Redirección de puertos en formatos DataSIS</h1>"; $data["head"] = script("jquery.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
public static function listRole() { Bundle::start('datagrid'); $rolelist = Admin_UserRole::where('roleid', '<>', 1)->get(); $datagrid = new Datagrid(); $datagrid->setFields(array('roleid' => 'Role Id', 'role' => 'User Role Description')); $datagrid->setAction('edit', 'editRoleModal', true, array('roleid')); //false,array('id'=>'roleid','data-toggle'=>'modal')); $datagrid->setAction('delete', 'deleteRole', true, array('roleid')); $datagrid->setContainer('list01', 'span12'); $datagrid->setTable('users', 'table table-bordered table-hover table-striped table-condensed'); $datagrid->build($rolelist, 'roleid'); return $datagrid->render(); }
protected function SetupDatagrid() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intDatagridId = QApplication::QueryString('intDatagridId'); if ($intDatagridId) { $this->objDatagrid = Datagrid::Load($intDatagridId); if (!$this->objDatagrid) { throw new Exception('Could not find a Datagrid object with PK arguments: ' . $intDatagridId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objDatagrid = new Datagrid(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
protected function dtgDatagrid_Bind() { // Because we want to enable pagination AND sorting, we need to setup the $objClauses array to send to LoadAll() // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below $this->dtgDatagrid->TotalItemCount = Datagrid::CountAll(); // Setup the $objClauses Array $objClauses = array(); // 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->dtgDatagrid->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->dtgDatagrid->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be the array of all Datagrid objects, given the clauses above $this->dtgDatagrid->DataSource = Datagrid::LoadAll($objClauses); }
function proc($request_type = '') { $this->load->helper('url'); if ($action = Datagrid::getPostAction()) { $error = ""; switch ($action) { case 'delete': if (!$this->Datagrid->deletePostSelection()) { $error = 'Items could not be deleted'; } break; } if ($request_type != 'ajax') { $this->load->library('session'); $this->session->set_flashdata('form_error', $error); redirect('test/index'); } else { echo json_encode(array('error' => $error)); } } else { die("Bad Request"); } }
public static function listDetailsHistory($claimsId) { $allClaims = Claims_App::find($claimsId)->detail()->paginate(10); $datagrid = new Datagrid(); $datagrid->setFields(array('detaildate' => 'Date')); $datagrid->setFields(array('detaildesc' => 'Description')); $datagrid->setFields(array('detailfrom' => 'Distance From')); $datagrid->setFields(array('detailto' => 'Distance To')); $datagrid->setFields(array('detailmile' => 'Milage')); $datagrid->setFields(array('detailtoll' => 'Toll')); $datagrid->setFields(array('detailpark' => 'Parking')); $datagrid->setAction('receipt', 'uploadResit', true, array('claimdetailid')); $datagrid->setTable('claimsDetails', 'table table-bordered table-hover table-striped table-condensed'); $datagrid->build($allClaims, 'claimdetailid'); return $datagrid->render(); }
public function dtgDatagrid_Bind() { // Get Total Count b/c of Pagination $this->dtgDatagrid->TotalItemCount = Datagrid::CountAll(); $objClauses = array(); if ($objClause = $this->dtgDatagrid->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgDatagrid->LimitClause) { array_push($objClauses, $objClause); } $this->dtgDatagrid->DataSource = Datagrid::LoadAll($objClauses); }
public function createLink($page) { $routeLink = new RouteLink([$this->datagrid->getParamNameCurrentPage() => $page], $this->getRoute()); $routeLink->setValue($page); return $routeLink; }
.dg_form th{ background-color:gray; font-family:"Courier New", Courier, mono; font-size:12px; } .dg_form td{ background-color:gainsboro; font-size:12px; } .dg_form input[type=submit]{ margin-top:2px; } </style> <?php $this->Datagrid->hidePkCol(true); $this->Datagrid->setHeadings(array('email' => 'E-mail')); $this->Datagrid->ignoreFields(array('password')); if ($error = $this->session->flashdata('form_error')) { echo "<font color=red>{$error}</font>"; } echo form_open('test/proc', array('class' => 'dg_form')); echo $this->Datagrid->generate(); echo Datagrid::createButton('delete', 'Delete'); echo form_close(); ?> </body> </html>
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, Datagrid::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * 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 DatagridMetaControl * @param integer $intDatagridId primary key value * @param QMetaControlCreateType $intCreateType rules governing Datagrid object creation - defaults to CreateOrEdit * @return DatagridMetaControl */ public static function Create($objParentObject, $intDatagridId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intDatagridId)) { $objDatagrid = Datagrid::Load($intDatagridId); // Datagrid was found -- return it! if ($objDatagrid) { return new DatagridMetaControl($objParentObject, $objDatagrid); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a Datagrid object with PK arguments: ' . $intDatagridId); } } // 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 DatagridMetaControl($objParentObject, new Datagrid()); }
/** * Sort an array based datagrid */ private function _sortArray($a, $b) { if (empty(Datagrid::$orderby)) { Datagrid::$orderby = key($a); Datagrid::$orderdir = 1; // Ascending } // Ascending if (Datagrid::$orderby['direction']) { if ($a[Datagrid::$orderby['column']] > $b[Datagrid::$orderby['column']]) { return 1; } elseif ($a[Datagrid::$orderby['column']] < $b[Datagrid::$orderby['column']]) { return -1; } else { return 0; } // Descending } else { if ($a[Datagrid::$orderby['column']] > $b[Datagrid::$orderby['column']]) { return -1; } elseif ($a[Datagrid::$orderby['column']] < $b[Datagrid::$orderby['column']]) { return 1; } else { return 0; } } }
public function createLink($value) { $routeLink = new RouteLink([$this->datagrid->getParamNameMaxEntries() => $value], $this->getRoute()); $routeLink->setValue($value); return $routeLink; }
function copia($usua = null) { $this->rapyd->load("datafilter", "datagrid"); $usuario = $usua; function ractivo($acceso, $codigo) { if ($acceso == 'S') { $retorna = form_checkbox($codigo, 'accept', TRUE); } else { $retorna = form_checkbox($codigo, 'accept', FALSE); } return $retorna; } $filter = new DataFilter(""); $filter->db->select(array("b.modulo", 'b.codigo', "a.usuario", "a.usuario as value", "a.acceso", "b.titulo")); $filter->db->from("sida AS a"); $filter->db->join("tmenus AS b", "a.modulo=b.codigo"); $filter->db->orderby("b.modulo"); $filter->usuario = new dropdownField("Copiar de", "usuario"); $filter->usuario->options("Select us_codigo as value,CONCAT_WS(' - ', us_codigo, us_nombre) as codigo from usuario group by us_codigo"); $filter->usuario->style = 'width:250px;'; $filter->buttons("reset", "search"); $filter->build(); if ($this->rapyd->uri->is_set("search") and $filter->is_valid()) { $usr = $filter->usuario->newValue; $mSQL = "INSERT IGNORE INTO sida SELECT '{$usr}',b.codigo,'N' FROM sida AS a RIGHT JOIN tmenus AS b ON a.modulo=b.codigo AND a.usuario='{$usr}' WHERE a.modulo IS NULL"; $this->db->simple_query($mSQL); $copiar = anchor("supervisor/acdatasis/copiar/{$usr}/{$usuario}", 'Copiar'); $grid = new Datagrid("Resultados"); $grid->use_function('ractivo'); $link = site_url('/supervisor/acdatasis/activar'); //$grid->per_page = 15; $grid->column("Módulo", "modulo"); $grid->column("Nombre", "titulo"); $grid->column("Acceso", "<ractivo><#acceso#>|<#codigo#>|</ractivo>", 'align="center"'); $grid->build(); $tabla = $copiar . $grid->output; //echo $grid->db->last_query(); $url = site_url('supervisor/acdatasis/activar'); $data['script'] = '<script type="text/javascript"> $(document).ready(function() { $("form :checkbox").click(function () { usr=$("#usuario").attr("value"); $.ajax({type: "POST", url: "' . $url . '", data: "codigo="+this.name+"&usuario="+usr, success: function(msg){ if (msg==0) alert("Ocurrio un problema"); } }); }).change(); }); </script>'; } else { $tabla = ''; } $data['content'] = ' Usuario:' . $usuario . $filter->output . form_open('') . $tabla . form_close(); $data['title'] = "<h1>Copiar Accesos de Usuario en DataSIS</h1>"; $data["head"] = script("jquery.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objDatagrid) { $objObject->objDatagrid = Datagrid::GetSoapObjectFromObject($objObject->objDatagrid, false); } else { if (!$blnBindRelatedObjects) { $objObject->intDatagridId = null; } } if ($objObject->objUserAccount) { $objObject->objUserAccount = UserAccount::GetSoapObjectFromObject($objObject->objUserAccount, false); } else { if (!$blnBindRelatedObjects) { $objObject->intUserAccountId = null; } } return $objObject; }
protected function lstDatagrid_Create() { $this->lstDatagrid = new QListBox($this); $this->lstDatagrid->Name = QApplication::Translate('Datagrid'); $this->lstDatagrid->Required = true; if (!$this->blnEditMode) { $this->lstDatagrid->AddItem(QApplication::Translate('- Select One -'), null); } $objDatagridArray = Datagrid::LoadAll(); if ($objDatagridArray) { foreach ($objDatagridArray as $objDatagrid) { $objListItem = new QListItem($objDatagrid->__toString(), $objDatagrid->DatagridId); if ($this->objDatagridColumnPreference->Datagrid && $this->objDatagridColumnPreference->Datagrid->DatagridId == $objDatagrid->DatagridId) { $objListItem->Selected = true; } $this->lstDatagrid->AddItem($objListItem); } } }
/** * Internally called method to assist with early binding of objects * on load methods. Can only early-bind references that this class owns in the database. * @param string $strParentAlias the alias of the parent (if any) * @param string $strAlias the alias of this object * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding * @param QueryExpansion an already instantiated QueryExpansion object (used as a utility object to assist with object expansion) */ public static function ExpandQuery($strParentAlias, $strAlias, $objExpansionMap, QQueryExpansion $objQueryExpansion) { if ($strAlias) { $objQueryExpansion->AddFromItem(sprintf('LEFT JOIN `datagrid_column_preference` AS `%s__%s` ON `%s`.`%s` = `%s__%s`.`datagrid_column_preference_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`datagrid_column_preference_id` AS `%s__%s__datagrid_column_preference_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`datagrid_id` AS `%s__%s__datagrid_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`column_name` AS `%s__%s__column_name`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`user_account_id` AS `%s__%s__user_account_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`display_flag` AS `%s__%s__display_flag`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $strParentAlias = $strParentAlias . '__' . $strAlias; } if (is_array($objExpansionMap)) { foreach ($objExpansionMap as $strKey => $objValue) { switch ($strKey) { case 'datagrid_id': try { Datagrid::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'user_account_id': try { UserAccount::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: throw new QCallerException(sprintf('Unknown Object to Expand in %s: %s', $strParentAlias, $strKey)); } } } }
public function SaveDisplayPreference($strDatagridName) { $objDatagridColumnPreference = DatagridColumnPreference::LoadByDatagridShortDescriptionColumnNameUserAccountId($strDatagridName, $this->Name, QApplication::$objUserAccount->UserAccountId); if (!$objDatagridColumnPreference) { $objDatagridColumnPreference = new DatagridColumnPreference(); $objDatagrid = Datagrid::LoadByShortDescription($strDatagridName); if ($objDatagrid) { $objDatagridColumnPreference->DatagridId = $objDatagrid->DatagridId; } else { throw new Exception(sprintf("The datagrid %s is not represented in the database", $strDatagridName)); } $objDatagridColumnPreference->ColumnName = $this->Name; $objDatagridColumnPreference->UserAccountId = QApplication::$objUserAccount->UserAccountId; } $objDatagridColumnPreference->DisplayFlag = $this->Display; $objDatagridColumnPreference->Save(); }
/** * This is better tested in the DatagridFunctionalTest * * @see DatagridFunctionalTest */ function testFieldHolder() { $grid = new Datagrid('Testgrid'); $grid->setDatasource(new DataList('DatagridTest_Person')); $this->assertNotNull($grid->FieldHolder()); }
/** * Refresh this MetaControl with Data from the local DatagridColumnPreference object. * @param boolean $blnReload reload DatagridColumnPreference from the database * @return void */ public function Refresh($blnReload = false) { if ($blnReload) { $this->objDatagridColumnPreference->Reload(); } if ($this->lblDatagridColumnPreferenceId) { if ($this->blnEditMode) { $this->lblDatagridColumnPreferenceId->Text = $this->objDatagridColumnPreference->DatagridColumnPreferenceId; } } if ($this->lstDatagrid) { $this->lstDatagrid->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstDatagrid->AddItem(QApplication::Translate('- Select One -'), null); } $objDatagridArray = Datagrid::LoadAll(); if ($objDatagridArray) { foreach ($objDatagridArray as $objDatagrid) { $objListItem = new QListItem($objDatagrid->__toString(), $objDatagrid->DatagridId); if ($this->objDatagridColumnPreference->Datagrid && $this->objDatagridColumnPreference->Datagrid->DatagridId == $objDatagrid->DatagridId) { $objListItem->Selected = true; } $this->lstDatagrid->AddItem($objListItem); } } } if ($this->lblDatagridId) { $this->lblDatagridId->Text = $this->objDatagridColumnPreference->Datagrid ? $this->objDatagridColumnPreference->Datagrid->__toString() : null; } if ($this->txtColumnName) { $this->txtColumnName->Text = $this->objDatagridColumnPreference->ColumnName; } if ($this->lblColumnName) { $this->lblColumnName->Text = $this->objDatagridColumnPreference->ColumnName; } if ($this->lstUserAccount) { $this->lstUserAccount->RemoveAllItems(); if (!$this->blnEditMode) { $this->lstUserAccount->AddItem(QApplication::Translate('- Select One -'), null); } $objUserAccountArray = UserAccount::LoadAll(); if ($objUserAccountArray) { foreach ($objUserAccountArray as $objUserAccount) { $objListItem = new QListItem($objUserAccount->__toString(), $objUserAccount->UserAccountId); if ($this->objDatagridColumnPreference->UserAccount && $this->objDatagridColumnPreference->UserAccount->UserAccountId == $objUserAccount->UserAccountId) { $objListItem->Selected = true; } $this->lstUserAccount->AddItem($objListItem); } } } if ($this->lblUserAccountId) { $this->lblUserAccountId->Text = $this->objDatagridColumnPreference->UserAccount ? $this->objDatagridColumnPreference->UserAccount->__toString() : null; } if ($this->chkDisplayFlag) { $this->chkDisplayFlag->Checked = $this->objDatagridColumnPreference->DisplayFlag; } if ($this->lblDisplayFlag) { $this->lblDisplayFlag->Text = $this->objDatagridColumnPreference->DisplayFlag ? QApplication::Translate('Yes') : QApplication::Translate('No'); } }
/** * 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 = Datagrid::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 Datagrid, given the clauses above $this->DataSource = Datagrid::QueryArray($objCondition, $objClauses); }