NEW Add a status on supplier price ref (WIP to close a supplier ref)

This commit is contained in:
Laurent Destailleur 2023-03-28 21:30:08 +02:00
parent 4a0f4f15b9
commit 5b0b874535
6 changed files with 78 additions and 14 deletions

View File

@ -517,7 +517,7 @@ class modProduct extends DolibarrModules
'p.price_base_type' => "PriceBaseType", //price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card
'p.tva_tx' => 'VATRate',
'p.datec' => 'DateCreation',
'p.cost_price' => "CostPrice",
'p.cost_price' => "CostPrice"
);
$this->import_convertvalue_array[$r] = array(
@ -748,6 +748,7 @@ class modProduct extends DolibarrModules
$this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled
}
if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
// Import suppliers prices (note: this code is duplicated in module Service)
$r++;
@ -765,7 +766,8 @@ class modProduct extends DolibarrModules
'sp.tva_tx' => 'VATRate',
'sp.default_vat_code' => 'VATCode',
'sp.delivery_time_days' => 'DeliveryDelay',
'sp.supplier_reputation' => 'SupplierReputation'
'sp.supplier_reputation' => 'SupplierReputation',
'sp.status' => 'Status'
);
if (is_object($mysoc) && $usenpr) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));
@ -827,7 +829,8 @@ class modProduct extends DolibarrModules
'sp.remise_percent'=>'0',
'sp.default_vat_code' => '',
'sp.delivery_time_days' => '5',
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER',
'sp.status' => '1'
);
if (is_object($mysoc) && $usenpr) {
$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));

View File

