WHERE shipto_id = $self->{shipto_id}|;
$dbh->do($query) || $self->dberror($query);
} else {
- my $query =
- qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1, shiptodepartment_2, shiptostreet,
+ my $query = qq|SELECT * FROM shipto
+ WHERE shiptoname = '$self->{shiptoname}' AND
+ shiptodepartment_1 = '$self->{shiptodepartment_1}' AND
+ shiptodepartment_2 = '$self->{shiptodepartment_2}' AND
+ shiptostreet = '$self->{shiptostreet}' AND
+ shiptozipcode = '$self->{shiptozipcode}' AND
+ shiptocity = '$self->{shiptocity}' AND
+ shiptocountry = '$self->{shiptocountry}' AND
+ shiptocontact = '$self->{shiptocontact}' AND
+ shiptophone = '$self->{shiptophone}' AND
+ shiptofax = '$self->{shiptofax}' AND
+ shiptoemail = '$self->{shiptoemail}'
+ | ;
+ my $sth = $dbh->prepare($query);
+ $sth->execute() || $self->dberror($query);
+ my $insert_check = $sth->fetch();
+ $sth->finish();
+ if(!$insert_check){
+ $query =
+ qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1,
+ shiptodepartment_2, shiptostreet,
shiptozipcode, shiptocity, shiptocountry, shiptocontact,
shiptophone, shiptofax, shiptoemail, module) VALUES ($id,
'$self->{shiptoname}', '$self->{shiptodepartment_1}', '$self->{shiptodepartment_2}', '$self->{shiptostreet}',
'$self->{shiptozipcode}', '$self->{shiptocity}',
'$self->{shiptocountry}', '$self->{shiptocontact}',
'$self->{shiptophone}', '$self->{shiptofax}',
- '$self->{shiptoemail}', '$module')|;
- $dbh->do($query) || $self->dberror($query);
+ '$self->{shiptoemail}', '$module')|;
+ $dbh->do($query) || $self->dberror($query);
+ }
}
}
##/LINET
my ($self, $myconfig, $salesman_id) = @_;
+ $main::lxdebug->leave_sub() and return unless $salesman_id;
+
my $dbh = $self->dbconnect($myconfig);
my ($login) =
$main::lxdebug->leave_sub();
}
+sub _get_business_types {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $dbh, $key) = @_;
+
+ $key = "all_business_types" unless ($key);
+ $self->{$key} =
+ selectall_hashref_query($self, $dbh, qq|SELECT * FROM business|);
+
+ $main::lxdebug->leave_sub();
+}
+
sub get_lists {
$main::lxdebug->enter_sub();
$self->_get_employees($dbh, $params{"employees"});
}
+ if ($params{"business_types"}) {
+ $self->_get_business_types($dbh, $params{"business_types"});
+ }
+
$dbh->disconnect();
$main::lxdebug->leave_sub();
ORDER BY c.accno|;
$sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
-
+
+ do_statement($form, $sth, $query);
+
$self->{accounts} = "";
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
LEFT JOIN department d ON (d.id = a.department_id)
WHERE a.id = $self->{id}|;
$sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
+ do_statement($form, $sth, $query);
$ref = $sth->fetchrow_hashref(NAME_lc);
foreach $key (keys %$ref) {
}
# now get the account numbers
- $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id
- FROM chart c, taxkeys tk
- WHERE c.link LIKE '%$module%' AND (((tk.chart_id=c.id) AND NOT(c.link like '%_tax%')) OR (NOT(tk.chart_id=c.id) AND (c.link like '%_tax%'))) AND (((tk.id = (SELECT id from taxkeys where taxkeys.chart_id =c.id AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)) AND NOT(c.link like '%_tax%')) OR (c.link like '%_tax%'))
- ORDER BY c.accno|;
-
+ $query = qq|
+ SELECT
+ c.accno,
+ c.description,
+ c.link,
+ c.taxkey_id,
+ tk.tax_id
+ FROM chart c
+ LEFT JOIN taxkeys tk ON (tk.chart_id = c.id)
+ WHERE
+ c.link LIKE ?
+ AND
+ (tk.chart_id = c.id AND NOT c.link like '%_tax%')
+ OR (NOT tk.chart_id = c.id AND c.link like '%_tax%')
+ AND
+ tk.id = ( SELECT id from taxkeys
+ WHERE taxkeys.chart_id = c.id
+ AND startdate <= ?
+ ORDER BY startdate desc LIMIT 1
+ )
+ ORDER BY c.accno|;
+
$sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
+ do_statement($form, $sth, $query, "%$module%", $transdate);
$self->{accounts} = "";
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
AND a.fx_transaction = '0'
ORDER BY a.oid,a.transdate|;
$sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
+ do_statement($form, $sth, $query);
my $fld = ($table eq 'customer') ? 'buy' : 'sell';
WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
FROM defaults d|;
$sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
+ do_statement($form, $sth, $query);
$ref = $sth->fetchrow_hashref(NAME_lc);
map { $self->{$_} = $ref->{$_} } keys %$ref;
WHERE d.fxloss_accno_id = c.id) AS fxloss_accno
FROM defaults d|;
$sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
+ do_statement($form, $sth, $query);
$ref = $sth->fetchrow_hashref(NAME_lc);
map { $self->{$_} = $ref->{$_} } keys %$ref;
sub update_business {
$main::lxdebug->enter_sub();
- my ($self, $myconfig, $business_id) = @_;
+ my ($self, $myconfig, $business_id, $provided_dbh) = @_;
- my $dbh = $self->dbconnect_noauto($myconfig);
+ my $dbh;
+ if ($provided_dbh) {
+ $dbh = $provided_dbh;
+ } else {
+ $dbh = $self->dbconnect_noauto($myconfig);
+ }
my $query =
qq|SELECT customernumberinit FROM business WHERE id=$business_id FOR UPDATE|;
my $sth = $dbh->prepare($query);
SET customernumberinit = '$var' WHERE id=$business_id|;
$dbh->do($query) || $self->dberror($query);
- $dbh->commit;
- $dbh->disconnect;
+ if (!$provided_dbh) {
+ $dbh->commit;
+ $dbh->disconnect;
+ }
$main::lxdebug->leave_sub();