Esempio n. 1
0
 public function renderCalendar($element, $script = true, $echo = true)
 {
     $s = "";
     if ($script) {
         $s .= "<script type='text/javascript'>";
         $s .= "jQuery(document).ready(function() {";
     }
     $s .= "if(jQuery.ui) { if(jQuery.ui.datepicker) { ";
     if ($this->buttonIcon || $this->buttonOnly) {
         $s .= "jQuery('" . $element . "').after('<button>Calendar</button>').next()";
         $s .= ".button({icons:{primary: 'ui-icon-calendar'}, text:false})";
         $s .= ".css({'font-size':'" . $this->fontsize . "'})";
         $s .= ".click(function(e){jQuery('" . $element . "').datepicker('show');return false;});";
     }
     if ($this->buttonOnly) {
         $this->setOption('showOn', 'button');
     }
     $s .= "jQuery('" . $element . "').datepicker(" . jqGridUtils::encode($this->coptions) . ");";
     if ($this->buttonOnly) {
         // delete the auto generated button.
         $s .= "jQuery('.ui-datepicker-trigger').remove();";
     }
     $s .= "jQuery('.ui-datepicker').css({'font-size':'" . $this->fontsize . "'});";
     $s .= "} }";
     if ($script) {
         $s .= " });</script>";
     }
     if ($echo) {
         echo $s;
     } else {
         return $s;
     }
 }
