payment control of studenst please i need help over here

payment control of studenst please i need help over here

by Angel Rojas -
Number of replies: 23
Hi, first of all i really sorry for my english, I`m From Guatemala and we normally speak spanish.

by the way I really need help with doing a payment control of the estudents in moodle.

example:
___________________________________________________________-
john 
     id 23;
            acount: 92-123456-02
            month: july
            amount: 100$
            date: 2006-07-15
            method: ......
            pending: 0$
        
            
            acount: 92-123456-02
            month: august
            amount: 80$
            date: 2006-08-10
            method: ......
            pending: 20$
____________________________________________________________________

it could be something like this. Could someone please help me with this, is urgent for a presentation in a school.

thanks.
Average of ratings: -
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Art Lader -

Hi, Angel,

Maybe you could give a little more information. What is it you would like to know? What are you trying to do? Do you want to generate a report of which students have paid all of their money and which students still owe you money?

Regards,
Art

In reply to Art Lader

Re: payment control of studenst please i need help over here

by Angel Rojas -
hi, Art Lader.

First of all thanks for answering i really apreciate it.

And about more information of the proyect here it is my idea.

for more information I add that this is just to get records, the information could be added manually by a user (eg. a secretary , a person in charge of it) so is not like a really system of payments online, is just for the students so they can see if they are missing any payment.

well the finally idea (for the feature) is to connect that database to a bank and have the bank and moodle connected and transfering information of payments but thats other thing that i have to make for now please i really need to have this done by soon as posible.

supose we have 50 students and they have to pay and inscription , other stuffs and a montly payment, so i need to get that information in a database, example "g_pagos" so the information in the database could be something like.

and example of the fields (well could be exactly does).

-the name of the user (student)==john doe

-id number or other thing to join the user with a bank or something like acount number==092-123456-03

-inscription==open number $00.00 (could be a decimal field)
-other==open number  $00.00
-other==open number $00.00
-School bus==
and fields for each month of the year and hes payment field
i put and image of the estructure.

oh and one other question that could help here, how i can add a new field to the users (and id) of alpha numeric if is posible that can be see by all. is just to find more easily the users, like in school the teachers assing a id (or number or key  or  number  identification)  to find more easily the students instead of looking his name and last name in the list, a lot of people have the same names even same names and last names so could be a problem in some cases like qualify tasks(or homeworks).
well is not very important but I`m want to make it easy for the teachers.

i hope you can help me and thanks again.

Attachment example.JPG
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by David Hicks -
Firstly, are any of the enrollement plugins useful to you? PayPal is supported as an enrollement plugin, you could perhapse make an enrollement plugin that dealt with your bank.

There is some documentation about enrollement plugins, a discussion forum about them and some more documentation about how to improve the system.

> this is just to get records, the information could be added manually by a
> user (eg. a secretary , a person in charge of it) so is not like a really system
> of payments online, is just for the students so they can see if they are
> missing any payment.

Okay, so rather that paying to be allowed to subscribe to a course, your students are paying for items once they are on a course. Payment happens seperately to Moodle - information can be manually typed in by admin staff for now.

This would probably be best implemented as a block (the developer documentation has a good step-by-step guide on how to create blocks). All the block would need to do is look in a database table to see what payments the current student had made.

It seems that there's no provision in the block system for adding database tables and fields, so you'll have to do that stage manually. As this block would be specific to your organisation, this shouldn't be a problem.

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by David Hicks -
> It seems that there's no provision in the block system for adding database tables
> and fields, so you'll have to do that stage manually. As this block would be
> specific to your organisation, this shouldn't be a problem.

Sorry, scratch that last bit, it's 100% wrong! Seemingly, database tables and fields can be added to blocks just as with modules - simply add a .sql file (or a php file if you are updating) to a subdirectory db inside your block directory. It will be executed when you visit the admin page after installing the block (thanks to Jan Dierckx for that answer). See the rss_client block for an example.

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by Angel Rojas -
Hi David, thanks for your help i really apreciete it.

well about making a block seems to be the best idea, but how i join the students to the payment database.

