Hi guys, I'm trying to creat a new module following the instructions based on this tutorial: http://docs.ispconfig.org/development/interface/ I created the DB Table of the new module on my own at the main account accoding to the model used on the other tables... and did all the steps, changing what is concerned to my new module instead of "help". I'm able to select the new module for the admin, but when I login again and click on the link of the it, I got the following error on a alertbox: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Error</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="../themes/default/css/central.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="uniForm"> <div id="errorMsg"> <h3>Error</h3> <ol> <li>301</li> </ol> </div> </div> </body> </html> Does anybody knows what's going on? Thanks guys!
Last release... 3.0.2.2 I installed on a computer for testing. I creat a new table at the DB and uploading the files I created to the ISPConfig directory and testing...
I had success on creating my new module and so on... Now I'm trying to setup the admin and user permissions. How can I set a button, for exemple the "delete entry" button to only appear when the logged account is from the Admin? Thks guys!
This should work in all templates: Code: <tmpl_if name="is_admin"> .... your html code here .... </tmpl_if>
Thanks till! It worked! I have another question if you allow me... I'm trying to get a valeu from the DB, doing this: $sql = $app->db->query("SELECT groupid FROM sys_group WHERE client_id = ".$this->dataRecord['indicou_id']); $group = $app->db->queryOneRecord($sql); And then update "sys_groupid" from my table "indicacao": $app->db->query("UPDATE indicacao SET sys_groupid = ".$group." WHERE indicacao_id = ".$this->id); These lines are in the function onAfterInsert()... and when I execute another stuff from my code in that section they are executed, but not the update above. Could you help? Thanks again!
The code to get the group has to look like this: $group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$this->dataRecord['indicou_id']);
I could not store the value from the DB to my $group variable... Is this the right way to get a value from the Db and put into the variable? Thanks again till!
Oh I see... Both echo or print_f doesn't work. How can I print values on the screen? That would be much easier for me here...
Any ideia till? i'm trying to get a SUM(field) from my DB and show it on my indicacao_list.htm using this: <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> How can I simply get this calculated value and show there? Where do I have to write de SQL sentence? on my indicacao.tform.php? Thanks a lot!!!
The tform files are only for the edit forms and not the lists. The lists are defined in the .list.php files, but this file contains only the definition and not the the actual list generation. If you want to create custom list colums, you have to extend a function in the list library. For an example see e.g. the mail_user_list.php file in the mail module. As you want to calculate a specific value in every row, you will have to extend the prepareDataRow($rec) function of the listform_actions.inc.php class.
Am I getting right? This is on my indicacao_list.php: class list_action extends listform_actions { public function prepareDataRow($rec) { global $app, $sql_comissao, $sql_nao_comissao; $sql_comissao = "SELECT SUM(valor_comissao) FROM indicacao WHERE status = '0' AND indicou_id = ".$_SESSION['s']['user']['userid']; $sql_nao_comissao = "SELECT SUM(valor_comissao) FROM indicacao WHERE status = '1' AND indicou_id = ".$_SESSION['s']['user']['userid']; $soma = $app->db->queryOneRecord($sql_comissao); $soma_nao = $app->db->queryOneRecord($sql_nao_comissao); $app->tpl->setVar('total_valor_comissionado', $soma); $app->tpl->setVar('total_valor_nao_comissionado', $soma_nao); } } But it didnt worked out yet.
Looks good. But you missed to call the parent function to add the data that gets normally added. Try to add a call to parent:repareDataRow($rec); at the end of the function: Code: class list_action extends listform_actions { public function prepareDataRow($rec) { global $app, $sql_comissao, $sql_nao_comissao; $sql_comissao = "SELECT SUM(valor_comissao) FROM indicacao WHERE status = '0' AND indicou_id = ".$_SESSION['s']['user']['userid']; $sql_nao_comissao = "SELECT SUM(valor_comissao) FROM indicacao WHERE status = '1' AND indicou_id = ".$_SESSION['s']['user']['userid']; $soma = $app->db->queryOneRecord($sql_comissao); $soma_nao = $app->db->queryOneRecord($sql_nao_comissao); $app->tpl->setVar('total_valor_comissionado', $soma); $app->tpl->setVar('total_valor_nao_comissionado', $soma_nao); parent::prepareDataRow($rec); } }
Well I added and i still can't get a value... my whole indicacao_list.php its like this: Code: <?php require_once('../../lib/config.inc.php'); require_once('../../lib/app.inc.php'); //* Path to the list definition file $list_def_file = "list/indicacao.list.php"; //* Check permissions for module $app->auth->check_module_permissions('indicacao'); //* Loading the class $app->uses('listform_actions'); class list_action extends listform_actions { public function prepareDataRow($rec) { global $app, $sql_comissao, $sql_nao_comissao; $sql_comissao = "SELECT SUM(valor_comissao) FROM indicacao WHERE status = '0' AND indicou_id = " . $_SESSION['s']['user']['userid']; $sql_nao_comissao = "SELECT SUM(valor_comissao) FROM indicacao WHERE status = '1' AND indicou_id = " . $_SESSION['s']['user']['userid']; $soma = $app->db->queryOneRecord($sql_comissao); $soma_nao = $app->db->queryOneRecord($sql_nao_comissao); $app->tpl->setVar('total_valor_comissionado', $soma); $app->tpl->setVar('total_valor_nao_comissionado', $soma_nao); parent::prepareDataRow($rec); } } //* Optional limit //$app->listform_actions->SQLExtWhere = "indicado_id = ".$_SESSION['s']['user']['userid']; //* Start the form rendering and action ahndling $app->listform_actions->onLoad(); ?> And I use the 2 variables I created, on my indicacao_list.htm as I showed you... {tmpl_var name="total_valor_comissionado"} , {tmpl_var name="total_valor_nao_comissionado"} Is there anything missing?
1) Is the list shown and just these two values are missing? 2) Did you add these two values in the template within the loop or outside the loop?
- The list is shown, but only these values that I inserted with my form. - I inserted inside the loop: 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> <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>
Ok. I read trough the sources of the class again and it might be that we have to add the fields in the .lis.php file of that list too (the file where the list fields are defined). Add there this code: Code: $liste["item"][] = array( 'field' => "total_valor_comissionado", 'datatype' => "VARCHAR", 'formtype' => "TEXT", 'op' => "like", 'prefix' => "%", 'suffix' => "%", 'width' => "", 'value' => ""); $liste["item"][] = array( 'field' => "total_valor_nao_comissionado", 'datatype' => "VARCHAR", 'formtype' => "TEXT", 'op' => "like", 'prefix' => "%", 'suffix' => "%", 'width' => "", 'value' => ""); and then change in your code the lines: $app->tpl->setVar('total_valor_comissionado', $soma); $app->tpl->setVar('total_valor_nao_comissionado', $soma_nao); with: $rec['total_valor_comissionado'] = $soma; $rec['total_valor_nao_comissionado'] = $soma_nao;
It didnt work till... I added the 2 itens on my .list.php and changed to $rec['total_valor_comissionado'] = $soma; $rec['total_valor_nao_comissionado'] = $soma_nao; but the value doesn't show. I tested the SQL sentence and it's working... is there any way to print values of variables on the screen? I'm really sorry to disturb you till, but this is really importante for me... thanks again!