temporary branch
This commit is contained in:
@@ -20,4 +20,5 @@ package com.axelor.apps.quality.report;
|
||||
public interface IReport {
|
||||
|
||||
public static final String QUALITY_CONTROL = "QualityControl.rptdesign";
|
||||
public static final String ART_WORK = "ArtWork.rptdesign";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Axelor Business Solutions
|
||||
*
|
||||
* Copyright (C) 2019 Axelor (<http://axelor.com>).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.axelor.apps.quality.service.print;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.quality.db.ArtWork;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.quality.db.QualityControl;
|
||||
import com.axelor.apps.quality.exception.IExceptionMessage;
|
||||
import com.axelor.apps.quality.report.IReport;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.apps.tool.file.PdfTool;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class ArtWorkPrintServiceImpl {
|
||||
|
||||
public String getFileName(ArtWork artWork) {
|
||||
|
||||
return I18n.get("ArtWork") + " " + artWork.getRef();
|
||||
}
|
||||
|
||||
public String printArtWork(ArtWork artWork, String format)
|
||||
throws AxelorException {
|
||||
|
||||
String fileName =
|
||||
I18n.get("ArtWork")
|
||||
+ " - "
|
||||
+ LocalDate.now().toString()
|
||||
+ "."
|
||||
+ format;
|
||||
|
||||
return PdfTool.getFileLinkFromPdfFile(print(artWork, format), fileName);
|
||||
}
|
||||
|
||||
public File print(ArtWork artWork, String format) throws AxelorException {
|
||||
|
||||
ReportSettings reportSettings = prepareReportSettings(artWork, format);
|
||||
|
||||
return reportSettings.generate().getFile();
|
||||
}
|
||||
|
||||
public ReportSettings prepareReportSettings(ArtWork artWork, String format)
|
||||
throws AxelorException {
|
||||
|
||||
if (artWork.getPrintingSettings() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD,
|
||||
String.format(I18n.get(IExceptionMessage.QUALITY_CONTROL_MISSING_PRINTING_SETTINGS)),
|
||||
artWork);
|
||||
}
|
||||
|
||||
String locale =
|
||||
ReportSettings.getPrintingLocale(artWork.getCompany().getPartner());
|
||||
String title = getFileName(artWork);
|
||||
|
||||
ReportSettings reportSetting =
|
||||
ReportFactory.createReport(IReport.ART_WORK, title + " - ${date}");
|
||||
|
||||
return reportSetting
|
||||
.addParam("artWorkId", artWork.getId())
|
||||
.addParam("Locale", locale)
|
||||
.addFormat(format);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Axelor Business Solutions
|
||||
*
|
||||
* Copyright (C) 2019 Axelor (<http://axelor.com>).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.axelor.apps.quality.web;
|
||||
|
||||
import com.axelor.apps.quality.db.ArtWork;
|
||||
import com.axelor.apps.quality.db.repo.ArtWorkRepository;
|
||||
import com.axelor.apps.quality.service.print.ArtWorkPrintServiceImpl;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class ArtWorkController {
|
||||
|
||||
public void printQualityControl(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
ArtWork artWork = request.getContext().asType(ArtWork.class);
|
||||
artWork = Beans.get(ArtWorkRepository.class).find(artWork.getId());
|
||||
|
||||
String fileLink;
|
||||
String title = Beans.get(ArtWorkPrintServiceImpl.class).getFileName(artWork);
|
||||
fileLink =
|
||||
Beans.get(ArtWorkPrintServiceImpl.class)
|
||||
.printArtWork(artWork, ReportSettings.FORMAT_PDF);
|
||||
|
||||
response.setView(ActionView.define(title).add("html", fileLink).map());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="quality" package="com.axelor.apps.quality.db"/>
|
||||
|
||||
<entity name="ArtWork" lang="java">
|
||||
<string name="ref" title="Ref" />
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" required="true"/>
|
||||
<string name="artWorkType" title="Artwork" selection="quality.artwork.type.select"/>
|
||||
<integer name="statusSelect" title="Status" selection="quality.control.art.work.status.select" readonly="true"/>
|
||||
<datetime name="firstDate" title="First validation date" readonly="true"/>
|
||||
<many-to-one name="firstApprovedByUser" ref="com.axelor.auth.db.User" readonly="true" title="First approved by"/>
|
||||
<datetime name="secondDate" title="First validation date" readonly="true"/>
|
||||
<many-to-one name="secondApprovedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Second approved by"/>
|
||||
<many-to-one name="thirdApprovedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Third approved by"/>
|
||||
<datetime name="thirdDate" title="Third validation date" readonly="true"/>
|
||||
<many-to-one name="fourthApprovedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Forth approved by"/>
|
||||
<datetime name="fourthtDate" title="Forth validation date" readonly="true"/>
|
||||
<many-to-one name="artWorkFile" ref="com.axelor.meta.db.MetaFile" title="Artwork file" />
|
||||
<string name="textColor" title="Text color" />
|
||||
<string name="dimensions" title="Dimension" />
|
||||
<string name="varnishing" title="Varnishing" />
|
||||
<string name="weight" title="Weight" />
|
||||
<string name="diameter" title="Diameter" />
|
||||
<string name="nature" title="Nature" />
|
||||
<string name="direction" title="Direction" />
|
||||
<string name="printingSupport" title="Printing support" />
|
||||
<many-to-one name="printingSettings" ref="com.axelor.apps.base.db.PrintingSettings" title="Printing settings"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="true"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
//STATUS SELECT
|
||||
public static final int STATUS_DRAFT = 1;
|
||||
public static final int STATUS_CANCELED = 2;
|
||||
public static final int STATUS_PLANNED = 3;
|
||||
public static final int STATUS_IN_PROGRESS = 4;
|
||||
public static final int STATUS_STANDBY = 5;
|
||||
public static final int STATUS_FINISHED = 6;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<object-views xmlns="http://axelor.com/xml/ns/object-views" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">
|
||||
|
||||
<form name="art-work-form" title="Art work" model="com.axelor.apps.quality.db.ArtWork">
|
||||
<toolbar>
|
||||
<button name="printBtn" title="Print" readonlyIf="!id" icon="fa-print" onClick="com.axelor.apps.quality.web.ArtWorkController:printQualityControl"/>
|
||||
</toolbar>
|
||||
<panel>
|
||||
<field name="statusSelect" showTitle="false" readonly="true" colSpan="12" widget="nav-select" default="1"/>
|
||||
</panel>
|
||||
<panel title="Overview">
|
||||
|
||||
<field name="ref"/>
|
||||
<field name="product"/>
|
||||
<field name="artWorkType"/>
|
||||
<field name="artWorkFile" widget="binary-link"/>
|
||||
<field name="textColor"/>
|
||||
<field name="dimensions"/>
|
||||
<field name="varnishing"/>
|
||||
<field name="printingSupport"/>
|
||||
<field name="weight"/>
|
||||
<field name="diameter"/>
|
||||
<field name="nature"/>
|
||||
<field name="direction"/>
|
||||
<field name="company"/>
|
||||
<field name="printingSettings"/>
|
||||
</panel>
|
||||
<panel-related field="accessConfigList" target="com.axelor.apps.base.db.AccessConfig">
|
||||
<field name="name"/>
|
||||
</panel-related>
|
||||
<panel-related field="dependsOnSet" target="com.axelor.apps.base.db.App">
|
||||
<field name="name"/>
|
||||
</panel-related>
|
||||
<panel name="actionsPanel" sidebar="true">
|
||||
<button name="prepareBtn" title="Graphic Designer Approval" onClick="save,action-importation-folder-record-preparation,save"/>
|
||||
<button name="openedBtn" title="Regulatory Affaires Approval" onClick="save,action-importation-folder-record-entamee,save"/>
|
||||
<button name="validationCoaBtn" title="Quality Control Approval" onClick="save,action-purchase-importation-folder-validation-coa,save,action-whatsapp-logistics" />
|
||||
<button name="logisticBtn" title="Quality Assurance Approval" onClick="save,action-importation-folder-record-logistique,save"/>
|
||||
<button name="logisticBtn" css-btn="info" title="New version" onClick="save"/>
|
||||
</panel>
|
||||
<panel sidebar="true">
|
||||
<field name="firstDate"/>
|
||||
<field name="firstApprovedByUser"/>
|
||||
<field name="secondDate"/>
|
||||
<field name="secondApprovedByUser"/>
|
||||
<field name="thirdApprovedByUser"/>
|
||||
<field name="thirdDate"/>
|
||||
<field name="fourthApprovedByUser"/>
|
||||
<field name="fourthtDate"/>
|
||||
</panel>
|
||||
<panel-mail>
|
||||
<mail-messages limit="4"/>
|
||||
<mail-followers/>
|
||||
</panel-mail>
|
||||
</form>
|
||||
|
||||
|
||||
<grid name="art-work-grid" title="Art works" model="com.axelor.apps.quality.db.ArtWork" edit-icon="true">
|
||||
<field name="ref"/>
|
||||
<field name="product"/>
|
||||
<field name="artWorkType"/>
|
||||
<field name="firstDate"/>
|
||||
<field name="firstApprovedByUser"/>
|
||||
<field name="secondDate"/>
|
||||
<field name="secondApprovedByUser"/>
|
||||
<field name="thirdApprovedByUser"/>
|
||||
<field name="thirdDate"/>
|
||||
<field name="fourthApprovedByUser"/>
|
||||
<field name="fourthtDate"/>
|
||||
<field name="artWorkFile"/>
|
||||
<field name="textColor"/>
|
||||
<field name="dimensions"/>
|
||||
<field name="varnishing"/>
|
||||
<field name="printingSupport"/>
|
||||
<field name="weight"/>
|
||||
<field name="diameter"/>
|
||||
<field name="nature"/>
|
||||
<field name="direction"/>
|
||||
<field name="languageSelect"/>
|
||||
<field name="installOrder"/>
|
||||
<field name="sequence"/>
|
||||
<field name="active"/>
|
||||
<field name="isRolesImported"/>
|
||||
<field name="demoDataLoaded"/>
|
||||
<field name="initDataLoaded"/>
|
||||
<field name="image"/>
|
||||
<field name="modules"/>
|
||||
<field name="description"/>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
</grid>
|
||||
|
||||
|
||||
|
||||
</object-views>
|
||||
Reference in New Issue
Block a user