4 use vars qw( @ISA @EXPORT_OK );
12 $FS::svc_domain::whois_hack = 1;
13 $FS::svc_domain::whois_hack = 1;
15 @ISA = qw( Exporter );
16 @EXPORT_OK = qw( create_initial_data );
20 FS::Setup - Database setup
28 Currently this module simply provides a place to store common subroutines for
39 sub create_initial_data {
42 my $oldAutoCommit = $FS::UID::AutoCommit;
43 local $FS::UID::AutoCommit = 0;
44 $FS::UID::AutoCommit = 0;
49 populate_initial_data(%opt);
55 if ( $oldAutoCommit ) {
56 dbh->commit or die dbh->errstr;
61 sub populate_locales {
64 use FS::cust_main_county;
67 foreach my $country ( sort map uc($_), all_country_codes ) {
68 _add_country($country);
73 sub populate_addl_locales {
77 'FM' => 'Federated States of Micronesia',
78 'MH' => 'Marshall Islands',
80 'AA' => "Armed Forces Americas (except Canada)",
81 'AE' => "Armed Forces Europe / Canada / Middle East / Africa",
82 'AP' => "Armed Forces Pacific",
86 foreach my $country ( keys %addl ) {
87 foreach my $state ( keys %{ $addl{$country} } ) {
88 # $longname = $addl{$country}{$state};
89 _add_locale( 'country'=>$country, 'state'=>$state);
97 use Locale::SubCountry;
99 my( $country ) = shift;
101 my $subcountry = eval { new Locale::SubCountry($country) };
102 my @states = $subcountry ? $subcountry->all_codes : undef;
104 if ( !scalar(@states) || ( scalar(@states)==1 && !defined($states[0]) ) ) {
106 _add_locale( 'country'=>$country );
110 if ( $states[0] =~ /^(\d+|\w)$/ ) {
111 @states = map $subcountry->full_name($_), @states
114 foreach my $state ( @states ) {
115 _add_locale( 'country'=>$country, 'state'=>$state);
123 my $cust_main_county = new FS::cust_main_county( { 'tax'=>0, @_ });
124 my $error = $cust_main_county->insert;
125 die $error if $error;
128 sub populate_initial_data {
131 my $data = initial_data(%opt);
133 foreach my $table ( keys %$data ) {
135 my $class = "FS::$table";
139 my @records = @{ $data->{$table} };
141 foreach my $record ( @records ) {
142 my $args = delete($record->{'_insert_args'}) || [];
143 my $object = $class->new( $record );
144 my $error = $object->insert( @$args );
145 die "error inserting record into $table: $error\n"
156 #tie my %hash, 'Tie::DxHash',
157 tie my %hash, 'Tie::IxHash',
161 { 'groupname' => 'Superuser' },
165 'part_bill_event' => [
167 'event' => 'Batch card',
169 'eventcode' => '$cust_bill->batch_card(%options);',
171 'plan' => 'batch-card',
174 'event' => 'Send invoice',
176 'eventcode' => '$cust_bill->send();',
181 'event' => 'Send invoice',
183 'eventcode' => '$cust_bill->send();',
188 'event' => 'Send invoice',
190 'eventcode' => '$cust_bill->send();',
195 'event' => 'Suspend',
197 'eventcode' => '$cust_bill->suspend();',
201 #{ 'payby' => 'DCLN',
202 # 'event' => 'Retriable',
204 # 'eventcode' => '$cust_bill_event->retriable();',
206 # 'plan' => 'retriable',
210 #you must create a service definition. An example of a service definition
211 #would be a dial-up account or a domain. First, it is necessary to create a
212 #domain definition. Click on View/Edit service definitions and Add a new
213 #service definition with Table svc_domain (and no modifiers).
216 'svcdb' => 'svc_domain',
220 #Now that you have created your first service, you must create a package
221 #including this service which you can sell to customers. Zero, one, or many
222 #services are bundled into a package. Click on View/Edit package
223 #definitions and Add a new package definition which includes quantity 1 of
224 #the svc_domain service you created above.
226 { 'pkg' => 'System Domain',
227 'comment' => '(NOT FOR CUSTOMERS)',
231 'pkg_svc' => { 1 => 1 }, # XXX
232 'primary_svc' => 1, #XXX
241 #After you create your first package, then you must define who is able to
242 #sell that package by creating an agent type. An example of an agent type
243 #would be an internal sales representitive which sells regular and
244 #promotional packages, as opposed to an external sales representitive
245 #which would only sell regular packages of services. Click on View/Edit
246 #agent types and Add a new agent type.
248 { 'atype' => 'internal' },
251 #Allow this agent type to sell the package you created above.
253 { 'typenum' => 1, #XXX
258 #After creating a new agent type, you must create an agent. Click on
259 #View/Edit agents and Add a new agent.
261 { 'agent' => 'Internal',
262 'typenum' => 1, # XXX
266 #Set up at least one Advertising source. Advertising sources will help you
267 #keep track of how effective your advertising is, tracking where customers
268 #heard of your service offerings. You must create at least one advertising
269 #source. If you do not wish to use the referral functionality, simply
270 #create a single advertising source only. Click on View/Edit advertising
271 #sources and Add a new advertising source.
273 { 'referral' => 'Internal', },
276 #Click on New Customer and create a new customer for your system accounts
277 #with billing type Complimentary. Leave the First package dropdown set to
280 { 'agentnum' => 1, #XXX
283 'last' => 'Accounts',
284 'address1' => '1234 System Lane',
285 'city' => 'Systemtown',
290 'payinfo' => 'system', #or something
291 'paydate' => '1/2037',
295 #From the Customer View screen of the newly created customer, order the
296 #package you defined above.
298 { 'custnum' => 1, #XXX
303 #From the Package View screen of the newly created package, choose
304 #(Provision) to add the customer's service for this new package.
305 #Add your own domain.
307 { 'domain' => $opt{'domain'},
310 'action' => 'N', #pseudo-field
314 #Go back to View/Edit service definitions on the main menu, and Add a new
315 #service definition with Table svc_acct. Select your domain in the domsvc
316 #Modifier. Set Fixed to define a service locked-in to this domain, or
317 #Default to define a service which may select from among this domain and
318 #the customer's domains.
329 sub populate_access {
332 use FS::access_right;
334 foreach my $rightname ( FS::AccessRight->rights ) {
335 my $access_right = new FS::access_right {
336 'righttype' => 'FS::access_group',
337 'rightobjnum' => 1, #$supergroup->groupnum,
338 'rightname' => $rightname,
340 my $ar_error = $access_right->insert;
341 die $ar_error if $ar_error;
344 #foreach my $agent ( qsearch('agent', {} ) ) {
345 my $access_groupagent = new FS::access_groupagent {
346 'groupnum' => 1, #$supergroup->groupnum,
347 'agentnum' => 1, #$agent->agentnum,
349 my $aga_error = $access_groupagent->insert;
350 die $aga_error if $aga_error;
355 sub populate_msgcat {
357 use FS::Record qw(qsearch);
360 foreach my $del_msgcat ( qsearch('msgcat', {}) ) {
361 my $error = $del_msgcat->delete;
362 die $error if $error;
365 my %messages = msgcat_messages();
367 foreach my $msgcode ( keys %messages ) {
368 foreach my $locale ( keys %{$messages{$msgcode}} ) {
369 my $msgcat = new FS::msgcat( {
370 'msgcode' => $msgcode,
372 'msg' => $messages{$msgcode}{$locale},
374 my $error = $msgcat->insert;
375 die $error if $error;
381 sub msgcat_messages {
384 # 'en_US' => 'Message',
389 'passwords_dont_match' => {
390 'en_US' => "Passwords don't match",
394 'en_US' => 'Invalid credit card number',
397 'unknown_card_type' => {
398 'en_US' => 'Unknown card type',
405 'empty_password' => {
406 'en_US' => 'Empty password',
409 'no_access_number_selected' => {
410 'en_US' => 'No access number selected',
414 'en_US' => 'Illegal (text)',
415 #'en_US' => 'Only letters, numbers, spaces, and the following punctuation symbols are permitted: ! @ # $ % & ( ) - + ; : \' " , . ? / in field',
418 'illegal_or_empty_text' => {
419 'en_US' => 'Illegal or empty (text)',
420 #'en_US' => 'Only letters, numbers, spaces, and the following punctuation symbols are permitted: ! @ # $ % & ( ) - + ; : \' " , . ? / in required field',
423 'illegal_username' => {
424 'en_US' => 'Illegal username',
427 'illegal_password' => {
428 'en_US' => 'Illegal password (',
431 'illegal_password_characters' => {
432 'en_US' => ' characters)',
435 'username_in_use' => {
436 'en_US' => 'Username in use',
439 'illegal_email_invoice_address' => {
440 'en_US' => 'Illegal email invoice address',
444 'en_US' => 'Illegal (name)',
445 #'en_US' => 'Only letters, numbers, spaces and the following punctuation symbols are permitted: , . - \' in field',
449 'en_US' => 'Illegal (phone)',
454 'en_US' => 'Illegal (zip)',
459 'en_US' => 'Expired card',
463 'en_US' => 'Day Phone',
467 'en_US' => 'Night Phone',
470 'svc_external-id' => {
471 'en_US' => 'External ID',
474 'svc_external-title' => {
479 'en_US' => 'Driver\'s License',
483 'en_US' => 'Driver\'s License State',