2
0
forked from Wavyzz/dolibarr

New: Clone product/service composition

This commit is contained in:
Marcos García
2013-06-10 00:11:25 +02:00
parent 9c0fe61a21
commit e727100cf0
5 changed files with 42 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ For users:
- New: Add object_hour as substitution tag for opendocument generation.
- New: Add option MEMBER_PAYONLINE_SENDEMAIL to send email when paypal or paybox payment is done.
- New: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
- New: Clone product/service composition
For translators:
- Normalized sort order of all languages files with english ref file.

View File

@@ -77,6 +77,7 @@ ContractStatusToRun=A mettre en service
ContractNotRunning=This contract is not running
ErrorProductAlreadyExists=A product with reference %s already exists.
ErrorProductBadRefOrLabel=Wrong value for reference or label.
ErrorProductClone=There was a problem while trying to clone the product or service.
Suppliers=Suppliers
SupplierRef=Supplier's product ref.
ShowProduct=Show product
@@ -164,6 +165,7 @@ CloneProduct=Clone product or service
ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b> ?
CloneContentProduct=Clone all main informations of product/service
ClonePricesProduct=Clone main informations and prices
CloneCompositionProduct=Clone product/service composition
ProductIsUsed=This product is used
NewRefForClone=Ref. of new product/service
CustomerPrices=Customers prices

View File

@@ -77,6 +77,7 @@ ContractStatusToRun=A poner en servicio
ContractNotRunning=Este contrato no está en servicio
ErrorProductAlreadyExists=Un producto con la referencia %s ya existe.
ErrorProductBadRefOrLabel=El valor de la referencia o etiqueta es incorrecto
ErrorProductClone=Ha ocurrido un error al intentar clonar el producto o servicio.
Suppliers=Proveedores
SupplierRef=Ref. producto proveedor
ShowProduct=Mostrar producto
@@ -164,6 +165,7 @@ CloneProduct=Clonar producto/servicio
ConfirmCloneProduct=¿Está seguro de querer clonar el producto o servicio <b>%s</b>?
CloneContentProduct=Clonar solamente la información general del producto/servicio
ClonePricesProduct=Clonar la información general y los precios
CloneCompositionProduct=Clonar la composición del producto/servicio
ProductIsUsed=Este producto es utilizado
NewRefForClone=Ref. del nuevo producto/servicio
CustomerPrices=Precios clientes

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2007-2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
*
* 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
@@ -2073,6 +2074,24 @@ class Product extends CommonObject
return 1;
}
function clone_associations($fromId, $toId)
{
$this->db->begin();
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (rowid, fk_product_pere, fk_product_fils, qty)';
$sql.= " SELECT null, $toId, fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association";
$sql.= " WHERE fk_product_pere = '".$fromId."'";
if (! $this->db->query($sql))
{
$this->db->rollback();
return -1;
}
$this->db->commit();
return 1;
}
/**
* Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre
*

View File

@@ -6,6 +6,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Auguria SARL <info@auguria.org>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
*
* 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
@@ -320,6 +321,19 @@ if (empty($reshook))
$id = $object->create($user);
if ($id > 0)
{
if (GETPOST('clone_composition'))
{
$result = $object->clone_associations($originalId, $id);
if ($result < 1)
{
$db->rollback();
setEventMessage($langs->trans('ErrorProductClone'), 'errors');
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId);
exit;
}
}
// $object->clone_fournisseurs($originalId, $id);
$db->commit();
@@ -1234,7 +1248,8 @@ $formquestionclone=array(
'text' => $langs->trans("ConfirmClone"),
array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => $langs->trans("CopyOf").' '.$object->ref, 'size'=>24),
array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true)
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1)
);
// Confirm delete product
@@ -1246,7 +1261,7 @@ if ($action == 'delete' && empty($conf->use_javascript_ajax))
// Clone confirmation
if ($action == 'clone' && empty($conf->use_javascript_ajax))
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600);
}
@@ -1270,7 +1285,7 @@ if ($action == '' || $action == 'view')
if (! empty($conf->use_javascript_ajax))
{
print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span></div>'."\n";
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600);
}
else
{