<?php
ob_start();
session_start();

 ini_set('session.bug_compat_warn', 0);
 ini_set('session.bug_compat_42', 1);
/*
This example works only for those users which are using Cloud Service and do not want to run
client application on their end.


You just need to Start the Cloud Service from the Dashboard and Scan QR Code.
When WhatsApp gets ready, then you can start sending messages.

*/

include('WhatsappAPI.php'); // include given API file
include("litter_read.php");
include("db.php");
$wp = new WhatsappAPI("3979", "a0e65bc22bff71e532edc4109e2b55334a559d2b"); // create an object of the WhatsappAPI class with your user id and api key

 $customerId_get=$_GET['customer_id'];
  
 $detils_sql="select * from sms";
 $detils_query = $db ->query($detils_sql);
 $detils_row=$detils_query ->fetch_array();
 
 $customerId =$detils_row['customer_id'];
 $date       =$detils_row['date'];
 $dr_cr      =$detils_row['dr_cr'];
 $currency   =$detils_row['currency'];
 $description=$detils_row['description'];
 $amount     =round($detils_row['amount']);
 $tell       =$detils_row['tell'];
 $pool       =$detils_row['pool'];
 $afn        =number_format($detils_row['afn']);
 $usd        =number_format($detils_row['usd']);
 $euro       =number_format($detils_row['euro']);
 $irr        =number_format($detils_row['irr']);
 $pkr        =number_format($detils_row['pkr']);
 $update_id=$detils_row['update_id'];
 
 $nemaish_amount=number_format($amount);
 if($customerId_get!=$customerId){header("location: dailyTransactionCustomer");die;}
 if($customerId_get==$customerId){
  //********************************************
  $explode=explode("*",$pool);
  
  $pool_1=$explode[0];
  $pool_2=$explode[1];
  $pool_3=$explode[2];
  $pool_4=$explode[3];
  $pool_5=$explode[4];
  
  //*********************************************
 if($usd<0){$usd=$usd. "(بردگی)";}
 if($afn<0){$afn=$afn. "(بردگی)";}
 if($euro<0){$euro=$euro. "(بردگی)";}
 if($irr<0){$irr=$irr. "(بردگی)";}
 if($pkr<0){$pkr=$pkr. "(بردگی)";}
  
 if($usd>0){$usd=$usd. "(رسیدگی)";}
 if($afn>0){$afn=$afn. "(رسیدگی)";}
 if($euro>0){$euro=$euro. "(رسیدگی)";}
 if($irr>0){$irr=$irr. "(رسیدگی)";}
 if($pkr>0){$pkr=$pkr. "(رسیدگی)";} 
  $number =$tell; // NOTE: Phone Number should be with country code
 
   
 $meqdar = new Number2Word;
 $horoof=$meqdar->numberToWords($amount);
  
 $message="≿━━━━༺❀ شرکت صرافی و خدمات پولی هرات صداقت ❀༻━━━━≾
	
                            	تاریخ: ".$date."
                            	
	مبلغ ".$nemaish_amount." ".$currency." ".$dr_cr."
	مبلغ ".$horoof." ".$currency." ".$dr_cr."
	
	  ━━━━⊱⋆⊰━━━━ 
✍".$pool_1."
  ✍"
  .$pool_2."
  ✍"
  .$pool_3."
  ✍"
  .$pool_4."
  ✍"
  .$pool_5." 
   
  📝 توضیحات : ".$description."
☆ با تشکر مدیریت صرافی هرات صداقت ☆ 
	
✿———— اعتماد شما افتخار ماست ————✿
	";


//$media_url = 'http://www.africau.edu/images/default/sample.pdf'; // Direct global accessible URL of the file, image, docs etc.
 // Max file size should be 10MB otherwise you may get error.
//$group_name = 'My Test Group';
//$caption = 'Its my Caption'; // For media files



/*

  UNCOMMENT YOUR REQUIRED FUNCTIONS FROM BELOW

*/

// Send Text Message to number
 $status = $wp->sendText($number, $message);

// Send PDF, Documents, File, Images etc  Message to number
// $status = $wp->sendFromURL($number, $media_url, $caption);

// Send Text message in Group
//$status = $wp->sendTextInGroup($group_name, $message);
// Send Media message in Group
//$status = $wp->sendFromURLInGroup($group_name, $media_url, $caption);

$status = json_decode($status);
 print_r($status);
    $update_send_sql="update customerpayment set send_sms='1' where id='$update_id'";
    $update_send_query= $db ->query($update_send_sql);
    header("location:dailyTransactionCustomer.php");
 exit();
if($status->status == 'error'){
    echo $status->response;
}elseif($status->status == 'success'){
    echo 'Success <br />';
    echo $status->response;
    
}else{
  print_r($status);
 
}}
 
?>