Esempio n. 2
0
    /**
     * Main method which do allmost everthing for the grid.
     * Construct the grid, perform CRUD operations, perform Query and serch operations,
     * export to excel, set a jqGrid method, and javascript code
     * @param string $tblelement the id of the table element to costrict the grid
     * @param string $pager the id for the pager element
     * @param boolean $script if set to true add a script tag before constructin the grid.
     * @param array $summary - set which columns should be sumarized in order to be displayed to the grid
     * By default this parameter uses SQL SUM function: array("colmodelname"=>"sqlname");
     * It can be set to use other one this way :
     * array("colmodelname"=>array("sqlname"=>"AVG"));
     * By default the first field correspond to the name of colModel the second to
     * the database name
     * @param array $params parameters passed to the query
     * @param boolean $createtbl if set to true the table element is created automatically
     * from this method. Default is false
     * @param boolean $createpg if set to true the pager element is created automatically
     * from this script. Default false.
     * @param boolean $echo if set to false the function return the string representing
     * the grid
     * @return mixed.
     */
    public function renderGrid($tblelement = '', $pager = '', $script = true, array $summary = null, array $params = null, $createtbl = false, $createpg = false, $echo = true)
    {
        $oper = $this->GridParams["oper"];
        $goper = $this->oper ? $this->oper : 'nooper';
        if ($goper == $this->GridParams["autocomplete"]) {
            return false;
        } else {
            if ($goper == $this->GridParams["excel"]) {
                if (!$this->export) {
                    return false;
                }
                $this->exportToExcel($summary, $params, $this->colModel, true, $this->exportfile);
            } else {
                if ($goper == "pdf") {
                    if (!$this->export) {
                        return false;
                    }
                    $this->exportToPdf($summary, $params, $this->colModel, $this->pdffile);
                } else {
                    if ($goper == "csv") {
                        if (!$this->export) {
                            return false;
                        }
                        $this->exportToCsv($summary, $params, $this->colModel, true, $this->csvfile, $this->csvsep, $this->csvsepreplace);
                    } else {
                        if (in_array($goper, array_values($this->GridParams))) {
                            if ($this->inlineNav) {
                                $this->getLastInsert = true;
                            }
                            return $this->editGrid($summary, $params, $goper, $echo);
                        } else {
                            if (!isset($this->gridOptions["datatype"])) {
                                $this->gridOptions["datatype"] = $this->dataType;
                            }
                            // hack for editable=true as default
                            $ed = true;
                            if (isset($this->gridOptions['cmTemplate'])) {
                                $edt = $this->gridOptions['cmTemplate'];
                                $ed = isset($edt['editable']) ? $edt['editable'] : true;
                            }
                            foreach ($this->colModel as $k => $cm) {
                                if (!isset($this->colModel[$k]['editable'])) {
                                    $this->colModel[$k]['editable'] = $ed;
                                }
                            }
                            $this->gridOptions['colModel'] = $this->colModel;
                            if (isset($this->gridOptions['postData'])) {
                                $this->gridOptions['postData'] = jqGridUtils::array_extend($this->gridOptions['postData'], array($oper => $this->GridParams["query"]));
                            } else {
                                $this->setGridOptions(array("postData" => array($oper => $this->GridParams["query"])));
                            }
                            if (isset($this->primaryKey)) {
                                $this->GridParams["id"] = $this->primaryKey;
                            }
                            $this->setGridOptions(array("prmNames" => $this->GridParams));
                            $s = '';
                            if ($createtbl) {
                                $tmptbl = $tblelement;
                                if (strpos($tblelement, "#") === false) {
                                    $tblelement = "#" . $tblelement;
                                } else {
                                    $tmptbl = substr($tblelement, 1);
                                }
                                $s .= "<table id='" . $tmptbl . "'></table>";
                            }
                            if (strlen($pager) > 0) {
                                $tmppg = $pager;
                                if (strpos($pager, "#") === false) {
                                    $pager = "#" . $pager;
                                } else {
                                    $tmppg = substr($pager, 1);
                                }
                                if ($createpg) {
                                    $s .= "<div id='" . $tmppg . "'></div>";
                                }
                            }
                            // set the Error handler for data
                            if (!isset($this->gridOptions['loadError'])) {
                                $err = "function(xhr,status, err){ try {jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,'<div class=\"ui-state-error\">'+ xhr.responseText +'</div>', jQuery.jgrid.edit.bClose,{buttonalign:'right'});} catch(e) { alert(xhr.responseText);} }";
                                $this->setGridEvent('loadError', $err);
                            }
                            //if(!isset($this->editOptions['mtype']) && $this->showError) {
                            //$this->setNavEvent('edit', 'afterSubmit', "function(res,pdata){ var result = res.responseText.split('#'); if(result[0]=='$this->successmsg') return [true,result[1],result[2]]; else return [false,result[1],'']; }");
                            //}
                            //if(!isset($this->addOptions['mtype']) && $this->showError) {
                            //$this->setNavEvent('add', 'afterSubmit', "function(res,pdata){ var result = res.responseText.split('#'); if(result[0]=='$this->successmsg') return [true,result[1],result[2]]; else return [false,result[1],''];}");
                            //}
                            if (strlen($pager) > 0) {
                                $this->setGridOptions(array("pager" => $pager));
                            }
                            //$this->editOptions['mtype'] = $this->mtype;
                            //$this->addOptions['mtype'] = $this->mtype;
                            //$this->delOptions['mtype'] = $this->mtype;
                            if ($this->sharedEditOptions == true) {
                                $this->gridOptions['editOptions'] = $this->editOptions;
                            }
                            if ($this->sharedAddOptions == true) {
                                $this->gridOptions['addOptions'] = $this->addOptions;
                            }
                            if ($this->sharedDelOptions == true) {
                                $this->gridOptions['delOptions'] = $this->delOptions;
                            }
                            if ($script) {
                                $s .= "<script type='text/javascript'>";
                                $s .= "jQuery(document).ready(function(\$) {";
                            }
                            $s .= "jQuery('" . $tblelement . "').jqGrid(" . jqGridUtils::encode($this->gridOptions) . ");";
                            if ($this->navigator && strlen($pager) > 0) {
                                $s .= "jQuery('" . $tblelement . "').jqGrid('navGrid','" . $pager . "'," . jqGridUtils::encode($this->navOptions);
                                $s .= "," . jqGridUtils::encode($this->editOptions);
                                $s .= "," . jqGridUtils::encode($this->addOptions);
                                $s .= "," . jqGridUtils::encode($this->delOptions);
                                $s .= "," . jqGridUtils::encode($this->searchOptions);
                                $s .= "," . jqGridUtils::encode($this->viewOptions) . ");";
                                if ($this->navOptions["excel"] == true) {
                                    $eurl = $this->getGridOption('url');
                                    $exexcel = <<<EXCELE
onClickButton : function(e)
{
\ttry {
\t\tjQuery("{$tblelement}").jqGrid('excelExport',{tag:'excel', url:'{$eurl}'});
\t} catch (e) {
\t\twindow.location= '{$eurl}?oper=excel';
\t}
}
EXCELE;
                                    $s .= "jQuery('" . $tblelement . "').jqGrid('navButtonAdd','" . $pager . "',{id:'" . $tmppg . "_excel', caption:'" . $this->expoptions['excel']['caption'] . "',title:'" . $this->expoptions['excel']['title'] . "'," . $exexcel . ",buttonicon:'" . $this->expoptions['excel']['buttonicon'] . "'});";
                                }
                                if ($this->navOptions["pdf"] == true) {
                                    $eurl = $this->getGridOption('url');
                                    $expdf = <<<PDFE
onClickButton : function(e)
{
\ttry {
\t\tjQuery("{$tblelement}").jqGrid('excelExport',{tag:'pdf', url:'{$eurl}'});
\t} catch (e) {
\t\twindow.location= '{$eurl}?oper=pdf';
\t}
}
PDFE;
                                    $s .= "jQuery('" . $tblelement . "').jqGrid('navButtonAdd','" . $pager . "',{id:'" . $tmppg . "_pdf',caption:'" . $this->expoptions['pdf']['caption'] . "',title:'" . $this->expoptions['pdf']['title'] . "'," . $expdf . ", buttonicon:'" . $this->expoptions['pdf']['buttonicon'] . "'});";
                                }
                                if ($this->navOptions["csv"] == true) {
                                    $eurl = $this->getGridOption('url');
                                    $excsv = <<<CSVE
onClickButton : function(e)
{
\ttry {
\t\tjQuery("{$tblelement}").jqGrid('excelExport',{tag:'csv', url:'{$eurl}'});
\t} catch (e) {
\t\twindow.location= '{$eurl}?oper=csv';
\t}
}
CSVE;
                                    $s .= "jQuery('" . $tblelement . "').jqGrid('navButtonAdd','" . $pager . "',{id:'" . $tmppg . "_csv',caption:'" . $this->expoptions['csv']['caption'] . "',title:'" . $this->expoptions['csv']['title'] . "'," . $excsv . ",buttonicon:'" . $this->expoptions['csv']['buttonicon'] . "'});";
                                }
                                if ($this->navOptions["columns"] == true) {
                                    $clopt = jqGridUtils::encode($this->expoptions['columns']['options']);
                                    $excolumns = <<<COLUMNS
onClickButton : function(e)
{
\tjQuery("{$tblelement}").jqGrid('columnChooser',{$clopt});
}
COLUMNS;
                                    $s .= "jQuery('" . $tblelement . "').jqGrid('navButtonAdd','" . $pager . "',{id:'" . $tmppg . "_col',caption:'" . $this->expoptions['columns']['caption'] . "',title:'" . $this->expoptions['columns']['title'] . "'," . $excolumns . ",buttonicon:'" . $this->expoptions['columns']['buttonicon'] . "'});";
                                }
                            }
                            // inline navigator
                            if ($this->inlineNav && strlen($pager) > 0) {
                                $aftersave = <<<AFTERS
function (id, res)
{
\tres = res.responseText.split("#");
\ttry {
\t\t\$(this).jqGrid('setCell', id, res[0], res[1]);
\t\t\$("#"+id, "#"+this.p.id).removeClass("jqgrid-new-row").attr("id",res[1] );
\t\t\$(this)[0].p.selrow = res[1];
\t} catch (asr) {}
}
AFTERS;
                                $this->inlineNavOpt['addParams'] = jqGridUtils::array_extend($this->inlineNavOpt['addParams'], array("aftersavefunc" => "js:" . $aftersave));
                                $this->inlineNavOpt['editParams'] = jqGridUtils::array_extend($this->inlineNavOpt['editParams'], array("aftersavefunc" => "js:" . $aftersave));
                                $s .= "jQuery('" . $tblelement . "').jqGrid('inlineNav','" . $pager . "'," . jqGridUtils::encode($this->inlineNavOpt) . ");\n";
                            }
                            // toolbar filter
                            if ($this->toolbarfilter) {
                                $s .= "jQuery('" . $tblelement . "').jqGrid('filterToolbar'," . jqGridUtils::encode($this->filterOptions) . ");\n";
                            }
                            // grid methods
                            $gM = count($this->gridMethods);
                            if ($gM > 0) {
                                for ($i = 0; $i < $gM; $i++) {
                                    $s .= $this->gridMethods[$i] . "\n";
                                }
                            }
                            //at end the custom code
                            if (strlen($this->customCode) > 0) {
                                $s .= jqGridUtils::encode($this->customCode);
                            }
                            if ($script) {
                                $s .= " });</script>";
                            }
                            if ($echo) {
                                echo $s;
                            }
                            return $echo ? "" : $s;
                        }
                    }
                }
            }
        }
    }
