summaryrefslogtreecommitdiff
path: root/doc/todo/structured_page_data
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-10-25 23:03:28 -0400
committerJoey Hess <joey@kitenet.net>2010-10-25 23:03:28 -0400
commitac8aad2ecaad1204e00d0b6eac834ff619e0dc09 (patch)
tree0d07ef26a2320c191bd14ebb2182385531ead8d0 /doc/todo/structured_page_data
parent5c6eb167b8e69e0607330f06c893a73dfe1c675a (diff)
remove a last that won't work
Diffstat (limited to 'doc/todo/structured_page_data')
0 files changed, 0 insertions, 0 deletions
_35" class="hl">package CT;
  • sub create_links {
  • my ( $self, $myconfig, $form ) = @_;
  • my $dbh = $form->{dbh};
  • my $query;
  • my $sth;
  • my $ref;
  • my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap";
  • my $ARAP = uc $arap;
  • if ( $form->{id} ) {
  • $query = qq|
  • SELECT ct.*, b.description AS business, s.*,
  • e.name AS employee,
  • g.pricegroup AS pricegroup,
  • l.description AS language, ct.curr
  • FROM $form->{db} ct
  • LEFT JOIN business b ON (ct.business_id = b.id)
  • LEFT JOIN shipto s ON (ct.id = s.trans_id)
  • LEFT JOIN employee e ON (ct.employee_id = e.id)
  • LEFT JOIN pricegroup g ON (g.id = ct.pricegroup_id)
  • LEFT JOIN language l ON (l.code = ct.language_code)
  • WHERE ct.id = ?|;
  • $sth = $dbh->prepare($query);
  • $sth->execute( $form->{id} ) || $form->dberror($query);
  • $ref = $sth->fetchrow_hashref(NAME_lc);
  • for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
  • $sth->finish;
  • # check if it is orphaned
  • $query = qq|
  • SELECT a.id
  • FROM $arap a
  • JOIN $form->{db} ct ON (a.$form->{db}_id = ct.id)
  • WHERE ct.id = ?
  • UNION
  • SELECT a.id
  • FROM oe a
  • JOIN $form->{db} ct ON (a.$form->{db}_id = ct.id)
  • WHERE ct.id = ?|;
  • $sth = $dbh->prepare($query);
  • $sth->execute( $form->{id}, $form->{id} )
  • || $form->dberror($query);
  • unless ( $sth->fetchrow_array ) {
  • $form->{status} = "orphaned";
  • }
  • $sth->finish;
  • # get taxes for customer/vendor
  • $query = qq|
  • SELECT c.accno
  • FROM chart c
  • JOIN $form->{db}tax t ON (t.chart_id = c.id)
  • WHERE t.$form->{db}_id = ?|;
  • $sth = $dbh->prepare($query);
  • $sth->execute( $form->{id} ) || $form->dberror($query);
  • while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
  • $form->{tax}{ $ref->{accno} }{taxable} = 1;
  • }
  • $sth->finish;
  • }
  • else {
  • ( $form->{employee}, $form->{employee_id} ) = $form->get_employee($dbh);
  • $query = qq|SELECT current_date|;
  • ( $form->{startdate} ) = $dbh->selectrow_array($query);
  • }
  • # get tax labels
  • $query = qq|
  • SELECT DISTINCT c.accno, c.description
  • FROM chart c
  • JOIN tax t ON (t.chart_id = c.id)
  • WHERE c.link LIKE ?
  • ORDER BY c.accno|;
  • $sth = $dbh->prepare($query);
  • $sth->execute("%${ARAP}_tax%") || $form->dberror($query);
  • while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
  • $form->{taxaccounts} .= "$ref->{accno} ";
  • $form->{tax}{ $ref->{accno} }{description} = $ref->{description};
  • }
  • $sth->finish;
  • chop $form->{taxaccounts};
  • # get business types ## needs fixing, this is bad (SELECT * ...) with order by 2. Yuck
  • $query = qq|
  • SELECT *
  • FROM business
  • ORDER BY 2|;
  • $sth = $dbh->prepare($query);
  • $sth->execute || $form->dberror($query);
  • while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
  • push @{ $form->{all_business} }, $ref;
  • }
  • $sth->finish;
  • # employees/salespersons
  • $form->all_employees( $myconfig, $dbh, undef,
  • ( $form->{vc} eq 'customer' )
  • ? 1
  • : 0 );
  • # get language ## needs fixing, this is bad (SELECT * ...) with order by 2. Yuck
  • $query = qq|
  • SELECT *
  • FROM language
  • ORDER BY 2|;
  • $sth = $dbh->prepare($query);
  • $sth->execute || $form->dberror($query);
  • while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
  • push @{ $form->{all_language} }, $ref;
  • }
  • $sth->finish;
  • # get pricegroups ## needs fixing, this is bad (SELECT * ...) with order by 2. Yuck
  • $query = qq|
  • SELECT *
  • FROM pricegroup
  • ORDER BY 2|;
  • $sth = $dbh->prepare($query);
  • $sth->execute || $form->dberror($query);
  • while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
  • push @{ $form->{all_pricegroup} }, $ref;
  • }
  • $sth->finish;
  • # get currencies
  • $query = qq|
  • SELECT value AS currencies
  • FROM defaults
  • WHERE setting_key = 'curr'|;
  • ( $form->{currencies} ) = $dbh->selectrow_array($query);
  • $dbh->commit;
  • }
  • sub save_customer {
  • my ( $self, $myconfig, $form ) = @_;
  • # connect to database
  • my $dbh = $form->{dbh};
  • my $query;
  • my $sth;
  • my $null;
  • $form->{customernumber} =
  • $form->update_defaults( $myconfig, "customernumber", $dbh )
  • if !$form->{customernumber};
  • # remove double spaces
  • $form->{name} =~ s/ / /g;
  • # remove double minus and minus at the end
  • $form->{name} =~ s/--+/-/g;
  • $form->{name} =~ s/-+$//;
  • # assign value discount, terms, creditlimit
  • $form->{discount} = $form->parse_amount( $myconfig, $form->{discount} );
  • $form->{discount} /= 100;
  • $form->{terms} *= 1;
  • $form->{taxincluded} *= 1;
  • $form->{creditlimit} =
  • $form->parse_amount( $myconfig, $form->{creditlimit} );
  • if ( !$form->{creditlimit} ) {
  • $form->{creditlimit} = 0;
  • }
  • if ( $form->{id} ) {
  • $query = qq|
  • DELETE FROM customertax
  • WHERE customer_id = ?|;