BrentNJ
Joined: 03 Jun 2004
Posts: 12
Posted: 2004-06-13 21:41
Back to top
Reply with quote
|
Any examples on how to use Virtual Fields?
|
BrentNJ
Joined: 03 Jun 2004
Posts: 12
Posted: 2004-06-14 15:27
Back to top
Reply with quote
|
I learned some more since I posted this question, but need some more clarification.
This example prints current date even though field CurrentDate is not in table
| Code: |
$opts['fdd']['CurrentDate'] = array(
'name' => 'Current Date',
'select' => 'T',
'maxlen' => 14,
'options' => L,
'sql' => 'CURDATE()',
'sort' => true
); |
This example prints a link even though field dummy1 is not in table
| Code: |
$opts['fdd']['itemid'] = array(
'name' => 'Part Number',
'select' => 'T',
'maxlen' => 11,
'default' => '0',
'required' => true,
'values' => array( 'table' => 'items', 'column' => 'itemid', 'description' => 'n
ame' ),
'sort' => true
);
$opts['fdd']['dummy1'] = array (
'name' => 'Email',
'sql' => 'PMEjoin1.name',
'options' => 'RACPDVL',
'escape' => false,
'URL' => 'mailto:',
'sort' => true
); |
The common line that seems to make it work is sql.
The above PMEjoin1.name works since the join was already performed on the two tables. But I have trouble creating "virtual joins"
My question
for three tables (fields reduced for question)
Contact
contactID
name
city
DinnerTableLink
dinnertablelinkID
contactID
dinnertableID
DinnerTable
dinnertableID
tablenumber
totalseats
We need to have tablenumber displaced as read only dummy field on Contact form.
I tried for quite a bit of time but without much success.
| Code: |
$opts['fdd']['dummy1'] = array (
'name' => 'Table Number',
'sql' => 'PMEjoin2.tablenumber',
'options' => 'RACPDVL',
'escape' => false,
'join' => 'Contact.contactID = dinnertablelink.contactID'),
'join' => 'DinnerTableLink.dinnertableID = DinnerTable.dinnertableID'),
'sort' => true
); |
But it doesn't work.
Any ideas?
Thanks
|
BrentNJ
Joined: 03 Jun 2004
Posts: 12
Posted: 2004-06-15 00:47
Back to top
Reply with quote
|
Nevermind. I had to do two dummy fields to get two joins to work.
You guys are good. Just by posting a question the answer appears in my fingers!!
|
Amit
Joined: 16 May 2004
Posts: 22
Posted: 2004-06-19 13:24
Back to top
Reply with quote
|
I tried the following code to create a Virtual Field but it did not work. Can you pint me to the correct location where I can read up something about Virtual Fields.
| Quote: |
$opts['fdd']['Balance'] = array(
'name' => 'Balance',
'select' => 'N',
'maxlen' => 14,
'options' => 'L',
'sort' => false
);
|
|
BrentNJ
Joined: 03 Jun 2004
Posts: 12
Posted: 2004-06-19 13:55
Back to top
Reply with quote
|
I think the virtual fields only work if they are used with an sql statement since they are not actually configured in the database as a field.
I guess that means they are only read-only.
So for the above example
| Code: |
$opts['fdd']['CurrentDate'] = array(
'name' => 'Current Date',
'select' => 'T',
'maxlen' => 14,
'options' => L,
'sql' => 'CURDATE()',
'sort' => true
); |
CurrentDate was not in the database, but since the sql line asks to print current date, the field shows up on the phpMyEdit forms.
What do you want to display in the virtual field?[/code]
|
Amit
Joined: 16 May 2004
Posts: 22
Posted: 2004-06-19 15:22
Back to top
Reply with quote
|
I am trying to keep track of a running total for my Books of accounts.
Virtual Field = Balance (keeps the running total)
Database Field = Amount
| Quote: |
$opts['fdd']['Balance'] = array(
'name' => 'Balance',
'select' => 'N',
'maxlen' => 14,
'options' => 'L',
'sql' => 'if(DebitAccount = $account, Balance - Amount, Balance + Amount)',
'sort' => true
);
|
But the above code has an error which I cannot figure out.
Thanks for your help.
|
Amit
Joined: 16 May 2004
Posts: 22
Posted: 2004-06-20 17:33
Back to top
Reply with quote
|
| doug wrote: |
| Where is $account coming from? Perhaps the 'sql' part of the above needs to read like this: |
See the entire code:
| Code: |
global $book, $from_date, $to_date, $acc;
$opts['fdd']['Amount'] = array(
'name' => 'Amount',
'select' => 'N',
'maxlen' => 16,
'default' => '0.00',
'options' => 'R',
'sort' => true
);
$opts['fdd']['Balance'] = array(
'name' => 'Balance',
'select' => 'N',
'maxlen' => 14,
'options' => 'L',
'sql|LV' => 'if(
DebitAccount = '.$acc',
CONCAT(Balance - Amount),
CONCAT(Balance + Amount)
)',
'sort' => true
);
|
now calls the report extension which creates a form with the following additional row (just above Rows per screen)
| Code: |
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'" colspan="2">';
echo $this->labels['Books'],'</td>';
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">';
echo '<select name="book">
<option>Cashbook</option>
<option>Bank</option>
<option>Balance Sheet</option>
<option>Income tax</option>
<option>P&L</option>
</select> ';
$book = 'book';
if ($book == 'Cashbook')
{$acc = 'Cash';}
elseif ($book == 'Bank')
{$acc = 'Bank';}
echo 'From Date: ';
echo '<input class="',$css_class_name,'" type="date" name="from_date" value="1980-01-01" size="10",$from_date>';
$from_date = 'from_date';
echo 'To Date: ';
echo '<input class="',$css_class_name,'" type="date" name="to_date" value="2010-12-31" size="10",$to_date>';
$to_date = 'to_date';
echo '</td></tr>',"\n";
|
Here is the
| Quote: |
http://127.0.0.1/~juneja/phpmyedit-5.4/displayreport.php?have_Name=on&qf0_id=Vedanta&have_Reference=on&have_Date=on
&have_DebitAccount=on&have_CreditAccount=on&have_Currency=on
&qf5_id=%2A&have_Amount=on&have_Description=on
&have_ChequeNumber=on&have_AccountNumber=on
&qf9_id=%2A&book=Cashbook&from_date=1980-01-01
&to_date=2010-12-31&inc=0&filter=Make%20report&inc=0
&have_Name=on&have_Reference=on&have_Date=on
&have_DebitAccount=on&have_CreditAccount=on
&have_Currency=on&have_Amount=on&have_Description=on
&have_ChequeNumber=on&have_AccountNumber=on |
that shows at the top of the form when 'Make report' is clicked.
I tried the following recommendations made by you but neither worked.
| Code: |
'sql|LV' =>
'if(
DebitAccount = $account,
CONCAT(Balance - Amount),
CONCAT(Balance + Amount)
)', |
or maybe
| Code: |
'sql|LV' =>
'if(
DebitAccount = '.$account.',
CONCAT(Balance - Amount),
CONCAT(Balance + Amount)
)', |
Thanks for your help!
|
pakman
Joined: 09 Jul 2004
Posts: 5
Posted: 2004-07-13 18:03
Back to top
Reply with quote
|
| BrentNJ wrote: |
Contact
contactID
name
city
DinnerTableLink
dinnertablelinkID
contactID
dinnertableID
DinnerTable
dinnertableID
tablenumber
totalseats
We need to have tablenumber displaced as read only dummy field on Contact form.
I tried for quite a bit of time but without much success.
| Code: |
$opts['fdd']['dummy1'] = array (
'name' => 'Table Number',
'sql' => 'PMEjoin2.tablenumber',
'options' => 'RACPDVL',
'escape' => false,
'join' => 'Contact.contactID = dinnertablelink.contactID'),
'join' => 'DinnerTableLink.dinnertableID = DinnerTable.dinnertableID'),
'sort' => true
); |
|
I've got the same, but it does not work in any of the systems i used. The 'description' field in the html select statement tries to lookup data from a field IN the table, but i can't force the 'description' field to be a 'result' of my own query, i tried to do it manually, but i cannot define descriptions.
Maybe you can help me!!!
|
jiliray916@
Joined: 01 Nov 2023
Posts: 563
Posted: 2024-01-06 10:29
Back to top
Reply with quote
|
Excellent weblog here! after reading, i decide to buy a sleeping bag ASAP
roof cleaning bristol
|
QADIRSEO
Joined: 29 Dec 2023
Posts: 1168
Posted: 2024-01-08 11:59
Back to top
Reply with quote
|
Thank you for sharing excellent informations. Your web-site is very cool. I’m impressed by the details that you¡¦ve on this web site. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for extra articles. You, my friend, ROCK! I found simply the information I already searched all over the place and simply couldn’t come across. What a perfect web-site. rentacarkosova
shillong teer result
|
|
Post new topic
Reply to topic
|
|