I need help with thise script im trying to get going, I keep receiving erros.... Here is the first and second script, mite be familiar it is the automated billing script..
#1 Oversight
:global found
/system script run monthend
:if ([$found] = true) do={ /system script run billing ; :log info "Automatic Billing Triggered by Oversight"}
:if ([$found] = false) do={ /system script run usagewarnings ; :log info "Usage Warning Script triggered by Oversight" }
#2 billing
: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
:local server
:local newcomment
:local comment
:local cap
:local warning
:local lastinvoicemonth
:local month
:local monthnum
:local newmonthnum
:local lastmonth
:set server [:resolve smtp.yourserver.com]
:set month [:pick [/system clock get date] 0 3]
:if ([$month] = jan) do={ :set newmonthnum 01 }
:if ([$month] = feb) do={ :set newmonthnum 02 }
:if ([$month] = mar) do={ :set newmonthnum 03 }
:if ([$month] = apr) do={ :set newmonthnum 04 }
:if ([$month] = may) do={ :set newmonthnum 05 }
:if ([$month] = jun) do={ :set newmonthnum 06 }
:if ([$month] = jul) do={ :set newmonthnum 07 }
:if ([$month] = aug) do={ :set newmonthnum 08 }
:if ([$month] = sep) do={ :set newmonthnum 09 }
:if ([$month] = oct) do={ :set newmonthnum 10 }
:if ([$month] = nov) do={ :set newmonthnum 11 }
:if ([$month] = dec) do={ :set newmonthnum 12 }
# Loop through all the users in User Manager - My only Subscriber is Admin
/tool user-manager user
:foreach i in=[ /tool user-manager user find subscriber=admin ] do={
#Pull out all the information I need
: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 comment [get $i comment]
:set invoice [:pick $comment 0 5]
:set cap [:pick $comment 5 9]
:set warning [:pick $comment 9 11]
:set lastmonth [:pick $comment 11 13]
:set lastinvoicemonth [:pick $comment 11 13]
: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)
:set email [get $i email]
:set basecharge 140
:set usagecharge 0
:put $poolname
:set newcomment "$nextinvoicenumber$cap$warning$newmonthnum"
/tool user-manager user set $i comment=$newcomment
:if ([$discountcheck] > 0 ) do={ :set discount [get $i discount] } else={ :set discount 0 }
#Here, I set the Cost based on what Package the clients have - usage based, discounts... blabla.
# I have an in-house mail server to handle all the outgoing e-mail
# For Capped Services
:if ([$poolname] = "64") do={ :set amount "220" }
:if ([$poolname] = "128") do={ :set amount "330" }
:if ([$poolname] = "256") do={ :set amount "450" }
# For Uncapped Services
:if ([$poolname] = "64uncapped") do={ :set amount "550" }
:if ([$poolname] = "128uncapped") do={ :set amount "675" }
:if ([$poolname] = "256uncapped") do={ :set amount "800" }
: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 "-" }
#this one E-mails a basics-only invoice to Accounts for my WISP:
/tool e-mail send to=accounts@YourWISP.com from=NoReply@YourWISP.com server=$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"
#this one sends a more elaborate version with all the necessary information to the Client's E-mail addy.
/tool e-mail send to=$email from=NoReply@YourWISP.com server=$server subject="Wireless Statement" body="Dear $clientname $clientsurname
Statement For Wireless Internet Services $poolname kbps Package
Statement Number: $usrname-$date-$invoice
This is a statement 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: YourBranchName
Account: YourAccountNumber
Holder: YourAccountHolder
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 statement 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
YourWISP"
:log info "Sent Invoice for user $usrname to $email"
/tool user-manager user reset-counters $i
}
}
I Beleive something is wrong in the syntax of configuration, but i am not sure.. I am in a rush to get this script going that is why i posted. I cannot get Oversight to trigger the billing script.. So just getting #1 script going would be a good start. And if you show me were a few of the common errors are I will go through and fix them..
Im using 3. rc7 because that is what it was designed on.. Tried 3.1 but same erros.. so i tryed to downgrade and still haveing the same problems... So hopefully somebody can help me here MRZ or somebody??? thanks -Jordan