This is a demo profile that you may find on BoonEx.

BoonEx mission is to Unite People and thus make the world a better place.

', 'AU', 'Castle Hill', '1981-03-31', 'boonex, community, unite, people', 10), (47, 'Bimbo', 'bambi@bumba.com', 'Unconfirmed', 1, '', '', '', '', 'Bomba', '0000-00-00', '', 3), (50, 'X-Man', 'x@man.me', 'Unconfirmed', 1, '', '', '', '', 'Movie City', '0000-00-00', '', 10); */ class BxGridMy extends BxTemplGrid { public function __construct ($aOptions, $oTemplate = false) { parent::__construct ($aOptions, $oTemplate); } /** * add js file for AJAX form submission */ protected function _addJsCss() { parent::_addJsCss(); $this->_oTemplate->addJs('jquery.form.min.js'); $oForm = new BxTemplFormView(array()); $oForm->addCssJs(); } /** * 'add' action handler */ public function performActionAdd() { $sAction = 'add'; $aForm = array( 'form_attrs' => array( 'id' => 'sample-add-form', 'action' => 'grid.php?' . bx_encode_url_params($_GET, array('ids', '_r')), // grid.php is usiversal actions handler file, we need to pass object and action names to it at least, or just all the params to preserve such states like filter and paginate 'method' => 'post', ), 'params' => array ( 'db' => array( 'table' => 'sample_grid_data', 'key' => 'ID', 'submit_name' => 'do_submit', ), ), 'inputs' => array( 'NickName' => array( 'type' => 'text', 'name' => 'NickName', 'caption' => _t('Username'), 'required' => true, 'checker' => array( 'func' => 'length', 'params' => array(1, 150), 'error' => _t( 'Username is required' ) ), 'db' => array ( 'pass' => 'Xss', ), ), 'Email' => array( 'type' => 'text', 'name' => 'Email', 'caption' => _t('Email'), 'required' => true, 'checker' => array( 'func' => 'email', 'error' => _t( '_Incorrect Email' ) ), 'db' => array ( 'pass' => 'Xss', ), ), 'City' => array( 'type' => 'text', 'name' => 'City', 'caption' => _t('City'), 'required' => true, 'checker' => array( 'func' => 'length', 'params' => array(1, 150), 'error' => _t( 'City is required' ) ), 'db' => array ( 'pass' => 'Xss', ), ), 'submit' => array( 'type' => 'input_set', 0 => array ( 'type' => 'submit', 'name' => 'do_submit', 'value' => _t('_Submit'), ), 1 => array ( 'type' => 'reset', 'name' => 'close', 'value' => _t('Close'), 'attrs' => array( 'onclick' => "$('.bx-popup-active').dolPopupHide()", 'class' => 'bx-def-margin-sec-left', ), ), ), ), ); $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { // if form is submitted and all fields are valid $iNewId = $oForm->insert (array(), true); // insert record to database if ($iNewId) $aRes = array('grid' => $this->getCode(false), 'blink' => $iNewId); // if record is successfully added, reload grid and highlight added row else $aRes = array('msg' => "Error occured"); // if record adding failed, display error message echoJson($aRes); } else { // if form is not submitted or some fields are invalid, display popup with form // we need to use 'transBox' function to properly display 'popup' $s = BxTemplFunctions::getInstance()->transBox('', '
' . $oForm->getCode() . '
'); echoJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false)))); } } /** * 'approve' action handler */ public function performActionApprove() { $iAffected = 0; $aIds = bx_get('ids'); if (!$aIds || !is_array($aIds)) { echoJson(array()); exit; } $aIdsAffected = array (); foreach ($aIds as $mixedId) { if (!$this->_approve($mixedId)) continue; $aIdsAffected[] = $mixedId; $iAffected++; } echoJson(array_merge( array( 'grid' => $this->getCode(false), 'blink' => $aIdsAffected, 'eval' => 'alert(22)', ), $iAffected ? array () : array('msg' => "Profile(s) activation failed") ) ); } /** * helper funtion for 'approve' action handler */ protected function _approve ($mixedId) { $oDb = BxDolDb::getInstance(); $sTable = $this->_aOptions['table']; $sFieldId = $this->_aOptions['field_id']; $sQuery = $oDb->prepare("UPDATE `{$sTable}` SET `Status` = 'Active' WHERE `{$sFieldId}` = ?", $mixedId); return $oDb->query($sQuery); } /** * custom cell look for 'Status' field */ protected function _getCellStatus ($mixedValue, $sKey, $aField, $aRow) { $sAttr = $this->_convertAttrs( $aField, 'attr_cell', false, isset($aField['width']) ? 'width:' . $aField['width'] : false // add default styles ); return '' . $mixedValue . ''; } /** * custom column header look for 'Status' field */ protected function _getCellHeaderStatus ($sKey, $aField) { $s = parent::_getCellHeaderDefault($sKey, $aField); return preg_replace ('/(.*?)<\/th>/', '', $s); } /** * custom behavior for 'custom1' action */ protected function _getActionCustom1 ($sType, $sKey, $a, $isSmall = false) { $sAttr = $this->_convertAttrs( $a, 'attr', 'bx-btn bx-def-margin-sec-left' . ($isSmall ? ' bx-btn-small' : '') // add default classes ); return ''; } } /** @} */