NEW ADDED IMPORT TOOL FOR PROPOSAL MODULE

Added proposal import functionality in import module
This commit is contained in:
Ahmad Jamaly Rabib 2020-10-01 11:52:56 +06:00 committed by Ahmad Jamaly Rabib
parent f063a144c1
commit 0b35a07290
11 changed files with 207 additions and 1 deletions

View File

@ -5,6 +5,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Ahmad Jamaly Rabib <rabib@metroworks.co.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -254,6 +255,174 @@ class modPropale extends DolibarrModules
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('propal').')';
if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
// Imports
//--------
$r = 0;
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = 'Proposals'; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = ['c' => MAIN_DB_PREFIX . 'propal', 'extra' => MAIN_DB_PREFIX . 'propal_extrafields'];
$this->import_tables_creator_array[$r] = ['c'=>'fk_user_author']; // Fields to store import user id
$this->import_fields_array[$r] = [
'c.ref' => 'Document Ref*',
'c.ref_client' => 'RefCustomer',
'c.fk_soc' => 'ThirdPartyName*',
'c.datec' => 'DateCreation',
'c.datep' => 'DatePropal',
'c.fin_validite' => 'DateEndPropal',
'c.remise_percent' => 'GlobalDiscount',
'c.total_ht' => 'TotalHT',
'c.total' => 'TotalTTC',
'c.fk_statut' => 'Status*',
'c.note_public' => 'Note',
'c.date_livraison' => 'DeliveryDate',
'c.fk_user_valid' => 'ValidatedById'
];
if (! empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['c.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate';
$this->import_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT';
$this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
$import_extrafield_sample = [];
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'propal' AND entity IN (0, " . $conf->entity . ")";
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel;
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'propal'];
$this->import_regex_array[$r] = ['c.ref' => '[^ ]'];
$import_sample = [
'c.ref' => 'PROV0077',
'c.ref_client' => 'Client1',
'c.fk_soc' => 'MyBigCompany',
'c.datec' => '2020-01-01',
'c.datep' => '2020-01-01',
'c.fin_validite' => '2020-01-01',
'c.remise_percent' => '',
'c.total_ht' => '0',
'c.total' => '0',
'c.fk_statut' => '1',
'c.note_public' => '',
'c.date_livraison' => '2020-01-01',
'c.fk_user_valid' => '1',
'c.multicurrency_code' => '',
'c.multicurrency_tx' => '1',
'c.multicurrency_total_ht' => '0',
'c.multicurrency_total_tva' => '0',
'c.multicurrency_total_ttc' => '0'
];
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = ['c.ref'=>'Ref'];
$this->import_convertvalue_array[$r] = [
'c.fk_soc' => [
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
]
];
//Import Proposal Lines
$r++;
$this->import_code[$r] = $this->rights_class.'line_'.$r;
$this->import_label[$r] = "ProposalLine"; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = []; // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = [
'cd' => MAIN_DB_PREFIX . 'propaldet',
'extra' => MAIN_DB_PREFIX . 'propaldet_extrafields'
];
$this->import_fields_array[$r] = [
'cd.fk_propal' => 'Document Ref*',
'cd.fk_parent_line' => 'PrParentLine',
'cd.fk_product' => 'IdProduct',
'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.product_type' => 'TypeOfLineServiceOrProduct',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
'cd.remise' => 'Reduc.',
'cd.price' => 'Price',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
'cd.total_tva' => 'LineTotalVAT',
'cd.total_ttc' => 'LineTotalTTC',
'cd.date_start' => 'Start Date',
'cd.date_end' => 'End Date',
'cd.buy_price_ht' => 'LineBuyPriceHT'
];
if (! empty($conf->multicurrency->enabled)) {
$this->import_fields_array[$r]['cd.multicurrency_code'] = 'Currency';
$this->import_fields_array[$r]['cd.multicurrency_subprice'] = 'CurrencyRate';
$this->import_fields_array[$r]['cd.multicurrency_total_ht'] = 'MulticurrencyAmountHT';
$this->import_fields_array[$r]['cd.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
$import_extrafield_sample = [];
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propaldet' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.' . $obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel;
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'propaldet'];
$this->import_regex_array[$r] = ['cd.product_type' => '[0|1]$'];
$import_sample = [
'cd.fk_propal' => 'PROV(0001)',
'cd.fk_parent_line' => '',
'cd.fk_product' => '',
'cd.label' => '',
'cd.description' => 'Line description',
'cd.product_type' => '1',
'cd.tva_tx' => '0',
'cd.qty' => '2',
'cd.remise_percent' => '0',
'cd.remise' => '0',
'cd.price' => '',
'cd.subprice' => '5000',
'cd.total_ht' => '10000',
'cd.total_tva' => '0',
'cd.total_ttc' => '10100',
'cd.date_start' => '',
'cd.date_end' => '',
'cd.buy_price_ht' => '7000',
'cd.multicurrency_code' => 'JPY',
'cd.multicurrency_tx' => '1',
'cd.multicurrency_total_ht' => '10000',
'cd.multicurrency_total_tva' => '0',
'cd.multicurrency_total_ttc' => '10100'
];
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = ['cd.fk_propal' => 'Quotation Id', 'cd.fk_product' => 'Product Id'];
$this->import_convertvalue_array[$r] = [
'cd.fk_propal' => [
'rule'=>'fetchidfromref',
'file'=>'/comm/propal/class/propal.class.php',
'class'=>'Propal',
'method'=>'fetch'
]
];
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2020 Ahmad Jamaly Rabib <rabib@metroworks.co.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -101,6 +102,8 @@ class Import
// Defined if module is enabled
$enabled = true;
$part = strtolower(preg_replace('/^mod/i', '', $modulename));
// Adds condition for propal module
if ($part === 'propale') $part = 'propal';
if (empty($conf->$part->enabled)) $enabled = false;
if (empty($enabled)) continue;

View File

@ -85,3 +85,7 @@ ProposalCustomerSignature=Written acceptance, company stamp, date and signature
ProposalsStatisticsSuppliers=Vendor proposals statistics
CaseFollowedBy=Case followed by
SignedOnly=Signed only
IdProposal=Proposal ID
IdProduct=Product ID
PrParentLine=Proposal Parent Line
LineBuyPriceHT=Buy Price Amount net of tax for line

View File

@ -85,3 +85,7 @@ ProposalCustomerSignature=Bei Beauftragung: Name in Klarschrift, Ort, Datum, Unt
ProposalsStatisticsSuppliers=Statistik Lieferantenanfragen
CaseFollowedBy=Fall gefolgt von
SignedOnly=nur signiert
IdProposal=Angebots-ID
IdProduct=Produkt ID
PrParentLine=Übergeordnete Zeile des Vorschlags
LineBuyPriceHT=Kaufpreis Betrag abzüglich Steuern für Linie

View File

@ -371,6 +371,7 @@ MulticurrencyPaymentAmount=Payment amount, original currency
MulticurrencyAmountHT=Amount (excl. tax), original currency
MulticurrencyAmountTTC=Amount (inc. of tax), original currency
MulticurrencyAmountVAT=Amount tax, original currency
MulticurrencySubPrice=Amount sub price multi currency
AmountLT1=Amount tax 2
AmountLT2=Amount tax 3
AmountLT1ES=Amount RE
@ -1094,4 +1095,4 @@ PublicVendorName=Public name of vendor
DateOfBirth=Date of birth
SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry=Security token has expired, so action has been canceled. Please try again.
UpToDate=Up-to-date
OutOfDate=Out-of-date
OutOfDate=Out-of-date

View File

@ -84,3 +84,8 @@ ProposalCustomerSignature=Written acceptance, company stamp, date and signature
ProposalsStatisticsSuppliers=Vendor proposals statistics
CaseFollowedBy=Case followed by
SignedOnly=Signed only
IdProposal=Proposal ID
IdProduct=Product ID
PrParentLine=Proposal Parent Line
LineBuyPriceHT=Buy Price Amount net of tax for line

View File

@ -98,3 +98,7 @@ ConfirmMassValidationQuestion = Voulez-vous confirmer la validation des devis br
ConfirmMassSignatureQuestion = Voulez-vous confirmer la signature des devis ouvert selectionnés ?
PropNoProductOrService = devis ne contient pas de produits ni de services
PropsNoProductOrService = devis ne contiennent pas de produits ni de services
IdProposal=ID de proposition
IdProduct=ID produit
PrParentLine=Ligne parent de proposition
LineBuyPriceHT=Prix d'achat Montant net de taxe pour la ligne

View File

@ -85,3 +85,7 @@ ProposalCustomerSignature=承諾書、会社印、日付、署名
ProposalsStatisticsSuppliers=Vendor proposals statistics
CaseFollowedBy=Case followed by
SignedOnly=Signed only
IdProposal=提案番号
IdProduct=製品番号
PrParentLine=提案親ライン
LineBuyPriceHT=購入価格ラインの税控除後の金額

View File

@ -85,3 +85,7 @@ ProposalCustomerSignature=Written acceptance, company stamp, date and signature
ProposalsStatisticsSuppliers=Vendor proposals statistics
CaseFollowedBy=Case followed by
SignedOnly=Signed only
IdProposal=Proposal ID
IdProduct=Product ID
PrParentLine=Proposal Parent Line
LineBuyPriceHT=Buy Price Amount net of tax for line

View File

@ -85,3 +85,7 @@ ProposalCustomerSignature=Văn bản chấp nhận, dấu công ty, ngày và ch
ProposalsStatisticsSuppliers=Thống kê đề xuất nhà cung cấp
CaseFollowedBy=Theo bởi trường hợp
SignedOnly=Signed only
IdProposal=ID đề xuất
IdProduct=ID sản phẩm
PrParentLine=Dòng mẹ đề xuất
LineBuyPriceHT=Giá mua Số lượng ròng của thuế cho dòng

View File

@ -85,3 +85,7 @@ ProposalCustomerSignature=书面接受,公司盖章,日期和签名
ProposalsStatisticsSuppliers=Vendor proposals statistics
CaseFollowedBy=Case followed by
SignedOnly=Signed only
IdProposal=提案编号
IdProduct=产品编号
PrParentLine=提案父行
LineBuyPriceHT=购买价格扣除税额