Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #21  
Old 24th September 2010, 19:48
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,421
Thanks: 812
Thanked 5,205 Times in 4,081 Posts
Default

Quote:
I tested the SQL sentence and it's working... is there any way to print values of variables on the screen?
use "echo" or for arrays the print_r() command.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Sponsored Links
  #22  
Old 25th September 2010, 00:19
bruno_floyd bruno_floyd is offline
Member
 
Join Date: Aug 2010
Posts: 73
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Ah, ok.. i tried once but i couldnt make it work, but now I know it works.

Do you have any other idea to help me till?
Is there another file to be modified?

I'm kind of lost... =/
Reply With Quote
  #23  
Old 27th September 2010, 10:00
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,421
Thanks: 812
Thanked 5,205 Times in 4,081 Posts
Default

If you add a echo or print_r for your values in the prepareDataRow function, does they get displayed for every row that was processed?
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #24  
Old 27th September 2010, 15:29
bruno_floyd bruno_floyd is offline
Member
 
Join Date: Aug 2010
Posts: 73
Thanks: 1
Thanked 2 Times in 2 Posts
Default

I tried this:

Code:
]
 public function prepareDataRow($rec) {

        global $app;

        $sql_comissao = "SELECT SUM(valor_contrato) FROM indicacao";
        $sql_nao_comissao = "SELECT SUM(valor_comissao) FROM indicacao";
		
		echo "TESTING";

        $soma = $app->db->queryOneRecord($sql_comissao);
        $soma_nao = $app->db->queryOneRecord($sql_nao_comissao);

       	$rec['total_valor_comissionado'] = $soma;
		$rec['total_valor_nao_comissionado'] = $soma_nao; 
		
		print_r($rec);
	
        parent::prepareDataRow($rec);
	}
but nothing is shown. Is it supposed to print?
Is right to put the variable inside the loop? Cause this field I'm trying to get is a single SUM value from one field of my DB...

Code:
<td class="tbl_col_total_valor_comissionado"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="total_valor_comissionado"}</a></td>

Last edited by bruno_floyd; 27th September 2010 at 15:33.
Reply With Quote
  #25  
Old 27th September 2010, 15:34
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,421
Thanks: 812
Thanked 5,205 Times in 4,081 Posts
Default

Ok. Now i see why the code does not get executed. Replace the line:

$app->listform_actions->onLoad();

with:

$my_list = new list_action()
$my_list->onLoad();
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #26  
Old 27th September 2010, 16:19
bruno_floyd bruno_floyd is offline
Member
 
Join Date: Aug 2010
Posts: 73
Thanks: 1
Thanked 2 Times in 2 Posts
Default

till,

i get this error message:

Warning: vlibTemplate Warning: Invalid loop structure passed to vlibTemplate::setLoop() (loop name: records). in /usr/local/ispconfig/interface/lib/classes/tpl_error.inc.php on line 83

is it related to the modification you suggested?
Reply With Quote
  #27  
Old 27th September 2010, 19:31
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,421
Thanks: 812
Thanked 5,205 Times in 4,081 Posts
Default

No. This means that there is a error in the html template. most likely the template loop is not closed or opened correctly or the name does not match.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #28  
Old 28th September 2010, 14:16
bruno_floyd bruno_floyd is offline
Member
 
Join Date: Aug 2010
Posts: 73
Thanks: 1
Thanked 2 Times in 2 Posts
Default

till, I took off my 2 new fields and let the html template as before... but the error continues.
My new single value has to be inside this loop "records"? Cause its one value actually...

Here's the loop with my new 2 fields in red:

Code:
<tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">    
            <td class="tbl_col_indicou_id"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="indicou_id"}</a></td>
            <td class="tbl_col_indicado_id"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="indicado_id"}</a></td>
            <td class="tbl_col_data_cadastro"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="data_cadastro"}</a></td>
            <td class="tbl_col_plano"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="plano"}</a></td>
            <td class="tbl_col_nome_dominio"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="nome_dominio"}</a></td>
            <td class="tbl_col_telefone"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="telefone"}</a></td>
            <td class="tbl_col_status"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="status"}</a></td>
            <td class="tbl_col_valor_comissao"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="valor_contrato"}</a></td>
           <td class="tbl_col_valor_contrato"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="valor_comissao"}</a></td>
           <td class="tbl_col_total_valor_comissionado"><a href="#" onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="total_valor_comissionado"}</a></td>
           <td class="tbl_col_total_valor_nao_comissionado"><a href="#"onClick="loadContent('indicacao/indicacao_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="total_valor_nao_comissionado"}</a></td>
            <tmpl_if name="is_admin">
              <div class="buttons icons16">    
                <a class="icons16 icoDelete" href="javascript: del_record('indicacao/indicacao_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
              </div>
            </tmpl_if>
            </td>
          </tr>
          </tmpl_loop>
Reply With Quote
  #29  
Old 28th September 2010, 14:31
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,421
Thanks: 812
Thanked 5,205 Times in 4,081 Posts
Default

As far as I can see, $soma and $soma_nao that you pass are arrays and not values, but you can set only values for a template variable. So the lines:

$sql_comissao = "SELECT SUM(valor_contrato) FROM indicacao";
$sql_nao_comissao = "SELECT SUM(valor_comissao) FROM indicacao";

$soma = $app->db->queryOneRecord($sql_comissao);
$soma_nao = $app->db->queryOneRecord($sql_nao_comissao);

$rec['total_valor_comissionado'] = $soma;
$rec['total_valor_nao_comissionado'] = $soma_nao;

should be:

$sql_comissao = "SELECT SUM(valor_contrato) as soma FROM indicacao";
$sql_nao_comissao = "SELECT SUM(valor_comissao) as soma_nao FROM indicacao";

$soma = $app->db->queryOneRecord($sql_comissao);
$soma_nao = $app->db->queryOneRecord($sql_nao_comissao);

$rec['total_valor_comissionado'] = $soma['soma'];
$rec['total_valor_nao_comissionado'] = $soma_nao['soma_nao'];
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #30  
Old 30th September 2010, 15:44
bruno_floyd bruno_floyd is offline
Member
 
Join Date: Aug 2010
Posts: 73
Thanks: 1
Thanked 2 Times in 2 Posts
 
Default

Hey till... it worked!

but I don't know why I had to put the whole prepareDataRow($rec) method inside the list_action class.

Now if you allow me I have more 2 doubts...

On the templates when I put my new 2 variables that is inside the <tmpl_loop name="records">
it's shown, but shows the number of entries on the DB, not a single line... but the SUM value is okay, is there a way to show it outside the "tmpl_loop"?

Secondly, I have an issue related to dates... here in Brazil we use the date format "d/m/Y"... when I add an entry into DB it goes on the "Y-m-d" format. How can I put my date conversion method when I show the entry on the screen?

I could not work yesterday... sorry about the late!
Thanks again!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freeradius and Mysql uvstudios HOWTO-Related Questions 4 19th February 2014 12:11
Proftpd + MySQL virtual users, can't connect geekman HOWTO-Related Questions 28 27th September 2010 18:03
FreeRadius + MySQL working, but I don't know how to customise SQL queries awe Installation/Configuration 4 4th April 2010 23:28
ffmpeg Video support for ubuntu 7.10 [suphp-ispconfig] amaurib Installation/Configuration 13 16th February 2010 17:26
Webmin docs missing namit Server Operation 11 5th January 2006 09:51


All times are GMT +2. The time now is 04:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.