if we upload a txt file with 10 users or manually, I think 10 records should be created in the payment database too, with minimun records of the id, account, name and last name. but i really don`t have a bit of idea of how to make that.

and finally a block uses moodle programing (add_instance. update_instance) and other ways to insert records and get records from a database and its a bit confusing ,and i really don´t have a lot of time to learn all that programing and then think in how to make it work.

please i really need help with that, I can make the database using "phpmyadmin" or the mysql command line directly and then upload the database.sql to the block db directory, and create the code in simple php. but i need help using moodle functions and knowing what makes what.

could someone help me with moodle functions and making a block or a litle introduction for making a block and his functions please, we could work as a team, them when i learn to use moodle a litle bit more i could help others. is just that i need to finish that proyect as soon as posible.

PD. Again sorry about my spelling and english writing, but i learn by my onw because i normaly speak spanish.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Angel Rojas -
Mmm well it looks like is too much to ask so at least could someone tell me where i can find documentation about making blocks,modules and about functions please.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Art Lader -

Hi, angel,

I think you are loooking for this - http://docs.moodle.org/en/Developer_documentation and this http://docs.moodle.org/en/Blocks_Howto

Hope that helps.

-- Art

P. S. By the way, your English is a lot better than my Spanish! smile

In reply to Art Lader

Re: payment control of studenst please i need help over here

by Angel Rojas -
jaja i hope that you have a really good spanish.

well about the docs i found documentation about blocks but to be honest i did´nt find info about modules, anybody knows where i can find a tutorial, at least just for know how to get , insert and update data from a database.

please i really need this.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by David Hicks -
There is some documentation on module creation in the "contrib" area of the CVS reposatory - look at the NEWMODULE directory for an explanation of how to create new modules.

I don't think, though, that a module is what you're looking for - modules tend to be items that teachers can add as activites in courses, associated with a particular lesson, whereas blocks are associated with whole courses.

Firstly, you should decide what database tables you'll need to use. This is just basic database design stuff, non Moodle-specific, but remember that Moodle already stores things like pupil names. From your diagram you posted earlier, maybe you need tables like so (place the following in mysql.sql in the DB subdirectory of your module):

CREATE TABLE prefix_payment_type (
  id int(10) unsigned NOT NULL auto_increment,
  description text,
  amount int(10),
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
) TYPE=MyISAM;

CREATE TABLE prefix_payment (
  id int(10) unsigned NOT NULL auto_increment,
  student int(10) unsigned NOT NULL,
  type int(10) unsigned NOT NULL,
  paid boolean,
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
  KEY student (student),
  KEY payment_type (payment)
) TYPE=MyISAM;

This would give you a "payment" item that has either been paid or not and is always associated with exactly one student and one payment type. I don't know how you want to go about deciding which students are liable for which payments, but you'll need to create new "payment" records for each student that's liable for a payment. Do this with the insert_record function, eg:

insert_record('payment', array("student"=>$student->id, "type=>$type->id, "paid"=>false));

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by Angel Rojas -
hi David.

thanks for the database help, to be honest that part i can do it very well(design DB), well the real problem here is that i simply want no know how to create a module where i can insert, update and record in a database, i really can`t find the Documentation about creating modules and looks like nobody here is going to tell me jeje.

i only want to have records in a database of payments made it by the students, and have a web page that shows that records.

the idea is that we have a parent (or person in charge of a student) that want to see how the payments records are. so he have a link to the payment page. then he enter a name, id or password to see only he`s son (student) payments.

well i hope somebody can help me with this (this part of the proyect it had to be presented by the end of july (7 or 8 days ago). so please a really need help with this).

I know that i have to read documentation and made it by my self but i really do`nt have that time rigth now and i really sorry for bother this much.



In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
In reply to Jon Bolton

Re: payment control of studenst please i need help over here

by Angel Rojas -
hi Jon, thanks for the link, but the documentation is a litle short about instances, i try to install a mod and the database is made it, the name is correct but when i get to the point of add instances i don`t know what to make here (whats all that about instances), i just want to show,insert, display and update from a database but i can`t do it. did you know any tutorial to make something very simple? i would really apreciate that, thanks a lot and sorry for keep bodering.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Angel Rojas -
well i kind of get this idea from David Hicks (thanks a lot) and hope this give you a better idea of what i need, please ask me what ever you want and

