Jump to content

Hook not working


Bidi

Recommended Posts

Hy there cand someone help me why is this one not working ? :( from admin area if i use Create Add Funds Invoice it works but it ads the amount to the customer directly :(

 

<?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

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