diff options
| -rw-r--r-- | archaeological_files/models.py | 87 | ||||
| -rw-r--r-- | archaeological_files/templates/ishtar/sheet_file.html | 593 | ||||
| -rw-r--r-- | ishtar_common/migrations/0216_auto_20210805_1703.py | 25 | ||||
| -rw-r--r-- | ishtar_common/models.py | 2 | 
4 files changed, 507 insertions, 200 deletions
| diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 79dabc84d..0eac73119 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -235,6 +235,12 @@ class EquipmentServiceCost(models.Model):      def history_compress(self):          return self.slug +    @property +    def unit_label(self): +        if self.unit and self.unit in DCT_ES_UNITS: +            return DCT_ES_UNITS[self.unit] +        return "" +  class FileType(GeneralType):      class Meta: @@ -1033,6 +1039,47 @@ class File(              self.general_contractor.save()          return True +    @property +    def job_cost_planned(self): +        return sum(job.cost_planned for job in self.jobs.all()) + +    @property +    def ground_job_cost_planned(self): +        return sum(job.cost_planned for job in self.ground_jobs.all()) + +    @property +    def job_cost_worked(self): +        return sum(job.cost_worked for job in self.jobs.all()) + +    @property +    def ground_job_cost_worked(self): +        return sum(job.cost_worked for job in self.ground_jobs.all()) + +    @property +    def job_cost_diff_planned_worked(self): +        return self.job_cost_planned - self.job_cost_worked + +    @property +    def ground_job_cost_diff_planned_worked(self): +        return self.ground_job_cost_planned - self.ground_job_cost_worked + +    @property +    def used_equipments(self): +        equipments = [] +        service_types = list(GenericEquipmentServiceType.objects.all()) +        for service_type in service_types: +            q = self.equipment_costs.filter( +                equipment_service_cost__equipment_service_type__generic_equipment_type=service_type) +            if not q.count(): +                continue +            equipments.append([service_type.label, 0, 0, 0, []]) +            for cost in q.all(): +                equipments[-1][-4] += cost.cost_planned +                equipments[-1][-3] += cost.cost_worked +                equipments[-1][-1].append(cost) +            equipments[-1][-2] = equipments[-1][-4] - equipments[-1][-3] +        return equipments +      def get_extra_actions(self, request):          # url, base_text, icon, extra_text, extra css class, is a quick action          actions = super(File, self).get_extra_actions(request) @@ -1318,6 +1365,14 @@ class PreventiveFileGroundJob(ManDays):      class Meta:          ordering = ("job",) +    @property +    def cost_planned(self): +        return (self.job.ground_daily_cost or 0) * self.quantity_planned + +    @property +    def cost_worked(self): +        return (self.job.ground_daily_cost or 0) * self.quantity_worked +  class PreventiveFileJob(ManDays):      file = models.ForeignKey(File, related_name="jobs") @@ -1326,8 +1381,18 @@ class PreventiveFileJob(ManDays):      class Meta:          ordering = ("job",) +    @property +    def cost_planned(self): +        return (self.job.daily_cost or 0) * self.quantity_planned + +    @property +    def cost_worked(self): +        return (self.job.daily_cost or 0) * self.quantity_worked + -class TechDays(models.Model): +class PreventiveFileEquipmentServiceCost(models.Model): +    file = models.ForeignKey(File, related_name="equipment_costs") +    equipment_service_cost = models.ForeignKey(EquipmentServiceCost)      quantity_by_day_planned = models.FloatField(          _("Quantity by day - planned"), null=True, blank=True      ) @@ -1338,24 +1403,28 @@ class TechDays(models.Model):      days_worked = models.FloatField(_("Days - worked"), null=True, blank=True)      class Meta: -        abstract = True +        ordering = ("equipment_service_cost",)      @property      def quantity_planned(self): +        if self.equipment_service_cost.flat_rate: +            return self.quantity_by_day_planned or 0          if not self.days_planned or not self.quantity_by_day_planned:              return 0          return self.days_planned * self.quantity_by_day_planned      @property      def quantity_worked(self): -        if not self.days_worked or not self.quantity_by_day_worked: +        if self.equipment_service_cost.flat_rate: +            return self.quantity_by_day_worked or 0 +        if not self.quantity_by_day_worked or not self.days_worked:              return 0          return self.days_worked * self.quantity_by_day_worked +    @property +    def cost_planned(self): +        return (self.equipment_service_cost.unitary_cost or 0) * self.quantity_planned -class PreventiveFileEquipmentServiceCost(TechDays): -    file = models.ForeignKey(File, related_name="equipment_costs") -    equipment_service_cost = models.ForeignKey(EquipmentServiceCost) - -    class Meta: -        ordering = ("equipment_service_cost",) +    @property +    def cost_worked(self): +        return (self.equipment_service_cost.unitary_cost or 0) * self.quantity_worked diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html index 7d3279988..d54d29e7e 100644 --- a/archaeological_files/templates/ishtar/sheet_file.html +++ b/archaeological_files/templates/ishtar/sheet_file.html @@ -11,211 +11,422 @@  {% with can_view_documents=permission_view_own_document|or_:permission_view_document %}  {% with has_documents=item.documents.count %}  {% with display_documents=can_view_documents|and_:has_documents %} +{% with has_costs=item.equipment_costs.count|or_:item.ground_jobs.count|or_:item.jobs.count %} + +{% if output != "ODT" and output != "PDF"%} +<ul class="nav nav-tabs" id="{{window_id}}-tabs" role="tablist"> +    <li class="nav-item"> +        <a class="nav-link active" id="{{window_id}}-general-tab" +           data-toggle="tab" href="#{{window_id}}-general" role="tab" +           aria-controls="{{window_id}}-general" aria-selected="false"> +            {% trans "General" %} +        </a> +    </li> +    {% if has_costs %}<li class="nav-item"> +        <a class="nav-link" id="{{window_id}}-costs-tab" +           data-toggle="tab" href="#{{window_id}}-costs" role="tab" +           aria-controls="{{window_id}}-costs" aria-selected="false"> +            {% trans "Preventive" %} +        </a> +    </li>{% endif %} +</ul> +{% endif %} -<div class="row"> -  <div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12"> -    <div class="card"> -      {% include "ishtar/blocks/window_image.html" %} -      <div class="card-body"> -        <div class="card-text"> -            {% if item.complete_identifier %}<p class="window-refs" -                    title="{% trans 'Complete identifier' %}"> -            <strong>{{ item.complete_identifier }}</strong></p>{% endif %} -            <p class='window-refs'>{{item.full_internal_ref|default:''}}</p> -            <p class='window-refs'>{{item.internal_reference|default:''}}</p> -            <p class='window-refs'>{{item.name|default:''}}</p> -            {% include "ishtar/blocks/sheet_external_id.html" %} +<div class="tab-content" id="{{window_id}}-tab-content"> +    <div class="tab-pane fade show active" id="{{window_id}}-general" +         role="tabpanel" aria-labelledby="{{window_id}}-general-tab"> + +        <div class="row"> +          <div class="offset-lg-4 col-lg-4 offset-md-3 col-md-6 offset-sm-1 col-sm-10 col-12"> +            <div class="card"> +              {% include "ishtar/blocks/window_image.html" %} +              <div class="card-body"> +                <div class="card-text"> +                    {% if item.complete_identifier %}<p class="window-refs" +                            title="{% trans 'Complete identifier' %}"> +                    <strong>{{ item.complete_identifier }}</strong></p>{% endif %} +                    <p class='window-refs'>{{item.full_internal_ref|default:''}}</p> +                    <p class='window-refs'>{{item.internal_reference|default:''}}</p> +                    <p class='window-refs'>{{item.name|default:''}}</p> +                    {% include "ishtar/blocks/sheet_external_id.html" %} +                </div> +              </div> +            </div> +          </div>          </div> -      </div> -    </div> -  </div> -</div> - - -<h3>{% trans "General"%}</h3> -<div class="row"> -    {% field_flex "Reception date" item.reception_date|date:"DATE_FORMAT" %} -    {% include "ishtar/blocks/sheet_creation_section.html" %} +        <h3>{% trans "General"%}</h3> + +        <div class="row"> +            {% field_flex "Reception date" item.reception_date|date:"DATE_FORMAT" %} +            {% include "ishtar/blocks/sheet_creation_section.html" %} + +        {% comment %} +        {% if item.deadline_date and not item.acts %} +            <p><label>{%trans "Deadline"%}</label> <span class='value'>{% item.deadline_date %}</span></p> <!-- calculated deadline for some preventive files , see saisine_type, not displayed if an act as been send --> +        {% endif %} +        {% endcomment %} + +            {% field_flex_detail "In charge" item.in_charge %} +            <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> +            <dt class="col-5">{%trans "State"%}</dt> +            <dd class='col-7'> +              {% if item.is_active %}{%trans "Active file"%}{% else %}{%trans "Closed file"%}{% endif %} +            </dd> +            </div> +            {% if item.closing %} +            <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> +            <dt class="col-5">{%trans "Closing date"%}</dt> +            <dd class='col-7'> +              {{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user.full_label }} +            </dd> +            </div> +            {% endif %} +            {% field_flex "Type" item.file_type %} +            {% field_flex_detail "Related file" item.related_file %} +            {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %} +        </div> -{% comment %} -{% if item.deadline_date and not item.acts %} -    <p><label>{%trans "Deadline"%}</label> <span class='value'>{% item.deadline_date %}</span></p> <!-- calculated deadline for some preventive files , see saisine_type, not displayed if an act as been send --> -{% endif %} -{% endcomment %} - -    {% field_flex_detail "In charge" item.in_charge %} -    <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> -    <dt class="col-5">{%trans "State"%}</dt> -    <dd class='col-7'> -      {% if item.is_active %}{%trans "Active file"%}{% else %}{%trans "Closed file"%}{% endif %} -    </dd> -    </div> -    {% if item.closing %} -    <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> -    <dt class="col-5">{%trans "Closing date"%}</dt> -    <dd class='col-7'> -      {{ item.closing.date }} <strong>{%trans "by" %}</strong> {{ item.closing.user.full_label }} -    </dd> -    </div> -    {% endif %} -    {% field_flex "Type" item.file_type %} -    {% field_flex_detail "Related file" item.related_file %} -    {% field_flex_full "Comment" item.comment "<pre>" "</pre>" %} -</div> +        {% include "ishtar/blocks/sheet_json.html" %} + +        <h3>{% trans "Localisation"%}</h3> +        <div class="row"> +            {% field_flex_multiple_obj "Towns" item 'towns' %} +            {% field_flex_multiple_obj "Departments" item 'departments' %} +            {% field_flex "Main address" item.address %} +            {% field_flex "Complement" item.address_complement %} +            {% field_flex "Postal code" item.postal_code %} +            {% if item.total_surface %} +            <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> +                <dt class="col-5">{%trans "Surface"%}</dt> +                <dd class='col-7'> +                    {{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha) +                </dd> +            </div> +            {% endif %} +        </div> -{% include "ishtar/blocks/sheet_json.html" %} - -<h3>{% trans "Localisation"%}</h3> -<div class="row"> -    {% field_flex_multiple_obj "Towns" item 'towns' %} -    {% field_flex_multiple_obj "Departments" item 'departments' %} -    {% field_flex "Main address" item.address %} -    {% field_flex "Complement" item.address_complement %} -    {% field_flex "Postal code" item.postal_code %} -    {% if item.total_surface %} -    <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> -        <dt class="col-5">{%trans "Surface"%}</dt> -        <dd class='col-7'> -            {{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha) -        </dd> -    </div> -    {% endif %} -</div> +        {% if item.is_preventive %} + +        <h3>{% trans "Preventive archaeological file"%}</h3> +        <div class="row"> + +            {% if item.total_developed_surface %} +            <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> +                <dt class="col-5">{%trans "Developed surface"%}</dt> +                <dd class='col-7'> +                {{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha)</span></li> +                </dd> +            </div> +            {% endif %} + +            {% field_flex "Saisine type" item.saisine_type %} + +            {% field_flex_detail "Responsible for planning service" item.responsible_town_planning_service %} +            {% field_flex "Responsible for planning service address" item.responsible_town_planning_service.full_address %} +            {% if item.town_planning_service %} +              {% field_flex "Planning service organization" item.town_planning_service.full_address %} +            {% else %} +              {% field_flex "Planning service organization" item.responsible_town_planning_service.attached_to.full_address %} +            {% endif %} + +            {% field_flex "Permit type" item.permit_type %} +            {% field_flex "Permit reference" item.permit_reference %} +            {% field_flex "Date of planning service file" item.planning_service_date|date:"DATE_FORMAT" %} + +            {% field_flex "General contractor" item.general_contractor.full_address %} +            {% if item.corporation_general_contractor %} +              {% field_flex "General contractor organization" item.corporation_general_contractor.full_address %} +            {% else%} +              {% field_flex "General contractor organization" item.general_contractor.attached_to.full_address %} +            {% endif %} -{% if item.is_preventive %} - -<h3>{% trans "Preventive archaeological file"%}</h3> -<div class="row"> - -    {% if item.total_developed_surface %} -    <div class="col-12 col-md-6 col-lg-4 d-flex flex-wrap row"> -        <dt class="col-5">{%trans "Developed surface"%}</dt> -        <dd class='col-7'> -        {{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha)</span></li> -        </dd> -    </div> -    {% endif %} - -    {% field_flex "Saisine type" item.saisine_type %} - -    {% field_flex_detail "Responsible for planning service" item.responsible_town_planning_service %} -    {% field_flex "Responsible for planning service address" item.responsible_town_planning_service.full_address %} -    {% if item.town_planning_service %} -      {% field_flex "Planning service organization" item.town_planning_service.full_address %} -    {% else %} -      {% field_flex "Planning service organization" item.responsible_town_planning_service.attached_to.full_address %} -    {% endif %} - -    {% field_flex "Permit type" item.permit_type %} -    {% field_flex "Permit reference" item.permit_reference %} -    {% field_flex "Date of planning service file" item.planning_service_date|date:"DATE_FORMAT" %} - -    {% field_flex "General contractor" item.general_contractor.full_address %} -    {% if item.corporation_general_contractor %} -      {% field_flex "General contractor organization" item.corporation_general_contractor.full_address %} -    {% else%} -      {% field_flex "General contractor organization" item.general_contractor.attached_to.full_address %} -    {% endif %} +        </div> +        {% else %} -</div> -{% else %} +        <h3>{% trans "Research archaeology"%}</h3> +        <div class="row"> +            {% field_flex_detail "Head scientist" item.scientist %} +            {% field_flex "Requested operation type" item.requested_operation_type %} +            {% field_flex_detail "Organization" item.organization %} -<h3>{% trans "Research archaeology"%}</h3> -<div class="row"> -    {% field_flex_detail "Head scientist" item.scientist %} -    {% field_flex "Requested operation type" item.requested_operation_type %} -    {% field_flex_detail "Organization" item.organization %} +            {% if item.cira_advised != None %} +            {% field_flex "Passage en CIRA" item.cira_advised|yesno %} +            {% endif %} -    {% if item.cira_advised != None %} -    {% field_flex "Passage en CIRA" item.cira_advised|yesno %} -    {% endif %} +            {% if item.mh_register != None %} +            {% field_flex "Sur Monument Historique classé" item.mh_register|yesno %} +            {% endif %} -    {% if item.mh_register != None %} -    {% field_flex "Sur Monument Historique classé" item.mh_register|yesno %} -    {% endif %} +            {% if item.mh_listing != None %} +            {% field_flex "Sur Monument Historique inscrit" item.mh_listing|yesno %} +            {% endif %} -    {% if item.mh_listing != None %} -    {% field_flex "Sur Monument Historique inscrit" item.mh_listing|yesno %} -    {% endif %} +            {% if item.classified_area  != None %} +            {% field_flex "Classified area" item.classified_area|yesno %} +            {% endif %} -    {% if item.classified_area  != None %} -    {% field_flex "Classified area" item.classified_area|yesno %} -    {% endif %} +            {% if item.protected_area  != None %} +            {% field_flex "Protected area" item.protected_area|yesno %} +            {% endif %} -    {% if item.protected_area  != None %} -    {% field_flex "Protected area" item.protected_area|yesno %} -    {% endif %} +            {% field_flex_full "Comment" item.research_comment "<pre>" "</pre>" %} +        </div> -    {% field_flex_full "Comment" item.research_comment "<pre>" "</pre>" %} +        {% endif %} + +        {% if not next %} + +        {% trans "Associated parcels" as parcels_label %} +        {% include "ishtar/blocks/window_tables/parcels.html" %} + +        {% trans "Administrative acts" as administrativeacts_label %} +        {% table_administrativact administrativeacts_label item.administrative_act.all %} + +        <h3>{%trans "Associated operations"%}</h3> +        <table class="table table-striped"> +          <tr> +            <th>{% trans "Ref." %}</th> +            <th>Code Patriarche</th> +            <th>{% trans "Type" %}</th> +            <th>{% trans "In charge" %}</th> +            <th>{% trans "Start date" %}</th> +            <th>{% trans "Excavation end date" %}</th> +            <th class='link'> </th> +          </tr> +          {% for operation in item.operations.all %} +          <tr> +            <td>{{operation.year_index}}</td> +            <td>{{operation.full_code_patriarche|default:""}}</td> +            <td class='string'>{{operation.operation_type}}</td> +            <td class='string'>{{operation.in_charge|default:""}}</td> +            <td>{{operation.start_date|default:""}}</td> +            <td>{{operation.excavation_end_date|default:""}}</td> +            <td class='link'><a href="#" class='display_details' +                                onclick='load_window("{% url "show-operation" operation.pk "" %}")'><i class="fa fa-info-circle" aria-hidden="true"></i></a></td> +          </tr> +          {% empty %} +          <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaeological file" %}</td></tr> +          {% endfor %} +        </table> + +        <h3>{%trans "Admninistrative acts linked to associated operations"%}</h3> +        <table class="table table-striped"> +          <tr> +            <th>{% trans "Year" %}</th> +            <th>{% trans "Ref." %}</th> +            <th>{% trans "Type" %}</th> +            <th>{% trans "Date" %}</th> +          </tr> +          {% for act in item.operation_acts %} +          <tr> +            <td>{{act.signature_date.year}}</td> +            <td>{{act.ref_sra}}</td> +            <td class='string'>{{act.act_type}}</td> +            <td>{{act.signature_date}}</td> +          </tr> +          {% empty %} +          <tr><td colspan="4" class='no_items'>{% trans "No administrative act linked to operations" %}</td></tr> +          {% endfor %} +        </table> + +        {% endif %} + +        {% trans "Document for this archaeological file" as fle_docs %} +        {% if permission_view_own_document or permission_view_document %} +        {% if item.documents.count %} +        {% dynamic_table_document fle_docs 'documents' 'files' item.pk '' output %} +        {% endif %} +        {% endif %} + +    </div>{% if has_costs %} +    <div class="tab-pane fade show active" id="{{window_id}}-costs" +         role="tabpanel" aria-labelledby="{{window_id}}-costs-tab"> +        <div class="row"> +            {% field_flex "Start date" item.start_date|date:"DATE_FORMAT" %} +            {% field_flex "End date" item.end_date|date:"DATE_FORMAT" %} +            {% field_flex "Ground start date" item.ground_start_date|date:"DATE_FORMAT" %} +            {% field_flex "Ground end date" item.ground_end_date|date:"DATE_FORMAT" %} +            {% field_flex "Study period" item.study_period %} +            {% field_flex "Execution report date" item.execution_report_date|date:"DATE_FORMAT" %} +        </div> +        <div class="row"> +            {% if item.total_developed_surface %} +            <dl class="col-12 col-lg-6 flex-wrap"> +                <dt>{%trans "Total developed surface"%}</dt> +                <dd> +                    {{ item.total_developed_surface }} m<sup>2</sup> ({{ item.total_developed_surface_ha }} ha) +                </dd> +            </dl> +            {% endif %} +            {% if item.total_surface %} +            <dl class="col-12 col-lg-6 flex-wrap"> +                <dt>{% trans "Surface" %}</dt> +                <dd> +                    {{ item.total_surface }} m<sup>2</sup> ({{ item.total_surface_ha }} ha) +                </dd> +            </dl> +            {% endif %} +        </div> +        <h3>{% trans "Human and technical requirements" %}</h3> +        {% if item.ground_jobs.count %} +        <div class="col-12"> +            <h4>{% trans "Ground jobs" %}</h4> +            <table class="table table-striped"> +                <thead> +                <tr> +                    <th>{% trans "Job" %}</th> +                    <th colspan="3">{% trans "Planned" %}</th> +                    <th colspan="3">{% trans "Effective" %}</th> +                </tr> +                <tr> +                    <td> </td> +                    <th>{% trans "Man by day" %}</th> +                    <th>{% trans "Days" %}</th> +                    <th>{% trans "Cost" %}</th> +                    <th>{% trans "Man by day" %}</th> +                    <th>{% trans "Days" %}</th> +                    <th>{% trans "Cost" %}</th> +                </tr> +                </thead> +                {% for job in item.ground_jobs.all %} +                <tr> +                    <td><em>{{job.job}}</em></td> +                    <td class="text-right">{{job.man_by_day_planned|default:"-"}}</td> +                    <td class="text-right">{{job.days_planned|default:"-"}}</td> +                    <td class="text-right">{{job.cost_planned|default:"-"|floatformat:2}}</td> +                    <td class="text-right">{{job.man_by_day_worked|default:"-"}}</td> +                    <td class="text-right">{{job.days_worked|default:"-"}}</td> +                    <td class="text-right">{{job.cost_worked|default:"-"|floatformat:2}}</td> +                </tr> +                {% endfor %} +                <tr class="table-info"> +                    <td><strong>{% trans "Total" %}</strong></td> +                    <td colspan="2"> </td> +                    <td class="text-right"> +                        <strong>{{item.ground_job_cost_planned|default:"-"|floatformat:2}}</strong> +                    </td> +                    <td colspan="2"> </td> +                    <td class="text-right"> +                        <strong>{{item.ground_job_cost_worked|default:"-"|floatformat:2}}</strong> +                    </td> +                </tr> +                <tr class="table-info"> +                    <td><em>{% trans "Difference" %}</em></td> +                    <td colspan="5"> </td> +                    <td class="text-right"> +                        <em>{{item.ground_job_cost_diff_planned_worked|default:"-"|floatformat:2}}</em> +                    </td> +                </tr> +            </table> +        </div> +        {% endif %} +        {% if item.jobs.count %} +        <div class="col-12"> +            <h4>{% trans "Post-excavation jobs" %}</h4> +            <table class="table table-striped"> +                <thead> +                <tr> +                    <th>{% trans "Job" %}</th> +                    <th colspan="3">{% trans "Planned" %}</th> +                    <th colspan="3">{% trans "Effective" %}</th> +                </tr> +                <tr> +                    <td> </td> +                    <th>{% trans "Man by day" %}</th> +                    <th>{% trans "Days" %}</th> +                    <th>{% trans "Cost" %}</th> +                    <th>{% trans "Man by day" %}</th> +                    <th>{% trans "Days" %}</th> +                    <th>{% trans "Cost" %}</th> +                </tr> +                </thead> +                {% for job in item.jobs.all %} +                <tr> +                    <td><em>{{job.job}}</em></td> +                    <td class="text-right">{{job.man_by_day_planned|default:"-"}}</td> +                    <td class="text-right">{{job.days_planned|default:"-"}}</td> +                    <td class="text-right">{{job.cost_planned|default:"-"|floatformat:2}}</td> +                    <td class="text-right">{{job.man_by_day_worked|default:"-"}}</td> +                    <td class="text-right">{{job.days_worked|default:"-"}}</td> +                    <td class="text-right">{{job.cost_worked|default:"-"|floatformat:2}}</td> +                </tr> +                {% endfor %} +                <tr class="table-info"> +                    <td><strong>{% trans "Total" %}</strong></td> +                    <td colspan="2"> </td> +                    <td class="text-right"> +                        <strong>{{item.job_cost_planned|default:"-"|floatformat:2}}</strong> +                    </td> +                    <td colspan="2"> </td> +                    <td class="text-right"> +                        <strong>{{item.job_cost_worked|default:"-"|floatformat:2}}</strong> +                    </td> +                </tr> +                <tr class="table-info"> +                    <td><em>{% trans "Difference" %}</em></td> +                    <td colspan="5"> </td> +                    <td class="text-right"> +                        <em>{{item.job_cost_diff_planned_worked|default:"-"|floatformat:2}}</em> +                    </td> +                </tr> +            </table> +        </div> +        {% endif %} +        {% for service_type, cost_planned, cost_worked, diff, equipments in item.used_equipments %} +        <div class="col-12"> +            <h4>{{service_type}}</h4> +            <table class="table table-striped"> +                <thead> +                <tr> +                    <th>{% trans "Equipment / service" %}</th> +                    <th colspan="4">{% trans "Planned" %}</th> +                    <th colspan="4">{% trans "Effective" %}</th> +                </tr> +                <tr> +                    <td> </td> +                    <th>{% trans "Quantity" %}</th> +                    <th colspan="2"> </th> +                    <th>{% trans "Cost" %}</th> +                    <th>{% trans "Quantity" %}</th> +                    <th colspan="2"> </th> +                    <th>{% trans "Cost" %}</th> +                </tr> +                </thead> +                {% for equipment in equipments %} +                {% if equipment.cost_planned or equipment.cost_worked %} +                <tr> +                    <td><em>{{equipment.equipment_service_cost.equipment_service_type.label}}</em></td> +                    <td class="text-right">{{equipment.quantity_by_day_planned|default:"-"}}</td> +                    <td class="text-right">{{equipment.days_planned|default:"-"}}</td> +                    <td>{{equipment.equipment_service_cost.unit_label}}</td> +                    <td class="text-right">{{equipment.cost_planned|default:"-"|floatformat:2}}</td> +                    <td class="text-right">{{equipment.quantity_by_day_worked|default:"-"}}</td> +                    <td class="text-right">{{equipment.days_worked|default:"-"}}</td> +                    <td>{{equipment.equipment_service_cost.unit_label}}</td> +                    <td class="text-right">{{equipment.cost_worked|default:"-"|floatformat:2}}</td> +                </tr> +                {% endif %} +                {% endfor %} +                <tr class="table-info"> +                    <td><strong>{% trans "Total" %}</strong></td> +                    <td colspan="3"> </td> +                    <td class="text-right"><strong>{{cost_planned|default:"-"|floatformat:2}}</strong></td> +                    <td colspan="3"> </td> +                    <td class="text-right"><strong>{{cost_worked|default:"-"|floatformat:2}}</strong></td> +                </tr> +                <tr class="table-info"> +                    <td><em>{% trans "Difference" %}</em></td> +                    <td colspan="7"> </td> +                    <td class="text-right"> +                        <em>{{diff|default:"-"|floatformat:2}}</em> +                    </td> +                </tr> +            </table> +        </div> +        {% endfor %} +    </div>{% endif %}  </div> -{% endif %} - -{% if not next %} - -{% trans "Associated parcels" as parcels_label %} -{% include "ishtar/blocks/window_tables/parcels.html" %} - -{% trans "Administrative acts" as administrativeacts_label %} -{% table_administrativact administrativeacts_label item.administrative_act.all %} - -<h3>{%trans "Associated operations"%}</h3> -<table class="table table-striped"> -  <tr> -    <th>{% trans "Ref." %}</th> -    <th>Code Patriarche</th> -    <th>{% trans "Type" %}</th> -    <th>{% trans "In charge" %}</th> -    <th>{% trans "Start date" %}</th> -    <th>{% trans "Excavation end date" %}</th> -    <th class='link'> </th> -  </tr> -  {% for operation in item.operations.all %} -  <tr> -    <td>{{operation.year_index}}</td> -    <td>{{operation.full_code_patriarche|default:""}}</td> -    <td class='string'>{{operation.operation_type}}</td> -    <td class='string'>{{operation.in_charge|default:""}}</td> -    <td>{{operation.start_date|default:""}}</td> -    <td>{{operation.excavation_end_date|default:""}}</td> -    <td class='link'><a href="#" class='display_details' -                        onclick='load_window("{% url "show-operation" operation.pk "" %}")'><i class="fa fa-info-circle" aria-hidden="true"></i></a></td> -  </tr> -  {% empty %} -  <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaeological file" %}</td></tr> -  {% endfor %} -</table> - -<h3>{%trans "Admninistrative acts linked to associated operations"%}</h3> -<table class="table table-striped"> -  <tr> -    <th>{% trans "Year" %}</th> -    <th>{% trans "Ref." %}</th> -    <th>{% trans "Type" %}</th> -    <th>{% trans "Date" %}</th> -  </tr> -  {% for act in item.operation_acts %} -  <tr> -    <td>{{act.signature_date.year}}</td> -    <td>{{act.ref_sra}}</td> -    <td class='string'>{{act.act_type}}</td> -    <td>{{act.signature_date}}</td> -  </tr> -  {% empty %} -  <tr><td colspan="4" class='no_items'>{% trans "No administrative act linked to operations" %}</td></tr> -  {% endfor %} -</table> - -{% endif %} - -{% trans "Document for this archaeological file" as fle_docs %} -{% if permission_view_own_document or permission_view_document %} -{% if item.documents.count %} -{% dynamic_table_document fle_docs 'documents' 'files' item.pk '' output %} -{% endif %} -{% endif %} - - -{% endwith %} {% endwith %} {% endwith %} +{% endwith %} {% endwith %} {% endwith %}{% endwith %}  {% endblock %} diff --git a/ishtar_common/migrations/0216_auto_20210805_1703.py b/ishtar_common/migrations/0216_auto_20210805_1703.py new file mode 100644 index 000000000..40e0dd0f2 --- /dev/null +++ b/ishtar_common/migrations/0216_auto_20210805_1703.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.28 on 2021-08-05 17:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('ishtar_common', '0215_ishtarsiteprofile_parent_relations_engine'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='ishtarsiteprofile', +            name='preventive_operator', +            field=models.BooleanField(default=False, verbose_name='Preventive operator module'), +        ), +        migrations.AlterField( +            model_name='formatertype', +            name='formater_type', +            field=models.CharField(choices=[('IntegerFormater', 'Integer'), ('FloatFormater', 'Float'), ('UnicodeFormater', 'String'), ('DateFormater', 'Date'), ('TypeFormater', 'Type'), ('YearFormater', 'Year'), ('InseeFormater', 'INSEE code'), ('UpperFormater', 'Upper case'), ('LowerFormater', 'Lower case'), ('StrToBoolean', 'String to boolean'), ('FileFormater', 'File'), ('UnknowType', 'Unknow type')], max_length=20, verbose_name='Formater type'), +        ), +    ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d2a476640..6da129adb 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1102,6 +1102,8 @@ class IshtarSiteProfile(models.Model, Cached):          _("Use town to locate when coordinates are missing"), default=True      )      relation_graph = models.BooleanField(_("Generate relation graph"), default=False) +    preventive_operator = models.BooleanField(_("Preventive operator module"), +                                              default=False)      underwater = models.BooleanField(_("Underwater module"), default=False)      parcel_mandatory = models.BooleanField(          _("Parcel are mandatory for context records"), default=True | 
