Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<? namespace App\Http\Controllers\Seal; use App\Http\Controllers\Controller; use Illu..

Decoded Output download

<?    
 namespace App\Http\Controllers\Seal; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Http\Controllers\Logger; use App\Http\Controllers\Alerts\Alerts; class Seals extends Controller { public function SaveSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal_no = $request->input("seal"); $userid = $request->input("userid"); if ($seal_no != '' && strlen($userid) > 3) { $check_item = DB::table("seals")->select("ID")->where("Seal_No", $seal_no)->get(); if (count($check_item) == 1) { $response = array("Status" => 0, "message" => "Seal {$seal_no} Already Exits"); } else { $insert = DB::table("seals")->insert(array("Seal_No" => $seal_no, "scanby" => $userid, "created_at" => date("Y-m-d H:i:s"))); if ($insert) { $response = array("Status" => 1, "message" => "Seal Saved"); } else { $response = array("Status" => 0, "message" => "Save Error"); } } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Seal Save", $userid, json_encode($response), $request); return json_encode($response); } public function DeleteReceipt(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $userid = $request->input("userid"); $receiptid = $request->input("receiptid"); if (strlen($userid) > 3 && strlen($receiptid) > 0) { $check_receipt = DB::table("receipts")->select("ID")->where("userid", $userid)->where("ID", $receiptid)->where("status", 0)->count(); if ($check_receipt == 1) { $check_receipt = DB::table("receipts")->where("ID", $receiptid)->update(array("status" => -1)); $check_receipt = DB::table("receipt_details")->where("ReceiptID", $receiptid)->update(array("status" => -1, "updated_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Deleted"); } else { $response = array("Status" => 0, "message" => "Cannot be Deleted"); } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Delete Receipt", $userid, json_encode($response), $request); return json_encode($response); } public function MakeReceipt(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $customer_name = $request->input("customer"); $collection = $request->input("collection"); $collection_email = $request->input("collection_email"); $collection_phone = $request->input("collection_phone"); $delivery = $request->input("delivery"); $delivery_email = $request->input("delivery_email"); $delivery_phone = $request->input("delivery_phone"); $branch = $request->input("branch"); $userid = $request->input("userid"); $bullion = $request->input("bullion_no"); if (strlen($customer_name) > 3 && strlen($collection) > 3 && strlen($collection_email) > 3 && strlen($collection_phone) > 3 && strlen($delivery) > 3 && strlen($delivery_email) > 3 && strlen($delivery_phone) > 3 && strlen($branch) > 3 && strlen($userid) > 3 && strlen($bullion) > 3) { $check_user = DB::table("users")->where("Type", 2)->where("Status", 1)->where("UserID", $userid)->count(); if ($check_user == 1) { $check_in_que = DB::table("receipts")->select("ID")->where("userid", $userid)->where("status", 0)->count(); if ($check_in_que == 0) { $transit_save = DB::table("receipts")->insert(array("customer" => $customer_name, "collection" => $collection, "collection_email" => $collection_email, "collection_phone" => $collection_phone, "collection_at" => date("Y-m-d H:i:s"), "delivery" => $delivery, "delivery_email" => $delivery_email, "delivery_phone" => $delivery_phone, "branch" => $branch, "updated_at" => date("Y-m-d H:i:s"), "userid" => $userid, "bullion" => $bullion)); $response = array("Status" => 1, "message" => "Generated"); } else { $response = array("Status" => 0, "message" => "You have a Pending Receipt"); } } else { $response = array("Status" => 0, "message" => "Unauthorized User"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Create Receipt", $userid, json_encode($response), $request); return json_encode($response); } function UseSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal = $request->input("seal"); $boxno = $request->input("boxno"); $userid = $request->input("userid"); if (strlen($seal) > 3 && strlen($userid) > 3 && strlen($boxno) > 2) { $check_user = DB::table("users")->where("Type", 2)->where("Status", 1)->where("UserID", $userid)->count(); if ($check_user == 1) { $check_in_que = DB::table("receipts")->select("ID")->where("userid", $userid)->where("status", 0)->get(); if (count($check_in_que) == 1) { $receipt = $check_in_que[0]->ID; $check_seal = DB::table("seals")->where("Seal_No", $seal)->where("status", 0)->where("commander", $userid)->count(); if ($check_seal == 1) { $confirm_seal = DB::table("receipt_details")->where("SealNo", $seal)->where("status", 0)->count(); if ($confirm_seal == 0) { $add = DB::table("receipt_details")->insert(array("ReceiptID" => $receipt, "SealNo" => $seal, "BoxNo" => $boxno, "created_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Success"); } else { $response = array("Status" => 0, "message" => "Seal Already Exists"); } } else { $response = array("Status" => 0, "message" => "Invaild Or Expired Seal"); } } else { $response = array("Status" => 0, "message" => "Generate Receipt First"); } } else { $response = array("Status" => 0, "message" => "Unauthorized User"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Use Seal", $userid, json_encode($response), $request); return json_encode($response); } function ConfirmOrder(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $userid = $request->input("userid"); if (strlen($userid) > 3) { $check_in_que = DB::table("receipts")->where("userid", $userid)->where("status", 0)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->where("status", 0)->get(); if (count($get_seals) > 0) { $otp = rand(100000, 999999); $save_otp = DB::table("otps")->insert(array("code" => $otp, "Receipt_No" => $receipt_id, "Type" => "Collect", "created_at" => date("Y-m-d H:i:s"))); $alertClass = new Alerts(); $smsmessage = "Dear Customer,{$otp} is the Collection code for Receipt No {$receipt_id}.\xa                        Kindly check the details sent to {$collection_email} then Share this code to  {$userid}"; $footer = $_ENV["EMAIL_FOOTER"]; $emailmessage = "Dear {$collection}, {$otp} is the Collection code. 
                                        Find the Attached PDF file for more details. <p>{$footer}</p>"; $table_details = "<table style="border-collapse: collapse; width: 100%;"> 
                    <thead >\xa                        <tr  style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;" >\xa                              
                            <th >Box No.</th>\xa                            <th>Seal No.</th> 
                        </tr>\xa                    </thead> 
                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $alertClass->SendSms($collection_phone, $smsmessage); $alertClass->SendCollectionOTPEmail($collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $table_details); $response = array("Status" => 1, "message" => "Get Code From Customer"); } else { $response = array("Status" => 0, "message" => "Kindly Scan Some Seals"); } } else { $response = array("Status" => 0, "message" => "Invalid Receipt"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Confirm Order", $userid, json_encode($response), $request); return json_encode($response); } function CloseSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal = $request->input("seal"); $userid = $request->input("userid"); if (strlen($seal) > 3 && strlen($userid) > 3) { $check_in_que = DB::table("receipts")->select("ID")->where("userid", $userid)->where("status", 1)->get(); if (count($check_in_que) == 1) { $receipt = $check_in_que[0]->ID; $check_seal = DB::table("seals")->where("Seal_No", $seal)->where("status", 1)->count(); if ($check_seal == 1) { $confirm_seal = DB::table("receipt_details")->where("SealNo", $seal)->where("status", 1)->count(); if ($confirm_seal == 1) { $update = DB::table("receipt_details")->where("SealNo", $seal)->update(array("status" => 2, "updated_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Success"); } else { $response = array("Status" => 0, "message" => "Seal invalid"); } } else { $response = array("Status" => 0, "message" => "Invaild Or Expired Seal"); } } else { $response = array("Status" => 0, "message" => "Invalid Receipt"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Use Seal", $userid, json_encode($response), $request); return json_encode($response); } function EndOrder(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $userid = $request->input("userid"); $receipt_id = $request->input("receiptid"); if (strlen($userid) > 3 && strlen($receipt_id) > 0) { $check_in_que = DB::table("receipts")->where("userid", $userid)->where("ID", $receipt_id)->where("status", 1)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->get(); $otp = rand(100000, 999999); $save_otp = DB::table("otps")->insert(array("code" => $otp, "Receipt_No" => $receipt_id, "Type" => "Deliver", "created_at" => date("Y-m-d H:i:s"))); $alertClass = new Alerts(); $smsmessage = "Dear {$delivery},{$otp} is the Delivery code for Receipt No {$receipt_id} Delivered 
                        Kindly check details sent to {$delivery_email} then Share this code to  {$userid}"; $footer = $_ENV["EMAIL_FOOTER"]; $emailmessage = "Dear Customer,{$otp} is the Delivery code.\xa                        Find the Attached PDF file for more details. <p>{$footer}</p> "; $table_details = "<table style="border-collapse: collapse; width: 100%;" > 
                    <thead> 
                        <tr style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;">\xa                             \xa                            <th>Box No.</th> 
                            <th>Seal No.</th>\xa                        </tr>\xa                    </thead> 
                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $alertClass->SendSms($delivery_phone, $smsmessage); $alertClass->SendDeliveryOTPEmail($collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $table_details); $response = array("Status" => 1, "message" => "Get Code From Customer"); } else { $response = array("Status" => 0, "message" => "Invalid Receipt"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("End Order", $userid, json_encode($response), $request); return json_encode($response); } function VerifySealOTP(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $otpcode = $request->input("otp"); $userid = $request->input("userid"); if (strlen($otpcode) > 3 && strlen($userid) > 3) { $checkcode = DB::table("otps")->select("Type", "created_at", "Receipt_No")->where("code", $otpcode)->where("status", 0)->get(); if (count($checkcode) == 1) { $type = $checkcode[0]->Type; $receiptNo = $checkcode[0]->Receipt_No; if ($type == "Collect") { $update_opt = DB::table("otps")->where("code", $otpcode)->update(array("updated_at" => date("Y-m-d H:i:s"), "status" => 1)); $get_all_seals = DB::table("receipt_details")->select("SealNo")->where("ReceiptID", $receiptNo)->get(); $total = 0; foreach ($get_all_seals as $seal) { $seal_no = $seal->SealNo; $update_seal = DB::table("seals")->where("Seal_No", $seal_no)->where("status", 0)->update(array("status" => 1)); $total = $total + 1; } $update_ = DB::table("receipts")->where("ID", $receiptNo)->where("status", 0)->update(array("collection_at" => date("Y-m-d H:i:s"), "status" => 1, "collection_code" => $otpcode, "status" => 1, "count" => $total)); $check_receipt = DB::table("receipt_details")->where("ReceiptID", $receiptNo)->update(array("status" => 1, "updated_at" => date("Y-m-d H:i:s"))); $check_in_que = DB::table("receipts")->where("userid", $userid)->where("ID", $receiptNo)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $collection_code = $check_in_que[0]->collection_code; $collection_time = $check_in_que[0]->collection_at; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->get(); if (count($get_seals) > 0) { $alertClass = new Alerts(); $smsmessage = "Dear Customer, Consignment No {$receipt_id}. is Now in Transit"; $emailmessage = "Dear Customer, Consignment No {$receipt_id}. is Now in Transit"; $table_details = "<table style="border-collapse: collapse; width: 100%;"  >\xa                    <thead> 
                        <tr style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;">\xa                             \xa                            <th>Box No.</th>\xa                            <th>Seal No.</th> 
                        </tr>\xa                    </thead>\xa                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $get_settings = DB::table("settings")->select("Email", "phone")->where("ID", 1)->get(); $ops_email = $get_settings[0]->Email; $ops_phone = $get_settings[0]->phone; $alertClass->SendSms($collection_phone, $smsmessage); $alertClass->SendSms($ops_phone, $smsmessage); $alertClass->SendTransitEmail($ops_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $receipt_id, $table_details); $alertClass->SendTransitEmail($collection_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $receipt_id, $table_details); } else { $response = array("Status" => 0, "message" => "Kindly Scan Some Seals"); } } $response = array("Status" => 1, "message" => "Transit Mode Activated"); } else { if ($type == "Deliver") { $update_opt = DB::table("otps")->where("code", $otpcode)->update(array("updated_at" => date("Y-m-d H:i:s"), "status" => 1)); $get_all_seals = DB::table("receipt_details")->select("SealNo")->where("ReceiptID", $receiptNo)->get(); foreach ($get_all_seals as $seal) { $seal_no = $seal->SealNo; $update_seal = DB::table("seals")->where("Seal_No", $seal_no)->where("status", 1)->update(array("status" => 2)); } $update_ = DB::table("receipts")->where("ID", $receiptNo)->where("status", 1)->update(array("delivery_at" => date("Y-m-d H:i:s"), "status" => 1, "delivery_code" => $otpcode, "status" => 2)); $check_receipt = DB::table("receipt_details")->where("ReceiptID", $receiptNo)->update(array("status" => 2, "updated_at" => date("Y-m-d H:i:s"))); $check_in_que = DB::table("receipts")->where("userid", $userid)->where("ID", $receiptNo)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $delivery_code = $check_in_que[0]->delivery_code; $delivery_time = $check_in_que[0]->delivery_at; $bullion = $check_in_que[0]->bullion; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $collection_code = $check_in_que[0]->collection_code; $collection_time = $check_in_que[0]->collection_at; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->get(); $alertClass = new Alerts(); $smsmessage = "Dear Customer, Consignment No {$receipt_id}. has been  Delivered"; $footer = $_ENV["EMAIL_FOOTER"]; $emailmessage = "Dear Customer, Consignment No {$receipt_id}. has been  Delivered.Find the Attached delivery note <p>{$footer}</p>"; $table_details = "<table style="border-collapse: collapse; width: 100%;"> 
                    <thead>\xa                        <tr style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;"> 
                              
                            <th>Box No.</th>\xa                            <th>Seal No.</th> 
                        </tr> 
                    </thead>\xa                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $get_settings = DB::table("settings")->select("Email", "phone")->where("ID", 1)->get(); $ops_email = $get_settings[0]->Email; $ops_phone = $get_settings[0]->phone; $alertClass->SendSms($collection_phone, $smsmessage); $alertClass->SendSms($delivery_phone, $smsmessage); $alertClass->SendSms($ops_phone, $smsmessage); $alertClass->SendDeliveryEmail($ops_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $delivery_code, $delivery_time, $userid, $bullion, $receipt_id, $table_details); $alertClass->SendDeliveryEmail($collection_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $delivery_code, $delivery_time, $userid, $bullion, $receipt_id, $table_details); $alertClass->SendDeliveryEmail($delivery_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $delivery_code, $delivery_time, $userid, $bullion, $receipt_id, $table_details); } $response = array("Status" => 1, "message" => "Delivery Success"); } } } else { $response = array("Status" => 0, "message" => "Invalid Or Exipred Code"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Verify OTP", $userid, json_encode($response), $request); return json_encode($response); } public function TransferSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal_no = $request->input("seal"); $userid = $request->input("userid"); $citid = $request->input("citid"); if ($seal_no != '' && strlen($userid) > 3 && strlen($citid) > 3) { $check_users = DB::select("select count(*) As count from users admin,users cit\xa                        where admin.Type=1 AND cit.Type=2 AND admin.UserID='{$userid}'\xa                         AND cit.UserID='{$citid}'"); if ($check_users[0]->count == 1) { $check_item = DB::table("seals")->select("ID")->where("Seal_No", $seal_no)->where("status", 0)->where("commander", null)->get(); if (count($check_item) == 1) { $transfer_seal = DB::table("seals")->where("Seal_No", $seal_no)->update(array("commander" => $citid)); $save_history = DB::table("seal_history")->insert(array("seal" => $seal_no, "admin" => $userid, "commander" => $citid, "activity" => 1, "created_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Transfered"); } else { $response = array("Status" => 0, "message" => "Invalid Seal"); } } else { $response = array("Status" => 0, "message" => "Invalid Users"); } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Seal Transfer", $userid, json_encode($response), $request); return json_encode($response); } public function ReturnSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal_no = $request->input("seal"); $userid = $request->input("userid"); $citid = $request->input("citid"); if ($seal_no != '' && strlen($userid) > 3 && strlen($citid) > 3) { $check_users = DB::select("select count(*) As count from users admin,users cit\xa                        where admin.Type=1 AND cit.Type=2 AND admin.UserID='{$userid}'\xa                         AND cit.UserID='{$citid}'"); if ($check_users[0]->count == 1) { $check_item = DB::table("seals")->select("ID")->where("Seal_No", $seal_no)->where("status", 0)->where("commander", $citid)->get(); if (count($check_item) == 1) { $return_seal = DB::table("seals")->where("Seal_No", $seal_no)->update(array("commander" => null)); $save_history = DB::table("seal_history")->insert(array("seal" => $seal_no, "admin" => $userid, "commander" => $citid, "activity" => 2, "created_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Returned"); } else { $response = array("Status" => 0, "message" => "Invalid Seal"); } } else { $response = array("Status" => 0, "message" => "Invalid Users"); } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Seal Returned", $userid, json_encode($response), $request); return json_encode($response); } ?>

Did this file decode correctly?

Original Code

<?   
 namespace App\Http\Controllers\Seal; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Http\Controllers\Logger; use App\Http\Controllers\Alerts\Alerts; class Seals extends Controller { public function SaveSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal_no = $request->input("seal"); $userid = $request->input("userid"); if ($seal_no != '' && strlen($userid) > 3) { $check_item = DB::table("seals")->select("ID")->where("Seal_No", $seal_no)->get(); if (count($check_item) == 1) { $response = array("Status" => 0, "message" => "Seal {$seal_no} Already Exits"); } else { $insert = DB::table("seals")->insert(array("Seal_No" => $seal_no, "scanby" => $userid, "created_at" => date("Y-m-d H:i:s"))); if ($insert) { $response = array("Status" => 1, "message" => "Seal Saved"); } else { $response = array("Status" => 0, "message" => "Save Error"); } } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Seal Save", $userid, json_encode($response), $request); return json_encode($response); } public function DeleteReceipt(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $userid = $request->input("userid"); $receiptid = $request->input("receiptid"); if (strlen($userid) > 3 && strlen($receiptid) > 0) { $check_receipt = DB::table("receipts")->select("ID")->where("userid", $userid)->where("ID", $receiptid)->where("status", 0)->count(); if ($check_receipt == 1) { $check_receipt = DB::table("receipts")->where("ID", $receiptid)->update(array("status" => -1)); $check_receipt = DB::table("receipt_details")->where("ReceiptID", $receiptid)->update(array("status" => -1, "updated_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Deleted"); } else { $response = array("Status" => 0, "message" => "Cannot be Deleted"); } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Delete Receipt", $userid, json_encode($response), $request); return json_encode($response); } public function MakeReceipt(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $customer_name = $request->input("customer"); $collection = $request->input("collection"); $collection_email = $request->input("collection_email"); $collection_phone = $request->input("collection_phone"); $delivery = $request->input("delivery"); $delivery_email = $request->input("delivery_email"); $delivery_phone = $request->input("delivery_phone"); $branch = $request->input("branch"); $userid = $request->input("userid"); $bullion = $request->input("bullion_no"); if (strlen($customer_name) > 3 && strlen($collection) > 3 && strlen($collection_email) > 3 && strlen($collection_phone) > 3 && strlen($delivery) > 3 && strlen($delivery_email) > 3 && strlen($delivery_phone) > 3 && strlen($branch) > 3 && strlen($userid) > 3 && strlen($bullion) > 3) { $check_user = DB::table("users")->where("Type", 2)->where("Status", 1)->where("UserID", $userid)->count(); if ($check_user == 1) { $check_in_que = DB::table("receipts")->select("ID")->where("userid", $userid)->where("status", 0)->count(); if ($check_in_que == 0) { $transit_save = DB::table("receipts")->insert(array("customer" => $customer_name, "collection" => $collection, "collection_email" => $collection_email, "collection_phone" => $collection_phone, "collection_at" => date("Y-m-d H:i:s"), "delivery" => $delivery, "delivery_email" => $delivery_email, "delivery_phone" => $delivery_phone, "branch" => $branch, "updated_at" => date("Y-m-d H:i:s"), "userid" => $userid, "bullion" => $bullion)); $response = array("Status" => 1, "message" => "Generated"); } else { $response = array("Status" => 0, "message" => "You have a Pending Receipt"); } } else { $response = array("Status" => 0, "message" => "Unauthorized User"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Create Receipt", $userid, json_encode($response), $request); return json_encode($response); } function UseSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal = $request->input("seal"); $boxno = $request->input("boxno"); $userid = $request->input("userid"); if (strlen($seal) > 3 && strlen($userid) > 3 && strlen($boxno) > 2) { $check_user = DB::table("users")->where("Type", 2)->where("Status", 1)->where("UserID", $userid)->count(); if ($check_user == 1) { $check_in_que = DB::table("receipts")->select("ID")->where("userid", $userid)->where("status", 0)->get(); if (count($check_in_que) == 1) { $receipt = $check_in_que[0]->ID; $check_seal = DB::table("seals")->where("Seal_No", $seal)->where("status", 0)->where("commander", $userid)->count(); if ($check_seal == 1) { $confirm_seal = DB::table("receipt_details")->where("SealNo", $seal)->where("status", 0)->count(); if ($confirm_seal == 0) { $add = DB::table("receipt_details")->insert(array("ReceiptID" => $receipt, "SealNo" => $seal, "BoxNo" => $boxno, "created_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Success"); } else { $response = array("Status" => 0, "message" => "Seal Already Exists"); } } else { $response = array("Status" => 0, "message" => "Invaild Or Expired Seal"); } } else { $response = array("Status" => 0, "message" => "Generate Receipt First"); } } else { $response = array("Status" => 0, "message" => "Unauthorized User"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Use Seal", $userid, json_encode($response), $request); return json_encode($response); } function ConfirmOrder(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $userid = $request->input("userid"); if (strlen($userid) > 3) { $check_in_que = DB::table("receipts")->where("userid", $userid)->where("status", 0)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->where("status", 0)->get(); if (count($get_seals) > 0) { $otp = rand(100000, 999999); $save_otp = DB::table("otps")->insert(array("code" => $otp, "Receipt_No" => $receipt_id, "Type" => "Collect", "created_at" => date("Y-m-d H:i:s"))); $alertClass = new Alerts(); $smsmessage = "Dear Customer,{$otp} is the Collection code for Receipt No {$receipt_id}.\xa                        Kindly check the details sent to {$collection_email} then Share this code to  {$userid}"; $footer = $_ENV["EMAIL_FOOTER"]; $emailmessage = "Dear {$collection}, {$otp} is the Collection code.
                                        Find the Attached PDF file for more details. <p>{$footer}</p>"; $table_details = "<table style="border-collapse: collapse; width: 100%;">
                    <thead >\xa                        <tr  style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;" >\xa                             
                            <th >Box No.</th>\xa                            <th>Seal No.</th>
                        </tr>\xa                    </thead>
                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $alertClass->SendSms($collection_phone, $smsmessage); $alertClass->SendCollectionOTPEmail($collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $table_details); $response = array("Status" => 1, "message" => "Get Code From Customer"); } else { $response = array("Status" => 0, "message" => "Kindly Scan Some Seals"); } } else { $response = array("Status" => 0, "message" => "Invalid Receipt"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Confirm Order", $userid, json_encode($response), $request); return json_encode($response); } function CloseSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal = $request->input("seal"); $userid = $request->input("userid"); if (strlen($seal) > 3 && strlen($userid) > 3) { $check_in_que = DB::table("receipts")->select("ID")->where("userid", $userid)->where("status", 1)->get(); if (count($check_in_que) == 1) { $receipt = $check_in_que[0]->ID; $check_seal = DB::table("seals")->where("Seal_No", $seal)->where("status", 1)->count(); if ($check_seal == 1) { $confirm_seal = DB::table("receipt_details")->where("SealNo", $seal)->where("status", 1)->count(); if ($confirm_seal == 1) { $update = DB::table("receipt_details")->where("SealNo", $seal)->update(array("status" => 2, "updated_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Success"); } else { $response = array("Status" => 0, "message" => "Seal invalid"); } } else { $response = array("Status" => 0, "message" => "Invaild Or Expired Seal"); } } else { $response = array("Status" => 0, "message" => "Invalid Receipt"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Use Seal", $userid, json_encode($response), $request); return json_encode($response); } function EndOrder(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $userid = $request->input("userid"); $receipt_id = $request->input("receiptid"); if (strlen($userid) > 3 && strlen($receipt_id) > 0) { $check_in_que = DB::table("receipts")->where("userid", $userid)->where("ID", $receipt_id)->where("status", 1)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->get(); $otp = rand(100000, 999999); $save_otp = DB::table("otps")->insert(array("code" => $otp, "Receipt_No" => $receipt_id, "Type" => "Deliver", "created_at" => date("Y-m-d H:i:s"))); $alertClass = new Alerts(); $smsmessage = "Dear {$delivery},{$otp} is the Delivery code for Receipt No {$receipt_id} Delivered
                        Kindly check details sent to {$delivery_email} then Share this code to  {$userid}"; $footer = $_ENV["EMAIL_FOOTER"]; $emailmessage = "Dear Customer,{$otp} is the Delivery code.\xa                        Find the Attached PDF file for more details. <p>{$footer}</p> "; $table_details = "<table style="border-collapse: collapse; width: 100%;" >
                    <thead>
                        <tr style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;">\xa                             \xa                            <th>Box No.</th>
                            <th>Seal No.</th>\xa                        </tr>\xa                    </thead>
                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $alertClass->SendSms($delivery_phone, $smsmessage); $alertClass->SendDeliveryOTPEmail($collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $table_details); $response = array("Status" => 1, "message" => "Get Code From Customer"); } else { $response = array("Status" => 0, "message" => "Invalid Receipt"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("End Order", $userid, json_encode($response), $request); return json_encode($response); } function VerifySealOTP(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $otpcode = $request->input("otp"); $userid = $request->input("userid"); if (strlen($otpcode) > 3 && strlen($userid) > 3) { $checkcode = DB::table("otps")->select("Type", "created_at", "Receipt_No")->where("code", $otpcode)->where("status", 0)->get(); if (count($checkcode) == 1) { $type = $checkcode[0]->Type; $receiptNo = $checkcode[0]->Receipt_No; if ($type == "Collect") { $update_opt = DB::table("otps")->where("code", $otpcode)->update(array("updated_at" => date("Y-m-d H:i:s"), "status" => 1)); $get_all_seals = DB::table("receipt_details")->select("SealNo")->where("ReceiptID", $receiptNo)->get(); $total = 0; foreach ($get_all_seals as $seal) { $seal_no = $seal->SealNo; $update_seal = DB::table("seals")->where("Seal_No", $seal_no)->where("status", 0)->update(array("status" => 1)); $total = $total + 1; } $update_ = DB::table("receipts")->where("ID", $receiptNo)->where("status", 0)->update(array("collection_at" => date("Y-m-d H:i:s"), "status" => 1, "collection_code" => $otpcode, "status" => 1, "count" => $total)); $check_receipt = DB::table("receipt_details")->where("ReceiptID", $receiptNo)->update(array("status" => 1, "updated_at" => date("Y-m-d H:i:s"))); $check_in_que = DB::table("receipts")->where("userid", $userid)->where("ID", $receiptNo)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $collection_code = $check_in_que[0]->collection_code; $collection_time = $check_in_que[0]->collection_at; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->get(); if (count($get_seals) > 0) { $alertClass = new Alerts(); $smsmessage = "Dear Customer, Consignment No {$receipt_id}. is Now in Transit"; $emailmessage = "Dear Customer, Consignment No {$receipt_id}. is Now in Transit"; $table_details = "<table style="border-collapse: collapse; width: 100%;"  >\xa                    <thead>
                        <tr style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;">\xa                             \xa                            <th>Box No.</th>\xa                            <th>Seal No.</th>
                        </tr>\xa                    </thead>\xa                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $get_settings = DB::table("settings")->select("Email", "phone")->where("ID", 1)->get(); $ops_email = $get_settings[0]->Email; $ops_phone = $get_settings[0]->phone; $alertClass->SendSms($collection_phone, $smsmessage); $alertClass->SendSms($ops_phone, $smsmessage); $alertClass->SendTransitEmail($ops_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $receipt_id, $table_details); $alertClass->SendTransitEmail($collection_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $receipt_id, $table_details); } else { $response = array("Status" => 0, "message" => "Kindly Scan Some Seals"); } } $response = array("Status" => 1, "message" => "Transit Mode Activated"); } else { if ($type == "Deliver") { $update_opt = DB::table("otps")->where("code", $otpcode)->update(array("updated_at" => date("Y-m-d H:i:s"), "status" => 1)); $get_all_seals = DB::table("receipt_details")->select("SealNo")->where("ReceiptID", $receiptNo)->get(); foreach ($get_all_seals as $seal) { $seal_no = $seal->SealNo; $update_seal = DB::table("seals")->where("Seal_No", $seal_no)->where("status", 1)->update(array("status" => 2)); } $update_ = DB::table("receipts")->where("ID", $receiptNo)->where("status", 1)->update(array("delivery_at" => date("Y-m-d H:i:s"), "status" => 1, "delivery_code" => $otpcode, "status" => 2)); $check_receipt = DB::table("receipt_details")->where("ReceiptID", $receiptNo)->update(array("status" => 2, "updated_at" => date("Y-m-d H:i:s"))); $check_in_que = DB::table("receipts")->where("userid", $userid)->where("ID", $receiptNo)->get(); if (count($check_in_que) == 1) { $receipt_id = $check_in_que[0]->ID; $collection_email = $check_in_que[0]->collection_email; $collection_phone = $check_in_que[0]->collection_phone; $delivery_email = $check_in_que[0]->delivery_email; $delivery_phone = $check_in_que[0]->delivery_phone; $delivery_code = $check_in_que[0]->delivery_code; $delivery_time = $check_in_que[0]->delivery_at; $bullion = $check_in_que[0]->bullion; $customer = $check_in_que[0]->customer; $branch = $check_in_que[0]->branch; $collection = $check_in_que[0]->collection; $delivery = $check_in_que[0]->delivery; $collection_code = $check_in_que[0]->collection_code; $collection_time = $check_in_que[0]->collection_at; $get_seals = DB::table("receipt_details")->where("ReceiptID", $receipt_id)->get(); $alertClass = new Alerts(); $smsmessage = "Dear Customer, Consignment No {$receipt_id}. has been  Delivered"; $footer = $_ENV["EMAIL_FOOTER"]; $emailmessage = "Dear Customer, Consignment No {$receipt_id}. has been  Delivered.Find the Attached delivery note <p>{$footer}</p>"; $table_details = "<table style="border-collapse: collapse; width: 100%;">
                    <thead>\xa                        <tr style="background-color: #FFAE42;color: white;text-align: center; padding: 8px;">
                             
                            <th>Box No.</th>\xa                            <th>Seal No.</th>
                        </tr>
                    </thead>\xa                    <tbody>"; foreach ($get_seals as $seal) { $box = $seal->BoxNo; $seal_no = $seal->SealNo; $table_details = $table_details . "<tr style='background-color: #f2f2f2; padding: 8px;'><td style='text-align: center;'>{$box}</td><td style='text-align: center;'>{$seal_no}</td></tr>"; } $table_details = $table_details . "</tbody></table>"; $get_settings = DB::table("settings")->select("Email", "phone")->where("ID", 1)->get(); $ops_email = $get_settings[0]->Email; $ops_phone = $get_settings[0]->phone; $alertClass->SendSms($collection_phone, $smsmessage); $alertClass->SendSms($delivery_phone, $smsmessage); $alertClass->SendSms($ops_phone, $smsmessage); $alertClass->SendDeliveryEmail($ops_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $delivery_code, $delivery_time, $userid, $bullion, $receipt_id, $table_details); $alertClass->SendDeliveryEmail($collection_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $delivery_code, $delivery_time, $userid, $bullion, $receipt_id, $table_details); $alertClass->SendDeliveryEmail($delivery_email, $collection_email, $collection, $collection_phone, $delivery, $delivery_email, $delivery_phone, $customer, $branch, $emailmessage, $collection_code, $collection_time, $delivery_code, $delivery_time, $userid, $bullion, $receipt_id, $table_details); } $response = array("Status" => 1, "message" => "Delivery Success"); } } } else { $response = array("Status" => 0, "message" => "Invalid Or Exipred Code"); } } else { $response = array("Status" => 0, "message" => "Missing Information"); } $logger->Log("Verify OTP", $userid, json_encode($response), $request); return json_encode($response); } public function TransferSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal_no = $request->input("seal"); $userid = $request->input("userid"); $citid = $request->input("citid"); if ($seal_no != '' && strlen($userid) > 3 && strlen($citid) > 3) { $check_users = DB::select("select count(*) As count from users admin,users cit\xa                        where admin.Type=1 AND cit.Type=2 AND admin.UserID='{$userid}'\xa                         AND cit.UserID='{$citid}'"); if ($check_users[0]->count == 1) { $check_item = DB::table("seals")->select("ID")->where("Seal_No", $seal_no)->where("status", 0)->where("commander", null)->get(); if (count($check_item) == 1) { $transfer_seal = DB::table("seals")->where("Seal_No", $seal_no)->update(array("commander" => $citid)); $save_history = DB::table("seal_history")->insert(array("seal" => $seal_no, "admin" => $userid, "commander" => $citid, "activity" => 1, "created_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Transfered"); } else { $response = array("Status" => 0, "message" => "Invalid Seal"); } } else { $response = array("Status" => 0, "message" => "Invalid Users"); } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Seal Transfer", $userid, json_encode($response), $request); return json_encode($response); } public function ReturnSeal(Request $request) { date_default_timezone_set("Africa/Nairobi"); $response = array(); $logger = new Logger(); $seal_no = $request->input("seal"); $userid = $request->input("userid"); $citid = $request->input("citid"); if ($seal_no != '' && strlen($userid) > 3 && strlen($citid) > 3) { $check_users = DB::select("select count(*) As count from users admin,users cit\xa                        where admin.Type=1 AND cit.Type=2 AND admin.UserID='{$userid}'\xa                         AND cit.UserID='{$citid}'"); if ($check_users[0]->count == 1) { $check_item = DB::table("seals")->select("ID")->where("Seal_No", $seal_no)->where("status", 0)->where("commander", $citid)->get(); if (count($check_item) == 1) { $return_seal = DB::table("seals")->where("Seal_No", $seal_no)->update(array("commander" => null)); $save_history = DB::table("seal_history")->insert(array("seal" => $seal_no, "admin" => $userid, "commander" => $citid, "activity" => 2, "created_at" => date("Y-m-d H:i:s"))); $response = array("Status" => 1, "message" => "Returned"); } else { $response = array("Status" => 0, "message" => "Invalid Seal"); } } else { $response = array("Status" => 0, "message" => "Invalid Users"); } } else { $response = array("Status" => 0, "message" => "MIssing information"); } $logger->Log("Seal Returned", $userid, json_encode($response), $request); return json_encode($response); } ?>

Function Calls

None

Variables

None

Stats

MD5 c1e312ebf99927d3d6b862b797c1f582
Eval Count 0
Decode Time 79 ms