massacrtion for updating product prices
This commit is contained in:
parent
29d819be5e
commit
d15493e50d
@ -1240,6 +1240,50 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoadd) {
|
||||||
|
$db->begin();
|
||||||
|
if (GETPOSTISSET('pricevariation')) {
|
||||||
|
$pricepercentage=GETPOST('pricevariation', 'int');
|
||||||
|
if ($pricepercentage == 0) {
|
||||||
|
setEventMessages($langs->trans("RecordsModified", 0), null);
|
||||||
|
} else {
|
||||||
|
foreach ($toselect as $toselectid) {
|
||||||
|
$result = $object->fetch($toselectid);
|
||||||
|
//var_dump($contcats);exit;
|
||||||
|
if ($result > 0) {
|
||||||
|
if ($obj->price_base_type == 'TTC') {
|
||||||
|
$newprice = $object->price_ttc * (100 + $pricepercentage) / 100;
|
||||||
|
$minprice = $object->price_min_ttc;
|
||||||
|
} else {
|
||||||
|
$newprice = $object->price * (100 + $pricepercentage) / 100;
|
||||||
|
$minprice = $object->price_min;
|
||||||
|
}
|
||||||
|
$res = $object->updatePrice($newprice, $obj->price_base_type, $user, $object->tva_tx, $minprice, 0, $object->tva_npr, 0, 0, array(), $object->default_vat_code);
|
||||||
|
if ($res > 0) {
|
||||||
|
$nbok++;
|
||||||
|
} else {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
$error++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
if ($nbok > 0) {
|
||||||
|
setEventMessages($langs->trans("RecordsModified", $nbok), null);
|
||||||
|
}
|
||||||
|
$db->commit();
|
||||||
|
$toselect=array();
|
||||||
|
} else {
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) {
|
if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
$supervisortoset=GETPOST('supervisortoset');
|
$supervisortoset=GETPOST('supervisortoset');
|
||||||
|
|||||||
@ -78,6 +78,23 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($massaction == 'preupdateprice' && isModEnabled('category')) {
|
||||||
|
$formquestion = array();
|
||||||
|
|
||||||
|
$valuefield = '<div style="display: flex; align-items: center; justify-content: flex-end; padding-right: 150px">';
|
||||||
|
$valuefield .= '<input type="number" name="pricevariation" id="pricevariation" min="-100" value="0" style="width: 100px; text-align: right; margin-right: 10px" />%';
|
||||||
|
$valuefield .= '</div>';
|
||||||
|
|
||||||
|
$formquestion[] = array(
|
||||||
|
'type' => 'other',
|
||||||
|
'name' => 'pricevariation',
|
||||||
|
'label' => $langs->trans("PriceVariation"),
|
||||||
|
'value' => $valuefield
|
||||||
|
);
|
||||||
|
|
||||||
|
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmUpdatePrice"), $langs->trans("ConfirmUpdatePriceQuestion", count($toselect)), "updateprice", $formquestion, 1, 0, 200, 500, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if ($massaction == 'presetsupervisor') {
|
if ($massaction == 'presetsupervisor') {
|
||||||
$formquestion = array();
|
$formquestion = array();
|
||||||
|
|
||||||
@ -96,6 +113,7 @@ if ($massaction == 'presetsupervisor') {
|
|||||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmSetSupervisor"), $langs->trans("ConfirmSetSupervisorQuestion", count($toselect)), "setsupervisor", $formquestion, 1, 0, 200, 500, 1);
|
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmSetSupervisor"), $langs->trans("ConfirmSetSupervisorQuestion", count($toselect)), "setsupervisor", $formquestion, 1, 0, 200, 500, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($massaction == 'presend') {
|
if ($massaction == 'presend') {
|
||||||
$langs->load("mails");
|
$langs->load("mails");
|
||||||
|
|
||||||
|
|||||||
@ -1150,9 +1150,12 @@ SetSupervisor=Set Supervisor
|
|||||||
CreateExternalUser=Create external user
|
CreateExternalUser=Create external user
|
||||||
ConfirmAffectTag=Bulk Tag Affect
|
ConfirmAffectTag=Bulk Tag Affect
|
||||||
ConfirmSetSupervisor=Bulk Supervisor Set
|
ConfirmSetSupervisor=Bulk Supervisor Set
|
||||||
|
ConfirmUpdatePrice=Choose a price update percentage
|
||||||
ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)?
|
ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)?
|
||||||
ConfirmSetSupervisorQuestion=Are you sure you want to set supervisor to the %s selected record(s)?
|
ConfirmSetSupervisorQuestion=Are you sure you want to set supervisor to the %s selected record(s)?
|
||||||
|
ConfirmUpdatePriceQuestion=Are you sure you want to update the price of the %s selected record(s)?
|
||||||
CategTypeNotFound=No tag type found for type of records
|
CategTypeNotFound=No tag type found for type of records
|
||||||
|
PriceVariation=Price variation
|
||||||
SupervisorNotFound=Supervisor not found
|
SupervisorNotFound=Supervisor not found
|
||||||
CopiedToClipboard=Copied to clipboard
|
CopiedToClipboard=Copied to clipboard
|
||||||
InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration.
|
InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration.
|
||||||
|
|||||||
@ -416,6 +416,7 @@ ProductsMergeSuccess=Products have been merged
|
|||||||
ErrorsProductsMerge=Errors in products merge
|
ErrorsProductsMerge=Errors in products merge
|
||||||
SwitchOnSaleStatus=Switch on sale status
|
SwitchOnSaleStatus=Switch on sale status
|
||||||
SwitchOnPurchaseStatus=Switch on purchase status
|
SwitchOnPurchaseStatus=Switch on purchase status
|
||||||
|
UpdatePrice=Update price
|
||||||
StockMouvementExtraFields= Extra Fields (stock mouvement)
|
StockMouvementExtraFields= Extra Fields (stock mouvement)
|
||||||
InventoryExtraFields= Extra Fields (inventory)
|
InventoryExtraFields= Extra Fields (inventory)
|
||||||
ScanOrTypeOrCopyPasteYourBarCodes=Scan or type or copy/paste your barcodes
|
ScanOrTypeOrCopyPasteYourBarCodes=Scan or type or copy/paste your barcodes
|
||||||
|
|||||||
@ -1150,9 +1150,12 @@ SetSupervisor=Choisir un superviseur
|
|||||||
CreateExternalUser=Créer utilisateur externe
|
CreateExternalUser=Créer utilisateur externe
|
||||||
ConfirmAffectTag=Affecter les tags en masse
|
ConfirmAffectTag=Affecter les tags en masse
|
||||||
ConfirmSetSupervisor=Choisir un superviseur en masse
|
ConfirmSetSupervisor=Choisir un superviseur en masse
|
||||||
|
ConfirmUpdatePrice=Choisir un pourcentage de hausse/baisse des prix
|
||||||
ConfirmAffectTagQuestion=Êtes-vous sur de vouloir affecter ces catégories aux %s lignes sélectionnées ?
|
ConfirmAffectTagQuestion=Êtes-vous sur de vouloir affecter ces catégories aux %s lignes sélectionnées ?
|
||||||
ConfirmSetSupervisorQuestion=Êtes-vous sur de vouloir affecter ce superviseur aux %s lignes sélectionnées ?
|
ConfirmSetSupervisorQuestion=Êtes-vous sur de vouloir affecter ce superviseur aux %s lignes sélectionnées ?
|
||||||
|
ConfirmUpdatePriceQuestion=Êtes-vous sur de vouloir mettre à jour les prix des %s lignes sélectionnées ?
|
||||||
CategTypeNotFound=Aucun type de tag trouvé pour ce type d'enregistrements
|
CategTypeNotFound=Aucun type de tag trouvé pour ce type d'enregistrements
|
||||||
|
PriceVariation=Variation de prix
|
||||||
SupervisorNotFound=Supervisuer non trouvé
|
SupervisorNotFound=Supervisuer non trouvé
|
||||||
CopiedToClipboard=Copié dans le presse-papier
|
CopiedToClipboard=Copié dans le presse-papier
|
||||||
InformationOnLinkToContract=Ce montant n’est que le total de toutes les lignes du contrat. Aucune notion de temps n’est prise en considération.
|
InformationOnLinkToContract=Ce montant n’est que le total de toutes les lignes du contrat. Aucune notion de temps n’est prise en considération.
|
||||||
|
|||||||
@ -416,6 +416,7 @@ ProductsMergeSuccess=Produits fusionnés
|
|||||||
ErrorsProductsMerge=Erreur lors de la fusion des produits
|
ErrorsProductsMerge=Erreur lors de la fusion des produits
|
||||||
SwitchOnSaleStatus=Basculer le statut En vente
|
SwitchOnSaleStatus=Basculer le statut En vente
|
||||||
SwitchOnPurchaseStatus=Basculer le statut En achat
|
SwitchOnPurchaseStatus=Basculer le statut En achat
|
||||||
|
UpdatePrice=Mettre à jour le prix
|
||||||
StockMouvementExtraFields= Champs supplémentaires (mouvement de stock)
|
StockMouvementExtraFields= Champs supplémentaires (mouvement de stock)
|
||||||
InventoryExtraFields= Attributs supplémentaires (inventaire)
|
InventoryExtraFields= Attributs supplémentaires (inventaire)
|
||||||
ScanOrTypeOrCopyPasteYourBarCodes=Scannez ou tapez ou copiez/collez vos codes-barres
|
ScanOrTypeOrCopyPasteYourBarCodes=Scannez ou tapez ou copiez/collez vos codes-barres
|
||||||
|
|||||||
@ -310,7 +310,6 @@ if (GETPOST('cancel', 'alpha')) {
|
|||||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||||
$massaction = '';
|
$massaction = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($reshook < 0) {
|
if ($reshook < 0) {
|
||||||
@ -737,11 +736,12 @@ if ($resql) {
|
|||||||
if ($user->rights->{$rightskey}->creer) {
|
if ($user->rights->{$rightskey}->creer) {
|
||||||
$arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus");
|
$arrayofmassactions['switchonsalestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnSaleStatus");
|
||||||
$arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus");
|
$arrayofmassactions['switchonpurchasestatus'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SwitchOnPurchaseStatus");
|
||||||
|
$arrayofmassactions['preupdateprice'] = img_picto('', 'edit', 'class="pictofixedwidth"').$langs->trans("UpdatePrice");
|
||||||
}
|
}
|
||||||
if (isModEnabled('category') && $user->rights->{$rightskey}->creer) {
|
if (isModEnabled('category') && $user->rights->{$rightskey}->creer) {
|
||||||
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
|
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
|
||||||
}
|
}
|
||||||
if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields'))) {
|
if (in_array($massaction, array('presend', 'predelete','preaffecttag', 'edit_extrafields', 'preupdateprice'))) {
|
||||||
$arrayofmassactions = array();
|
$arrayofmassactions = array();
|
||||||
}
|
}
|
||||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user