#!/usr/bin/perl

# $ENV{DBIC_TRACE}=1;
use JSON;
use strict;
use Data::Show;
use lib '/home/sites/clm.dmadelivers.com/www/clmapp/lib';
use CLMApp::Schema;
use DateTime;
use Text::CSV;
use POSIX;
use MIME::Lite;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $dbix = CLMApp::Schema->connect("dbi:mysql:host=rds1.dmadelivers.com;db=dmaclm", 'dmaclm', '3lUz1OV2!',{unsafe=>1,RaiseError=>0,PrintError=>1});



	my $file = '/tmp/opf.inactive.csv';
	my $csv = Text::CSV->new ( { binary => 1 } ) or die "Cannot use CSV: ".Text::CSV->error_diag ();
	# $csv->column_names(("Store","Customer","AmphireID","PartnerNumber","DistCoID","PartnerAbbrev","WarehouseID","Brand","BrandID","Concept","ConceptID","OperatorType","Operator","SubOperator","Site","StoreName","AddressLine1","City","State","Zip","StoreStatus","Latitude","Longitude","DistancetoDC","OperatingStatus","StoreStatusDate","InvoiceSystem","OrderSystem","CustomWarehouseName","CustomWarehouseNumber"));
	open my $fh, "<:encoding(utf8)", $file or die "test.csv: $!";
	my @rows;
	while ( my $r = $csv->getline( $fh ) ){
		push(@rows,$r->[0]);
	}
	shift(@rows);
	
	foreach my $r (@rows){
		# print $r . "\n";
		$dbix->resultset('Customer')->search({customerid => $r})->update({opfstatus => 0});
	}