Make empty filed space - php

I have this menu:
items:[
{
xtype: 'form',
id: 'searchPanel',
title: 'Search',
collapsible: true,
bodyPadding: 10,
height: 210,
buttonAlign: 'left',
defaults: {
width: 400,
labelWidth: 120,
allowBlank: true,
enableKeyEvents: true
},
layout: {
type: 'table',
columns: 2
},
items: [
{
xtype: 'textfield',
name: 'txtFltrSiteName',
fieldLabel: 'Site name or alias',
id: 'txtFltrSiteName'
},
{
xtype: 'textfield',
name: 'txtDiskCost',
fieldLabel: 'Disk cost',
id: 'txtDiskCost',
style: 'margin-left: 100px;'
},
{
xtype: 'textfield',
name: 'txtFltrProjectName',
fieldLabel: 'Project name',
id: 'txtFltrProjectName'
},
// many other fields
And chackboxes and text fields have diffirent width, so it looks ugly.
So the queston is:
How to make empty <td> in this form?
For examle I want 6-2 items:
----------
| 1 | 1 |
| 2 | 2 |
| 3 | |
| 4 | |
|..etc...|
----------

Just make hidden input.
like this:
{
xtype: 'hidden',
name: 'hidden1',
id: 'hidden1'
},
This will make <td> column, but it'll be empty coz it'll be hidden input in it.

Here's a better one:
{
xtype : 'label',
text : '',
labelSeparator: ''
}

Related

How to filter with extra column in JSON PHP

I have a little statistic page where I can summorize my txt messages by user and by country.
I need now to have a new column where i can have operator as well.
To be more accurate, I need column to count all the Vodafone messages. I have already operator in my database and there are 5 different operators. I just need to bring out Vodafone.
Here are json php:
require_once("../corporate/php/modules/core/init.inc.php");
$where = " queue.dt_entered >= '".mysql_real_escape_string(trim($_POST["startdate"]))." 00:00:00' and queue.dt_entered <= '".mysql_real_escape_string(trim($_POST["enddate"]))." 23:59:59' ";
$result = $db -> query("
SELECT queue.user_id AS user, users.username as username, SUM( queue.amount ) AS amount, COUNT( queue.amount ) AS count, IFNULL( (
SELECT TRIM( country )
FROM CORE_E164
WHERE code = SUBSTR( queue.receiver, 3, 3 ) ) , IFNULL( (
SELECT TRIM( country )
FROM CORE_E164
WHERE code = SUBSTR( queue.receiver, 3, 2 ) ) , IFNULL( (
SELECT TRIM( country )
FROM CORE_E164
WHERE code = SUBSTR( queue.receiver, 3, 1 ) ) , 'None'
)
)
) AS country
FROM sms_queue AS queue, users AS users
WHERE queue.user_id = users.id
AND queue.client_type = 'corporative'
AND ".$where."
GROUP BY user, country
order by username
");
$result_array = array();
while ($row = mysql_fetch_array($result)) {
array_push($result_array, array("user" => $row["user"],
"username" => $row["username"],
"country" => $row["country"],
"amount" => $row["amount"],
"count" => $row["count"]
));
}
$result_total = array(
"success"=>true,
"messages" => $result_array
);
echo json_encode($result_total);
I am adding now the html page as well:
function columnWrap(val){
return '<div style="white-space:normal !important;">'+ val +'</div>';
}
var stat_store=new Ext.data.JsonStore({
root: 'messages',
fields : [
{name: 'id', mapping: 'user'},
{name: 'username', mapping: 'username'},
{name: 'country', mapping: 'country'},
{name: 'amount', mapping: 'amount'},
{name: 'count', mapping: 'count'},
{name: 'emt', mapping: 'emt'}
],
proxy : new Ext.data.HttpProxy({url:'group_stats.json.php'})
});
var filters = new Ext.ux.grid.GridFilters({
encode: false,
local: true,
filters: [{
type: 'string',
dataIndex: 'username'
},{
type: 'string',
dataIndex: 'country'
},{
type: 'string',
dataIndex: 'operator'
}]
});
var summary = new Ext.ux.grid.GridSummary();
var stat_grid = new Ext.grid.EditorGridPanel({
store: stat_store,
region: 'center',
plugins: [filters, summary],
columns: [
{header: "User ID", width: 50, dataIndex: 'id', sortable: true},
{header: "Username", width: 160, dataIndex: 'username', sortable: true, filterable: true},
{header: "Target country", width: 330, dataIndex: 'country', sortable: true, filterable: true},
{header: "Request count", width: 110, dataIndex: 'count', sortable: true, filterable: true, summaryType: 'sum'},
{header: "EMT count", width: 110, dataIndex: 'count', sortable: true, filterable: true, summaryType: 'sum'},
{header: "SMS sum", width: 110, dataIndex: 'amount', sortable: true, filterable: true, summaryType: 'sum'}
]
});
var FilterPanel = new Ext.FormPanel({
labelAlign: 'top',
frame:true,
region: 'north',
bodyStyle:'padding:5px 5px 0',
height: 95,
items: [{
layout:'column',
items:[{
columnWidth: 0.1,
layout: 'form',
items: [new Ext.form.DateField({
fieldLabel: 'Alguskuupäev',
name: 'startdate',
id: 'startdate',
value: new Date().format('Y-m-d'),
format:'Y-m-d',
anchor:'95%',
allowBlank:false })]
},{
columnWidth:.1,
layout: 'form',
items: [ new Ext.form.DateField({
fieldLabel: 'Lõppkuupäev',
name: 'enddate',
id: 'enddate',
value: new Date().format('Y-m-d'),
format:'Y-m-d',
anchor:'95%',
allowBlank:false })]
}]
}],
buttons: [{
text: 'Otsi',
handler: function(){
stat_store.baseParams = {startdate: Ext.get('startdate').dom.value, enddate: Ext.get('enddate').dom.value};
stat_store.load({params:{startdate: Ext.get('startdate').dom.value, enddate: Ext.get('enddate').dom.value}});
}
}]
});
var ContentPanel = new Ext.Panel({
layout: 'border',
items : [FilterPanel, stat_grid],
renderTo: 'list',
width: Ext.get('contentdiv').getWidth() - 5,
height: Ext.get('contentdiv').getHeight() - 30
});
Thank you,
Allan
So You want to count number of Vodafone messages among all selected messages.
SELECT ... SUM(IF(queue.operator = 'Vodafone', 1, 0)) AS vodafoners FROM ...
If You have access to some administration of the database (Adminer, phpMyAdmin or something similar), You can add the column in it. If You don't have such access, use SQL query to add the column:
ALTER TABLE yourTable ADD columnName columnType
For example:
ALTER TABLE sms_queue ADD opername VARCHAR(50)
And then use that column in Your SQL query:
... WHERE sms_queue.opername = 'Vodafone'
I also suggest using an index on that column.

drop down problems using symfony

i am new in symfony,its has been two days i have stacked on a problems making drop downs using symfony froms relations based on schema.yml
schema.yml is
FieldsCategory:
tableName: fld_category
columns:
id:
name: id as FieldsId
type: integer(10)
primary: true
autoincrement: true
category_name:
name: category_name as CategoryName
type: string
default: ''
notnull: true
relations:
FieldsCategory:
class: FieldsCategory
foreignAlias: Fields
local: id
foreign: fields_category_id
Fields:
tableName: fld_fields
columns:
id:
name: id as FieldsId
type: integer(10)
primary: true
autoincrement: true
fields_name:
name: fields_name as FieldsName
type: string
default: ''
notnull: true
fields_desc:
name: fields_desc as FieldsDescription
type: string
default: ''
notnull: true
amount:
name: amount as TotalAmount
type: integer
notnull: true
fields_type_id:
name: fields_type_id as FieldsTypeId
type: integer
fields_category_id:
name: fields_category_id as FieldsCategoryId
type: integer
and my forms is
$this->setWidgets(array(
'FieldsId' => new sfWidgetFormInputHidden(),
'fields_type_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Fields'), 'add_empty' => false)),
'FieldsName' => new sfWidgetFormTextarea(),
));
$this->setValidators(array(
'FieldsId' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('FieldsId')), 'empty_value' => $this->getObject()->get('FieldsId'), 'required' => false)),
'fields_type_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Fields'), 'required' => false)),
'FieldsName' => new sfValidatorString(array('required' => false)),
));
its given me this error
i have tried all possible ways but i couldnt solve this problems/
and help will be approciated in advance

