adding prefix for phone no
This commit is contained in:
parent
d973c05c15
commit
7f2a24bae9
BIN
assets/pasted-20260211-124352-68ac57b9.png
Normal file
BIN
assets/pasted-20260211-124352-68ac57b9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
assets/pasted-20260211-131304-152989f6.png
Normal file
BIN
assets/pasted-20260211-131304-152989f6.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
@ -21,34 +21,55 @@ except ImportError:
|
||||
pass
|
||||
|
||||
# --- FIX: Preload libraries for WeasyPrint/Pango ---
|
||||
# Ensure LD_LIBRARY_PATH includes standard paths
|
||||
if 'LD_LIBRARY_PATH' not in os.environ:
|
||||
os.environ['LD_LIBRARY_PATH'] = '/usr/lib/x86_64-linux-gnu:/usr/lib'
|
||||
else:
|
||||
if '/usr/lib/x86_64-linux-gnu' not in os.environ['LD_LIBRARY_PATH']:
|
||||
os.environ['LD_LIBRARY_PATH'] += ':/usr/lib/x86_64-linux-gnu'
|
||||
# Manually load libraries using absolute paths
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
import traceback
|
||||
import sys
|
||||
|
||||
# Manually load the library
|
||||
lib_paths = [
|
||||
'/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libfontconfig.so.1',
|
||||
'/usr/lib/x86_64-linux-gnu/libcairo.so.2',
|
||||
'/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0',
|
||||
]
|
||||
|
||||
for path in lib_paths:
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Try to import weasyprint
|
||||
try:
|
||||
if not ctypes.util.find_library('libgobject-2.0-0'):
|
||||
# Try to load known paths directly
|
||||
candidates = [
|
||||
'libgobject-2.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0',
|
||||
'/usr/lib/libgobject-2.0.so.0'
|
||||
]
|
||||
for c in candidates:
|
||||
try:
|
||||
ctypes.CDLL(c)
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
# ---------------------------------------------------
|
||||
import weasyprint
|
||||
except Exception as e:
|
||||
# Log error to file and stderr
|
||||
error_msg = f"WeasyPrint Import Error: {str(e)}\n{traceback.format_exc()}"
|
||||
sys.stderr.write(error_msg)
|
||||
try:
|
||||
with open("weasyprint_wsgi_error.log", "w") as f:
|
||||
f.write(error_msg)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
# Fallback to mock
|
||||
import types
|
||||
class MockHTML:
|
||||
def __init__(self, string=None, base_url=None):
|
||||
pass
|
||||
def write_pdf(self, target=None):
|
||||
raise OSError("WeasyPrint system dependencies are missing. PDF generation is disabled.")
|
||||
|
||||
mock_wp = types.ModuleType("weasyprint")
|
||||
mock_wp.HTML = MockHTML
|
||||
sys.modules["weasyprint"] = mock_wp
|
||||
# ---------------------------------------------------
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
application = get_wsgi_application()
|
||||
Binary file not shown.
@ -25,7 +25,7 @@
|
||||
<label for="cashier" class="form-label">{% trans "Cashier" %}</label>
|
||||
<select name="cashier_id" id="cashier" class="form-select" required>
|
||||
<option value="">{% trans "Select Cashier" %}</option>
|
||||
{% for user in cashiers %}
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}">
|
||||
{{ user.first_name }} {{ user.last_name }} ({{ user.username }})
|
||||
</option>
|
||||
|
||||
@ -65,6 +65,43 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Edit Customer Modal -->
|
||||
<div class="modal fade" id="editCustomerModal{{ customer.id }}" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content rounded-4 border-0 shadow">
|
||||
<div class="modal-header border-0 pb-0">
|
||||
<h5 class="modal-title fw-bold">{% trans "Edit Customer" %}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form action="{% url 'edit_customer' customer.id %}" method="POST">
|
||||
{% csrf_token %}
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Full Name" %}</label>
|
||||
<input type="text" name="name" class="form-control rounded-3" value="{{ customer.name }}" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Phone Number" %}</label>
|
||||
<input type="text" name="phone" class="form-control rounded-3" value="{{ customer.phone }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Email Address" %}</label>
|
||||
<input type="email" name="email" class="form-control rounded-3" value="{{ customer.email }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Address" %}</label>
|
||||
<textarea name="address" class="form-control rounded-3" rows="3">{{ customer.address }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer border-0">
|
||||
<button type="button" class="btn btn-light rounded-3" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
||||
<button type="submit" class="btn btn-primary rounded-3 px-4">{% trans "Save Changes" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
@ -89,7 +126,7 @@
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Phone Number" %}</label>
|
||||
<input type="text" id="addCustPhone" class="form-control rounded-3">
|
||||
<input type="text" id="addCustPhone" class="form-control rounded-3" value="968">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Email Address" %}</label>
|
||||
@ -130,7 +167,7 @@
|
||||
if (data.success) {
|
||||
if (stayOpen) {
|
||||
document.getElementById('addCustName').value = '';
|
||||
document.getElementById('addCustPhone').value = '';
|
||||
document.getElementById('addCustPhone').value = '968';
|
||||
document.getElementById('addCustEmail').value = '';
|
||||
document.getElementById('addCustAddress').value = '';
|
||||
alert('{% trans "Customer added. You can add another one." %}');
|
||||
|
||||
@ -126,7 +126,7 @@
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-bold">{% trans "Phone Number" %}</label>
|
||||
<input type="text" id="addSuppPhone" class="form-control rounded-3">
|
||||
<input type="text" id="addSuppPhone" class="form-control rounded-3" value="968">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer border-0">
|
||||
@ -159,7 +159,7 @@
|
||||
if (stayOpen) {
|
||||
document.getElementById('addSuppName').value = '';
|
||||
document.getElementById('addSuppContact').value = '';
|
||||
document.getElementById('addSuppPhone').value = '';
|
||||
document.getElementById('addSuppPhone').value = '968';
|
||||
alert('{% trans "Supplier added. You can add another one." %}');
|
||||
} else {
|
||||
window.location.reload();
|
||||
|
||||
@ -1265,6 +1265,8 @@ def edit_customer(request, pk):
|
||||
if request.method == 'POST':
|
||||
customer.name = request.POST.get('name')
|
||||
customer.phone = request.POST.get('phone')
|
||||
customer.email = request.POST.get('email')
|
||||
customer.address = request.POST.get('address')
|
||||
customer.save()
|
||||
return redirect('customers')
|
||||
|
||||
@ -1640,8 +1642,16 @@ def create_lpo_api(request):
|
||||
# --- Cashier / Sessions ---
|
||||
@login_required
|
||||
def cashier_registry(request):
|
||||
registries = CashierCounterRegistry.objects.all()
|
||||
return render(request, 'core/cashier_registry.html', {'registries': registries})
|
||||
registries = CashierCounterRegistry.objects.select_related('user', 'counter').all()
|
||||
# Provide data for dropdowns
|
||||
users = User.objects.filter(is_active=True).order_by('username')
|
||||
counters = Device.objects.all().order_by('name')
|
||||
|
||||
return render(request, 'core/cashier_registry.html', {
|
||||
'registries': registries,
|
||||
'users': users,
|
||||
'counters': counters
|
||||
})
|
||||
|
||||
@login_required
|
||||
def cashier_session_list(request):
|
||||
|
||||
68
manage.py
68
manage.py
@ -15,34 +15,52 @@ def main():
|
||||
pass
|
||||
|
||||
# --- FIX: Preload libraries for WeasyPrint/Pango ---
|
||||
# This fixes OSError: cannot load library 'libgobject-2.0-0' during deployment
|
||||
import ctypes.util
|
||||
# Manually load libraries using absolute paths since LD_LIBRARY_PATH
|
||||
# changes don't affect dlopen() in the running process.
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
import traceback
|
||||
|
||||
# 1. Ensure LD_LIBRARY_PATH includes standard paths (helper for find_library)
|
||||
if 'LD_LIBRARY_PATH' not in os.environ:
|
||||
os.environ['LD_LIBRARY_PATH'] = '/usr/lib/x86_64-linux-gnu:/usr/lib'
|
||||
else:
|
||||
if '/usr/lib/x86_64-linux-gnu' not in os.environ['LD_LIBRARY_PATH']:
|
||||
os.environ['LD_LIBRARY_PATH'] += ':/usr/lib/x86_64-linux-gnu'
|
||||
lib_paths = [
|
||||
'/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libfontconfig.so.1',
|
||||
'/usr/lib/x86_64-linux-gnu/libcairo.so.2',
|
||||
'/usr/lib/x86_64-linux-gnu/libpango-1.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0',
|
||||
]
|
||||
|
||||
# 2. Manually load the library to ensure it's available
|
||||
for path in lib_paths:
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except OSError:
|
||||
# Continue even if one fails
|
||||
pass
|
||||
|
||||
# Try to import weasyprint to see if it works
|
||||
try:
|
||||
if not ctypes.util.find_library('libgobject-2.0-0'):
|
||||
# Try to load known paths directly
|
||||
candidates = [
|
||||
'libgobject-2.0.so.0',
|
||||
'/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0',
|
||||
'/usr/lib/libgobject-2.0.so.0'
|
||||
]
|
||||
for c in candidates:
|
||||
try:
|
||||
ctypes.CDLL(c)
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
import weasyprint
|
||||
except Exception as e:
|
||||
# Log the specific error for debugging
|
||||
error_msg = f"WeasyPrint Import Error: {str(e)}\n{traceback.format_exc()}"
|
||||
sys.stderr.write(error_msg)
|
||||
try:
|
||||
with open("weasyprint_error.log", "w") as f:
|
||||
f.write(error_msg)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Fallback to mock if system dependencies are missing or import fails
|
||||
import types
|
||||
class MockHTML:
|
||||
def __init__(self, string=None, base_url=None):
|
||||
pass
|
||||
def write_pdf(self, target=None):
|
||||
raise OSError("WeasyPrint system dependencies are missing. PDF generation is disabled.")
|
||||
|
||||
mock_wp = types.ModuleType("weasyprint")
|
||||
mock_wp.HTML = MockHTML
|
||||
sys.modules["weasyprint"] = mock_wp
|
||||
# ---------------------------------------------------
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
@ -57,4 +75,4 @@ def main():
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
BIN
staticfiles/pasted-20260211-124352-68ac57b9.png
Normal file
BIN
staticfiles/pasted-20260211-124352-68ac57b9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
staticfiles/pasted-20260211-131304-152989f6.png
Normal file
BIN
staticfiles/pasted-20260211-131304-152989f6.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Loading…
x
Reference in New Issue
Block a user