| 
      
            Lines 99-117
          Searches for suppliers with late orders.
      
      
        Link Here
      
     | 
  
        
          | 99 | 
          =cut  | 
          99 | 
          =cut  | 
        
        
          | 100 | 
           | 
          100 | 
           | 
        
        
          | 101 | 
          sub GetBooksellersWithLateOrders { | 
          101 | 
          sub GetBooksellersWithLateOrders { | 
        
          
            
              | 102 | 
                  my $delay = shift;  | 
              102 | 
                  my ( $delay, $branch, $estimateddeliverydatefrom, $estimateddeliverydateto ) = @_;    # FIXME: Branch argument unused.  | 
            
            
              | 103 | 
                  my $dbh   = C4::Context->dbh;  | 
              103 | 
                  my $dbh = C4::Context->dbh;  | 
            
            
              | 104 | 
               | 
              104 | 
               | 
            
            
              | 105 | 
                  # TODO delay should be verified  | 
              105 | 
                  # FIXME NOT quite sure that this operation is valid for DBMs different from Mysql, HOPING so  | 
            
            
              | 106 | 
                  my $query_string =  | 
              106 | 
                  # should be tested with other DBMs  | 
            
            
              | 107 | 
                    "SELECT DISTINCT aqbasket.booksellerid, aqbooksellers.name  | 
              107 | 
               | 
            
            
              | 108 | 
                  FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno  | 
              108 | 
                  my $strsth;  | 
            
            
              | 109 | 
                  LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id  | 
              109 | 
                  my @query_params = ();  | 
            
            
              | 110 | 
                  WHERE (closedate < DATE_SUB(CURDATE( ),INTERVAL $delay DAY)  | 
              110 | 
                  my $dbdriver = C4::Context->config("db_scheme") || "mysql"; | 
            
            
              | 111 | 
                  AND (datereceived = '' OR datereceived IS NULL))";  | 
              111 | 
                  $strsth = "  | 
            
            
              | 112 | 
               | 
              112 | 
                      SELECT DISTINCT aqbasket.booksellerid, aqbooksellers.name  | 
            
            
              | 113 | 
                  my $sth = $dbh->prepare($query_string);  | 
              113 | 
                      FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno  | 
            
            
              | 114 | 
                  $sth->execute;  | 
              114 | 
                      LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id  | 
            
            
               | 
               | 
              115 | 
                      WHERE   | 
            
            
              | 116 | 
                          ( datereceived = ''  | 
            
            
              | 117 | 
                          OR datereceived IS NULL  | 
            
            
              | 118 | 
                          OR aqorders.quantityreceived < aqorders.quantity  | 
            
            
              | 119 | 
                          )  | 
            
            
              | 120 | 
                          AND aqorders.rrp <> 0  | 
            
            
              | 121 | 
                          AND aqorders.ecost <> 0  | 
            
            
              | 122 | 
                          AND aqorders.quantity - IFNULL(aqorders.quantityreceived,0) <> 0  | 
            
            
              | 123 | 
                          AND aqbasket.closedate IS NOT NULL  | 
            
            
              | 124 | 
                  ";  | 
            
            
              | 125 | 
                  if ( defined $delay ) { | 
            
            
              | 126 | 
                      $strsth .= " AND (closedate <= DATE_SUB(CURDATE( ),INTERVAL ? DAY)) ";  | 
            
            
              | 127 | 
                      push @query_params, $delay;  | 
            
            
              | 128 | 
                  }  | 
            
            
              | 129 | 
                  if ( defined $estimateddeliverydatefrom ) { | 
            
            
              | 130 | 
                      $strsth .= '  | 
            
            
              | 131 | 
                          AND aqbooksellers.deliverytime IS NOT NULL  | 
            
            
              | 132 | 
                          AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) >= ?';  | 
            
            
              | 133 | 
                      push @query_params, $estimateddeliverydatefrom;  | 
            
            
              | 134 | 
                  }  | 
            
            
              | 135 | 
                  if ( defined $estimateddeliverydatefrom and defined $estimateddeliverydateto ) { | 
            
            
              | 136 | 
                      $strsth .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= ?';  | 
            
            
              | 137 | 
                      push @query_params, $estimateddeliverydateto;  | 
            
            
              | 138 | 
                  } elsif ( defined $estimateddeliverydatefrom ) { | 
            
            
              | 139 | 
                      $strsth .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CURDATE()';  | 
            
            
              | 140 | 
                  }  | 
            
            
              | 141 | 
               | 
            
            
              | 142 | 
                  my $sth = $dbh->prepare($strsth);  | 
            
            
              | 143 | 
                  $sth->execute( @query_params );  | 
            
        
          | 115 | 
              my %supplierlist;  | 
          144 | 
              my %supplierlist;  | 
        
        
          | 116 | 
              while ( my ( $id, $name ) = $sth->fetchrow ) { | 
          145 | 
              while ( my ( $id, $name ) = $sth->fetchrow ) { | 
        
        
          | 117 | 
                  $supplierlist{$id} = $name; | 
          146 | 
                  $supplierlist{$id} = $name; | 
        
  
    | 
      
            Lines 198-204
          sub ModBookseller {
      
      
        Link Here
      
     | 
  
        
          | 198 | 
                      contphone=?,contfax=?,contaltphone=?,contemail=?,  | 
          227 | 
                      contphone=?,contfax=?,contaltphone=?,contemail=?,  | 
        
        
          | 199 | 
                      contnotes=?,active=?,listprice=?, invoiceprice=?,  | 
          228 | 
                      contnotes=?,active=?,listprice=?, invoiceprice=?,  | 
        
        
          | 200 | 
                      gstreg=?,listincgst=?,invoiceincgst=?,  | 
          229 | 
                      gstreg=?,listincgst=?,invoiceincgst=?,  | 
        
          
            
              | 201 | 
                          discount=?,notes=?,gstrate=?  | 
              230 | 
                          discount=?,notes=?,gstrate=?,deliverytime=?  | 
            
        
          | 202 | 
                  WHERE id=?';  | 
          231 | 
                  WHERE id=?';  | 
        
        
          | 203 | 
              my $sth = $dbh->prepare($query);  | 
          232 | 
              my $sth = $dbh->prepare($query);  | 
        
        
          | 204 | 
              $sth->execute(  | 
          233 | 
              $sth->execute(  | 
        
  
    | 
      
            Lines 215-221
          sub ModBookseller {
      
      
        Link Here
      
     | 
  
        
          | 215 | 
                  $data->{'invoiceprice'}, $data->{'gstreg'}, | 
          244 | 
                  $data->{'invoiceprice'}, $data->{'gstreg'}, | 
        
        
          | 216 | 
                  $data->{'listincgst'},   $data->{'invoiceincgst'}, | 
          245 | 
                  $data->{'listincgst'},   $data->{'invoiceincgst'}, | 
        
        
          | 217 | 
                  $data->{'discount'},     $data->{'notes'}, | 
          246 | 
                  $data->{'discount'},     $data->{'notes'}, | 
        
          
            
              | 218 | 
                      $data->{'gstrate'},      $data->{'id'} | 
              247 | 
                      $data->{'gstrate'}, | 
            
            
               | 
               | 
              248 | 
                      $data->{deliverytime}, | 
            
            
              | 249 | 
                      $data->{'id'} | 
            
        
          | 219 | 
              );  | 
          250 | 
              );  | 
        
        
          | 220 | 
              return;  | 
          251 | 
              return;  | 
        
        
          | 221 | 
          }  | 
          252 | 
          }  |