Esempio n. 3
0
<?php

require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH . "php/jqGrid.php";
// include the driver class
require_once ABSPATH . "php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Get the needed parameters passed from the main grid
$rowid = jqGridUtils::GetParam("id");
if (!$rowid) {
    die("Missed parameters");
}
// Create the base jqGrid instance
$grid = new jqGrid($conn);
// Write the SQL Query
$grid->SubgridCommand = "SELECT OrderID, RequiredDate, ShipName, ShipCity, Freight FROM orders WHERE CustomerID=? ORDER BY OrderID desc";
// set the ouput format to json
$grid->dataType = 'json';
// Use the build in function for the simple subgrid
$grid->querySubGrid(array(&$rowid));
$conn = null;
Esempio n. 4
0
        $str .= "BSE;" . "\n";
    }
}
if (isset($otherset['ajax_success'])) {
    if (trim($otherset['ajax_success'])) {
        $str .= "\$" . "success = <<< SU" . "\n";
        $str .= "function( response, status, xhr) {" . "\n";
        $str .= html_entity_decode($otherset['ajax_success']) . "\n";
        $str .= "}" . "\n";
        $str .= "SU;" . "\n";
    }
}
$ajax = "array(";
if (isset($otherset['ajax_data'])) {
    if (trim($otherset['ajax_data'])) {
        $apr = jqGridUtils::decode("{" . $otherset['ajax_data'] . "}");
        $new_array = array_map(create_function('$key, $value', 'return "\\"". $key."\\" => \\"".$value."\\" ";'), array_keys($apr), array_values($apr));
        $ajax .= "'data'=>array(" . implode($new_array, ",") . ")," . "\n";
    }
}
if (isset($otherset['ajax_dataType'])) {
    if ($otherset['ajax_dataType']) {
        if ($otherset['ajax_dataType'] == 'null') {
            $ajax .= "'dataType'=>" . $otherset['ajax_dataType'] . "," . "\n";
        } else {
            $ajax .= "'dataType'=>'" . $otherset['ajax_dataType'] . "'," . "\n";
        }
    }
}
if (isset($otherset['ajax_resetForm'])) {
    if ($otherset['ajax_resetForm']) {
Esempio n. 5
0
<?php

require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH . "php/jqGrid.php";
// include the driver class
require_once ABSPATH . "php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Get the needed parameters passed from the main grid
$subtable = jqGridUtils::Strip($_REQUEST["subgrid"]);
$rowid = jqGridUtils::Strip($_REQUEST["rowid"]);
if (!$subtable && !$rowid) {
    die("Missed parameters");
}
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = "SELECT OrderID, ProductID, Quantity, UnitPrice FROM order_details WHERE OrderID=?";
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel(null, array(&$rowid));
// Set the url from where we obtain the data
$grid->setUrl('subsubgrid.php');
// Set some grid options
$grid->setGridOptions(array("width" => 480, "rowNum" => 10, "sortname" => "OrderID", "height" => 'auto', "postData" => array("subgrid" => $subtable, "rowid" => $rowid)));
// Change some property of the field(s)
$grid->navigator = true;
Esempio n. 6
0
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// this table is 1252 encoded, so we need to tell the grid
// Set the table data source
$grid->setTable('products');
// set the ouput format to xml since json have problems
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
// Set some grid options
//get the height passed as parameter
$height = jqGridUtils::GetParam('gridheigh', '200');
$grid->setGridOptions(array("rowNum" => 10, "rowList" => array(10, 20, 30), "sortname" => "ProductID", "height" => $height, "shrinkToFit" => false, "hoverrows" => true));
$grid->setColProperty("ProductID", array("width" => 80));
// We can hide some columns
$grid->setColProperty("SupplierID", array("hidden" => true));
$grid->setColProperty("CategoryID", array("hidden" => true));
$grid->setColProperty("UnitsOnOrder", array("hidden" => true));
$grid->setColProperty("ReorderLevel", array("hidden" => true));
$grid->setColProperty("Discontinued", array("hidden" => true));
// Enable toolbar searching
$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult" => true));
// Enjoy
$grid->renderGrid('#grid', '#pager', true, null, null, true, true);
$conn = null;
Esempio n. 7
0
include_once 'jqformconfig.php';
include_once $CODE_PATH . 'jqUtils.php';
include_once $CODE_PATH . 'jqForm.php';
// Create instance
$newForm = new jqForm('newForm', array('method' => 'post', 'id' => 'newForm'));
// Demo Mode creating connection
include_once $CODE_PATH . 'jqGridPdo.php';
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
$newForm->setConnection($conn);
// Set url
$newForm->setUrl($SERVER_HOST . $SELF_PATH . 'sqlcheckdata.php');
// Set Form header
$formhead = 'Edit Ship Details';
$newForm->setFormHeader($formhead, 'ui-icon-pencil');
// Set parameters
$Order = jqGridUtils::GetParam('Order', '10254');
$Order = is_numeric($Order) ? (int) $Order : 0;
$jqformparams = array($Order);
// Set SQL Command, table, keys
$newForm->SelectCommand = 'SELECT OrderID, ShipName, ShipAddress, ShipCity, ShipPostalCode, ShipCountry, Freight FROM orders WHERE OrderID = ?';
$newForm->table = 'orders';
$newForm->setPrimaryKeys('OrderID');
$newForm->serialKey = true;
// Set Form layout
$newForm->setColumnLayout('twocolumn');
$newForm->setTableStyles('width:580px;', '', '');
// Add elements
$newForm->addElement('OrderID', 'hidden', array('label' => 'OrderID', 'id' => 'newForm_OrderID'));
$newForm->addElement('ShipName', 'text', array('label' => 'ShipName', 'maxlength' => '40', 'style' => 'width:98%;', 'id' => 'newForm_ShipName'));
$newForm->addElement('ShipAddress', 'text', array('label' => 'ShipAddress', 'maxlength' => '60', 'style' => 'width:98%;', 'id' => 'newForm_ShipAddress'));
$newForm->addElement('ShipCity', 'text', array('label' => 'ShipCity', 'maxlength' => '15', 'size' => '20', 'id' => 'newForm_ShipCity'));
Esempio n. 8
0
<?php

require_once '../../../jq-config.php';
require_once ABSPATH . "php/jqUtils.php";
require_once ABSPATH . "php/jqChart.php";
ini_set("display_errors", "1");
$data = array(array("y" => 55.11, "color" => "js:colors[0]", "drilldown" => array("name" => 'MSIE versions', "categories" => array('MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'), "data" => array(10.85, 7.35, 33.06, 2.81), "color" => "js:colors[0]")), array("y" => 21.63, "color" => "js:colors[1]", "drilldown" => array("name" => 'Firefox versions', "categories" => array('Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'), "data" => array(0.2, 0.83, 1.58, 13.12, 5.43), "color" => "js:colors[1]")), array("y" => 11.94, "color" => "js:colors[2]", "drilldown" => array("name" => 'Chrome versions', "categories" => array('Chrome 5.0', 'Chrome 6.0', 'Chrome 7.0', 'Chrome 8.0', 'Chrome 9.0', 'Chrome 10.0', 'Chrome 11.0', 'Chrome 12.0'), "data" => array(0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.5, 0.22), "color" => "js:colors[2]")), array("y" => 7.15, "color" => "js:colors[3]", "drilldown" => array("name" => 'Safari versions', "categories" => array('Safari 5.0', 'Safari 4.0', 'Safari Win 5.0', 'Safari 4.1', 'Safari/Maxthon', 'Safari 3.1', 'Safari 4.1'), "data" => array(4.55, 1.42, 0.23, 0.21, 0.2, 0.19, 0.14), "color" => "js:colors[3]")));
$sdata = jqGridUtils::encode($data);
$click = <<<CLICK
function(){
\tvar drilldown = this.drilldown; 
\tif (drilldown) { 
\t\tsetChart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color);
\t} else {
\t\tsetChart(name, categories, {$sdata});
\t}
}
CLICK;
$chart = new jqChart();
$chart->setChartOptions(array("defaultSeriesType" => "column"))->setTitle(array('text' => 'Browser market share, April, 2011'))->setSubtitle(array("text" => "Click the columns to view versions. Click again to view brands."))->setxAxis(array("categories" => array('MSIE', 'Firefox', 'Chrome', 'Safari', 'Opera')))->setyAxis(array("title" => array("text" => "Total percent market share")))->setTooltip(array("formatter" => "function(){var point = this.point, s = this.x +':<b>'+ this.y +'% market share</b><br/>'; if (point.drilldown) {s += 'Click to view '+ point.category +' versions';} else {s += 'Click to return to browser brands';} return s;}"))->setPlotOptions(array("column" => array("cursor" => 'pointer', "point" => array("events" => array("click" => "js:" . $click), "dataLabels" => array("enabled" => true, "color" => "js:Highcharts.getOptions().colors[0]", "style" => array("fontWeight" => 'bold'), "formatter" => "js:function(){return this.y +'%';}")))))->addSeries('Browser brands', $data);
$setser = <<<SETSER
function setChart(name, categories, data, color) {
\tchart.xAxis[0].setCategories(categories);
\tchart.series[0].remove();
\tchart.addSeries({
\t\tname: name,
\t\tdata: data,
\t\tcolor: color || 'white'
     });
}
SETSER;
Esempio n. 9
0
 /**
  * Internal function which generates regex pattern from date pattern
  *
  * @param string $dateformat
  * @return string
  */
 public static function generatePattern($dateformat)
 {
     $k = 0;
     $datearray = preg_split("//", $dateformat);
     $patternkey = array();
     self::$patrVal = "";
     for ($i = 0; $i < count($datearray); $i++) {
         if (isset($datearray[$i - 1]) && $datearray[$i - 1] == "@") {
             $patternkey[$i] = $datearray[$i];
         } elseif ($datearray[$i] == "@") {
             $patternkey[$i] = "";
         } elseif ($datearray[$i] == " ") {
             $patternkey[$i] = " ";
         } elseif (in_array($datearray[$i], array_keys(self::$types))) {
             $patternkey[$i] = self::$types[$datearray[$i]];
             self::$patrVal[$k] = array_search($datearray[$i], array_keys(self::$types));
             $k++;
         } else {
             $patternkey[$i] = $datearray[$i];
         }
     }
     $patternkey = implode("", $patternkey);
     return "/" . $patternkey . "/";
 }
Esempio n. 10
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once '../php/jqUtils.php';
$myFile = jqGridUtils::GetParam('fname');
$r = "";
if (file_exists($myFile)) {
    if (is_writable($myFile)) {
        $r = save_server($myFile);
    } else {
        $r = "File is not Writtable";
    }
} else {
    $r = save_server($myFile);
}
echo $r;
function getRealPOST()
{
    $pairs = explode("&", file_get_contents("php://input"));
    $vars = array();
    foreach ($pairs as $pair) {
        $nv = explode("=", $pair);
        $name = urldecode($nv[0]);
        $value = urldecode($nv[1]);
        $vars[$name] = $value;
    }
    return $vars;
}
Esempio n. 11
0
<?php

require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH . "php/jqGrid.php";
// include the driver class
require_once ABSPATH . "php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Get the needed parameters passed from the main grid
if (isset($_REQUEST["CustomerID"])) {
    $rowid = jqGridUtils::Strip($_REQUEST["CustomerID"]);
} else {
    $rowid = "";
}
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = "SELECT OrderID, RequiredDate, ShipName, ShipCity, Freight FROM orders WHERE CustomerID= ?";
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel(null, array(&$rowid));
// Set the url from where we obtain the data
$grid->setUrl('detail.php');
// Set some grid options
$grid->setGridOptions(array("rowNum" => 10, "footerrow" => true, "userDataOnFooter" => true, "sortname" => "OrderID", "height" => 110));
// Change some property of the field(s)
$grid->setColProperty("RequiredDate", array("formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y"), "search" => false));
Esempio n. 12
0
    /**
     * Main method which do everthing for the autocomplete. Should be called
     * after all settings are done. Note that in one file we can have more than
     * one autocomplete definitions.
     * Construct the autocomplete and perform Query operations.
     * @param string $element The DOM element on which audocomplete should be
     * applied
     * @param <type> $target - if set the value selection from autocomplete
     * will be set to this element
     * @param boolean $script - if set to false the script tag:
     * <script type='text/javascript'> will not be included.
     * @param boolean $echo if set to false the result is not echoed but returned
     * @param boolean $runme - internal variable used into the jqGrid class
     * @return string 
     */
    public function renderAutocomplete($element, $target = false, $script = true, $echo = true, $runme = true)
    {
        if ($this->runAll && $runme) {
            $this->_setSrc($element);
            $s = "";
            if ($script) {
                $s .= "<script type='text/javascript'>";
                $s .= "jQuery(document).ready(function() {";
            }
            if ($this->cache) {
                $s .= "var {$this->cachearray} = {};";
            }
            if ($target) {
                $trg = <<<TARGET
function (event, ui)
{
\t// change function to set target value
\tvar ival;
\tif(ui.item) {
\t\tival = ui.item.id || ui.item.value;
\t}
\tif(ival) {
\t\tjQuery("{$target}").val(ival);
\t} else {
\t\tjQuery("{$target}").val("");
\t\tif("{$this->strictcheck}" == "true"){
\t\tthis.value = "";
\t}
}
}
TARGET;
                $this->setOption('change', "js:" . $trg);
            }
            $s .= "if(jQuery.ui) { if(jQuery.ui.autocomplete){";
            $s .= "jQuery('" . $element . "').autocomplete(" . jqGridUtils::encode($this->aoptions) . ");";
            $s .= "jQuery('" . $element . "').autocomplete('widget').css('font-size','" . $this->fontsize . "');";
            if ($this->scroll) {
                $s .= "jQuery('" . $element . "').autocomplete('widget').css({'height':'{$this->height}','overflow-y':'auto'});";
            }
            $s .= "} }";
            if ($script) {
                $s .= " });</script>";
            }
            if ($echo) {
                echo $s;
            } else {
                return $s;
            }
        } else {
            if (trim($this->element) === trim($element)) {
                header("Content-type: text/x-json;charset=" . $this->encoding);
                if (function_exists('json_encode') && strtolower($this->encoding) == 'utf-8') {
                    echo json_encode($this->getACData());
                } else {
                    echo jqGridUtils::encode($this->getACData());
                }
            }
        }
    }