if im_wrong=true (
 correct me
)
else(
please help me
)
(sorry very stupid joke)

CREATE TABLE prefix_payment_type (
  id int(10) unsigned NOT NULL auto_increment,
  type int(10) unsigned NOT NULL,
  description text,
  amount int(10),
  pending int(10),
  month varchar(20),
  paid boolean,
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
) TYPE=MyISAM;

CREATE TABLE prefix_payment (
  id int(10) unsigned NOT NULL auto_increment,
  bank varchar(20),
  account int(10),
  student int(10) unsigned NOT NULL,
  type = varchar(20)
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
  KEY student (student),
  KEY payment_type (payment)
) TYPE=MyISAM;

insert_record('payment', array("student"=>$student->id, "type=>$type->id, "paid"=>false));


i think with the insert_record moodle creates a record of payment for each student in moodle.
and then every student could create a payment_type item for each payment that he makes.

for example
//////////////////////////////////////////////////////////////
"Student john doe, id=29" <-- we click on this and goes to other page.
"Student pepe vars, id=30"

////////////////////////////////////////////////////////////
type=inscription; <-this could be a list (select field type)
description="payment for incription in the school";
amount=$150;
pemding=$0;
month="janury";
paid=true;

type=monhtly_payment_school;
description="payment of the monhtly payment for study in the school";
amount=$100;
pemding=$0;
month="janury";
paid=true;

type=monhtly_payment_bus;
description="payment of monhtly payment for the school bus";
amount=$0;
pemding=$0;
month="janury";
paid=false;
//////////////////////////////////////////////////////////


well that is what i think that is the idea, please correct me if im wrong.

know i think that adding this to a db directory in a module is one option.
then creating a page that displays all the students (type = links "i think"), and when we click on the student name, other page displays the payments types that he has. if we are admin or person of charge of add info to the school, then display the option to add new payments of the student like update, insert, delete and other options.

well i hope someone can help because i really need this and it was supposed to be presented a lot of days ago.

thanks for all the help that all of you has give me until now.
God bless you  and thank you very much.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by David Hicks -
> The idea is that we have a parent (or person in charge of a student) that
> want to see how the payments records are. so he have a link to the payment
> page. then he enter a name, id or password to see only he`s son (student)
> payments.

Oh crikey... Okay, so your student's parents all have logins of some kind already? And these accounts are linked to the pupil accounts in some way? If not, I'd just stick to a pupil-only solution for the moment and upgrade it later on.

In Moodle, Modules are "activities" designed to be placed in Courses. For instance, a Quiz is a type of Module. One course can have several instances of a Module - you might have a quiz at the end of each week in a Course, for example.

You are probably better off making a Moodle Block. This will appear on the side of a course page, just the one Block for a whole Course. A step-by-step guide to making a Block is available at http://docs.moodle.org/en/Blocks_Howto.

Your Block's get_content() function will be the part that produces the list of payments for a student. If you've got those two database tables set up - "payment_type" and "payment" - start by searching the "payment" table for any records associated with the current student, eg:

    $paymentsArray = get_records('payment', 'student', $USER->id);

Remember to declare $USER as global at the start of get_content:

    global $CFG, $USER;

You might also be needing the current course's record (different feed payable for different courses?):

    $course = get_record('course', 'id', $this->instance->pageid);

Anyway, you'll now have a list of a student's payments in $paymentArray. Loop through the array and print out a nice HTML list for the user to see (maybe just list unpaid items, or maybe list paid items with a green tick next to them and unpaid in red with a "Pay Now!..." link next to them?).

The "payment_type" table is there for your admin staff to define individual payment types. So, they could define payment types of "Annual Fee", "January School Fee", "January Bus Fee", "February...", etc. You'll only need one of each payment type, but you'll need a new record in the "payment" table to associate each student with a particular payment type that they're due to make. I don't know how you decide this - if all students simply pay all payment types, then every time a payment type is added you could have your code loop through all students and add a new "payment" record.

You'll probably need a seperate PHP page somewhere for your admin staff to set up new payment types, change students payment details, etc. Maybe call this "edit.php" and place it in your block directory. Then, your block's get_content() function can check to see if the current user is an admin user. If so, rather than try and list any payments it could simply display a link to the admin page.

Moodle's developer documentation is a bit patchy at the moment, and I realise it must be tricky trying to figure stuff out in a forign language! Your best bet is probably to look through the PHP files that make up Moodle itself - in particular, the functions in lib/datalib.php are going to be useful to you.

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by Angel Rojas -
Hi David, thanks a lot for all your help.

well actually no the parents doesn`t have a password yet, and the entity parent->son has not yet been implemented, i was thinking i adding a new field to the user depending of what account they have (eg E=student,P=parent,M=teacher) and depending of that grade of account they are going to be able of navegate trough moodle. well thats other idea.


well other thing is that maybe we can put and field for the parent and a field for the son so we have something like this.

parent John Doe
parent_id  =  328;

and 2 sons called
Johni Doe
with Parent_link=328;

Jahni Doe
with Parent_link=328;

and like that we can know who`s the father of who.


well i made this tables in my database with phpmyadmin.

CREATE TABLE prefix_payment_type (
  id int(10) NOT NULL auto_increment,
  link int(10),
  type varchar(20),
  description text,
  amount int(10),
  pending int(10),
  month varchar(20),
  paid bool,
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
) TYPE=innodb;

CREATE TABLE prefix_payment (
  id int(10) unsigned NOT NULL auto_increment,
  bank varchar(20),
  account int(10),
  student int(10) unsigned NOT NULL,
  parent_id int(10),
  password varchar(20),
  PRIMARY KEY  (id),
  UNIQUE KEY id (id),
) TYPE=innodb;

so we can put the password of the parent in the field "password".
the parent_id int(10) field is goig to have whos the father,
then make a sql sentence like.

$sql="select * from payment where parent_id = $USER->id"
echo "<table>";
while ($num=mysql_fetch_array($sql)){
echo "<tr>";
echo "<td>"."<a href=\"block_page.php?no=$num[0]\">$num[1]"."<td>";
echo "</tr>";
}
echo "<table>";

then in the block_page we catch the  var  no with the  $_GET metod  and  we make another  sql sentence int the payment_type table.

well thats the idea how did you see it? its too hard or to complicated or any suggestion about it please.

im starting to read about making blocks is just that i dont have enoung time to do it.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by David Hicks -
> i was thinking i adding a new field to the user depending of what account
> they have (eg E=student,P=parent,M=teacher) and depending of that grade
> of account they are going to be able of navegate trough moodle.

This is what the new roles feature does - lets you define things like parent accounts. Roles are due in release 1.7, although you might find them usable now. You will have difficulty upgrading your copy of Moodle if you're making lots of changes all over the place to accomodate your own roles-like implementation.

> im starting to read about making blocks is just that i dont have enoung time
> to do it.

Well, best of luck with your project, hope we've given you enough information to get you started!

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by Angel Rojas -
Hi David, again thanks a lot for all the help that you have provided me.

well im gonna investigated about roles, i have moodle 1.6.

and you have ( or had) provided  me a lot of information, im triying to read about making modules, i could (or i already)  make a new block like the html_block and make the tables in moodle database, now i only need to start making the functions and programing so this block make what i want, i think the functios for databases are something like insert_record() get_record() and others.

thanks a lot for your help moodlers.
In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Angel Rojas -
by the way, i know that is not correct to doesn`t have time but actually is the fact that i don`t have time for be asking for so much help, i normally read  and learn all about the proyect and learn new programing or other kind of things about, that i have to do but first of all normally the information is in spanish so is more easy to read it, but if is in english i have to use a trasnlastor like babelfish of altavista or something like that to write and understand better.

so excuse me if i boder someone with all this questions but i really can do it.
thanks for your help David and sorry for bodering that much.

In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by David Hicks -
No worries - I know I'd have a nightmare of a time if I had to do a project in Spanish! Hmm - that'd be a nice feature, being able to set an automatic translation method for web pages, discussion groups, etc. By default it could maybe use Google / Babelfish web services, but you could maybe hook it up to a proper translation service, too.

Hmm... I wonder if anywhere offers dicussion groups with posts professionally translated into a choice of languages? Simple revenue model - pay per word per language. The ultimate in global groupware - have a team of people talk seamlessly amoungst themselves via a website in their native language. Moodle would make a nice platform to base such a system on, I reckon, as you'd have all the content creation facilities and so on to use, too. Now, there's an idea...

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by Angel Rojas -
Im sure that you could learn spanish very easily and very fast, and your idea sounds very interesting and could help a lot of people given them a very easy way to comunicate with out borders (stops), when we use a translator sometimes could be nonunderstandable or not what the persona meants to say. other problem is that you lost a lot of time trasnlating so much words in babelfish, i use babelfish a lot of times the trasnlators so i could take a long time to write messeges very long and even them the messege could have a lot of errors (i hope not all this messeges jeje). well this idea could be done making some modifications to the post system (added to a database but not showed) them a translator could act there and make a copy in some new lenguajes then display the messege depending of the current user. well this thing have to be discussed more seriusly and slow jaja. 


In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by Angel Rojas -
hi again, well i manage to create a block in moodle and display some text so i think thats a start.

rember this "insert_record('payment', array("student"=>$student->id, "type=>$type->id, "paid"=>false));"

well i was thinking that a new record of payment item have to be created in the payment table with any new user that is registered so sorry for asking this

do you know how to make this or where the code could be.

and where i can find functions to acces to databases.

 and finally the block is a simple box that display something in one side of moodle pages but i need more space to show all the information of the student payments so do you know if the blocks have anything for this kind of request.

well sorry for keep bothering you  but  i dont know if you read about this proyect was for some time ago some im so kind of late and i really dont have time but i will as soon as i finish with this payment proyect.

In reply to Angel Rojas

Re: payment control of studenst please i need help over here

by David Hicks -
> i was thinking that a new record of payment item have to be created in
> the payment table with any new user that is registered

You'll have to think about all the places where students can be added to your copy of Moodle. For manual additions, /user/edit.php is where you want to look - probably around that block of code at lines 72 - 277, where user records seem to be added. Simply add your own function call in after a new user has been confirmed added to the database.

Users can be added in other ways (I don't know, though - they might all call that one form as a web service?) - if you import data from other sources, check the code for the one you use.

Remember, if you're making changes to things like /user/edit.php, keep track of the changes you make - if you upgrade Moodle you don't want to loose your work!

> and where i can find functions to acces to databases.

You want to look at the functions in /lib/datalib.php in your Moodle install directory.

> and finally the block is a simple box that display something in one side of
> moodle pages but i need more space to show all the information of the
> student payments so do you know if the blocks have anything for this kind
> of request.

You can display whatever you like inside a Block - images, tables, whatever - that get_content() function can return whatever HTML you like. You can include a preferred_width() function in your block_blockname.php to return a different width for your Block, if you like - seemingly, all standard Moodle course formats will handle up to 210 pixels, but you can always try bigger (or redesign the course page to allow bigger Blocks). If you still need more room, simply have a hyperlink from your Block to another PHP page in your Block's directory (details.php?) of your own where you can use the full page all you like. This PHP page would need to include Moodle's libraries and so on - I'm currently developing a block that uses such a page:

<?PHP
    require_once("../../config.php");

    $id = required_param('id', PARAM_INT); // If your page need any parameters,
    $path = required_param('path', PARAM_RAW); // set them here.

    if (!($course = get_record('course', 'id', $id))) {
        error('Invalid course id');
    }

    if (!$site = get_site()) {
        error("No site found!");
    }

    // Set up the breadcumb trail.
    print_header('Create or Edit a Widget', 'Create or Edit a Widget', "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> Create or Edit a Widget");
?>

<table> // Or whatever...
    You code goes here.
</table>

<?PHP
    print_footer();
?>

--
David Hicks
In reply to David Hicks

Re: payment control of studenst please i need help over here

by Angel Rojas -
Hi david, thanks for the help, well im triying moodle 1.7 cvs but looks like have a lot of bugs yet jeje.

what i dont see is how this role_feature can help with the parents problem but i imagite that in later release moodle staff is going to add more thing to this feature.