flot piechart from PHP

I am having a very strange issue creating a piechart in Flot with data from PHP.
It seems to be drawing incorrectly, and I can't figure out why.
My PHP code (for testing) is:
echo json_encode(
'[{ label: "Series1", data: 10},
{ label: "Series2", data: 3},
{ label: "Series3", data: 9},
{ label: "Series4", data: 7},
{ label: "Series5", data: 8},
{ label: "Series6", data: 17}]'
);
My JS file is:
$.ajax({
type:'GET',
dataType:"json",
url:'../phpfile.php',
success: function(data) {
console.log(data);
$.plot($("#piechart"),data,{
series: {
pie: {
show: true
}
}
});
}
});
The consol log shows:
[{ label: "Series1", data: 10},
{ label: "Series2", data: 3},
{ label: "Series3", data: 9},
{ label: "Series4", data: 7},
{ label: "Series5", data: 8},
{ label: "Series6", data: 17}]
Which I thought was the correct format for flot...
But it graphs like this:
Does anyone have any ideas?
I believe your JSON currently is invalid, at the moment, you're trying to parse an JSON String, into a JSON String (If you get what I mean!) Currently, when I echo out from the PHP end with your echo'ed json_encode(), I'm provided with:
"[{ label: \"Series1\", data: 10},\r\n{ label: \"Series2\"]"
Furthermore, I would use PHP Arrays to encode JSON, like below:
<?php
$arr = array(
array(
"label" => "Series1",
"data" => 10
),
array(
"label" => "Series2",
"data" => 3
),
array(
"label" => "Series3",
"data" => 9
),
array(
"label" => "Series4",
"data" => 7
),
array(
"label" => "Series5",
"data" => 8
),
array(
"label" => "Series7",
"data" => 17
)
);
echo json_encode( $arr );
?>
PHP json_encode() does accept mixed variable types, but it's most popularly used with PHP arrays.
With the above, I'm able to construct the PIE chart successfully:

