This topic is locked
[SOLVED]

 Disable column on list-page

3/23/2010 11:38:33 AM
PHPRunner General questions
J
jdu001 author

Hello
I have on a list page a dropdown-box and a linked dropdown-box. However I want this second dropdown-box not editable (disabled), just to show related information. How can I set this field read-only or is there another way to show the linked data.
Table person

id

name

age
Table group

id

name

person_id
I want to add persons to a group (inline add) by selecting a person from a dropdown box. Also the age of that person should be shown.

Now i use for age the dependent option, but then the age is editable. I just want to show the age.
Example:

. Name Age other data

. John 40 ...

. Harry 39 ...
Greetings,
Jo van Duin

J
jdu001 author 3/26/2010

Hello Jane,
I don't use an add/edit page, just a list-page with inline add/edit functionality.
greetings,
Jo

C
chaintm 3/26/2010

I somewhat get what you want, The only way I could make things work like that in the listings page without an add page was a ton of custom code. What I can do for you is give my excamples here of each section and in what area how they where used. It would take a few days to train you in all of this, but this should help you get the idea if you are even a bit savy.
on my list page I have the following...
ItemName ItemThumb ItemSize ItemRentalPrice on_hand add_field
ItemRentalPrice , on_hand and add_field are all customized....
ItemRentalPrice
For ItemRentalPrice, I needed to do the math prior to the given price of an item, I did this by echo of the value of that field...
global $conn,$strTableName;
if ($data["ItemID"])

{

$str1 = "select Delivery_cost from order_sales where Order_num=".$_SESSION[$strTableName."_masterkey1"];

$rsh1 = db_query($str1,$conn);

while ($data1= db_fetch_array($rsh1))

{

$data5["totalnow"] = $data["ItemRentalPrice"] + $data1["Delivery_cost"];

$value = str_format_number($data5["totalnow"]);
}

}
on_hand
For on_hand I used a ghost field (IE made a field in my database that holds nothing) so I could use this field in phprunner. in that field I added the following to allow me to view what is on hand during the pre-selected dates prior to the order. This then shows what is avalible for each item in those days selected. You could in theory use this sort of thing to display your own variations with your own math added. The add_field is probably what you are really interested in thou..
global $conn,$strTableName;
if ($data["ItemID"])

