Bidi Posted August 25, 2015 Share Posted August 25, 2015 Hy there guys, i try to make a hook to notice my customers who whants to get sms notice to theyr phone when a new invoice is generating. (When cron job runs ....etc) My problem is is not working and i dont understand why if i use the Add Funds Invoice or my customer add funds from hes area it works but when the cron runs at midnight not do i jump over sompting ? <?php function hook_smsinvoicecreated($vars) { $invoiceid = $vars['invoiceid']; include("../rwsfunctions.php"); include("../rwsconfig.php"); $rid = full_query("SELECT userid,duedate,total FROM tblinvoices WHERE id='".$invoiceid."'"); $did = mysql_fetch_array($rid); $clientid = $did['userid']; $rcr = full_query("SELECT credit,smsphone,smsinvoicecreated FROM tblclients WHERE id = '".$clientid."'"); $dcr = mysql_fetch_array($rcr); if ($dcr['smsinvoicecreated'] == "1" && "0.05" <= $dcr['credit']) { $phone = $dcr['smsphone']; $dd = $did['duedate']; $d = explode("-", $dd); $duedate = $d['2']." ".$d['1']." ".$d['0']; $total = $did['total']; $message = "Va informam ca a fost emisa in contul dvs o noua factura cu nr: ".$invoiceid.", total ".$total." Euro, data scadenta ".$duedate.". ".$brand; if (strlen($phone) == "10") { $command = "addcredit"; $adminuser = $adminuser; $values['clientid'] = $clientid; $values['description'] = "Trimitere SMS catre ".$phone; $values['amount'] = "0" - $amountinvoicecreated; $results = localAPI($command, $values, $adminuser); if ($results['result'] == "success") { sendsms($sid, $password, $phone, $message); } else { $res = $results['message']; } } else { $res = "Telefon Invalid"; } } } add_hook("InvoiceCreated", 2, "hook_smsinvoicecreated"); ?> 0 Quote Link to comment Share on other sites More sharing options...
Bidi Posted August 25, 2015 Author Share Posted August 25, 2015 I fixed the problem was the code writed in wrong way, but i got one more think i made one like. function hook_smsinvoicereminder($vars) { $invoiceid = $vars['invoiceid']; include($_SERVER['DOCUMENT_ROOT'].'/rwsfunctions.php'); include($_SERVER['DOCUMENT_ROOT'].'/rwsconfig.php'); $rid = full_query("SELECT userid,duedate,total FROM tblinvoices WHERE id='".$invoiceid."'"); $did = mysql_fetch_array($rid); $clientid = $did["userid"]; $rcr = full_query("SELECT credit,smsphone,smsinvoicereminder FROM tblclients WHERE id = '".$clientid."'"); $dcr = mysql_fetch_array($rcr); if($dcr["smsinvoicereminder"]=="1" && $dcr["credit"]>=$amountinvoicereminder){ $phone = $dcr["smsphone"]; $dd = $did["duedate"]; $d = explode("-", $dd); $duedate = $d['2']." ".$d['1']." ".$d['0']; $total = $did["total"]; $message = "Va reamintim ca termenul de plata al facturii nr: ".$invoiceid.", in valoare de ".$total." Euro, este ".$duedate.". ".$brand; if(strlen($phone)=="10"){ $command = "addcredit"; $adminuser = $adminuser; $values["clientid"] = $clientid; $values["description"] = "Trimitere SMS catre ".$phone; $values["amount"] = 0-$amountinvoicereminder; $results = localAPI($command,$values,$adminuser); if($results["result"]=="success"){ sendsms($sid,$password,$phone,$message); }else{ $res = $results["message"]; } }else{ $res = "Telefon Invalid"; } } } add_hook("InvoicePaymentReminder", 1, "hook_smsinvoicereminder"); and when the cron runs it dosent send the sms notification do i have to create or make sompting alse ? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.