flexigrid examples returning data from mysql

I'm sure it can be done, I just need to see some examples. I want to use flexigrid to show massive sets of data stored in mysql. I am proficient in php, but new to jquery and json.
Can anyone point me in the right direction or provide a good example? I need to see how to return data back to the flexigrid json.
Thank you
Great Tutorial on this topic
This is just the partial code for returning your database results, you would call you page with the flexigrid jquery code
while ($row = mysql_fetch_assoc($results)) {
$data['rows'][] = array(
'id' => $row['pf_id'],
'cell' => array(
$row['cat_code'],
$row['cat_title'],
$row['cat_link'] = "Edit | Associate Familys | Order Children")); }
echo json_encode($data);
call the page with the flexigrid jquery code
$("#flex1").flexigrid({
url: 'category_main_json.php',
dataType: 'json',
colModel : [
{display: 'Code', name : 'cat_code', width : 70, sortable : true, align: 'left'},
{display: 'Name', name : 'cat_title', width : 550, sortable : true, align: 'left'},
{display: 'Action', name : 'cat_link', width : 205, sortable : true, align: 'left'},
],
buttons : [
{name: 'Add New Category', bclass: 'add', onpress : test},
{separator: true}
],
searchitems : [
{display: 'Code', name : 'cat_code'},
{display: 'Name', name : 'cat_title', isdefault: true}
],
sortname: "cat_code",
sortorder: "asc",
usepager: true,
useRp: true,
rp: 50,
showTableToggleBtn: false,
resizable: false,
width: 880,
height: 450,
singleSelect: true,
showTableToggleBtn: false
}
);

Javascript script to change the source of an image

I am using flexigrid for one of my projects and I need to come up with a way to change the image source depending on the value of one of the cells. For people who are used to flexigrid, I have the following code:
$json .= ",'".addslashes("<span><img src='' id='flag' />" . $row['availability']. "</span>")."'";
and my javascript that I've come up with , looks like this:
<script type="text/javascript">
var available = "<?php echo '$row[availability]' ?>";
if (available == 0) {
document.getElementById('flag').src="images/flag_red.png";
}
elseif (available == 1) {
document.getElementById('flag').src="images/flag_green.png";
}
else {
document.getElementById('flag').src="images/flag_orange.png";
}
I am not sure where I need to insert this function and how to trigger it. Any help will be greatly appreciated.
Regards,
Cristian.
LE: The code where the problem is being reported:
url: 'post2.php',
dataType: 'json',
colModel : [
{display: 'ID', name : 'id', width : 40, sortable : true, align: 'center', hide: true},
{display: 'URL', name : 'url', width : 450, sortable : false, align: 'left'},
{display: 'File Name', name : 'filename', width : 270, sortable : true, align: 'left'},
{display: 'Availability', name : 'availability', width : 50, sortable : true, align: 'center'},
{display: 'State', name : 'state', width : 40, sortable : true, align: 'center'},
{display: 'Total Size', name : 'totalsize', width : 90, sortable : false, align: 'center'},
{display: 'Current Size', name : 'currentsize', width : 90, sortable : false, align: 'center'},
{display: 'Procent', name : 'procent', width : 40, sortable : true, align: 'center'},
{display: 'Log', width : 20, sortable : false, align: 'center'},
],
buttons : [
{name: 'Add', bclass: 'add', onpress : test},
{separator: true},
{name: 'Delete', bclass: 'delete', onpress : test},
{separator: true},
{name: 'Select All', bclass : 'selectall', onpress : test},
{name: 'DeSelect All', bclass : 'deselectall', onpress : test},
{separator: true}
],
searchitems : [
{display: 'URL', name : 'url'},
{display: 'Filename', name : 'filename', isdefault: true}
],
sortname: "state",
sortorder: "asc",
usepager: true,
title: '',
useRp: false,
rp: 5,
showTableToggleBtn: true,
} ----- **IE says there is a problem here** );
});
You shouldn't use javascript for this, you can do it directly in your existing PHP line.
$json .= ",'" .
addslashes("<span><img src='" .
($row['availability'] == 0 ? "images/flag_red.png" :
($row['availability'] == 1 ? "images/flag_green.png" :
"images/flag_orange.png")
) .
"' id='flag' />" . $row['availability'] . "</span>") . "'";

Categories