-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
334 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
__version__ = '2.1.5' | ||
__version__ = '2.1.6' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,11 +367,14 @@ def cancel_all_allocations(employee, day_of_week): | |
frappe.db.commit() | ||
|
||
def item_validate(self, method): | ||
if (self.rn_break_duration % 15 != 0): | ||
frappe.throw("Break duration must be in intervals of 15 minutes.") | ||
if self.is_stock_item == 0: | ||
if (self.rn_break_duration % 15 != 0): | ||
frappe.throw("Break duration must be in intervals of 15 minutes.") | ||
|
||
if (self.rn_service_duration % 15 != 0): | ||
frappe.throw("Service duration must be in intervals of 15 minutes.") | ||
if (self.rn_service_duration % 15 != 0): | ||
frappe.throw("Service duration must be in intervals of 15 minutes.") | ||
else: | ||
pass | ||
|
||
@frappe.whitelist() | ||
def get_availability_for_team_dow(team, day_of_week): | ||
|
@@ -510,14 +513,15 @@ def print_job_sheet(names): | |
pdf_options = { | ||
"no-outline": None, | ||
"encoding": "UTF-8", | ||
"title": "Job Sheet" | ||
"title": "Job Sheet", | ||
"orientation": "landscape" | ||
} | ||
|
||
#frappe.local.response.filename = "{filename}.pdf".format(filename="job_sheet_list".replace(" ", "-").replace("/", "-")) | ||
filecontent, filename = rn_get_pdf(final_html, options=pdf_options) | ||
|
||
frappe.local.response.filecontent = filecontent | ||
frappe.local.response.filename = "{filename}.pdf".format(filename=filename).replace(" ", "-").replace("/", "-") | ||
frappe.local.response.filename = "refreshed-jobsheet-{0}.pdf".format(frappe.utils.data.format_datetime(frappe.utils.today(),"YYYY-MM-dd")) | ||
frappe.local.response.type = "download" | ||
|
||
def prepare_bulk_print_html(names): | ||
|
@@ -539,8 +543,9 @@ def prepare_bulk_print_html(names): | |
|
||
ss_rn_golist = sorted(ss_rn_golist, key=lambda v:v.get("starts_on")) | ||
ss_rn_prolist = sorted(ss_rn_prolist, key=lambda v:v.get("starts_on")) | ||
date_for_title = frappe.utils.data.format_datetime(frappe.utils.data.add_to_date(frappe.utils.today(), days=1),"d-MMM") | ||
|
||
html_params = { "ss_rn_golist": ss_rn_golist or [], "ss_rn_prolist": ss_rn_prolist or []} | ||
html_params = { "ss_rn_golist": ss_rn_golist or [], "ss_rn_prolist": ss_rn_prolist or [], "date_for_title": date_for_title or ""} | ||
final_html = frappe.render_template("refreshednow_erpnext/templates/includes/refreshed_jobsheet.html", html_params) | ||
|
||
return final_html | ||
|
@@ -549,7 +554,7 @@ def prepare_bulk_print_html(names): | |
def rn_get_pdf(html, options=None): | ||
print "RN GET PDF" | ||
date = frappe.utils.add_days(frappe.utils.getdate(), 1) | ||
fname = os.path.join(frappe.get_site_path(), "public","files", "refreshed-jobsheet-{0}.pdf ".format(frappe.utils.data.format_datetime(date,"YYYY-MM-dd"))) | ||
fname = os.path.join(frappe.get_site_path(), "public","files", "refreshed-jobsheet-{0}.pdf".format(frappe.utils.data.format_datetime(date,"YYYY-MM-dd"))) | ||
cleanup(fname) | ||
try: | ||
pdfkit.from_string(html, fname, options=options or {}) | ||
|
@@ -595,11 +600,12 @@ def get_tomorrows_servicelist(): | |
pdf_options = { | ||
"no-outline": None, | ||
"encoding": "UTF-8", | ||
"title": "Job Sheet" | ||
"title": "Job Sheet", | ||
"orientation": "landscape" | ||
} | ||
pdf_data, pdf_fname = rn_get_pdf(final_html, pdf_options) | ||
|
||
return pdf_data, pdf_fname | ||
return tomorrow, pdf_data, pdf_fname | ||
|
||
def cleanup(fname): | ||
if os.path.exists(fname): | ||
|
@@ -650,9 +656,17 @@ def send_jobsheet(): | |
#Comparison times are adjusted for SF time. | ||
if nowtime_ak.hour in [20]: | ||
try: | ||
pdf_file, pdf_fname = get_tomorrows_servicelist() | ||
attachment = frappe._dict({"fname": pdf_fname, "fcontent":pdf_file}) | ||
frappe.sendmail(sender="[email protected]", recipients=["[email protected]", "[email protected]"], subject="Refreshed Now Job Sheet", message="[Test Message] PFA Job Sheet for tomorrow.", attachments=attachment) | ||
tomorrow, pdf_file, pdf_fname = get_tomorrows_servicelist() | ||
# pdf_name = os.path.basename(pdf_fname) | ||
pdf_name = "job-sheet-" + frappe.utils.data.format_datetime(tomorrow,"dd-MM-YYYY") + ".pdf" | ||
|
||
attachment = frappe._dict({"fname": pdf_name, "fcontent":pdf_file}) | ||
frappe.sendmail( | ||
sender="[email protected]", | ||
recipients=["[email protected]", "[email protected]"], | ||
subject="Refreshed Job Sheet for " + frappe.utils.data.format_datetime(tomorrow,"d-MMM"), | ||
message="Attached is the Job Sheet for " + frappe.utils.data.format_datetime(tomorrow,"EEEE d-MMM-Y"), | ||
attachments=attachment) | ||
except Exception as e: | ||
msg = "Job sheet was not sent. <br> Reason: {0}".format(e.message) | ||
else: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.