ผลต่างระหว่างรุ่นของ "Common Functions"
บรรทัดที่ 27: | บรรทัดที่ 27: | ||
{| style="margin-left:20px;" | {| style="margin-left:20px;" | ||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| style="width:120px;" | '''Description''' || | | style="width:120px;" | '''Description''' || Retrieve a single document (along with all its sub-entries) to display on the client-side. This function is tailored to the client-side mass-populate routine, so its algorithm leans heavily in that direction. For a more server-friendly retrieval, use '''[[#prefetch_all_docs|prefetch_all_docs]]''' instead. | ||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| '''Parameters''' || | | '''Parameters''' || '''DO NOT''' rely on argument order beyond ''detail_models''. | ||
* ''' | * '''bookcode''' ''(str)'': The database name (usually a three-lettered string). | ||
* ''' | * '''identifiers''' ''(dict)'': Under CuneiFox usual routine, this argument is extracted from the request via {{code|lang=python|json.loads(request.form.get('identifier'))}}. Since this function is tailored to fit the most common usage of multi-component pages, it expects the keys '''{{code|lang=python|'master.id'}}''' and '''{{code|lang=python|'pagenav'}}''' be present in this argument. ''(See [[Multi-component Page#Mass Populate Route]] for details.)'' | ||
* '''master_model''' ''(list or tuple)'': The list of specifications for master entry retrieval. Its members are: | |||
*# The ''CuneiModel'' for the master entry. | |||
*# The ''string'' to be used (in the returned dict) as the reference to the master entry. | |||
*# (Optional) The ''list'' of ordering column(s) for the main table. This list is used to determined the First/Previous/Next/Last master entry. If not given, the master table is sorted by {{code|lang=python|fn.LOWER(master_model[0].docno).asc()}}. | |||
* '''detail_models''' ''(list)'': The list of specifications for sub-entry retrievals. Each member of this argument is itself a list or a tuple corresponding to one sub-entry table, the sub-member are, in order: | |||
*# The ''CuneiModel'' for the sub-entry. | |||
*# The ''string'' to be used (in the returned dict) as the reference to the sub-entry list. | |||
*# The ''list'' of ordering column(s) for the sub-table. If not given (assigned as {{code|lang=python|None}}), the sub-table is sorted by {{code|lang=python|fn.LOWER(detail_models[i][0].id)}}. | |||
*# The back-reference ''string'' (backref) of the ForeignKeyField linking the sub-entries to the master entry. | |||
* '''isgl''' ''(bool)'': Whether the database is considered an accounting journal database. ''(One can also feed the argument '''bookcode''' in the format '''{{code|GL_XXX}}''' and ignore this argument.)'' | |||
* '''datatype''' ''(str: {{code|lang=python|'table'}}, {{code|lang=python|'data'}}, or {{code|lang=python|'report'}})'': The data type (location) of the database file. | |||
* '''month''' ''(str, date, or datetime)'': The data month (effective for {{code|lang=python|1= datatype='data'}}). If the argument is a string, it must be formatted either as {{code|YYYYMM}} or {{code|YYYYMMDD}}. | |||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| '''Returns''' || | | '''Returns''' || 3 objects: | ||
* ''' | * '''return_data''' ''(dict)'': The retrieved document in a dict format. The keys of the dict are the strings given as '''{{code|lang=python|master_model[1]}}''' and '''{{code|lang=python|detail_models[i][1]}}'''. The dict values are a CuneiModel object for the master entry and a list of CuneiModel objects for sub-entries. | ||
* ''' | * '''main_entry counter''' ''([int, int])'': The first integer represents the order of the current document (starting from 1), the Second integer is the number of documents present in the databse. | ||
* '''flash''' ''(list)'': A list of flash message to appear on the client-side along with the requested document. Usually the messages sent this way are the First/Last entry notifications. | |||
|} | |} | ||
รุ่นแก้ไขเมื่อ 10:29, 23 กรกฎาคม 2567
Main Functions
grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno")
Description | Fetch the ID of the looked-up entry. Because this function is usually utilized in the page-level search function, it is designed to target string-based column by looking for values that starts-with the search keyword. In case of multiple matches, the ID of the first match (ordered by the search column). |
Parameters |
|
Returns |
|
grab_whole_doc(bookcode, identifiers, master_model, detail_models, isgl=False,
datatype="data", month=None)
Description | Retrieve a single document (along with all its sub-entries) to display on the client-side. This function is tailored to the client-side mass-populate routine, so its algorithm leans heavily in that direction. For a more server-friendly retrieval, use prefetch_all_docs instead. |
Parameters | DO NOT rely on argument order beyond detail_models.
|
Returns | 3 objects:
|
gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None,
suppress_success_msg=False, lock_on_add=True, head_id_col="id",
get_dict=None, skip_validation=False, month=None)
Description | Conduct form validation and, if passed, commit the form data to database. |
Parameters | DO NOT rely on argument order beyond perm_bit.
|
Returns |
|
prefetch_all_docs(bookcode, master_spec, detail_specs, isgl=False, datatype="data",
month=None, headid=None, id_col="id", return_instance=False, crossers=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
create_doc_copy(cp_form, copy_params, bookcode, orig_doc, head_model, detail_models={},
isgl=False, omit_cols=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
check_modact_stat(modid=None, modcode=None, mode="activate", response="return")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
process_doc_file(dbtype, tbname, model, at_form, isgl=False, month=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_random_token(length=10, lower=True, upper=True, number=True)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
User Authentication Functions
process_beacon_args(internal_args, request)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
process_doclock(beacon_args, module_name, perm_name, headmodel=None, paired_gl=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
change_datetime(form, reset=False, date_obj=None, time_obj=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Thread Functions
init_task_db(job_token, overall_load, new_stat="", activity_str="",
suppress_request=True, further_action="")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
update_task_db(job_token, finished_load=0, overall_load=None,
new_stat=None, activity_str=None, further_action=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
read_task_db(job_token)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
read_resus_import_file(job_token, will_abort=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Printing Functions
print_in_thread(job_token, doc_objs, pseudo_mapper, modcode, template_name,
svg_name=None, stat_cols=[], skip_company_template=False,
make_pdfa3=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_qr(num, qr_type="out", info=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
replace_printsvg(tbfm_mapper, modcode, bookname=None, svg_name=None, suffix=None,
job_data=None, clear_printed=True, skip_company_template=False,
make_pdfa3=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Spreadsheet Export Functions
gen_spreadsheet(specs, round_all=None, col_desc=None, col_size={})
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Import & Mass Delete Functions
docimport_to_db(file_path, dbtype, dbname, models, specs, month=None,
verify_cmd=None, post_cmd=None, addi_args=[], autorun_specs=None,
job_token=None, custom_datasets=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None,
job_token=None, addi_args=[], docno_to_skip=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |