#define a couple of variables :local uptime :local count :local usrname :local clientname :local clientsurname :local poolname :local accounttype :local discount :local amount :local discountedamount :local discountcheck :local date :local invoice :local nextinvoicenumber :local bytesin :local bytesout :local bytestotal :local gigstotal :local email :local basecharge :local usagecharge :local total :local disabled :local doespay # Loop through all the users in User Manager /tool user-manager user :foreach i in=[ /tool user-manager user find subscriber=admin ] do={ :set disabled [get $i disabled] :if ([$disabled] = false) do={ #pull some data from it, and print it on screen :set date [/system clock get date] :set usrname [get $i name] :set uptime [get $i uptime-used] :set clientname [get $i first-name] :set clientsurname [get $i last-name] :set poolname [get $i pool-name] :set discountcheck [get $i discount] :set invoice [get $i comment] :set nextinvoicenumber ($invoice + 1) :if ([get $i download-used] > 0) do={ :set bytesin [get $i download-used] } else={ :set bytesin 0 } :if ([get $i upload-used] > 0) do={ :set bytesout [get $i upload-used] } else={ :set bytesout 0 } :set bytestotal ($bytesin + $bytesout) :set gigstotal ($bytestotal / 1000000) :put $bytesin :put $bytesout :put $bytestotal :put $gigstotal :put $disabled :set email [get $i email] :set basecharge 150 :set usagecharge 0 :put $poolname /tool user-manager user set $i comment=$nextinvoicenumber :if ([$discountcheck] > 0 ) do={ :set discount [get $i discount] } else={ :set discount 0 } :if ([$poolname] = "64") do={ :set amount "220" } :if ([$poolname] = "128") do={ :set amount "330" } :if ([$poolname] = "256") do={ :set amount "450" } :if ([$poolname] = "usagebased") do={ :set usagecharge ((($gigstotal/100) * 7) + 7) } :if ([$poolname] = "usagebased") do={ :set amount $basecharge} :set discountedamount ($amount - $discount) :set total ($discountedamount + $usagecharge) :if ([$total] = 0) do={ :set doespay "This is a Complimentary Account"} else={ :set doespay "-" } /tool e-mail send to=accounts@YourWISP.com from=NoReply@YourWISP.com server=Your.Mail.Server subject="Invoice for user $usrname" body="Sent Invoice to $email Invoice: $usrname-$date-$invoice Date: $date Data: $gigstotal MB Uptime: $uptime Subtotal: R $amount.00 Usage Charge: R $usagecharge.00 Discount: -R $discount.00 Total: R $total.00 $doespay" :log info "Sent Invoice for $usrname to Accounting" /tool e-mail send to=$email from=NoReply@YourWISP.com server=Your.Mail.Server subject=Usage body="Dear $clientname $clientsurname Invoice For Wireless Internet Services $poolname kbps Package Invoice Number: $usrname-$date-$invoice This is an invoice for user account: $usrname Your current total uptime is $uptime Total Data Transferred: $gigstotal MB Subtotal: R $amount.00 Usage Charge: R $usagecharge.00 Discount: -R $discount.00 --------- Total: R $total.00 ========= This is the payable amount on your user account. Our Banking Details are as follow: Bank: YourBankName Branch: BranchCOde Account: AccountNumber Holder: AccountHolderName Reference: $usrname Please remember to state your Username as reference for the deposit, in order to avoid confusion among transactions. If you have received this invoice in error, please reply to this E-mail stating that you are not the intended recipient, and then delete this message. Should there be any incorrect information on this report, please inform us immediately. Warm Regards Users Accounting YourWISPName YourAddress Tel: YourTel Fax: YourFax E-mail: admin@YourWISP.com" :log info "Sent Invoice for user $usrname to $email" /tool user-manager user reset-counters $i } }