There are two functions you can call in a loop while you read your
data that will pretty much do this for you.  The create_service and
service_message function.  These are from the include/services.inc.php
and include/support.inc.php.  You'll also probably want to have the
bunch of included files that get you into the database and give you
other functions that these might rely on too.

// Includes
include('./include/config.inc.php');
include('./include/database.inc.php');
include('./include/billing.inc.php');
include('./include/citrus_base.php');
include('./include/services.inc.php');
include('./include/support.inc.php');

// this function will put the data into the user services table and
attributes table
$new_user_service_id = create_service($account_number,
$master_service_id, $billing_id, $usage_multiple,
$attribute_table_name, $attribute_fieldname_string,
$attribute_fieldvalue_string);

The usage_multiple must 1 or greater.

If you have an attributes table you'll need to use
attribute_fieldname_string that names the attribute table fields you
want to fill in such as:
$attribute_fieldname_string = "username, password, domain";
$attributes_fieldvalue_string = "'benmonypenny', 'p4ssw0rd', 'gmail.com'";

If you do not have an attributes table you can leave them as NULL.  If
you do have an attributes table but are not inserting attributes right
now you'll still want to include something as a placeholder so it
makes the attributes table for this particular service item.

// this will put the note for the service being added in the customer history
service_message('added', $account_number, $master_service_id,
$new_user_service_id, NULL, NULL);

Note the service message takes the new_user_service_id that was output
by the create_service function.

// depending on your requirements for application logging you may also
want to log that
// this service was inserted by using the log_activity function
log_activity($DB,$user,$account_number,'create','service',$new_user_service_id,'success');

You can see this all in action around line 74 of the
/modules/services/create.php file


Paul


-- 
The CitrusDB Project | http://www.citrusdb.org
Open Source Customer Care & Billing System

2010/2/18 Ben Monypenny <benmonype...@googlemail.com>:
> Hi Paul,
>
> First of all can I say a huge thank you for the huge time and effort that
> you have obviously put into CitrusDB. Its great to see some quality open
> source software that helps out small businesses.
>
> My business provides  a service to customers every four weeks, but sometimes
> it can be five weeks or even more irregularly. I am building a new site and
> attempting to find a way to integrate CitrusDB with my current customer
> records and billing system. I have configured my services in CitrusDB with a
> frequency of zero so that I can add them to customers when they occur. But,
> I would like to be able to add them to batches of customers at a time.
>
> If I create a php script to append the CitrusDB mysql tables from a csv file
> (correctly formatted and with the correct CitrusDB account_number's and
> master_services id's), could you let me know which tables I should append?
>
> For example, if I add records to the bottom of the user_services table
> (making sure the sequential id numbers are correct) and then use the same
> process to add records to the bottom of the customer_history table (making
> sure the user_services id's match), will this work without breaking anything
> in CitrusDB? Or are there any other tables which I will need to append?
>
> Many thanks in advance,
>
> Ben Monypenny
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Citrusdb-users mailing list
> Citrusdb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/citrusdb-users
>
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Citrusdb-users mailing list
Citrusdb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/citrusdb-users

Reply via email to