{

$str1 = "select event_time_start,event_time_end from event_times where Order_ID=".$_SESSION[$strTableName."_masterkey1"];

$rsh1 = db_query($str1,$conn);

while ($data1= db_fetch_array($rsh1))
$str3 = "select sum(Qty_Order) as total_qty from event_times where Item_ID=".$data["ItemID"]."

and ".$data1["event_time_start"]." >= event_time_start

and ".$data1["event_time_start"]." <= event_time_end

and status ='1'

or Item_ID=".$data["ItemID"]."

and ".$data1["event_time_end"]." >= event_time_start

and ".$data1["event_time_end"]." <= event_time_end

and status ='1'

or Item_ID=".$data["ItemID"]."

and ".$data1["event_time_start"]." <= event_time_start

and ".$data1["event_time_end"]." >= event_time_end

and status ='1'";

$hrs3 = db_query($str3,$conn);

$rs3 = db_fetch_array($hrs3);

$value = $data["ItemStockPhys"] - $rs3["total_qty"];

//if ($value == $data["ItemStockPhys"])

if ($value<=0)

{

$value="*sold out";

$color="darkred";

$value="<font color='$color'>$value</font>";

}

else

{

$color="black";

$value="<font color='$color'>$value</font>";

}
}
add_field
For add_field I did the same as the prior, made a "Fake" field so I could use phprunner to identify this as a field then interact my code within the system. This is the one you probably will be most interested in. As you can adjust the visuals with phpcode for fields. If you know what I refer to just goto a php site (if you don't know off hand) and get the values for the type of list you want to use.
if ($data["ItemID"]==2)

{

$value.= "<BR><INPUT class=button id=submit5 type=button value=Add_Panel name=submit6 onclick=\"var form = $('#frmAdmin1')[0];form.a.value='add a panel'; form.submit();\">";
}

else

if ($data["ItemID"]==511)

{

$value.= "<BR><INPUT class=button id=submit5 type=button value=Add_Panel name=submit6 onclick=\"var form = $('#frmAdmin1')[0];form.a.value='add_panel'; form.submit();\">";
}

else

if ($data["ItemID"]==614)

{

$value.= "<BR><INPUT class=button id=submit5 type=button value=Add_Casino name=submit6 onclick=\"var form = $('#frmAdmin1')[0];form.a.value='addcasino'; form.submit();\">";
}

else

{

$value = "<INPUT class=text id=\"quantity
".$data["ItemID"]."\" type=text size=3 maxlength=3 value=1 name=\"quantity".$data["ItemID"]."\">";
$value.= "<INPUT class=button id=submit2 type=button value=Add name=submit2 onclick=\"var form = $('#frmAdmin1')[0];

form.a.value='".$data["ItemID"].",'+"."document.getElementById('quantity
".$data["ItemID"]."').value; form.submit();\">";
}
The last line should interest you most, phprunner only has one avalible call value built in that is the a value. the below excempts search features when attempting to use this value for your other means..
if (@$_REQUEST["a"] && @$_REQUEST["a"]!="delete" && @$_REQUEST["a"]!="search" && @$_REQUEST["a"]!="advsearch" && @$_REQUEST["a"]!="showall")

{

$arr = explode(",",$_REQUEST["a"]);

if (count($arr)>1)

{
you place that in the list before page event. in my above excample, I used the values add and others to then execute script in my list before page event. here are those bits ..
if (@$_REQUEST["a"]=="add a panel")

{

$_SESSION["TEMPDATA"] = 2;

header("Location: order_items_add.php?mastertable=order_sales&masterkey1=".$_SESSION[$strTableName."_masterkey1"]);

//=============== carry over values from other tables ===========//
exit();

}
if (@$_REQUEST["a"]=="add_panel")

{

header("Location: order_items_add.php?mastertable=order_sales&masterkey1=".$_SESSION[$strTableName."_masterkey1"]);

$_SESSION["TEMPDATA"] = 511;

//=============== carry over values from other tables ===========//
exit();

}
if (@$_REQUEST["a"]=="add_casino")

{

header("Location: order_items_casino_add.php?mastertable=order_sales&masterkey1=".$_SESSION[$strTableName."_masterkey1"]);
exit();

}
else

if (@$_REQUEST["a"]=="del")

{

echo "del disabled!";

}

else
if (@$_REQUEST["a"]=="cancel")
{

global $conn;

$str = "select Order_num from order_items where Order_num =".$_SESSION[$strTableName."_masterkey1"];

$rs = CustomQuery($str);

while($data = db_fetch_array($rs))

{

//remove detail records for selected master record

$strDelete = "delete from order_items where Order_num =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strDelete,$conn);

}

global $conn;

$str = "select Order_ID from event_times where Order_ID =".$_SESSION[$strTableName."_masterkey1"];

$rs = CustomQuery($str);

while($data = db_fetch_array($rs))

{

//remove detail records for selected master record

$strDelete = "delete from event_times where Order_ID =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strDelete,$conn);

}

global $conn;

$str = "select Order_num from order_sales where Order_num =".$_SESSION[$strTableName."_masterkey1"];

$rs = CustomQuery($str);

while($data = db_fetch_array($rs))

{

//remove detail records for selected master record

$strDelete = "delete from order_sales where Order_num =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strDelete,$conn);

}

echo "<script>alert('You Have Cancelled the Order')</script>";

echo "<script>window.location.href='order_sales_list.php?a=return';</script>";

//header("Location: order_sales_list.php?a=return");

exit();

}

else

if (@$_REQUEST["a"]=="Make A Quote")

{

global $conn;

$str1 = "select from order_sales where Order_num=".$_SESSION[$strTableName."_masterkey1"];

$rs1 = CustomQuery($str1);

while($data1 = db_fetch_array($rs1))

$sql = "insert into quote_order_sales (Order_num,Delivery_cost) values

('".db_addslashes($_SESSION[$strTableName."_masterkey1"])."','".db_addslashes($data1["Delivery_cost"])."')";

db_exec($sql,$conn);
$str99 = "select
from order_items where Order_num=".$_SESSION[$strTableName."_masterkey1"];

$rs99 = CustomQuery($str99);

while($data99 = db_fetch_array($rs99))

{

$sql99 = "insert into quote_order_items

(Order_num,ItemID,Qty_order,ItemRentalPrice,Line_comment,Sub_total,ItemThumb,Moduals) values

('".db_addslashes($data99["Order_num"])."'

,'".db_addslashes($data99["ItemID"])."'

,'".db_addslashes($data99["Qty_order"])."'

,'".db_addslashes($data99["ItemRentalPrice"])."'

,'".db_addslashes($data99["Line_comment"])."'

,'".db_addslashes($data99["Sub_total"])."'

,'".db_addslashes($data99["ItemThumb"])."'

,'".db_addslashes("1")."')";

db_exec($sql99,$conn);

}
$rs9 = CustomQuery("select sum(Sub_total) from order_items where Order_num=".$_SESSION[$strTableName."_masterkey1"]);

$data9 = db_fetch_numarray($rs9);

$strUpdate = "Update quote_order_sales set Order_sub_total=".$data9[0]." where Order_num =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strUpdate,$conn);

//------------------update STATUS of ORDER_SALES------------------//

$strUpdate = "Update quote_order_sales set Order_status ='9'where Order_num =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strUpdate,$conn);
//======================DELETE ORDER FROM ORDERS AS IT IS ADDED TO QUOTES ABOVE==================//

$str = "select Order_num from order_items where Order_num =".$_SESSION[$strTableName."_masterkey1"];

$rs = CustomQuery($str);

while($data = db_fetch_array($rs))

{

//remove detail records for selected master record

$strDelete = "delete from order_items where Order_num =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strDelete,$conn);

}

global $conn;

$str = "select Order_ID from event_times where Order_ID =".$_SESSION[$strTableName."_masterkey1"];

$rs = CustomQuery($str);

while($data = db_fetch_array($rs))

{

//remove detail records for selected master record

$strDelete = "delete from event_times where Order_ID =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strDelete,$conn);

}

global $conn;

$str = "select Order_num from order_sales where Order_num =".$_SESSION[$strTableName."_masterkey1"];

$rs = CustomQuery($str);

while($data = db_fetch_array($rs))

{

//remove detail records for selected master record

$strDelete = "delete from order_sales where Order_num =".$_SESSION[$strTableName."_masterkey1"];

db_exec($strDelete,$conn);

}

echo "<script>window.location.href='quote_order_sales_list.php';</script>";

exit();

}

else
it goes on and on, point is if you get this stuff you will know what to do from here, if you don't sadly there is really no easy way to do what you want in phprunner.

C
chaintm 3/26/2010

Jane gave you a link showing you how to disable editable items due to a factor, that would if done correctly work on the inline edit features. ofcourse most things can be figured out, from what I was reading over just slightly from the link that Jane did provide, the info for the disable code is there. Just needs some tweeking, if you are not really a coder then OPS! Sorry, about this and the previous post, most here are pretty good and most as myself sometimes just get stumped in how to use code in phprunner and where to implment it.

J
jdu001 author 3/30/2010



Jane gave you a link showing you how to disable editable items due to a factor, that would if done correctly work on the inline edit features. ofcourse most things can be figured out, from what I was reading over just slightly from the link that Jane did provide, the info for the disable code is there. Just needs some tweeking, if you are not really a coder then OPS! Sorry, about this and the previous post, most here are pretty good and most as myself sometimes just get stumped in how to use code in phprunner and where to implment it.


Dear chaintm,
For your knowledge, I am an developer for over 25 years, but I am learning PHP and JavaScript just now. So pleace don't make such comments about the knowledge or experience of other people. We are just asking this questions because we want to learn.

In the link, provided by Jane, I can't find any information about disable an attribute when I enter inline-edit or inline-add.
So perhaps you can help me how to thisable the correct attribute in the row when entering inline-edit or inline-add.
Greetings,
Jo

J
Jane 4/2/2010

Jo,
unfortunately it's not possible to hide fields on the list page in inline add/edit mode.

Whole HTML will be broken if you remove one cell only.