Esempio n. 13
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once 'connections.php';
include_once '../php/jqUtils.php';
$connstr = jqGridUtils::GetParam('conn');
$dbtype = jqGridUtils::GetParam('dbtype');
$action = jqGridUtils::GetParam('action');
$sqlstr = jqGridUtils::GetParam('sqlstring');
//var_dump($sqlstr);
if ($action == 'test') {
    if ($dbtype == 'mysql' || $dbtype == 'pgsql' || $dbtype == 'sqlite') {
        echo pdo_test_connection($connstr, $dbtype);
    }
}
//	var_dump($action);
if ($action == 'genform') {
    if ($dbtype == 'mysql' || $dbtype == 'pgsql' || $dbtype == 'sqlite') {
        include '../php/jqGridPdo.php';
        ini_set("display_errors", 1);
        $info = parse_connection_string($connstr);
        try {
            $conn = new PDO($dbtype . ':host=' . $info->host . ';dbname=' . $info->database, $info->user_id, $info->password);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $sqlstr = jqGridDB::limit($sqlstr, $dbtype, 1, 0);
            //var_dump($sqlstr);
            $stmt = jqGridDB::prepare($conn, $sqlstr, null);
            $ret = jqGridDB::execute($stmt);
Esempio n. 14
0
 public static function _mongoSearch($mongoquery, $GridParams = array(), $encoding = 'utf-8', $datearray = array(), $mongointegers = array())
 {
     $s = '';
     $v = array();
     $sopt = array('eq' => '===', 'ne' => '!==', 'lt' => '<', 'le' => '<=', 'gt' => '>', 'ge' => '>=', 'bw' => "", 'bn' => "", 'in' => '==', 'ni' => '!=', 'ew' => '', 'en' => '', 'cn' => '', 'nc' => '');
     $filters = jqGridUtils::GetParam($GridParams["filter"], "");
     $rules = "";
     // multiple filter
     if ($filters) {
         if (function_exists('json_decode') && strtolower(trim($encoding)) == "utf-8") {
             $jsona = json_decode($filters, true);
         } else {
             $jsona = jqGridUtils::decode($filters);
         }
         if (is_array($jsona)) {
             $gopr = strtolower(trim($jsona['groupOp']));
             $rules = $jsona['rules'];
         }
         // single filter
     } else {
         if (jqGridUtils::GetParam($GridParams['searchField'], '')) {
             $gopr = 'or';
             $rules[0]['field'] = jqGridUtils::GetParam($GridParams['searchField'], '');
             $rules[0]['op'] = jqGridUtils::GetParam($GridParams['searchOper'], '');
             $rules[0]['data'] = jqGridUtils::GetParam($GridParams['searchString'], '');
         }
     }
     if ($gopr == 'or') {
         $gopr = ' || ';
     } else {
         $gopr = ' && ';
     }
     $i = 0;
     if (!is_array($mongoquery)) {
         $mongoquery = array();
     }
     foreach ($rules as $key => $val) {
         $field = $val['field'];
         $op = $val['op'];
         $v = $val['data'];
         if (strlen($v) != 0 && $op) {
             $string = true;
             if (in_array($field, $datearray)) {
                 $av = explode(",", jqGridUtils::parseDate('d/m/Y H:i:s', $v, 'Y,m,d,H,i,s'));
                 $av[1] = (int) $av[1] - 1;
                 $v = "new Date(" . implode(",", $av) . ")";
                 $string = false;
             }
             if (in_array($field, $mongointegers)) {
                 $string = false;
             }
             $i++;
             if ($i > 1) {
                 $s .= $gopr;
             }
             switch ($op) {
                 case 'bw':
                     $s .= "this." . $field . ".match(/^{$v}.*\$/i)";
                     break;
                 case 'bn':
                     $s .= "!this." . $field . ".match(/^{$v}.*\$/i)";
                     break;
                 case 'ew':
                     $s .= "this." . $field . ".match(/^.*{$v}\$/i)";
                     break;
                 case 'en':
                     $s .= "!this." . $field . ".match(/^.*{$v}\$/i)";
                     break;
                 case 'cn':
                     $s .= "this." . $field . ".match(/^.*{$v}.*\$/i)";
                     break;
                 case 'nc':
                     $s .= "!this." . $field . ".match(/^.*{$v}.*\$/i)";
                     break;
                 default:
                     if ($string) {
                         $v = "'" . $v . "'";
                     }
                     $s .= " this." . $field . " " . $sopt[$op] . $v;
                     break;
             }
         }
     }
     if (isset($mongoquery) && is_array($mongoquery)) {
         $mongoquery = jqGridUtils::array_extend($mongoquery, array('$where' => "function(){ return " . $s . ";}"));
     } else {
         $mongoquery = array('$where' => "function(){ return " . $s . ";}");
     }
     return $mongoquery;
 }
Esempio n. 15
0
<?php

require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH . "php/jqGrid.php";
// include the driver class
require_once ABSPATH . "php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN, DB_USER, DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Get the needed parameters passed from the main grid
$rowid = jqGridUtils::GetParam('EmployeeID', 0);
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = "SELECT OrderID, RequiredDate, ShipName, ShipCity, Freight, EmployeeID FROM orders WHERE EmployeeID= ?";
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setPrimaryKeyId('OrderID');
$grid->setColModel(null, array((int) $rowid));
// Set the url from where we obtain the data
$grid->setUrl('detail.php');
// Set some grid options
$grid->setGridOptions(array("rowNum" => 10, "footerrow" => true, "userDataOnFooter" => true, "sortname" => "OrderID", "height" => 110));
// Change some property of the field(s)
$grid->setColProperty("RequiredDate", array("formatter" => "date", "formatoptions" => array("srcformat" => "Y-m-d H:i:s", "newformat" => "m/d/Y"), "search" => false));
// on beforeshow form when add we get the customer id and set it for posting
$beforeshow = <<<BEFORE
function(formid)
Esempio n. 16
0
 /**
  * Main method which construct the chart based on the options set
  * with the previous methods
  *
  * @param string $div_id the id of the chart element in the DOM. If empty
  * the default name 'jqchart' is used.
  * @param boolean $createlem if set to true a div element is created. If the
  * option is set to false the previous option should be set in order to render
  * the chart to a existing element.
  * @param mixed $width set the width of the chart. If  a number is used the
  * width is created in pixels. Have sense only if $createlem is true
  * @param <type> $height set the height of the chart. If  a number is used the
  * height is created in pixels. Have sense only if $createlem is true
  * @param string $chart the name which is used when a javascript chart object
  * is created. Can be used later to refer to the chart. The default
  * name is 'chart'
  *
  * @return string
  */
 public function renderChart($div_id = '', $createlem = true, $width = '800', $height = '400', $chart = 'chart')
 {
     if ($div_id == '') {
         $div_id = 'jqchart';
     }
     $this->coptions['chart']['renderTo'] = $div_id;
     $width = is_numeric($width) ? $width . 'px' : $width;
     $height = is_numeric($height) ? $height . 'px' : $height;
     $dim = "width:" . $width . ";height:" . $height . ";margin: 0 auto;";
     $s = "";
     if ($createlem) {
         $s .= '<div id="' . $div_id . '" style="' . $dim . '"></div>';
     }
     $s .= '<script type="text/javascript">';
     $s .= 'jQuery(document).ready(function(){';
     if ($this->theme && strlen($this->theme) > 0) {
         if (strpos($this->theme, '.js') === false) {
             $themeFile = $this->theme . ".js";
         } else {
             $themeFile = $this->theme;
         }
         try {
             $theme = file_get_contents($themeFile);
             if ($theme !== false) {
                 $s .= $theme;
             }
         } catch (Exception $e) {
         }
     }
     if (isset($this->coptions['lang'])) {
         $s .= 'Highcharts.setOptions({lang:' . jqGridUtils::encode($this->coptions["lang"]) . '});';
         unset($this->coptions['lang']);
     }
     $s .= 'var ' . $chart . ' = new Highcharts.Chart(' . jqGridUtils::encode($this->coptions) . ');';
     if ($this->jscode) {
         $s .= jqGridUtils::encode($this->jscode);
     }
     $s .= '});';
     $s .= '</script>';
     return $s;
 }
Esempio n. 17
0
    public function renderGrid($tblelement = '', $pager = '', $script = true, array $summary = null, array $params = null, $createtbl = false, $createpg = false, $echo = true)
    {
        $oper = $this->GridParams["oper"];
        $goper = jqGridUtils::GetParam($oper, 'nooper');
        if ($goper == $this->GridParams["excel"]) {
            if (!$this->export) {
                return false;
            }
            $this->exportToExcel($summary, $params, $this->colModel);
        } else {
            if (in_array($goper, array_values($this->GridParams))) {
                $this->editGrid($summary, $params, $goper);
            } else {
                if (!isset($this->gridOptions["datatype"])) {
                    $this->gridOptions["datatype"] = $this->dataType;
                }
                $this->gridOptions['colModel'] = $this->colModel;
                if (isset($this->gridOptions['postData'])) {
                    $this->gridOptions['postData'] = jqGridUtils::array_extend($this->gridOptions['postData'], array($oper => $this->GridParams["query"]));
                } else {
                    $this->setGridOptions(array("postData" => array($oper => $this->GridParams["query"])));
                }
                if (isset($this->primaryKey)) {
                    $this->GridParams["id"] = $this->primaryKey;
                }
                $this->setGridOptions(array("prmNames" => $this->GridParams));
                $s = '';
                if ($createtbl) {
                    $tmptbl = $tblelement;
                    if (strpos($tblelement, "#") === false) {
                        $tblelement = "#" . $tblelement;
                    } else {
                        $tmptbl = substr($tblelement, 1);
                    }
                    $s .= "<table id='" . $tmptbl . "'></table>";
                }
                if ($createpg) {
                    $tmppg = $pager;
                    if (strpos($pager, "#") === false) {
                        $pager = "#" . $pager;
                    } else {
                        $tmppg = substr($pager, 1);
                    }
                    $s .= "<div id='" . $tmppg . "'></div>";
                }
                if (strlen($pager) > 0) {
                    $this->setGridOptions(array("pager" => $pager));
                }
                $this->editOptions['mtype'] = $this->mtype;
                $this->addOptions['mtype'] = $this->mtype;
                $this->delOptions['mtype'] = $this->mtype;
                if ($script) {
                    $s .= "<script type='text/javascript'>";
                    $s .= "jQuery(document).ready(function() {";
                }
                $s .= "jQuery('" . $tblelement . "').jqGrid(" . jqGridUtils::encode($this->gridOptions) . ");";
                if ($this->navigator && strlen($pager) > 0) {
                    $s .= "jQuery('" . $tblelement . "').jqGrid('navGrid','" . $pager . "'," . jqGridUtils::encode($this->navOptions);
                    $s .= "," . jqGridUtils::encode($this->editOptions);
                    $s .= "," . jqGridUtils::encode($this->addOptions);
                    $s .= "," . jqGridUtils::encode($this->delOptions);
                    $s .= "," . jqGridUtils::encode($this->searchOptions);
                    $s .= "," . jqGridUtils::encode($this->viewOptions) . ");";
                    if ($this->navOptions["excel"] == true) {
                        $eurl = $this->getGridOption('url');
                        $exexcel = <<<EXCELE
onClickButton : function(e)
{
    try {
        jQuery("{$tblelement}").jqGrid('excelExport',{url:'{$eurl}'});
    } catch (e) {
        window.location= '{$eurl}?oper=excel';
    }
}
EXCELE;
                        $s .= "jQuery('" . $tblelement . "').jqGrid('navButtonAdd','" . $pager . "',{caption:'',title:'Export to Excel'," . $exexcel . "});";
                    }
                }
                if ($this->toolbarfilter) {
                    $s .= "jQuery('" . $tblelement . "').jqGrid('filterToolbar'," . jqGridUtils::encode($this->filterOptions) . ");\n";
                }
                $gM = count($this->gridMethods);
                if ($gM > 0) {
                    for ($i = 0; $i < $gM; $i++) {
                        $s .= $this->gridMethods[$i] . "\n";
                    }
                }
                if (strlen($this->customCode) > 0) {
                    $s .= jqGridUtils::encode($this->customCode);
                }
                if ($script) {
                    $s .= " });</script>";
                }
                if ($echo) {
                    echo $s;
                }
                return $echo ? "" : $s;
            }
        }
    }
Esempio n. 18
0
        \$("#mne_dialog").ready(function(){
        // Some magic to set the proper width of the grid inside a Modal window
        var modalWidth = \$("#mne_dialog").width();
        var modalHeight = \$("#mne_dialog").height() - 52;
        \$('#mnegrid').jqGrid('setGridWidth',modalWidth);
        \$('#mnegrid').jqGrid('setGridHeight',modalHeight);
        \$('#mnegrid').fluidGrid({base:'#mne_dialog', offset:-25});
        });
//---------------------------------------------------------------
// END: Mnemonic Select Dialog
//---------------------------------------------------------------


});

\$(window).resize(function()
{
        \$('#mnegrid').fluidGrid({base:'#ui-dialog-title-mne_dialog', offset:-25});
});


CUSTOM;
$grid->setJSCode($custom);
$oper = jqGridUtils::GetParam("oper");
if ($oper == "pdf") {
    $grid->setPdfOptions(array("header" => true, "margin_top" => 25, "page_orientation" => "P", "header_logo" => "../../../../../images/Logo_450x123_24bit_color.jpg", "header_logo_width" => 45, "header_title" => "                         Mnemonics Report"));
}
// Enjoy
$summaryrows = array("Seen" => array("Seen" => "SUM"));
$grid->renderGrid('#mnegrid', '#mnepager', true, $summaryrows, null, true, true);
$conn = null;
Esempio n. 19
0
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = 'SELECT CustomerID, CompanyName, Phone, PostalCode, City FROM customers';
// Set the table to where you update the data
$grid->table = 'customers';
// Set output format to json
$grid->dataType = 'json';
$grid->setPrimaryKeyId('CustomerID');
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
// Set some grid options
$grid->setGridOptions(array("rowNum" => 10, "rowList" => array(10, 20, 30), "sortname" => "CustomerID"));
$grid->setColProperty('CustomerID', array("editoptions" => array("readonly" => true)));
// For demonstration purposes only we will update the Customer name adding at end of
// the field U after the data is updated from the user
// We can set ulimited commands after edit occur.
// The same apply for del and add operation
$cid = jqGridUtils::GetParam('CustomerID');
// This command is executed immediatley after edit occur.
$grid->setAfterCrudAction('edit', "UPDATE customers SET CompanyName = CONCAT(CompanyName,' -U') WHERE CustomerID=?", array($cid));
// Enable navigator
$grid->navigator = true;
// Enable only editing
$grid->setNavOptions('navigator', array("excel" => false, "add" => false, "edit" => true, "del" => false, "view" => true, "search" => false));
// Close the dialog after editing
$grid->setNavOptions('edit', array("closeAfterEdit" => true, "editCaption" => "Update Customer", "bSubmit" => "Update"));
// Enjoy
$grid->renderGrid('#grid', '#pager', true, null, null, true, true);
$conn = null;