Subversion Repositories SmartDukaan

Rev

Rev 1382 | Rev 1404 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1382 Rev 1398
Line 167... Line 167...
167
            #Nothing much to do. Customer will not know that there was a transaction.
167
            #Nothing much to do. Customer will not know that there was a transaction.
168
            print ex
168
            print ex
169
    session.commit()
169
    session.commit()
170
    return True
170
    return True
171
 
171
 
172
def email_transaction_info_to_user(transaction_id):
172
def enqueue_transaction_info_email(transaction_id):
173
    transaction = get_transaction(transaction_id)
173
    transaction = get_transaction(transaction_id)
174
    
174
    
175
    html_header = """
175
    html_header = """
176
<html>
176
<html>
177
<body>
177
<body>
Line 193... Line 193...
193
            <th>Quantity</th>
193
            <th>Quantity</th>
194
            <th>Unit Price</th>
194
            <th>Unit Price</th>
195
            <th>Amount</th>
195
            <th>Amount</th>
196
        </tr>
196
        </tr>
197
    """
197
    """
-
 
198
    user_email = ""
198
    total_amount = 0.0
199
    total_amount = 0.0
199
    html_table = ""
200
    html_table = ""
200
    
201
    
201
    for order in transaction.orders:
202
    for order in transaction.orders:
202
        order_date = order.created_timestamp
203
        order_date = order.created_timestamp
-
 
204
        user_email = order.customer_email
203
        html_tr = "<tr><td>" + str(order.id) + "</td>"
205
        html_tr = "<tr><td>" + str(order.id) + "</td>"
204
        
206
        
205
        for lineitem in order.lineitems:
207
        for lineitem in order.lineitems:
206
            html_tr += "<td>" + str(lineitem) + "</td>"
208
            html_tr += "<td>" + str(lineitem) + "</td>"
207
            html_tr += "<td>" + str(lineitem.quantity) + "</td>"
209
            html_tr += "<td>" + str(lineitem.quantity) + "</td>"
Line 223... Line 225...
223
    </p>
225
    </p>
224
</div>
226
</div>
225
</body>
227
</body>
226
</html>
228
</html>
227
    """
229
    """
228
#    formated_order_date = strftime("%B %d, %Y %H:%M %p", time.strptime(order_date, "%Y-%m-%d %H:%M:%S"))
-
 
-
 
230
 
229
    formated_order_date = order_date
231
    formated_order_date = order_date
230
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date))
232
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date))
231
    email_footer = Template(html_footer).substitute(dict(total_amount = total_amount))
233
    email_footer = Template(html_footer).substitute(dict(total_amount = total_amount))
232
    
234
    
233
    try:
235
    try:
234
        user_client = UserClient().get_client()
-
 
235
        user = user_client.getUserById(transaction.customer_id)
-
 
236
    
-
 
237
        helper_client = HelperClient().get_client()
236
        helper_client = HelperClient().get_client()
238
        mail = Mail(user.email, "Saholic - Order Details", email_header + html_table + email_footer, None, None, None)
237
        helper_client.saveUserEmailForSending(user_email, "", "Saholic - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo")
239
        helper_client.sendMail(mail)
-
 
240
        return True
238
        return True
241
    except Exception as e:
239
    except Exception as e:
242
        print e
240
        print e
243
        return False
241
        return False
244
 
242