mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-14 06:19:44 -04:00
Add three missing plugin hook points for sale documents so plugins can
inject buttons into invoice, quote, and work order views alongside the
existing receipt hook. All four pass ['saleId' => $sale_id_num] and
follow the same naming pattern (view:sales_{type}_buttons).
Exempt plugins/*/webhook from CSRF filtering to support server-to-server
provider callbacks. Also convert the CSRF except list from a string to an
array — the previous 'login|migrate' string produced a single unanchored
pattern, making login/anything CSRF-exempt. Separate array entries anchor
each one individually. Plugin webhook handlers are responsible for their
own authentication.
Add WhatsApp Business Cloud API plugin (app/Plugins/WhatsAppPlugin/):
- Free-form messaging page registered as the 'whatsapp' office module
with its own permission, plus per-customer modal and thread view
- "Send via WhatsApp" button on all four sale document types via the new
hooks; renders only when the customer has a phone number
- PDF delivery using the same sales/{type}_email view core uses for email
- Inbound webhook at plugins/whatsapp/webhook authenticated by
X-Hub-Signature-256 HMAC; fails closed on missing/bad signature;
always returns 200 to suppress Meta retries
- Out-of-order status callbacks cannot downgrade sent → delivered → read
- Conversation log table via plugin migration; dropped on uninstall with
version reset so re-install recreates it cleanly
- Access token and app secret encrypted at rest in plugin_config; no
writes to app_config or initial_schema.sql
- utf8mb4_unicode_520_ci collation throughout (MySQL and MariaDB compat)
- Language file stubs for all existing locales; English strings complete
- README covering credentials, install, webhook setup, and uninstall
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* "Send via WhatsApp" button injected into a sale document view. The plugin has
|
|
* already confirmed the customer has a phone number.
|
|
*
|
|
* @var int $saleId
|
|
* @var string $documentType One of invoice|quote|work_order|receipt.
|
|
*/
|
|
?>
|
|
<button type="button" class="btn btn-success btn-sm" id="show_whatsapp_button">
|
|
<?= '<span class="glyphicon glyphicon-comment"> </span>' . lang('WhatsAppPlugin.send_whatsapp') ?>
|
|
</button>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$("#show_whatsapp_button").click(function() {
|
|
var $btn = $(this);
|
|
|
|
if ($btn.hasClass('disabled')) {
|
|
return;
|
|
}
|
|
|
|
$btn.addClass('disabled');
|
|
|
|
// The CSRF token is appended by the $.ajax wrapper in partial/header_js.
|
|
$.post('<?= site_url('whatsapp/sendDocument/' . $saleId . '/' . $documentType) ?>', {},
|
|
function(response) {
|
|
$.notify({
|
|
message: response.message
|
|
}, {
|
|
type: response.success ? 'success' : 'danger'
|
|
})
|
|
}, 'json'
|
|
).always(function() {
|
|
$btn.removeClass('disabled');
|
|
});
|
|
});
|
|
});
|
|
</script>
|