my @taglist = @ARGV;
my $arg_list_length = scalar @taglist;
-if($arg_list_length < 1) { @taglist = ("authorisedvalues","calendar","circrules","itemtypes","libraries","patrontypes","preferences","smsproviders"); } #borrowerattributes
+if($arg_list_length < 1) { @taglist = ("authorisedvalues","booksellers","budgets","borrowerattributes","calendar","circrules","itemtypes","letters","libraries","patrontypes","preferences","reports","smsproviders"); }
$MIGGITDIR =~ s/\/\//\//;
my $timestamp = create_timestamp();
print "Backing up $backupfile ... \n";
backup_authorisedvalues($dbh,$backupfile);
}
+ if ($backup eq 'booksellers') {
+ $backupfile = $MIGGITDIR . 'booksellers' . '.' . $timestamp . '.xml';
+ print "Backing up $backupfile ... \n";
+ backup_booksellers($dbh,$backupfile);
+ }
if ($backup eq 'borrowerattributes') {
- $backupfile = $MIGGITDIR . 'borrower_attributes' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
- backup_borrower_attributes($dbh,$backupfile);
+ $backupfile = $MIGGITDIR . 'borrowerattributes' . '.' . $timestamp . '.xml';
+ print "Backing up $backupfile ... \n";
+ backup_borrower_attributes($dbh,$backupfile);
+ }
+ if ($backup eq 'budgets') {
+ $backupfile = $MIGGITDIR . 'budgets' . '.' . $timestamp . '.xml';
+ print "Backing up $backupfile ... \n";
+ backup_budgets($dbh,$backupfile);
}
if ($backup eq 'calendar') {
$backupfile = $MIGGITDIR . 'calendar' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_calendar($dbh,$backupfile);
}
if ($backup eq 'circrules') {
$backupfile = $MIGGITDIR . 'circrules' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_circrules($dbh,$backupfile);
}
if ($backup eq 'itemtypes') {
$backupfile = $MIGGITDIR . 'itemtypes' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_itemtypes($dbh,$backupfile);
}
+ if ($backup eq 'letters') {
+ $backupfile = $MIGGITDIR . 'letters' . '.' . $timestamp . '.xml';
+ print "Backing up $backupfile ... \n";
+ backup_letters($dbh,$backupfile);
+ }
if ($backup eq 'libraries') {
$backupfile = $MIGGITDIR . 'libraries' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_libraries($dbh,$backupfile);
}
if ($backup eq 'patrontypes') {
$backupfile = $MIGGITDIR . 'patrontypes' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_patrontypes($dbh,$backupfile);
}
if ($backup eq 'preferences') {
$backupfile = $MIGGITDIR . 'systempreferences' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_preferences($dbh,$backupfile);
}
+ if ($backup eq 'reports') {
+ $backupfile = $MIGGITDIR . 'reports' . '.' . $timestamp . '.xml';
+ print "Backing up $backupfile ... \n";
+ backup_reports($dbh,$backupfile);
+ }
if ($backup eq 'smsproviders') {
$backupfile = $MIGGITDIR . 'smsproviders' . '.' . $timestamp . '.xml';
- print "Restoring from $restorefile ... \n";
+ print "Backing up $backupfile ... \n";
backup_smsproviders($dbh,$backupfile);
}
}
open(my $fh, '>', $backupfile) or die "Could not open $backupfile!";
my $xml = XML::Writer->new(OUTPUT => $fh, DATA_MODE => 1, DATA_INDENT => 2, );
$xml->xmlDecl('UTF-8');
+ $xml->startTag('document');
+
$xml->startTag('authorisedvalues');
my $query = "SELECT category,authorised_value,lib,lib_opac,imageurl FROM authorised_values WHERE category != 'ITEMTYPECAT'";
my $sth = $dbh->prepare($query);
$xml->endTag('value');
}
$xml->endTag('authorisedvalues');
+
+ $xml->startTag('categories');
+ $query = "SELECT category_name FROM authorised_value_categories WHERE category_name != 'ITEMTYPECAT'";
+ $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array) {
+ $xml->startTag('value');
+ $xml->dataElement('name', $row[0]);
+ $xml->endTag('value');
+ }
+ $xml->endTag('categories');
+
+ $xml->endTag('document');
+ $xml->end();
+ close $fh;
+ return;
+}
+
+sub backup_booksellers {
+ my $dbh = shift;
+ my $backupfile = shift;
+
+ open(my $fh, '>', $backupfile) or die "Could not open $backupfile!";
+ my $xml = XML::Writer->new(OUTPUT => $fh, DATA_MODE => 1, DATA_INDENT => 2, );
+ $xml->xmlDecl('UTF-8');
+ $xml->startTag('booksellers');
+ my $query = "SELECT name,address1,address2,address3,address4,phone,accountnumber,othersupplier,currency,booksellerfax,notes,bookselleremail,booksellerurl,postal,url,active,listprice,invoiceprice,gstreg,listincgst,invoiceincgst,tax_rate,discount,fax,deliverytime FROM aqbooksellers";
+ my $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array) {
+ $xml->startTag('value');
+ $xml->dataElement('name', $row[1]);
+ $xml->dataElement('address1', $row[2]);
+ $xml->dataElement('address2', $row[3]);
+ $xml->dataElement('address3', $row[4]);
+ $xml->dataElement('address4', $row[5]);
+ $xml->dataElement('phone', $row[6]);
+ $xml->dataElement('accountnumber', $row[7]);
+ $xml->dataElement('othersupplier', $row[8]);
+ $xml->dataElement('currency', $row[9]);
+ $xml->dataElement('booksellerfax', $row[10]);
+ $xml->dataElement('notes', $row[11]);
+ $xml->dataElement('bookselleremail', $row[12]);
+ $xml->dataElement('booksellerurl', $row[13]);
+ $xml->dataElement('postal', $row[14]);
+ $xml->dataElement('url', $row[15]);
+ $xml->dataElement('active', $row[16]);
+ $xml->dataElement('listprice', $row[17]);
+ $xml->dataElement('invoiceprice ', $row[18]);
+ $xml->dataElement('gstreg', $row[19]);
+ $xml->dataElement('listincgst', $row[20]);
+ $xml->dataElement('invoiceincgst', $row[21]);
+ $xml->dataElement('tax_rate', $row[22]);
+ $xml->dataElement('discount', $row[23]);
+ $xml->dataElement('fax ', $row[24]);
+ $xml->dataElement('deliverytime', $row[25]);
+ $xml->endTag('value');
+ }
+ $xml->endTag('booksellers');
$xml->end();
close $fh;
return;
return;
}
+sub backup_budgets {
+ my $dbh = shift;
+ my $backupfile = shift;
+
+ open(my $fh, '>', $backupfile) or die "Could not open $backupfile!";
+ my $xml = XML::Writer->new(OUTPUT => $fh, DATA_MODE => 1, DATA_INDENT => 2, );
+ $xml->xmlDecl('UTF-8');
+ $xml->startTag('document');
+
+ $xml->startTag('budgets');
+ my $query = 'SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_NAME = "aqbudgets"';
+ my $sth = $dbh->prepare($query);
+ $sth->execute();
+ my @ai = $sth->fetchrow_array;
+ $xml->dataElement('autoincrement', $ai[0]);
+ $query = "SELECT budget_id,budget_parent_id,budget_code,budget_name,budget_branchcode,budget_amount,budget_encumb,budget_expend,budget_notes,timestamp,budget_period_id,sort1_authcat,sort2_authcat,budget_owner_id,budget_permission FROM aqbudgets";
+ $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array) {
+ $xml->startTag('value');
+ $xml->dataElement('budget_id', $row[0]);
+ $xml->dataElement('budget_parent_id', $row[1]);
+ $xml->dataElement('budget_code', $row[2]);
+ $xml->dataElement('budget_name', $row[3]);
+ $xml->dataElement('budget_branchcode', $row[4]);
+ $xml->dataElement('budget_amount', $row[5]);
+ $xml->dataElement('budget_encumb', $row[6]);
+ $xml->dataElement('budget_expend', $row[7]);
+ $xml->dataElement('budget_notes', $row[8]);
+ $xml->dataElement('timestamp', $row[9]);
+ $xml->dataElement('budget_period_id', $row[10]);
+ $xml->dataElement('sort1_authcat', $row[11]);
+ $xml->dataElement('sort2_authcat', $row[12]);
+ $xml->dataElement('budget_owner_id', $row[13]);
+ $xml->dataElement('budget_permission', $row[14]);
+ $xml->endTag('value');
+ }
+ $xml->endTag('budgets');
+
+ $xml->startTag('budgetperiods');
+ $query = 'SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_NAME = "aqbudgetperiods"';
+ $sth = $dbh->prepare($query);
+ $sth->execute();
+ @ai = $sth->fetchrow_array;
+ $xml->dataElement('autoincrement', $ai[0]);
+ $query = "SELECT budget_period_id,budget_period_startdate,budget_period_enddate,budget_period_active,budget_period_description,budget_period_total,budget_period_locked,sort1_authcat,sort2_authcat FROM aqbudgetperiods";
+ $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array) {
+ $xml->startTag('value');
+ $xml->dataElement('budget_period_id', $row[0]);
+ $xml->dataElement('budget_period_startdate', $row[1]);
+ $xml->dataElement('budget_period_enddate', $row[2]);
+ $xml->dataElement('budget_period_active', $row[3]);
+ $xml->dataElement('budget_period_description', $row[4]);
+ $xml->dataElement('budget_period_total', $row[5]);
+ $xml->dataElement('budget_period_locked', $row[6]);
+ $xml->dataElement('sort1_authcat', $row[7]);
+ $xml->dataElement('sort2_authcat', $row[8]);
+ $xml->endTag('value');
+ }
+ $xml->endTag('budgetperiods');
+
+ $xml->endTag('document');
+ $xml->end();
+ close $fh;
+ return;
+}
+
sub backup_calendar {
my $dbh = shift;
my $backupfile = shift;
return;
}
+sub backup_letters {
+ my $dbh = shift;
+ my $backupfile = shift;
+
+ open(my $fh, '>', $backupfile) or die "Could not open $backupfile!";
+ my $xml = XML::Writer->new(OUTPUT => $fh, DATA_MODE => 1, DATA_INDENT => 2, );
+ $xml->xmlDecl('UTF-8');
+ $xml->startTag('letters');
+
+ my $query = "SELECT module,code,branchcode,name,is_html,title,content,message_transport_type,lang FROM letter";
+ my $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array) {
+ $xml->startTag('letter');
+ $xml->dataElement('module',$row[0]);
+ $xml->dataElement('code',$row[1]);
+ $xml->dataElement('branchcode',$row[2]);
+ $xml->dataElement('name',$row[3]);
+ $xml->dataElement('is_html',$row[4]);
+ $xml->dataElement('title',$row[5]);
+ $xml->dataElement('content',$row[6]);
+ $xml->dataElement('message_transport_type',$row[7]);
+ $xml->dataElement('lang',$row[8]);
+ $xml->endTag('letter');
+ }
+
+ $xml->endTag('letters');
+ $xml->end();
+ close $fh;
+ return;
+}
+
sub backup_libraries {
my $dbh = shift;
my $backupfile = shift;
return;
}
+sub backup_reports {
+ my $dbh = shift;
+ my $backupfile = shift;
+
+ open(my $fh, '>', $backupfile) or die "Could not open $backupfile!";
+ my $xml = XML::Writer->new(OUTPUT => $fh, DATA_MODE => 1, DATA_INDENT => 2, );
+ $xml->xmlDecl('UTF-8');
+ $xml->startTag('reports');
+
+ my $query = "SELECT s.date_created, s.last_modified, s.savedsql, s.report_name, s.type, s.notes, s.cache_expiry, s.public, s.report_area, s.report_group, s.report_subgroup, b.userid FROM saved_sql s LEFT JOIN borrowers b ON b.borrowernumber = s.borrowernumber";
+ my $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @row = $sth->fetchrow_array) {
+ $xml->startTag('sqlreport');
+ $xml->dataElement('date_created',$row[0]);
+ $xml->dataElement('last_modified',$row[1]);
+ $xml->dataElement('savedsql',$row[2]);
+ $xml->dataElement('report_name',$row[3]);
+ $xml->dataElement('type',$row[4]);
+ $xml->dataElement('notes',$row[5]);
+ $xml->dataElement('cache_expiry',$row[6]);
+ $xml->dataElement('public',$row[7]);
+ $xml->dataElement('report_area',$row[8]);
+ $xml->dataElement('report_group',$row[9]);
+ $xml->dataElement('report_subgroup',$row[10]);
+ $xml->dataElement('userid',$row[11]);
+ $xml->endTag('sqlreport');
+ }
+
+ $xml->endTag('reports');
+ $xml->end();
+ close $fh;
+ return;
+}
+
sub backup_smsproviders {
my $dbh = shift;
my $backupfile = shift;