<?php
session_start();
require("php_con.php");
require("function.php");

$current_user_qury=mysqli_query($connation,"SELECT * FROM user_details WHERE user_id='$_COOKIE[user_id]'");
$current_user_resalt=mysqli_fetch_array($current_user_qury);

$total=(float)(start_amount($current_date,$_COOKIE['user_id'])+user_cash_amount($current_date,$_COOKIE['user_id']))-(user_expenses($current_date,$_COOKIE['user_id']));

?>

<style>
	*{
		font-family: Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";
	}
</style>

<h4 align="center" style="margin-bottom: 5px;">Day End Report</h4>

<table style="font-size: 14px; width: 100%;">
  <tbody>
    <tr>
      <td>Name</td>
      <td><?php echo $current_user_resalt['user_fname']; ?> <?php echo $current_user_resalt['user_lname']; ?>
	  </td>
    </tr>
    <tr>
      <td>Valid Date</td>
      <td><?php echo $current_date; ?>
	  </td>
    </tr>
    <tr>
      <td colspan="2" align="center"><div style="border-bottom: 1px dashed #000000; width: 100%;"></div></td>
    </tr>
    <tr>
      <td>Start Cash Amount</td>
      <td align="right"><?php echo number_format((float)start_amount($current_date,$_COOKIE['user_id']),2); ?>
	  </td>
    </tr>
    <tr>
      <td>Sale Cash Amount</td>
      <td align="right"><?php echo number_format((float)user_cash_amount($current_date,$_COOKIE['user_id']),2); ?></td>
    </tr>
    <tr>
      <td>Sale Card Amount</td>
      <td align="right"><?php echo number_format((float)user_card_amount($current_date,$_COOKIE['user_id']),2); ?></td>
    </tr>
    <tr>
      <td>Discount Amount</td>
      <td align="right"><?php echo number_format((float)user_discount_amount($current_date,$_COOKIE['user_id']),2); ?></td>
    </tr>
    <tr>
      <td>Expenses</td>
      <td align="right"><?php echo number_format((float)user_expenses($current_date,$_COOKIE['user_id']),2); ?></td>
    </tr>
    <tr>
      <td>Cash Balance</td>
      <td align="right"><?php echo number_format((float)(start_amount($current_date,$_COOKIE['user_id'])+user_cash_amount($current_date,$_COOKIE['user_id']))-(user_expenses($current_date,$_COOKIE['user_id'])),2); ?></td>
    </tr>
    <tr>
      <td>Hand Count Cash Amount</td>
      <td align="right"><?php echo number_format((float)end_amount($current_date,$_COOKIE['user_id']),2); ?>
	  </td>
    </tr>
    <tr>
      <td>Difference</td>
      <td align="right"><?php echo number_format((float)(end_amount($current_date,$_COOKIE['user_id']))-$total,2); ?></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><div style="border-bottom: 1px dashed #000000; width: 100%;"></div></td>
    </tr>
    <tr>
      <td colspan="2" align="center">Printed: <?php echo date("Y-m-d h:i:s A"); ?></td>
    </tr>
  </tbody>
</table>

<?php
if($sms_send==1){
if(!setting_view("summery_send_phone")==""){
	
$dst="94".(int)setting_view("summery_send_phone");

$msg=urlencode("Day end Summary of $current_user_resalt[user_fname] $current_user_resalt[user_lname]

Start Cash Amount: ".number_format((float)start_amount($current_date,$_COOKIE['user_id']),2)."
Sale Cash Amount: ".number_format((float)user_cash_amount($current_date,$_COOKIE['user_id']),2)."
Sale Card Amount: ".number_format((float)user_card_amount($current_date,$_COOKIE['user_id']),2)."
Discount Amount: ".number_format((float)user_discount_amount($current_date,$_COOKIE['user_id']),2)."
Expenses: ".number_format((float)user_expenses($current_date,$_COOKIE['user_id']),2)."
Cash Balance: ".number_format((float)(start_amount($current_date,$_COOKIE['user_id'])+user_cash_amount($current_date,$_COOKIE['user_id'])+user_card_amount($current_date,$_COOKIE['user_id']))-(user_expenses($current_date,$_COOKIE['user_id'])+user_discount_amount($current_date,$_COOKIE['user_id'])),2)."
End Cash Amount: ".number_format((float)end_amount($current_date,$_COOKIE['user_id']),2)."
Difference: ".number_format((float)(end_amount($current_date,$_COOKIE['user_id'])+user_discount_amount($current_date,$_COOKIE['user_id']))-$total,2)."

Send Time: ".date("Y-m-d h:i:s A"));

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://smspanel.lk/api/sms/send?key=13VU4BD6EwYjte7g&dst=$dst&msg=$msg&from=OnlineSoft",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Cookie: PHPSESSID=ifs01eir6o6crf3gm2lrv5nopu'
  ),
));

$response = curl_exec($curl);
curl_close($curl);
	
}
}
?>

<script>
this.print();
</script>