Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 29. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Virtual Fields

phpMyEdit Features     Virtual Fields
Odoslať novú tému   Odpovedať na tému    
 
BrentNJ     Založený: 03.06.2004   Príspevky: 12  
Príspevok Zaslal: 2004-06-13 21:41
Návrat hore  Odpovedať s citátom     

Any examples on how to use Virtual Fields?

 
BrentNJ     Založený: 03.06.2004   Príspevky: 12  
Príspevok Zaslal: 2004-06-14 15:27
Návrat hore  Odpovedať s citátom     

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

Kód:
$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

Kód:
$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.

Kód:

   $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     Založený: 03.06.2004   Príspevky: 12  
Príspevok Zaslal: 2004-06-15 00:47
Návrat hore  Odpovedať s citátom     

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     Založený: 16.05.2004   Príspevky: 22  
Príspevok Zaslal: 2004-06-19 13:24
Návrat hore  Odpovedať s citátom     

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.

Citácia:
$opts['fdd']['Balance'] = array(
  'name'     => 'Balance',
  'select'   => 'N',
  'maxlen'   => 14,
  'options'  => 'L',
'sort' => false
);


 
BrentNJ     Založený: 03.06.2004   Príspevky: 12  
Príspevok Zaslal: 2004-06-19 13:55
Návrat hore  Odpovedať s citátom     

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

Kód:
$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     Založený: 16.05.2004   Príspevky: 22  
Príspevok Zaslal: 2004-06-19 15:22
Návrat hore  Odpovedať s citátom     

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
Citácia:
$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     Založený: 16.05.2004   Príspevky: 22  
Príspevok Zaslal: 2004-06-20 17:33
Návrat hore  Odpovedať s citátom     

doug Napísal:
Where is $account coming from? Perhaps the 'sql' part of the above needs to read like this:

See the entire code:
Kód:

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)
Kód:


      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
Citácia:
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.

Kód:
'sql|LV' =>
'if(
  DebitAccount = $account,
    CONCAT(Balance - Amount),
      CONCAT(Balance + Amount)
)',

or maybe
Kód:
'sql|LV' =>
'if(
  DebitAccount = '.$account.',
    CONCAT(Balance - Amount),
      CONCAT(Balance + Amount)
)',


Thanks for your help!

 
pakman     Založený: 09.07.2004   Príspevky: 5  
Príspevok Zaslal: 2004-07-13 18:03
Návrat hore  Odpovedať s citátom     

BrentNJ Napísal:


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.

Kód:

   $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!!!

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov