def fillresponse(self, limit_date=''): if limit_date == '': dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) dlg.add_component(img) lbl = XferCompLabelForm('lb_limit_date') lbl.set_value_as_name(_('limit date')) lbl.set_location(1, 1, 1) dlg.add_component(lbl) limite_date = XferCompDate('limit_date') limite_date.set_needed(True) limite_date.set_value((date.today() - timedelta(weeks=25))) limite_date.set_location(1, 2, 1) dlg.add_component(limite_date) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: third_ids = [val_third['third'] for val_third in EntryLineAccount.objects.filter( entry__date_value__gt=limit_date, third__gt=0).values('third')] for third in Third.objects.filter(status=0): if third.id not in third_ids: third.status = 1 third.save()
def fill_header(self, payer, reference): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(_("select cheque to deposit")) lbl.set_location(1, 0, 3) self.add_component(lbl) lbl = XferCompLabelForm('lbl_payer') lbl.set_value_as_name(_("payer contains")) lbl.set_location(0, 1) self.add_component(lbl) edt = XferCompEdit('payer') edt.set_value(payer) edt.set_location(1, 1) edt.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(edt) lbl = XferCompLabelForm('lbl_reference') lbl.set_value_as_name(_("reference contains")) lbl.set_location(2, 1) self.add_component(lbl) edt = XferCompEdit('reference') edt.set_value(reference) edt.set_location(3, 1) edt.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(edt)
def fillresponse_header(self): modelname = self.getparam('modelname', "") lab = XferCompLabelForm('lblmodelname') lab.set_location(0, 1) lab.set_value_as_name(_('model')) self.add_component(lab) model_list = {} for print_model in PrintModel.objects.all(): if print_model.modelname not in model_list.keys(): try: model_list[print_model.modelname] = print_model.model_associated_title() if modelname == '': modelname = print_model.modelname except LookupError: pass model_list = list(model_list.items()) model_list.sort(key=lambda item: item[1]) model_sel = XferCompSelect('modelname') model_sel.set_location(1, 1) model_sel.set_select(model_list) model_sel.set_value(modelname) model_sel.set_action(self.request, self.get_action("", ""), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(model_sel) self.filter = Q(modelname=modelname) self.fieldnames = ['name', 'kind', 'is_default'] return
def fillresponse(self, costaccounting=0): if self.getparam("SAVE") is None: dlg = self.create_custom() icon = XferCompImage('img') icon.set_location(0, 0, 1, 6) icon.set_value(self.icon_path()) dlg.add_component(icon) lbl = XferCompLabelForm('lb_costaccounting') lbl.set_value_as_name(CostAccounting._meta.verbose_name) lbl.set_location(1, 1) dlg.add_component(lbl) sel = XferCompSelect('costaccounting') sel.set_select_query(CostAccounting.objects.filter(status=0)) if self.item is not None: sel.set_value(self.item.costaccounting_id) sel.set_location(1, 2) dlg.add_component(sel) dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png')) else: if costaccounting == 0: new_cost = None else: new_cost = CostAccounting.objects.get(id=costaccounting) for item in self.items: if (item.costaccounting is None) or (item.costaccounting.status == 0): item.costaccounting = new_cost item.save()
def fillresponse(self): model_module = ".".join(self.item.model_associated().__module__.split('.')[:-1]) if self.getparam('SAVE') is None: dlg = self.create_custom(self.model) dlg.item = self.item img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_default_model') lbl.set_value_as_name(_("Model to reload")) lbl.set_location(1, 1) dlg.add_component(lbl) sel = XferCompSelect('default_model') sel.set_select(PrintModel.get_default_model(model_module, self.item.modelname, self.item.kind)) sel.set_location(2, 1) dlg.add_component(sel) dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: if self.item.load_model(model_module, self.getparam("default_model", ""), is_default=None): self.message(_('Model reloaded'))
def fillresponse(self): if self.getparam('SAVE') is None: dlg = self.create_custom(self.model) dlg.item = self.item img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_import_model') lbl.set_value_as_name(_("file to load")) lbl.set_location(1, 1) dlg.add_component(lbl) upload = XferCompUpLoad('import_model') upload.compress = False upload.http_file = True upload.maxsize = 128 * 1024 * 1024 # 128Mo upload.add_filter('.mdl') upload.set_location(2, 1) dlg.add_component(upload) dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: if 'import_model' in self.request.FILES.keys(): upload_file = self.request.FILES['import_model'] if self.item.import_file(upload_file): self.message(_('Model loaded'))
def edit(self, xfer): if xfer.item.id is None: third = xfer.get_components('third') xfer.remove_component('third') xfer.remove_component('lbl_third') lbl = XferCompLabelForm('lbl_third') lbl.set_location(third.col - 1, third.row) lbl.set_value_as_name(_('third')) xfer.add_component(lbl) sel = XferCompSelect('third') sel.needed = True sel.set_location(third.col, third.row) owner_third_ids = [] for owner in Owner.objects.all(): owner_third_ids.append(owner.third_id) items = Third.objects.all().exclude(id__in=owner_third_ids).distinct() items = sorted(items, key=lambda t: six.text_type(t)) sel.set_select_query(items) xfer.add_component(sel) btn = XferCompButton('add_third') btn.set_location(3, 0) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.Third', 'Add', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'new_account': Params.getvalue('condominium-default-owner-account')}) xfer.add_component(btn) else: xfer.change_to_readonly('third')
def fillresponse_header(self): status_filter = self.getparam('status_filter', 0) self.params['status_filter'] = status_filter date_filter = self.getparam('date_filter', 0) self.fieldnames = Expense.get_default_fields(status_filter) lbl = XferCompLabelForm('lbl_status_filter') lbl.set_value_as_name(_('Filter by type')) lbl.set_location(0, 3) self.add_component(lbl) dep_field = self.item.get_field_by_name('status') sel_list = list(dep_field.choices) edt = XferCompSelect("status_filter") edt.set_select(sel_list) edt.set_value(status_filter) edt.set_location(1, 3) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) lbl = XferCompLabelForm('lbl_date_filter') lbl.set_value_as_name(_('Filter by date')) lbl.set_location(0, 4) self.add_component(lbl) edt = XferCompSelect("date_filter") edt.set_select([(0, _('only current fiscal year')), (1, _('all expenses'))]) edt.set_value(date_filter) edt.set_location(1, 4) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) self.filter = Q(status=status_filter) if date_filter == 0: current_year = FiscalYear.get_current() self.filter &= Q(date__gte=current_year.begin) & Q(date__lte=current_year.end)
def fillresponse_body(self): self.get_components("title").colspan = 2 row_id = self.get_max_row() + 1 lbl = XferCompLabelForm('title_exp') lbl.set_value_as_headername(_("Expense")) lbl.set_location(0, row_id, 2) self.add_component(lbl) lbl = XferCompLabelForm('title_rev') lbl.set_value_as_headername(_("Revenue")) lbl.set_location(2, row_id, 2) self.add_component(lbl) row_id = self.get_max_row() self.fill_grid(row_id, self.model, 'budget_revenue', self.model.objects.filter(self.filter & Q(code__regex=current_system_account().get_revenue_mask()))) self.move_components('budget_revenue', 2, 0) self.fill_grid(row_id, self.model, 'budget_expense', self.model.objects.filter(self.filter & Q(code__regex=current_system_account().get_expence_mask()))) self.remove_component('nb_budget_expense') self.remove_component('nb_budget_revenue') resultat_budget = Budget.get_total(self.getparam('year'), self.getparam('cost_accounting')) if abs(resultat_budget) > 0.0001: row_id = self.get_max_row() + 1 lbl = XferCompLabelForm('title_result') if resultat_budget > 0: lbl.set_value_as_name(_('result (profit)')) else: lbl.set_value_as_name(_('result (deficit)')) lbl.set_location(0, row_id) self.add_component(lbl) lbl = XferCompLabelForm('result') lbl.set_value(format_devise(resultat_budget, 5)) lbl.set_location(1, row_id) self.add_component(lbl)
def fillresponse_header(self): contact_filter = self.getparam('filter', '') show_filter = self.getparam('show_filter', 0) lbl = XferCompLabelForm('lbl_filtre') lbl.set_value_as_name(_('Filtrer by contact')) lbl.set_location(0, 2) self.add_component(lbl) comp = XferCompEdit('filter') comp.set_value(contact_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 2) self.add_component(comp) lbl = XferCompLabelForm('lbl_showing') lbl.set_value_as_name(_('Accounts displayed')) lbl.set_location(0, 3) self.add_component(lbl) edt = XferCompSelect("show_filter") edt.set_select([(0, _('Hide the account total of thirds')), (1, _('Show the account total of thirds')), (2, _('Filter any thirds unbalanced'))]) edt.set_value(show_filter) edt.set_location(1, 3) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) if show_filter != 0: self.fieldnames = Third.get_other_fields() self.filter = Q(status=0) if contact_filter != "": q_legalentity = Q(contact__legalentity__name__icontains=contact_filter) q_individual = (Q(contact__individual__firstname__icontains=contact_filter) | Q(contact__individual__lastname__icontains=contact_filter)) self.filter &= (q_legalentity | q_individual)
def fillresponse_header(self): self.new_tab(_('Fiscal year list')) lbl = XferCompLabelForm('lbl_account_system') lbl.set_value_as_name(_('accounting system')) lbl.set_location(0, 1) self.add_component(lbl) select_account_system(self)
def fillresponse_add_title(self): XferSearchEditor.fillresponse_add_title(self) modelname = self.model.get_long_name() saved_list = SavedCriteria.objects.filter(modelname=modelname) new_row = self.get_max_row() lbl = XferCompLabelForm('lbl_saved_criteria') lbl.set_location(1, new_row + 1) lbl.set_value_as_name(_("saved criteria")) self.add_component(lbl) sel = XferCompSelect('saved_criteria') sel.set_location(2, new_row + 1, 2) sel.set_needed(False) sel.set_select_query(saved_list) sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(sel) if len(self.criteria_list) > 0: from lucterios.CORE.views import SavedCriteriaAddModify btn = XferCompButton('btn_saved_criteria') btn.set_location(4, new_row + 1, 2) btn.set_is_mini(True) btn.set_action(self.request, SavedCriteriaAddModify.get_action("+", ""), close=CLOSE_NO, params={'modelname': modelname, 'criteria': self.getparam('CRITERIA', '')}) self.add_component(btn) if self.getparam('saved_criteria', 0) != 0: saved_item = SavedCriteria.objects.get( id=self.getparam('saved_criteria', 0)) self.params['CRITERIA'] = saved_item.criteria self.read_criteria_from_params()
def fillresponse(self, begin_date, end_date): self.item.set_dates(begin_date, end_date) lbl = XferCompLabelForm('lbl_begin_date') lbl.set_value_as_name(_('initial date')) lbl.set_location(1, 0) self.add_component(lbl) date_init = XferCompDate("begin_date") date_init.set_needed(True) date_init.set_value(self.item.date_begin) date_init.set_location(2, 0) date_init.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(date_init) lbl = XferCompLabelForm('lbl_end_date') lbl.set_value_as_name(_('current date')) lbl.set_location(3, 0) self.add_component(lbl) date_end = XferCompDate("end_date") date_end.set_needed(True) date_end.set_value(self.item.date_end) date_end.set_location(4, 0) date_end.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(date_end) XferShowEditor.fillresponse(self) self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Show', self), close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0) self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Email', self), close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0)
def thirdaddon_accounting(item, xfer): if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'): try: entry_lines_filter = Q(entrylineaccount__third=item) lines_filter = xfer.getparam('lines_filter', 0) if lines_filter == 0: entry_lines_filter &= Q(year=FiscalYear.get_current()) elif lines_filter == 1: entry_lines_filter &= Q(year=FiscalYear.get_current()) & Q(close=False) xfer.new_tab(_('entry of account')) lbl = XferCompLabelForm('lbl_lines_filter') lbl.set_value_as_name(_('Accounts filter')) lbl.set_location(0, 1) xfer.add_component(lbl) edt = XferCompSelect("lines_filter") edt.set_select([(0, _('All entries of current fiscal year')), (1, _( 'Only no-closed entries of current fiscal year')), (2, _('All entries for all fiscal year'))]) edt.set_value(lines_filter) edt.set_location(1, 1) edt.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) xfer.add_component(edt) entries = EntryAccount.objects.filter(entry_lines_filter) link_grid_lines = XferCompGrid('entryaccount') link_grid_lines.set_model(entries, EntryAccount.get_default_fields(), xfer) link_grid_lines.set_location(0, 2, 2) link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'OpenFromLine', xfer), modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO) link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer), modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO) link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Link', xfer), modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO) xfer.add_component(link_grid_lines) except LucteriosException: pass
def conf_wizard_core(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("core_home", 0)) wizard_ident.append(("core_users", 100)) elif (xfer is not None) and (wizard_ident == "core_home"): initial_wizard = Params.getvalue("CORE-Wizard") param_wizard = xfer.getparam("CORE-Wizard", initial_wizard) if initial_wizard != param_wizard: Parameter.change_value("CORE-Wizard", param_wizard) Params.clear() lbl = XferCompLabelForm('title') lbl.set_centered() lbl.set_value_as_info(six.text_type(settings.APPLIS_NAME)) lbl.set_location(0, 3, 6) xfer.add_component(lbl) lbl = XferCompImage('img') lbl.type = 'jpg' lbl.set_value(settings.APPLIS_LOGO) lbl.set_location(2, 4, 2) xfer.add_component(lbl) lbl = XferCompLabelForm('home') lbl.set_value(_('This wizard will help you to configure this software.')) lbl.set_location(0, 5, 6) xfer.add_component(lbl) Params.fill(xfer, ['CORE-Wizard'], 1, 6, False) check = xfer.get_components("CORE-Wizard") check.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) lbl = XferCompLabelForm('lbl_wizard') lbl.set_value_as_name(check.description) lbl.set_location(2, 6) xfer.add_component(lbl) check.description = "" elif (xfer is not None) and (wizard_ident == "core_users"): xfer.add_title(six.text_type(settings.APPLIS_NAME), _("Groups and users")) param_lists = ['CORE-connectmode', 'CORE-Wizard'] Params.fill(xfer, param_lists, 1, xfer.get_max_row() + 1) btn = XferCompButton('editparam') btn.set_location(4, xfer.get_max_row()) btn.set_is_mini(True) btn.set_action(xfer.request, ParamEdit.get_action(TITLE_MODIFY, 'images/edit.png'), close=CLOSE_NO, params={'params': param_lists}) xfer.add_component(btn) lbl = XferCompLabelForm("nb_user") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LucteriosUser._meta.verbose_name_plural, 'count': len(LucteriosUser.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btnusers") btn.set_location(4, xfer.get_max_row()) btn.set_action(xfer.request, UsersList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn) lbl = XferCompLabelForm("nb_group") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LucteriosGroup._meta.verbose_name_plural, 'count': len(LucteriosGroup.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btngroups") btn.set_location(4, xfer.get_max_row()) btn.set_action(xfer.request, GroupsList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn)
def edit(self, xfer): lbl = XferCompLabelForm('lbl_begin_date') lbl.set_value_as_name(_('begin date')) lbl.set_location(1, 0) xfer.add_component(lbl) date = XferCompDate('begin_date') date.set_location(2, 0) date.set_needed(True) val = Period.objects.all().aggregate(Max('end_date')) if ('end_date__max' in val.keys()) and (val['end_date__max'] is not None): date.set_value(val['end_date__max'] + timedelta(days=1)) xfer.add_component(date)
def fillresponse_search_select(self): selector, script_ref = self.fields_desc.get_select_and_script() script_ref += """ var name=current.getValue(); var type=findFields[name]; parent.get('searchValueFloat').setVisible(type=='float'); parent.get('searchValueStr').setVisible(type=='str'); parent.get('searchValueBool').setVisible(type=='bool'); parent.get('searchValueDate').setVisible(type=='date' || type=='datetime'); parent.get('searchValueTime').setVisible(type=='time' || type=='datetime'); parent.get('searchValueList').setVisible(type=='list' || type=='listmult'); """ script_ref += get_script_for_operator() script_ref += """ if (type=='float') { var prec=findLists[name]; parent.get('searchValueFloat').setValue({min:prec[0],max:prec[1],prec:prec[2],value:0}); } if (type=='str') { parent.get('searchValueStr').setValue({value:''}); } if (type=='bool') { parent.get('searchValueBool').setValue({value:false}); } if (type=='date' || type=='datetime') { parent.get('searchValueDate').setValue({value:'2000-01-01'}); } if (type=='time' || type=='datetime') { parent.get('searchValueTime').setValue({value:'00:00'}); } if ((type=='list') || (type=='listmult')) { var select_case=findLists[name]; parent.get('searchValueList').setValue({case:select_case,value:0}); } """ label = XferCompLabelForm('labelsearchSelector') label.set_value_as_name(_("New criteria")) label.set_location(0, 10, 1, 7) self.add_component(label) comp = XferCompSelect("searchSelector") comp.set_select(selector) comp.set_value("") comp.set_location(1, 10, 1, 7) comp.set_size(20, 200) comp.java_script = script_ref self.add_component(comp) comp = XferCompSelect("searchOperator") comp.set_select({}) comp.set_value("") comp.set_size(20, 200) comp.set_location(2, 10, 1, 7) self.add_component(comp)
def fillresponse_header(self): all_cost = self.getparam('all_cost', False) sel = XferCompCheck("all_cost") sel.set_value(all_cost) sel.set_location(1, 3) sel.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(sel) lbl = XferCompLabelForm("all_costLbl") lbl.set_location(2, 3) lbl.set_value_as_name(_("Show all cost accounting")) self.add_component(lbl) if not all_cost: self.filter = Q(status=0)
def fillresponse(self, item_name='', subject='', message='', model=0, withpayment=False): if item_name != '': self.item = Supporting.objects.get(id=self.getparam(item_name, 0)) self.item = self.item.get_final_child() if self.getparam("OK") is None: dlg = self.create_custom() icon = XferCompImage('img') icon.set_location(0, 0, 1, 6) icon.set_value(self.icon_path()) dlg.add_component(icon) lbl = XferCompLabelForm('lb_subject') lbl.set_value_as_name(_('subject')) lbl.set_location(1, 1) dlg.add_component(lbl) lbl = XferCompEdit('subject') lbl.set_value(six.text_type(self.item)) lbl.set_location(2, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('lb_message') lbl.set_value_as_name(_('message')) lbl.set_location(1, 2) dlg.add_component(lbl) contact = self.item.third.contact.get_final_child() lbl = XferCompMemo('message') lbl.set_value(Params.getvalue('payoff-email-message') % { 'name': contact.get_presentation(), 'doc': self.item.get_docname()}) lbl.with_hypertext = True lbl.set_size(130, 450) lbl.set_location(2, 2) dlg.add_component(lbl) selectors = PrintModel.get_print_selector( 2, self.item.__class__)[0] lbl = XferCompLabelForm('lb_model') lbl.set_value_as_name(selectors[1]) lbl.set_location(1, 3) dlg.add_component(lbl) sel = XferCompSelect('model') sel.set_select(selectors[2]) sel.set_location(2, 3) dlg.add_component(sel) if self.item.payoff_have_payment() and (len(PaymentMethod.objects.all()) > 0): lbl = XferCompLabelForm('lb_withpayment') lbl.set_value_as_name(_('add payment methods in email')) lbl.set_location(1, 4) dlg.add_component(lbl) sel = XferCompCheck('withpayment') sel.set_value(True) sel.set_location(2, 4) dlg.add_component(sel) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"OK": "YES"}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: html_message = "<html>" html_message += message.replace('{[newline]}', '<br/>\n').replace('{[', '<').replace(']}', '>') if self.item.payoff_have_payment() and withpayment: html_message += get_html_payment(self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language, self.item) html_message += "</html>" self.item.send_email(subject, html_message, model)
def fill_filterCode(self): if self.add_filtering: filtercode = self.getparam('filtercode', '') lbl = XferCompLabelForm('filtercode_lbl') lbl.set_value_as_name(_("Accounting code starting with")) lbl.set_location(2, 3, 1) self.add_component(lbl) edt = XferCompEdit('filtercode') edt.set_value(filtercode) edt.set_location(3, 3, 2) edt.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(edt) if filtercode != '': self.filter &= Q(account__code__startswith=filtercode)
def _fill_listing_editor(self): lab = XferCompLabelForm('lbl_page_width') lab.set_location(1, 3) lab.set_value_as_name(_("list page width")) self.add_component(lab) edt = XferCompFloat('page_width', 0, 9999, 0) edt.set_location(2, 3, 2) edt.set_value(self.item.page_width) self.add_component(edt) lab = XferCompLabelForm('lbl_page_height') lab.set_location(1, 4) lab.set_value_as_name(_("list page height")) self.add_component(lab) edt = XferCompFloat('page_heigth', 0, 9999, 0) edt.set_location(2, 4, 2) edt.set_value(self.item.page_height) self.add_component(edt) lab = XferCompLabelForm('lbl_col_size') lab.set_location(1, 5) lab.set_value_as_infocenter(_("size")) self.add_component(lab) lab = XferCompLabelForm('lbl_col_title') lab.set_location(2, 5) lab.set_value_as_infocenter(_("title")) self.add_component(lab) lab = XferCompLabelForm('lbl_col_text') lab.set_location(3, 5) lab.set_value_as_infocenter(_("text")) self.add_component(lab) col_index = 0 for col_size, col_title, col_text in (self.item.columns + [[0, '', ''], [0, '', ''], [0, '', '']]): edt = XferCompFloat('col_size_%d' % col_index, 0, 999, 0) edt.set_location(1, 6 + col_index) edt.set_value(col_size) self.add_component(edt) edt = XferCompMemo('col_title_%d' % col_index) edt.set_location(2, 6 + col_index) edt.set_value(col_title) edt.set_size(75, 200) self.add_component(edt) edt = XferCompMemo('col_text_%d' % col_index) edt.set_location(3, 6 + col_index) edt.set_size(50, 300) edt.with_hypertext = True edt.set_value(col_text) self.fill_menu_memo(edt) self.add_component(edt) col_index += 1
def fillresponse_header(self): show_filter = self.getparam('show_filter', 0) lbl = XferCompLabelForm('lbl_showing') lbl.set_value_as_name(_('Show articles')) lbl.set_location(0, 3) self.add_component(lbl) edt = XferCompSelect("show_filter") edt.set_select([(0, _('Only activate')), (1, _('All'))]) edt.set_value(show_filter) edt.set_location(1, 3) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) self.filter = Q() if show_filter == 0: self.filter = Q(isdisabled=False)
def fillresponse_header(self): status_filter = self.getparam('status_filter', 1) self.params['status_filter'] = status_filter lbl = XferCompLabelForm('lbl_filter') lbl.set_value_as_name(_('Filter by type')) lbl.set_location(0, 3) self.add_component(lbl) dep_field = self.item.get_field_by_name('status') sel_list = list(dep_field.choices) edt = XferCompSelect("status_filter") edt.set_select(sel_list) edt.set_value(status_filter) edt.set_location(1, 3) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) self.filter = Q(status=status_filter)
def show(self, xfer): row = xfer.get_max_row() + 1 lbl = XferCompLabelForm('lbl_entrylineaccount') lbl.set_location(1, row) lbl.set_value_as_name(EntryLineAccount._meta.verbose_name) xfer.add_component(lbl) comp = XferCompGrid('entryaccount') comp.set_model(EntryAccount.objects.filter(entrylineaccount__account=self.item), None, xfer) comp.add_action(xfer.request, ActionsManage.get_action_url( 'accounting.EntryAccount', 'OpenFromLine', xfer), unique=SELECT_SINGLE, close=CLOSE_NO) comp.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer), unique=SELECT_MULTI, close=CLOSE_NO) if self.item.is_third: comp.add_action(xfer.request, ActionsManage.get_action_url( 'accounting.EntryAccount', 'Link', xfer), unique=SELECT_MULTI, close=CLOSE_NO) comp.set_location(2, row) xfer.add_component(comp)
def add_title(self, title, subtitle, helptext=''): lbl = XferCompLabelForm('title') lbl.set_centered() lbl.set_value_as_info(title) lbl.set_location(0, 3, 6) self.add_component(lbl) lbl = XferCompLabelForm('subtitle') lbl.set_centered() lbl.set_value_as_name(subtitle) lbl.set_location(0, 4, 6) self.add_component(lbl) lbl = XferCompLabelForm('help') lbl.set_italic() lbl.set_value(helptext + "{[br/]}") lbl.set_location(0, 5, 6) self.add_component(lbl)
def fillresponse_header(self): filter_postal_code = self.getparam('filter_postal_code') if filter_postal_code is None: local_struct = LegalEntity.objects.get(id=1) filter_postal_code = six.text_type(local_struct.postal_code) lbl = XferCompLabelForm('filtre') lbl.set_value_as_name(_('Filtrer by postal code')) lbl.set_location(1, 0) self.add_component(lbl) comp = XferCompEdit('filter_postal_code') comp.set_value(filter_postal_code) comp.is_default = True comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 1) self.add_component(comp) self.filter = Q(postal_code__startswith=filter_postal_code)
def fill_dlg(self): self.item.can_be_valid() dlg = self.create_custom() dlg.item = self.item img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) dlg.add_component(lbl) dlg.fill_from_model(1, 1, True, ['activity', 'date']) dlg.get_components('activity').colspan = 3 dlg.get_components('date').colspan = 3 lbl = XferCompLabelForm('sep') lbl.set_value("{[hr/]}") lbl.set_location(0, 4, 7) dlg.add_component(lbl) row_id = 5 for participant in self.item.participant_set.all(): lbl = XferCompLabelForm('name_%d' % participant.id) lbl.set_value_as_name(six.text_type(participant)) lbl.set_location(0, row_id) dlg.add_component(lbl) lbl = XferCompLabelForm('current_%d' % participant.id) lbl.set_value(participant.current_degree) lbl.set_location(1, row_id) dlg.add_component(lbl) sel = XferCompSelect('degree_%d' % participant.id) sel.set_select_query(participant.allow_degree()) sel.set_location(2, row_id) dlg.add_component(sel) if Params.getvalue("event-subdegree-enable") == 1: sel = XferCompSelect('subdegree_%d' % participant.id) sel.set_select_query(participant.allow_subdegree()) sel.set_location(3, row_id) dlg.add_component(sel) edt = XferCompMemo('comment_%d' % participant.id) edt.set_value(participant.comment) edt.set_location(4, row_id) dlg.add_component(edt) row_id += 1 dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
def fillresponse(self, send_email=True): cmd_manager = CommandManager(self.getparam('CMD_FILE', ''), self.items) if self.getparam('SAVE') is None: dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 4) dlg.add_component(img) lab = XferCompLabelForm('lbl_title') lab.set_value_as_title(self.caption) lab.set_location(1, 0, 2) dlg.add_component(lab) grid = XferCompGrid('AdhCmd') for fname, ftitle in cmd_manager.get_fields(): grid.add_header(fname, ftitle) for cmd_id, cmd_item in cmd_manager.get_content_txt(): for head_name, value in cmd_item.items(): grid.set_value(cmd_id, head_name, value) grid.set_location(1, 2, 2) grid.add_action(self.request, AdherentCommandModify.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO, unique=SELECT_SINGLE) grid.add_action(self.request, AdherentCommandDelete.get_action(TITLE_DELETE, "images/delete.png"), close=CLOSE_NO, unique=SELECT_SINGLE) dlg.params['CMD_FILE'] = cmd_manager.file_name dlg.add_component(grid) if len(grid.records) > 0: lab = XferCompLabelForm('lbl_send_email') lab.set_value_as_name(_('Send quotition by email for each adherent.')) lab.set_location(1, 3) dlg.add_component(lab) chk = XferCompCheck('send_email') chk.set_value(send_email) chk.set_location(2, 3) dlg.add_component(chk) dlg.add_action(AdherentCommand.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'}) dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png')) else: dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref) if send_email: param_email = self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language else: param_email = None nb_sub, nb_bill = cmd_manager.create_subscription(dateref, param_email) if send_email: msg = _('%(nbsub)d new subscription and %(nbbill)d quotation have been sent.') % {'nbsub': nb_sub, 'nbbill': nb_bill} else: msg = _('%d new subscription have been prepared.') % nb_sub self.message(msg)
def fillresponse(self, modelname=''): img_title = XferCompImage('img') img_title.set_location(0, 0, 1, 2) img_title.set_value(self.icon_path()) self.add_component(img_title) lab = XferCompLabelForm('title') lab.set_location(1, 0, 3) lab.set_value_as_title(_("Print models")) self.add_component(lab) lab = XferCompLabelForm('lblmodelname') lab.set_location(1, 1) lab.set_value_as_name(_('model')) self.add_component(lab) model_list = {} for print_model in PrintModel.objects.all(): if print_model.modelname not in model_list.keys(): try: model_list[ print_model.modelname] = print_model.model_associated_title() if modelname == '': modelname = print_model.modelname except LookupError: pass model_sel = XferCompSelect('modelname') model_sel.set_location(2, 1, 2) model_sel.set_select(model_list) model_sel.set_value(modelname) model_sel.set_action(self.request, self.get_action( "", ""), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO}) self.add_component(model_sel) items = PrintModel.objects.filter( modelname=modelname) grid = XferCompGrid('print_model') grid.set_location(1, 2, 3) grid.set_model(items, ['name', 'kind'], self) grid.add_action(self.request, PrintModelEdit.get_action( _('edit'), 'images/edit.png'), {'unique': SELECT_SINGLE}) grid.add_action(self.request, PrintModelClone.get_action( _('clone'), 'images/clone.png'), {'unique': SELECT_SINGLE}) grid.add_action(self.request, PrintModelDelete.get_action( _('delete'), 'images/delete.png'), {'unique': SELECT_SINGLE}) self.add_component(grid) self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
def fillresponse_header(self): filter_postal_code = self.getparam('filter_postal_code') if filter_postal_code is None: local_struct = LegalEntity.objects.get(id=1) filter_postal_code = six.text_type(local_struct.postal_code) lbl = XferCompLabelForm('filtre') lbl.set_value_as_name(_('Filtrer by postal code')) lbl.set_location(1, 0) self.add_component(lbl) comp = XferCompEdit('filter_postal_code') comp.set_value(filter_postal_code) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 1) self.add_component(comp) self.filter = Q(postal_code__startswith=filter_postal_code)
def _get_from_selector(self): if not isinstance(self.selector, list) and (self.selector is not None): raise LucteriosException(GRAVE, "Error of print selector!") gui = XferContainerCustom() gui.model = self.model gui._initialize(self.request) gui.is_view_right = self.is_view_right gui.caption = self.caption gui.extension = self.extension gui.action = self.action gui.params = self.params lbl = XferCompLabelForm('lblPrintMode') lbl.set_value_as_name(_('Kind of report')) lbl.set_location(0, 0) gui.add_component(lbl) print_mode = XferCompSelect('PRINT_MODE') print_mode.set_select(self.print_selector) print_mode.set_value(PRINT_PDF_FILE) print_mode.set_location(1, 0) gui.add_component(print_mode) if self.selector is not None: row_idx = 1 for name_selector, title_selector, option_selector in self.selector: lbl = XferCompLabelForm('lbl' + name_selector) lbl.set_value_as_name(title_selector) lbl.set_location(0, row_idx) gui.add_component(lbl) if isinstance(option_selector, list): comp = XferCompSelect(name_selector) comp.set_select(option_selector) comp.set_value(gui.getparam(name_selector, 0)) elif isinstance(option_selector, tuple): comp = XferCompFloat(name_selector, option_selector[0], option_selector[1], option_selector[2]) comp.set_value(option_selector[0]) comp.set_location(1, row_idx) gui.add_component(comp) row_idx += 1 gui.add_action(self.get_action(_("Print"), "images/print.png"), modal=FORMTYPE_MODAL, close=CLOSE_YES) gui.add_action(WrapAction(_("Close"), "images/close.png")) return gui
def edit(self, xfer): lbl = XferCompLabelForm('lbl_date_min') lbl.set_value_as_name(_("date min.")) lbl.set_location(1, 5) xfer.add_component(lbl) date = XferCompFloat('date_min', 1900, 2100, 0) date.set_location(2, 5) date.set_needed(True) date.set_value(self.item.date_min) xfer.add_component(date) lbl = XferCompLabelForm('lbl_date_max') lbl.set_value_as_name(_("date max.")) lbl.set_location(1, 6) xfer.add_component(lbl) date = XferCompFloat('date_max', 1900, 2100, 0) date.set_location(2, 6) date.set_needed(True) date.set_value(self.item.date_max) xfer.add_component(date)
def fill_dlg(self): self.item.can_be_valid() dlg = self.create_custom() dlg.item = self.item img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) dlg.add_component(lbl) dlg.fill_from_model(1, 1, True, ['activity', 'date']) lbl = XferCompLabelForm('sep') lbl.set_value("{[hr/]}") lbl.set_location(0, 4, 7) dlg.add_component(lbl) row_id = 5 for participant in self.item.participant_set.all(): lbl = XferCompLabelForm('name_%d' % participant.id) lbl.set_value_as_name(six.text_type(participant)) lbl.set_location(0, row_id) dlg.add_component(lbl) lbl = XferCompLabelForm('current_%d' % participant.id) lbl.set_value(participant.current_degree) lbl.set_location(1, row_id) dlg.add_component(lbl) sel = XferCompSelect('degree_%d' % participant.id) sel.set_select_query(participant.allow_degree()) sel.set_location(2, row_id) dlg.add_component(sel) if Params.getvalue("event-subdegree-enable") == 1: sel = XferCompSelect('subdegree_%d' % participant.id) sel.set_select_query(participant.allow_subdegree()) sel.set_location(3, row_id) dlg.add_component(sel) edt = XferCompMemo('comment_%d' % participant.id) edt.set_value(participant.comment) edt.set_location(4, row_id) dlg.add_component(edt) row_id += 1 dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
def fill_filterheader(self): if self.item.last_fiscalyear is not None: self.lastfilter = Q(entry__year=self.item.last_fiscalyear) lbl = XferCompLabelForm('sep_last') lbl.set_value("{[br/]}{[br/]}") lbl.set_location(2, 11, 3) self.add_component(lbl) lbl = XferCompLabelForm('lbllast_year') lbl.set_value_as_name(self.item.last_fiscalyear.get_identify()) lbl.set_location(1, 12) self.add_component(lbl) lbl = XferCompLabelForm('last_year') lbl.set_value(six.text_type(self.item.last_fiscalyear)) lbl.set_location(2, 12, 4) self.add_component(lbl) lbl = XferCompLabelForm('last_result') lbl.set_value(self.item.last_fiscalyear.total_result_text) lbl.set_location(2, 13, 4) self.add_component(lbl)
def fill_header(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) lbl = XferCompLabelForm('lblname') lbl.set_value_as_name( self.model._meta.verbose_name) lbl.set_location(1, 2) self.add_component(lbl) lbl = XferCompLabelForm('name') lbl.set_value(self.item) lbl.set_location(2, 2, 4) self.add_component(lbl) self.filltab_from_model(1, 6, True, [( (_('total revenue'), 'total_revenue'), (_('total expense'), 'total_expense'))]) self.filter = Q(entry__costaccounting=self.item) self.fill_filterCode() self.fill_filterheader() self.define_gridheader()
def edit_creditdebit_for_line(self, xfer, column, row): currency_decimal = Params.getvalue("accounting-devise-prec") lbl = XferCompLabelForm('debitlbl') lbl.set_location(column, row, 2) lbl.set_value_as_name(_('debit')) xfer.add_component(lbl) edt = XferCompFloat('debit_val', -10000000, 10000000, currency_decimal) edt.set_location(column + 2, row) edt.set_value(self.item.get_debit()) edt.set_size(20, 75) xfer.add_component(edt) lbl = XferCompLabelForm('creditlbl') lbl.set_location(column, row + 1, 2) lbl.set_value_as_name(_('credit')) xfer.add_component(lbl) edt = XferCompFloat('credit_val', -10000000, 10000000, currency_decimal) edt.set_location(column + 2, row + 1) edt.set_value(self.item.get_credit()) edt.set_size(20, 75) xfer.add_component(edt)
def fill_current_folder(self, new_col, new_row): lbl = XferCompLabelForm('lblcat') lbl.set_value_as_name(_("current folder:")) lbl.set_location(new_col, new_row) self.add_component(lbl) lbl = XferCompLabelForm('lbltitlecat') if self.current_folder > 0: folder_obj = Folder.objects.get(id=self.current_folder) lbl.set_value(folder_obj.get_title()) folder_description = folder_obj.description else: folder_obj = None lbl.set_value('>') folder_description = "" lbl.set_location(new_col + 1, new_row) self.add_component(lbl) lbl = XferCompLabelForm('lbldesc') lbl.set_value_as_header(folder_description) lbl.set_location(new_col + 2, new_row, 2) self.add_component(lbl) return folder_obj
def _add_bill_filter(xfer, row): status_filter = xfer.getparam('status_filter', -1) lbl = XferCompLabelForm('lbl_filter') lbl.set_value_as_name(_('Filter by type')) lbl.set_location(0, row) xfer.add_component(lbl) dep_field = Bill.get_field_by_name('status') sel_list = list(dep_field.choices) sel_list.insert(0, (-1, _('building+valid'))) edt = XferCompSelect("status_filter") edt.set_select(sel_list) edt.set_value(status_filter) edt.set_location(1, row) edt.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) xfer.add_component(edt) current_filter = Q() if status_filter >= 0: current_filter &= Q(status=status_filter) elif status_filter == -1: current_filter &= Q(status=0) | Q(status=1) return current_filter, status_filter
def fill_third_convert(self, dlg): lbl = XferCompLabelForm('tle_third') lbl.set_value(_('How do want to convert owner third account?')) lbl.set_location(0, 0, 2) dlg.add_component(lbl) select_account = [('', None)] for num_account in range(1, 5): owner_account = correct_accounting_code(Params.getvalue('condominium-default-owner-account%d' % num_account)) select_account.append((owner_account, owner_account)) row = 1 for code_item in AccountThird.objects.filter(code__regex=r"^45[0-9a-zA-Z]*$", third__status=0).values_list('code').distinct(): lbl = XferCompLabelForm('lbl_code_' + code_item[0]) lbl.set_value_as_name(code_item[0]) lbl.set_location(0, row) dlg.add_component(lbl) sel = XferCompSelect('code_' + code_item[0]) sel.set_location(1, row) sel.set_value(dlg.getparam('code_' + code_item[0], "")) sel.set_select(select_account) dlg.add_component(sel) row += 1
def header_title(self, step, steplist): if step > 0: btn = XferCompButton("prec_wizard") btn.set_location(0, 0) btn.set_is_mini(True) btn.set_action(self.request, self.get_action(_("Prec"), "images/left.png"), modal=FORMTYPE_REFRESH, close=CLOSE_NO, params={'step': step - 1}) self.add_component(btn) lbl = XferCompLabelForm('progress') lbl.set_centered() lbl.set_value_as_name(_("progress steps: %(current)d/%(max)d") % {'current': step + 1, "max": len(steplist)}) lbl.set_location(1, 0, 4) self.add_component(lbl) if step < (len(steplist) - 1): btn = XferCompButton("next_wizard") btn.set_location(5, 0) btn.set_is_mini(True) btn.set_action(self.request, self.get_action(_("Next"), "images/right.png"), modal=FORMTYPE_REFRESH, close=CLOSE_NO, params={'step': step + 1}) self.add_component(btn) lbl = XferCompLabelForm('sep1') lbl.set_value("{[hr/]}") lbl.set_location(0, 1, 6) self.add_component(lbl)
def fillresponse_add_title(self): XferSearchEditor.fillresponse_add_title(self) modelname = self.model.get_long_name() saved_list = SavedCriteria.objects.filter(modelname=modelname) new_row = self.get_max_row() lbl = XferCompLabelForm('lbl_saved_criteria') lbl.set_location(1, new_row + 1) lbl.set_value_as_name(_("saved criteria")) self.add_component(lbl) sel = XferCompSelect('saved_criteria') sel.set_location(2, new_row + 1, 2) sel.set_needed(False) sel.set_select_query(saved_list) sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(sel) if len(self.criteria_list) > 0: from lucterios.CORE.views import SavedCriteriaAddModify btn = XferCompButton('btn_saved_criteria') btn.set_location(4, new_row + 1, 2) btn.set_is_mini(True) btn.set_action(self.request, SavedCriteriaAddModify.get_action("+", ""), close=CLOSE_NO, params={ 'modelname': modelname, 'criteria': self.getparam('CRITERIA', '') }) self.add_component(btn) if self.getparam('saved_criteria', 0) != 0: saved_item = SavedCriteria.objects.get( id=self.getparam('saved_criteria', 0)) self.params['CRITERIA'] = saved_item.criteria self.read_criteria_from_params()
def create_dlg(self, username, legalentity): dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) dlg.add_component(img) dlg.fill_from_model(1, 0, False, ['genre', 'lastname', 'firstname', 'email']) dlg.get_components( 'email' ).mask = '^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$' row = dlg.get_max_row() + 1 lbl = XferCompLabelForm("username_lbl") lbl.set_location(1, row) lbl.set_value_as_name(_('username')) dlg.add_component(lbl) edt = XferCompEdit("username") edt.set_location(2, row) edt.set_needed(True) edt.set_value(username) dlg.add_component(edt) if Params.getvalue("contacts-createaccount") == 2: row = dlg.get_max_row() + 1 lbl = XferCompLabelForm("legalentity_lbl") lbl.set_location(1, row) lbl.set_value_as_name(_("your structure name")) dlg.add_component(lbl) edt = XferCompEdit("legalentity") edt.set_location(2, row) edt.set_needed(True) edt.set_value(legalentity) dlg.add_component(edt) row = dlg.get_max_row() + 1 lbl = XferCompLabelForm("captcha_lbl") lbl.set_location(1, row) lbl.set_value_as_name(_("captcha")) dlg.add_component(lbl) edt = XferCompCaptcha("captcha") edt.set_location(2, row) dlg.add_component(edt) lbl = XferCompLabelForm("error_lbl") lbl.set_location(2, row + 1) lbl.set_color('red') lbl.set_value(self.getparam('error', '')) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
def fillresponse(self): if self.getparam("CONFIRME") is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_record') lbl.set_value_as_name(_('record')) lbl.set_location(1, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('record') lbl.set_value(six.text_type(self.item)) lbl.set_location(2, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_current') lbl.set_value_as_name(_('current model')) lbl.set_location(1, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('current') lbl.set_value(self.item.__class__._meta.verbose_name) lbl.set_location(2, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_newmodel') lbl.set_value_as_name(_('new model')) lbl.set_location(1, 3) dlg.add_component(lbl) lbl = XferCompSelect('newmodel') lbl.set_select(self.item.__class__.get_select_contact_type(False)) lbl.set_location(2, 3) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), close=CLOSE_YES, modal=FORMTYPE_MODAL, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png")) else: new_model = apps.get_model(self.getparam('newmodel')) field_id_name = "%s_ptr_id" % self.model.__name__.lower() new_object = new_model(**{field_id_name: self.item.pk}) new_object.save() new_object.__dict__.update(self.item.__dict__) new_object.save() self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self))
def add_name(self, pos, name): lbl = XferCompLabelForm('name_%d' % pos) lbl.set_centered() lbl.set_value_as_name(name) lbl.set_location(0, pos) self.add_component(lbl)
def get_label_comp(self): lbl = XferCompLabelForm('lbl_' + self.name) lbl.set_value_as_name(ugettext_lazy(self.name)) return lbl
def show(self, xfer): IndividualEditor.show(self, xfer) if xfer.getparam('adherent') is None: xfer.params['adherent'] = xfer.getparam('individual', 0) if xfer.getparam('individual') is None: xfer.params['individual'] = xfer.getparam('adherent', 0) img = xfer.get_components('img') img.set_value(get_icon_path("diacamma.member/images/adherent.png")) if Params.getobject("member-family-type") is not None: xfer.tab = 1 row_init = xfer.get_max_row() + 1 lbl = XferCompLabelForm("family") current_family = self.item.family if current_family is None: lbl.set_value(None) else: lbl.set_value(six.text_type(self.item.family)) lbl.set_location(1, row_init, 2) lbl.description = _('family') xfer.add_component(lbl) btn = XferCompButton('famillybtn') btn.is_mini = True btn.set_location(3, row_init) if current_family is None: act = ActionsManage.get_action_url('member.Adherent', 'FamilyAdd', xfer) act.set_value("", "images/add.png") btn.set_action(xfer.request, act, modal=FORMTYPE_MODAL, close=CLOSE_NO) else: act = ActionsManage.get_action_url('contacts.LegalEntity', 'Show', xfer) act.set_value("", "images/edit.png") btn.set_action( xfer.request, act, modal=FORMTYPE_MODAL, close=CLOSE_NO, params={'legal_entity': six.text_type(current_family.id)}) xfer.add_component(btn) if xfer.item.current_subscription is not None: xfer.tab = 1 row_init = xfer.get_max_row() + 1 row = row_init + 1 for doc in xfer.item.current_subscription.docadherent_set.all(): ckc = XferCompCheck("doc_%d" % doc.id) ckc.set_value(doc.value) ckc.set_location(2, row) ckc.description = six.text_type(doc.document) xfer.add_component(ckc) row += 1 if row != row_init + 1: lbl = XferCompLabelForm("lbl_doc_sep") lbl.set_value("{[hr/]}") lbl.set_location(1, row_init, 4) xfer.add_component(lbl) lbl = XferCompLabelForm("lbl_doc") lbl.set_value_as_name(_('documents needs')) lbl.set_location(1, row_init + 1) xfer.add_component(lbl) btn = XferCompButton("btn_doc") btn.set_location(4, row_init + 1, 1, row - row_init) btn.set_action(xfer.request, ActionsManage.get_action_url( "member.Adherent", "Doc", xfer), close=CLOSE_NO) xfer.add_component(btn)
def fillresponse(self, season): if season is None: working_season = Season.current_season() else: working_season = Season.objects.get(id=season) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) self.add_component(img) sel = XferCompSelect('season') sel.set_needed(True) sel.set_select_query(Season.objects.all()) sel.set_value(working_season.id) sel.set_location(1, 0) sel.description = _('season') sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(sel) stat_result = Degree.get_statistic(working_season) if len(stat_result) == 0: lab = XferCompLabelForm('lbl_season') lab.set_color('red') lab.set_value_as_infocenter(_('no degree!')) lab.set_location(1, 1, 2) self.add_component(lab) else: total = 0 pos_y = 2 for activity, sublist in stat_result: subtotal = 0 if activity is not None: lab = XferCompLabelForm("lblactivite_%d" % activity.id) lab.set_italic() lab.set_value(six.text_type(activity)) lab.set_location(0, pos_y, 3) self.add_component(lab) pos_y += 1 for degree_name, val in sublist: lab = XferCompLabelForm("title_%d" % pos_y) lab.set_value(degree_name) lab.set_location(1, pos_y) self.add_component(lab) lab = XferCompLabelForm("val_%d" % pos_y) lab.set_value(six.text_type(val)) lab.set_location(2, pos_y) self.add_component(lab) subtotal += val total += val pos_y += 1 if activity is not None: lab = XferCompLabelForm("lblsubtotal_%d" % activity.id) lab.set_value_as_header(_("Total")) lab.set_location(1, pos_y) self.add_component(lab) lab = XferCompLabelForm("subtotal_%d" % activity.id) lab.set_italic() lab.set_value(six.text_type(subtotal)) lab.set_location(2, pos_y) self.add_component(lab) pos_y += 1 lab = XferCompLabelForm("lbltotal") lab.set_value_as_headername(_("Total")) lab.set_location(1, pos_y) self.add_component(lab) lab = XferCompLabelForm("total") lab.set_value_as_name(six.text_type(total)) lab.set_location(2, pos_y) self.add_component(lab) self.add_action(DegreeStatisticPrint.get_action( TITLE_PRINT, "images/print.png"), close=CLOSE_NO, params={'classname': self.__class__.__name__}) self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))