]> Softwares of Agnibho - librevax.git/commitdiff
Bugfix: add personnel
authorAgnibho Mondal <mondal@agnibho.com>
Thu, 11 Jan 2024 20:30:26 +0000 (02:00 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Thu, 11 Jan 2024 20:30:26 +0000 (02:00 +0530)
personnel.py
templates/personnel-edit.html
templates/personnel-view.html

index b2dbb2067eff8af4ba79a16c830e87e1f5187c61..75ace878f8e2614eb372d5ce8f0fbc463593804b 100644 (file)
@@ -7,7 +7,10 @@
 
 def create(cursor, data, active):
     try:
-        cursor.execute("INSERT INTO personnel (cid, mid, name, designation, contact, role, info, active) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", (data["cid"], data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active))
+        cid=None
+        if(data["cid"]!=""):
+            cid=data["cid"]
+        cursor.execute("INSERT INTO personnel (cid, mid, name, designation, contact, role, info, active) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", (cid, data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active))
         if(cursor.rowcount<=0):
             return (False, "Failed to create record.")
         else:
@@ -25,7 +28,10 @@ def read(cursor, sid):
 
 def update(cursor, sid, data, active):
     try:
-        cursor.execute("UPDATE personnel SET cid=?, mid=?, name=?, designation=?, contact=?, role=?, info=?, active=? WHERE sid=?", (data["cid"], data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active, sid))
+        cid=None
+        if(data["cid"]!=""):
+            cid=data["cid"]
+        cursor.execute("UPDATE personnel SET cid=?, mid=?, name=?, designation=?, contact=?, role=?, info=?, active=? WHERE sid=?", (cid, data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active, sid))
         if(cursor.rowcount<=0):
             return (False, "Failed to update record.")
         else:
index 019a841f00afb9a0cea4599aba8b0aedb9968876..21ed53c315416aa2b1111ab5fb3d381d94e7ef30 100644 (file)
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Lib
     <div class="mb-2 row">
       <label class="form-label col-sm-3">ID</label>
       <div class="col-sm-9">
-        <input name="cid" placeholder="ID" class="form-control" value="{{data["cid"]}}">
+        <input name="cid" placeholder="ID" class="form-control" value="{% if data["cid"] %}{{data["cid"]}}{% endif %}">
       </div>
     </div>
     <div class="mb-2 row">
@@ -52,7 +52,7 @@ You should have received a copy of the GNU General Public License along with Lib
     <div class="mb-2 row">
       <label class="form-label col-sm-3">Center</label>
       <div class="col-sm-9">
-        <select name="role" class="form-select">
+        <select name="mid" class="form-select">
           <option value="0" {% if data["mid"]==0 %}selected{% endif %}>ALL</option>
           {% for i in center %}
           <option value="{{i["mid"]}}" {% if data["mid"]==i["mid"] %}selected{% endif %}>{{i["center"]}}</option>
index 0f196433890a6013d3296af362281df300e893b8..fb859bcf3a09e07e0a01eab955e37361953d91ca 100644 (file)
@@ -28,7 +28,7 @@ You should have received a copy of the GNU General Public License along with Lib
 
   {% endif %}
 
-  {% if action=="view" and data["mid"] %}
+  {% if action=="view" %}
 
   <!-- VIEW -->
   <table class="table">