summaryrefslogtreecommitdiff
path: root/gdm/Sessions
diff options
context:
space:
mode:
Diffstat (limited to 'gdm/Sessions')
0 files changed, 0 insertions, 0 deletions
  • # Author: DWS Systems Inc.
  • # Web: http://www.sql-ledger.org
  • #
  • # Contributors:
  • #
  • #======================================================================
  • #
  • # This file has NOT undergone whitespace cleanup.
  • #
  • #======================================================================
  • #
  • # Project module
  • # also used for partsgroups
  • #
  • #======================================================================
  • package PE;
  • sub projects {
  • my ($self, $myconfig, $form) = @_;
  • # connect to database
  • my $dbh = $form->dbconnect($myconfig);
  • $form->{sort} = "projectnumber" unless $form->{sort};
  • my @a = ($form->{sort});
  • my %ordinal = ( projectnumber => 2,
  • description => 3,
  • startdate => 4,
  • enddate => 5,
  • );
  • my $sortorder = $form->sort_order(\@a, \%ordinal);
  • my $query;
  • my $where = "WHERE 1=1";
  • $query = qq|SELECT pr.*, c.name
  • FROM project pr
  • LEFT JOIN customer c ON (c.id = pr.customer_id)|;
  • if ($form->{type} eq 'job') {
  • $where .= qq| AND pr.id NOT IN (SELECT DISTINCT id
  • FROM parts
  • WHERE project_id > 0)|;
  • }
  • my $var;
  • if ($form->{projectnumber} ne "") {
  • $var = $form->like(lc $form->{projectnumber});
  • $where .= " AND lower(pr.projectnumber) LIKE '$var'";
  • }
  • if ($form->{description} ne "") {
  • $var = $form->like(lc $form->{description});
  • $where .= " AND lower(pr.description) LIKE '$var'";
  • }
  • ($form->{startdatefrom}, $form->{startdateto}) = $form->from_to($form->{year}, $form->{month}, $form->{interval}) if $form->{year} && $form->{month};
  • if ($form->{startdatefrom}) {
  • $where .= " AND (pr.startdate IS NULL OR pr.startdate >= '$form->{startdatefrom}')";
  • }
  • if ($form->{startdateto}) {
  • $where .= " AND (pr.startdate IS NULL OR pr.startdate <= '$form->{startdateto}')";
  • }
  • if ($form->{status} eq 'orphaned') {
  • $where .= qq| AND pr.id NOT IN (SELECT DISTINCT project_id
  • FROM acc_trans
  • WHERE project_id > 0
  • UNION
  • SELECT DISTINCT project_id
  • FROM invoice
  • WHERE project_id > 0
  • UNION
  • SELECT DISTINCT project_id
  • FROM orderitems
  • WHERE project_id > 0
  • UNION
  • SELECT DISTINCT project_id
  • FROM jcitems
  • WHERE project_id > 0)
  • |;
  • }
  • if ($form->{status} eq 'active') {
  • $where .= qq| AND (pr.enddate IS NULL OR pr.enddate >= current_date)|;
  • }
  • if ($form->{status} eq 'inactive') {
  • $where .= qq| AND pr.enddate <= current_date|;
  • }