@ -135,6 +135,9 @@ class ProductFournisseur extends Product
public $packaging;
const STATUS_OPEN = 1;
const STATUS_CANCELED = 0;
/**
* Constructor
@ -685,7 +688,7 @@ class ProductFournisseur extends Product
$sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
$sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
$sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging";
$sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging, pfp.status as pfstatus";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
$sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid";
@ -742,6 +745,7 @@ class ProductFournisseur extends Product
$prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
$prodfourn->packaging = $record["packaging"];
$prodfourn->status = $record["pfstatus"];
if (isModEnabled('barcode')) {
$prodfourn->supplier_barcode = $record["barcode"];
@ -1249,7 +1253,7 @@ class ProductFournisseur extends Product
$label .= $this->displayPriceProductFournisseurLog($logPrices);
}
$url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&token='.newToken().'&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id;
$url = DOL_URL_ROOT.'/product/fournisseurs.php?id='.((int) $this->id).'&action=add_price&token='.newToken().'&socid='.((int) $this->fourn_id).'&rowid='.((int) $this->product_fourn_price_id);
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
@ -1302,6 +1306,46 @@ class ProductFournisseur extends Product
return $result;
}
/**
* Return the label of the status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @param int $type Type of product
* @return string Label of status
*/
public function getLibStatut($mode = 0, $type = 0) // must be compatible with getLibStatut of inherited Product
{
return $this->LibStatut($this->status, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return the status
*
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @param int $type Type of product
* @return string Label of status
*/
public function LibStatut($status, $mode = 0, $type = 0)
{
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule@mymodule");
$this->labelStatus[self::STATUS_OPEN] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
}
$statusType = 'status4';
//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
if ($status == self::STATUS_CANCELED) {
$statusType = 'status6';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
/**
* Private function to log price history
*

View File

@ -376,3 +376,7 @@ UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = 'ZWE';
-- Generate documents on product batch
ALTER TABLE llx_product_lot ADD COLUMN model_pdf varchar(255) AFTER scrapping_date;
ALTER TABLE llx_product_lot ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
ALTER TABLE llx_product_fournisseur_price ADD COLUMN status integer DEFAULT 1;

View File

@ -47,7 +47,6 @@ create table llx_product_fournisseur_price
info_bits integer NOT NULL DEFAULT 0,
fk_user integer,
fk_supplier_price_expression integer, -- Link to the rule for dynamic price calculation
import_key varchar(14), -- Import key
delivery_time_days integer,
supplier_reputation varchar(10),
packaging real DEFAULT NULL,
@ -55,5 +54,7 @@ create table llx_product_fournisseur_price
multicurrency_code varchar(3),
multicurrency_tx double(24,8) DEFAULT 1,
multicurrency_unitprice double(24,8) DEFAULT NULL, -- unit price without tax
multicurrency_price double(24,8) DEFAULT NULL
multicurrency_price double(24,8) DEFAULT NULL,
import_key varchar(14), -- Import key
status integer DEFAULT 1
)ENGINE=innodb;

View File

@ -346,7 +346,7 @@ GoOnMenuToCreateVairants=Go on menu %s - %s to prepare attribute variants (like
UseProductFournDesc=Add a feature to define the product description defined by the vendors (for each vendor reference) in addition to the description for customers
ProductSupplierDescription=Vendor description for the product
UseProductSupplierPackaging=Use the "packaging" feature to round the quantities to some given multiples (when adding/updating line in a vendor documents, recalculate quantities and purchase prices according to the higher multiple set on the purchase prices of a product)
PackagingForThisProduct=Packaging
PackagingForThisProduct=Packaging of quantities
PackagingForThisProductDesc=You will automaticaly purchase a multiple of this quantity.
QtyRecalculatedWithPackaging=The quantity of the line were recalculated according to supplier packaging

View File

@ -507,7 +507,7 @@ if ($id > 0 || $ref) {
$reshook = $hookmanager->executeHooks('formCreateThirdpartyOptions', $parameters, $object, $action);
if (empty($reshook)) {
if (empty($form->result)) {
print '<a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&type=f&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$action).'">';
print '<a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&type=f&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action='.urlencode($action).($action == 'add_price' ? '&token='.newToken() : '')).'">';
print img_picto($langs->trans("CreateDolibarrThirdPartySupplier"), 'add', 'class="marginleftonly"');
print '</a>';
}
@ -909,7 +909,7 @@ END;
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
if ($usercancreate) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$object->id.'&action=add_price&token='.newToken().'">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.((int) $object->id).'&action=add_price&token='.newToken().'">';
print $langs->trans("AddSupplierPrice").'</a>';
}
}
@ -953,7 +953,8 @@ END;
'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => isModEnabled('barcode'), 'checked'=>0, 'position'=>15),
'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => isModEnabled('barcode'), 'checked'=>0, 'position'=>16),
'pfp.packaging'=>array('label'=>$langs->trans("PackagingForThisProduct"), 'enabled' => getDolGlobalInt('PRODUCT_USE_SUPPLIER_PACKAGING'), 'checked'=>0, 'position'=>17),
'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => isModEnabled('barcode'), 'checked'=>1, 'position'=>18),
'pfp.status'=>array('label'=>$langs->trans("Status"), 'enabled' => 1, 'checked'=>0, 'position'=>40),
'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => isModEnabled('barcode'), 'checked'=>1, 'position'=>50),
);
// fetch optionals attributes and labels
@ -1058,7 +1059,11 @@ END;
$nbfields++;
}
if (!empty($arrayfields['pfp.packaging']['checked'])) {
print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, '', $sortfield, $sortorder, 'center ');
$nbfields++;
}
if (!empty($arrayfields['pfp.status']['checked'])) {
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "pfp.status", "", $param, '', $sortfield, $sortorder, 'center ', '', 1);
$nbfields++;
}
if (!empty($arrayfields['pfp.tms']['checked'])) {
@ -1220,18 +1225,25 @@ END;
// Barcode
if (!empty($arrayfields['pfp.barcode']['checked'])) {
print '<td align="right">';
print '<td class="right">';
print $productfourn->supplier_barcode;
print '</td>';
}
// Packaging
if (!empty($arrayfields['pfp.packaging']['checked'])) {
print '<td align="center">';
print '<td class="center">';
print price2num($productfourn->packaging);
print '</td>';
}
// Status
if (!empty($arrayfields['pfp.status']['checked'])) {
print '<td class="center">';
print $productfourn->getLibStatut(3);
print '</td>';
}
// Date modification
if (!empty($arrayfields['pfp.tms']['checked'])) {
print '<td class="right nowraponall">';