Ejemplo n.º 1
0
def all_admin(request):
    cursor = connection.cursor()
    cursor.execute(
        "SELECT * FROM users_user where user_level_id = 0 group by user_name ")
    datalist = dictfetchall(cursor)

    context = {
        "datalist": datalist,
    }
    return render(request, 'admin/all_admin.html', context)
Ejemplo n.º 2
0
def details(request):
    if request.method == 'POST':
        cursor = connection.cursor()
        id = request.POST['id']
        # requette sql
        cursor.execute("SELECT * FROM users_user WHERE user_id =" + str(id) +
                       "")
        table = dictfetchall(cursor)
        nom = table[0]['user_name']
        prenom = table[0]['user_prenom']
        tel = table[0]['user_mobile']
        numero_compte = table[0]['user_account_no']

        # _______________________________________mouvement
        cursor.execute(
            "SELECT * FROM mytransaction  WHERE mytransaction_user_id =" + id +
            "")
        mouvement = dictfetchall(cursor)
        # date = mouvement[0]['mytransaction_date']
        # depot = mouvement[0]['mytransaction_montant_depot']
        # reception = mouvement[0]['mytransaction_montant_reception']
        # transfert = mouvement[0]['mytransaction_montant_transfer']
        # retrait = mouvement[0]['mytransaction_montant_retrait']

        context = {
            'mouvement': mouvement,
            'id': id,
            'nom': nom,
            'prenom': prenom,
            'tel': tel,
            'numero': numero_compte,

            #  'date': date,
            # 'depot': depot,
            #  'reception': reception,
            #  'transfert': transfert,
            #  'retrait': retrait,
        }

    return render(request, 'admin/details.html', context)
Ejemplo n.º 3
0
def getTransactionJSON(request, one=False):
    cur = connection.cursor()
    cur.execute(
        "SELECT mytransaction_amount FROM   mytransaction   WHERE mytransaction_user_id ="
        + str(request.session.get('user_id', None)) + "")
    dataList = dictfetchall(cur)
    transactionJson = {'list': []}
    i = 0
    for key in dataList:
        transactionJson['list'].append({
            "X": i + 1,
            "Y": int(key['mytransaction_amount'])
        })
        i = i + 1
    return transactionJson['list']
Ejemplo n.º 4
0
def transactions_all_account(request):
    cursor = connection.cursor()
    cursor.execute(
        "SELECT * FROM mytransaction WHERE mytransaction_user_id =" +
        str(request.session.get('user_id', None)) + "")
    datalist = dictfetchall(cursor)
    json_output = getTransactionJSON(request)
    graphData = {
        "linecolor": "#152c3f",
        "title": "Transactions",
        "values": json_output
    }
    json_string = json.dumps(graphData)
    context = {
        "datalist": datalist,
        "graphData": json_string,
        "json_output": request.session.get('user_id', None)
    }

    # Message according Salary #
    context['heading'] = "Detailes Des Transactions "
    return render(request, 'transaction-list.html', context)
Ejemplo n.º 5
0
def transfer(request):
    #today = datetime.datetime.now()
    time1 = datetime.datetime.now()
    time2 = str(time1)
    today = time2[0:19]

    context = {
        "txt": False,
        "msg": "",
        "fn": "add",
        "employeetypelist": getDropDown('users_user', 'user_id'),
    }
    cursor = connection.cursor()
    if (request.method == "POST"):
        # Credit the amount to Destination Account
        currentBalance = getData(request.POST['transfer_user_id'])
        amount = int(currentBalance['account_amount']) + int(
            request.POST['transfer_amount'])
        # credit --------------------------
        cursor.execute("SELECT * FROM   users_user WHERE user_id =" +
                       str(request.session.get('user_id', None)) + "")
        table = dictfetchall(cursor)
        # ----------------debit
        cursor.execute("SELECT * FROM   users_user WHERE user_id =" +
                       str(request.POST['transfer_user_id']) + "")
        table2 = dictfetchall(cursor)

        # --------------------------------------------

        cursor.execute(
            """
            UPDATE account
            SET account_amount=%s WHERE  account_user_id=%s  
        """, (amount, request.POST['transfer_user_id']))

        cursor.execute(
            """
            INSERT INTO `mytransaction`
            SET mytransaction_user_id=%s, mytransaction_type=%s, mytransaction_amount=%s, mytransaction_description=%s, mytransaction_date=%s, montant_restant=%s,mytransaction_montant_reception=%s   
        """, (request.POST['transfer_user_id'], "Credit",
              request.POST['transfer_amount'],
              "Vous avez recu " + request.POST['transfer_amount'] +
              " sur votre compte venant de " + str(table[0]['user_name']),
              today, amount, int(request.POST['transfer_amount'])))

        # Debit the amount from source Account
        context = {
            "fn": "add",
            "data": request.session.get('user_id', None),
            "employeetypelist": getDropDown('users_user', 'user_id'),
        }
        currentBalance = getData(int(request.session.get('user_id', None)))
        amount = int(currentBalance['account_amount']) - int(
            request.POST['transfer_amount'])
        cursor.execute(
            """
            UPDATE account
            SET account_amount=%s WHERE  account_user_id=%s  
        """, (amount, request.session.get('user_id', None)))

        cursor.execute(
            """
            INSERT INTO `mytransaction`
            SET mytransaction_user_id=%s, mytransaction_type=%s, mytransaction_amount=%s, mytransaction_description=%s, mytransaction_date=%s, montant_restant=%s, mytransaction_montant_transfer=%s   
        """, (request.session.get(
                'user_id', None), "Debit", request.POST['transfer_amount'],
              " vous avez envoye " + request.POST['transfer_amount'] +
              "  sur  compte de " + str(table2[0]['user_name']), today, amount,
              int(request.POST['transfer_amount'])))

        # messages.add_message(request, messages.INFO, "Transferer a " + request.POST[
        #     'transfer_amount'] + "/- a ete faite avec success sur votre compte.")
        context["txt"] = True
        context[
            "msg"] = "Vous avez effectue un Transfert  de  " + request.POST[
                'transfer_amount']

    return render(request, 'transfer.html', context)
Ejemplo n.º 6
0
def getDropDown(table, condtion):
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM " + table + " WHERE " + condtion)
    dropdownList = dictfetchall(cursor)
    return dropdownList
Ejemplo n.º 7
0
def getInsertID():
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM users_user ORDER BY user_id DESC LIMIT 0,1")
    dataList = dictfetchall(cursor)
    dataList = dataList[0]
    return dataList['user_id']
Ejemplo n.º 8
0
def getmyData(id):
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM users_user WHERE user_id = " + str(id))
    dataList = dictfetchall(cursor)
    return dataList[0]
Ejemplo n.º 9
0
def getData(id):
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM account WHERE account_user_id = " + str(id))
    dataList = dictfetchall(cursor)
    return dataList[0]