my $_invoices = param("invoices"); # Get the value of the textarea if ($_invoices && $_invoices =~ /\015\012/) { $_split_val = "\015\012"; } elsif ($_invoices && $_invoices =~ /\r\n/) { $_split_val = "\r\n"; } use HTTP::Cookies; $cookie_jar = HTTP::Cookies->new( 'file' => "/home/first/cook/lwp_cookies.dat", 'autosave' => 1, ); my $_post_url = 'http://www.eb2b.net/E2B_UMLogOn.process'; my $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); my $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content("IWPEProcessFlow.submitted.sequenceID=&logonUsername=myhiddenusername&logonPassword=myhidden_password&Logon=Login&hMsgUserNotFound=User with this name was not found.&hMsgInvalidPassword=Logon not valid.&fromHomePage=default_B2B.htm"); $req->referrer("http://www.eb2b.net/"); # Spoof their website... my $res = $ua->request($req); if (!$res->is_success) { $_message = get_error_table("I could not login to the eb2b.net website.... please check what is up with that..."); $in{view} = "start_form"; batch_features(); return; } my $_invoices_started = 0; my $_invoices_ended = 0; while($_invoices ne "") { $_invoices_started++; (my $_line_val, $_invoices) = split /$_split_val/, $_invoices, 2; # Split $_invoices and shorten by $_line_val.... next if !$_line_val; # Does not contain anything go to the next line.... ($_inv_num,$_store_number,$_inv_date,$_amount) = split /\,/, $_line_val, 4; # Reset Page.... $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $response = $ua->get('https://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process?RestartFlow=t'); # Start Template.... $_post_url = 'http://www.eb2b.net/E2B_SelectTemplate.process?restartFlow=t'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content("SelectTemplate=Use Template >"); $req->referrer("https://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process?RestartFlow=t"); $res = $ua->request($req); # Create Invoice from Template... $_post_url = 'http://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process?restartFlow=t&FromTemplate=t&Template_Id=522'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content("Relationship_Index=0&CInvoice=Create Invoice"); $req->referrer("https://www.eb2b.net/E2B_SelectTemplate.process?restartFlow=t"); $res = $ua->request($req); # Post Invoice... $_post_url = 'http://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); # Create content into form.... $_content = "E2B_OMInvoiceCreditForm.Purchase_Order_Number=&Location_Number=" . $_store_number . "&VendorRelationshipIndex=0&E2B_OMInvoiceCreditForm.Invoice_Number=" . $_inv_num . "&Purchase_Order_Date=&E2B_OMInvoiceCreditForm.Bill_Of_Lading_Number=&Invoice_Date=" . $_inv_date . "&E2B_OMInvoiceCreditForm.Trailer_Number=&Ship_Date=" . $_inv_date . "&E2B_OMInvoiceCreditForm.Fob_Code=CC&Total_Invoice_Cartons=1&Carrier_Code=ZZZZ&E2B_OMInvoiceCreditForm.Sales_Division_Number=6131195061&E2B_OMInvoiceCreditForm.Net_Invoice_Total=0&E2B_OMInvoiceCreditForm.EditPageMarker=&E2B_OMInvoiceCreditForm.LineItemVector[0].Line_Number=1&E2B_OMInvoiceCreditForm.LineItemVector[0].Vendor_Item_Number=DD&E2B_OMInvoiceCreditForm.LineItemVector[0].Customer_Item_Number=&E2B_OMInvoiceCreditForm.LineItemVector[0].Upc_Code=&E2B_OMInvoiceCreditForm.LineItemVector[0].UPC_NDC_Indicator= &E2B_OMInvoiceCreditForm.LineItemVector[0].Item_Description=Maintenance&E2B_OMInvoiceCreditForm.LineItemVector[0].Quantity_Shipped=1&E2B_OMInvoiceCreditForm.LineItemVector[0].Unit_Of_Measure=EA&E2B_OMInvoiceCreditForm.LineItemVector[0].Pack_Size=1&E2B_OMInvoiceCreditForm.LineItemVector[0].Unit_Price=" . $_amount . "&rcDirection=&selectedLine=&IWPEProcessFlow.submitted.sequenceID=/E2B_OMInvoiceCreditMgmt.process|runProcessE2B_OMManualInvoiceCredit|expandE2B_OMManualInvoiceCredit&Invoice_Complete_Flag=0&E2B_OMInvoiceCreditTermsAllowancesDirection="; $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content($_content); $req->referrer("https://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process?restartFlow=t&FromTemplate=t&Template_Id=522"); $res = $ua->request($req); # Ok, now take the invoice just created and add the "accounting code" then send it to ekerdx $_post_url = 'http://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); # Create content into form.... $_content = "E2B_OMInvoiceCreditTermsAllowancesDirection=&selectedAllowanceCollection=&selectedLine=&IWPEProcessFlow.submitted.sequenceID=/E2B_OMInvoiceCreditMgmt.process|runProcessE2B_OMInvoiceCreditTermsAllowances|expandE2B_OMInvoiceCreditTermsAllowances&Bus_Unit=00&Acct=664600&Cost_Dep_No=0000&RowSkip=&RowChunk=&TabChoice=&searchBy=&E2B_OMInvoiceCreditTermsAllowancesDirection=Confirm"; $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content($_content); $req->referrer("https://www.eb2b.net/E2B_OMInvoiceCreditMgmt.process"); $res = $ua->request($req); # All Done.... $_invoices_ended++; } $_page_content .= qq~Ok, I have started $_invoices_started invoices and finished $_invoices_ended invoices!

~;