Jump to content

Hook not working


Bidi

Recommended Posts

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");
?>

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated