Skip to content

Commit

Permalink
NEW add remove confirmation for purchase order
Browse files Browse the repository at this point in the history
  • Loading branch information
ksar-ksar committed Jan 7, 2023
1 parent a1b3cc3 commit 5b50bcb
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 14 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# CHANGELOG REMOVECONF FOR <a href="https://www.dolibarr.org">DOLIBARR ERP CRM</a>
## 2.2.0
New Suppress Supplier Order confirmation pop-ups

## 2.1.0
New suppress BOM confirmation pop-ups
New suppress MO confirmation pop-ups
Expand Down
94 changes: 88 additions & 6 deletions class/actions_removeconf.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2018-2021 ksar <ksar.ksar@gmail.com>
* Copyright (C) 2020-2020 akene <allo@iouston.com>
* Copyright (C) 2021-2021 Erik van Berkum <erikvanberkum@gmail.com>
/* Copyright (C) 2018-2023 ksar <ksar.ksar@gmail.com>
* Copyright (C) 2020-2020 akene <allo@iouston.com>
* Copyright (C) 2021-2021 Erik van Berkum <erikvanberkum@gmail.com>
* Copyright (C) 2023 Regis Houssin <regis.houssin@inodbox.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
Expand Down Expand Up @@ -85,6 +86,16 @@
setdraft confirm_setdraft DraftMO $_SERVER["PHP_SELF"] . '?id=' . $object->id
reopen confirm_reopen ReopenMO $_SERVER["PHP_SELF"] . '?id=' . $object->id
deleteline confirm_deleteline DeleteMOine $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $parameters['lineid']
fourn\commande\card ordersuppliercard, globalcard
delete confirm_delete DeleteOrder $_SERVER["PHP_SELF"].'?id='.$object->id
clone confirm_clone WARNING, need to select a third party, not possible to cancel
valid confirm_valid ValidateOrder $_SERVER["PHP_SELF"].'?id='.$object->id
approve confirm_approve ApproveThisOrder $_SERVER['PHP_SELF']."?id=".$object->id WARNING, if stock enabled, warehouse to be selected, not possible to cancel
approve2 confirm_approve2 ApproveThisOrder $_SERVER['PHP_SELF']."?id=".$object->id WARNING, if stock enabled, warehouse to be selected, not possible to cancel
refuse confirm_refuse DenyingThisOrder $_SERVER['PHP_SELF']."?id=$object->id" WARNING, need to indicate the Reason, Reason will be blank
cancel confirm_cancel Cancel $_SERVER['PHP_SELF']."?id=$object->id" WARNING, need to indicate the Reason, Reason will be blank
commande confirm_commande WARNING, a lot of things to send by POST, not possible to cancel
ask_deleteline confirm_deleteline DeleteProductLine $_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid
*/
Expand Down Expand Up @@ -197,7 +208,7 @@ public function formConfirm($parameters, &$object, &$action, $hookmanager)
$qualified_for_stock_change=$object->hasProductsOrServices(1);
}

if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change)
{
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
$warehouse = new Entrepot($this->db);
Expand Down Expand Up @@ -426,7 +437,8 @@ public function formConfirm($parameters, &$object, &$action, $hookmanager)

// BOM
if (strpos($parameters['context'], 'bomcard') !== false){
dol_syslog(get_class($this).'::Context = bomcard', LOG_DEBUG, 1 , '', '');

dol_syslog(get_class($this).'::Context = bomcard', LOG_DEBUG, 1 , '', '');

//Bom Delete
if (($action == 'delete') && ($user->rights->removeconf->delete_bom)){
Expand Down Expand Up @@ -481,7 +493,8 @@ public function formConfirm($parameters, &$object, &$action, $hookmanager)

// MO
if (strpos($parameters['context'], 'mocard') !== false){
dol_syslog(get_class($this).'::Context = mocard', LOG_DEBUG, 1 , '', '');

dol_syslog(get_class($this).'::Context = mocard', LOG_DEBUG, 1 , '', '');

//MO Delete
if (($action == 'delete') && ($user->rights->removeconf->delete_mo)){
Expand Down Expand Up @@ -527,6 +540,75 @@ public function formConfirm($parameters, &$object, &$action, $hookmanager)
}
}

// Purchase order
if (strpos($parameters['context'], 'ordersuppliercard') !== false){

dol_syslog(get_class($this).'::Context = ordersuppliercard', LOG_DEBUG, 1 , '', '');

// Purchase order Delete
if (($action == 'delete') && ($user->rights->removeconf->delete_purchase_order)){
$this->results = true;
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$action_confirm = 'confirm_delete';
dol_syslog(get_class($this).'::action = delete', LOG_DEBUG, 1 , '', '');
}
// Purchase order validate and approve
if (($action == 'valid') && ($user->rights->removeconf->validate_purchase_order)){
$this->results = true;
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$action_confirm = 'confirm_valid';
dol_syslog(get_class($this).'::action = valid', LOG_DEBUG, 1 , '', '');
}
// Purchase order approve
if (($action == 'approve' || $action == 'approve2') && ($user->rights->removeconf->approve_purchase_order)){
$qualified_for_stock_change = 0;
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$qualified_for_stock_change=$object->hasProductsOrServices(2);
}else{
$qualified_for_stock_change=$object->hasProductsOrServices(1);
}

if (isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change)
{
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
$warehouse = new Entrepot($this->db);
$warehouse_array = $warehouse->list_array();
if (count($warehouse_array) == 1) {
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&idwarehouse=' . key($warehouse_array);
$this->results = true;
$action_confirm = "confirm_".$action;
dol_syslog(get_class($this).'::action = '.$action, LOG_DEBUG, 1 , '', '');
}
}else{
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id ;
$this->results = true;
$action_confirm = "confirm_".$action;
dol_syslog(get_class($this).'::action = '.$action, LOG_DEBUG, 1 , '', '');
}
}
// Purchase order refuse
if (($action == 'refuse') && ($user->rights->removeconf->refuse_purchase_order)){
$this->results = true;
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$action_confirm = 'confirm_refuse';
dol_syslog(get_class($this).'::action = refuse', LOG_DEBUG, 1 , '', '');
}
// Purchase order cancel
if (($action == 'cancel') && ($user->rights->removeconf->cancel_purchase_order)){
$this->results = true;
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
$action_confirm = 'confirm_cancel';
dol_syslog(get_class($this).'::action = cancel', LOG_DEBUG, 1 , '', '');
}
// Purchase order delete line
if (($action == 'ask_deleteline') && ($user->rights->removeconf->delete_purchase_order_line)){
$this->results = true;
$page = $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $parameters['lineid'];
$action_confirm = 'confirm_deleteline';
dol_syslog(get_class($this).'::action = deleteline', LOG_DEBUG, 1 , '', '');
}
}

if (! $error) {
if ($this->results == true){
$pageyes=$page.(preg_match('/\?/',$page)?'&':'?').'action='.$action_confirm.'&confirm=yes';
Expand Down
49 changes: 46 additions & 3 deletions core/modules/modremoveconf.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2021 ksar <ksar.ksar@gmail.com>
* Copyright (C) 2018-2023 ksar <ksar.ksar@gmail.com>
* Copyright (C) 2020-2020 akene <allo@iouston.com>
* Copyright (C) 2021-2021 Erik van Berkum <erikvanberkum@gmail.com>
*
Expand Down Expand Up @@ -67,7 +67,7 @@ public function __construct($db)
$this->editor_url = 'https://github.com/ksar-ksar/';

// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = '2.1.0';
$this->version = '2.2.0';

// Url to the file with your last number version of this module
$this->url_last_version = 'https://raw.githubusercontent.com/ksar-ksar/Dolibarr_removeconf/master/version.txt';
Expand All @@ -92,7 +92,7 @@ public function __construct($db)
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("removeconf@removeconf");
$this->phpmin = array(5,3); // Minimum version of PHP required by module
$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
Expand Down Expand Up @@ -384,6 +384,49 @@ public function __construct($db)
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'delete_mo_line';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 20730038;
$this->rights[$r][1] = 'Delete purchase order without confirmation';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'delete_purchase_order';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 20730039;
$this->rights[$r][1] = 'Validate and approve purchase order without confirmation';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'validate_purchase_order';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 20730040;
$this->rights[$r][1] = 'Approve purchase order without confirmation';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'approve_purchase_order';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 20730041;
$this->rights[$r][1] = 'Refuse purchase order without confirmation';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'refuse_purchase_order';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 20730042;
$this->rights[$r][1] = 'Cancel purchase order without confirmation';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'cancel_purchase_order';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 20730043;
$this->rights[$r][1] = 'Delete a purchase order line without confirmation';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'delete_purchase_order_line';
$this->rights[$r][5] = '';
$r++;

// Main menu entries
$this->menu = array(); // List of menus to add
Expand Down
9 changes: 7 additions & 2 deletions langs/en_US/removeconf.lang
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ModuleremoveconfDesc = Allows administrators to remove some confirmation pop-up
#
About = About
removeconfAbout = About remove confirmation pop-up
removeconfAboutPage = Module that allows administrators to remove some confirmation pop-up.<br /> By default nothing is removed, need to activate removal in user permissions
removeconfAboutPage = Module that allows administrators to remove some confirmation pop-up.<br /> By default nothing is removed, need to activate removal in user permissions <br /> Initial idea module done by ksar, enhanced by the Dolibarr community <3
ForAnyQuestions = If you have any question please send an email to

#
Expand Down Expand Up @@ -71,4 +71,9 @@ Permission20730034 = Clone MO without confirmation
Permission20730035 = Back to draft MO without confirmation
Permission20730036 = Reopen MO without confirmation
Permission20730037 = Delete MO line without confirmation

Permission20730038 = Delete purchase order without confirmation
Permission20730039 = Validate and approve purchase order without confirmation
Permission20730040 = Approve purchase order without confirmationn<br/> <b style="color: red">WARNING : When using several warehouses, the confirmation form will show</b>
Permission20730041 = Refuse purchase order without confirmation
Permission20730042 = Cancel purchase order without confirmation
Permission20730043 = Delete a purchase order line without confirmation
10 changes: 8 additions & 2 deletions langs/fr_FR/removeconf.lang
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ModuleremoveconfDesc = Permet à l'administrateur de désactiver certains pop-up
#
About = À propos
removeconfAbout = À propos du module enlever les pop-up de confirmation
removeconfAboutPage = Permet à l'administrateur de désactiver certains pop-up de confirmation pour les utilisateurs. <br />Par défaut, aucuns pop-ups n'est supprimé, il faut activer la suppression dans les permissions des utilisateurs.
removeconfAboutPage = Permet à l'administrateur de désactiver certains pop-up de confirmation pour les utilisateurs. <br />Par défaut, aucuns pop-ups n'est supprimé, il faut activer la suppression dans les permissions des utilisateurs. <br /> Module original crée par ksar, ammélioré par la communautée Dolibarr <3
ForAnyQuestions = Si vous avez des question, envoyer un email à

#
Expand Down Expand Up @@ -69,4 +69,10 @@ Permission20730033 = Valider les ordres de fabrication sans confirmation
Permission20730034 = Cloner les ordres de fabrication sans confirmation
Permission20730035 = Retour au brouillon pour les ordres de fabrication sans confirmation
Permission20730036 = Rouvrir les ordres de fabrication sans confirmation
Permission20730037 = Supprimer les lignes des ordres de fabrication sans confirmation
Permission20730037 = Supprimer les lignes des ordres de fabrication sans confirmation
Permission20730038 = Supprimer les commandes fournisseurs sans confirmation
Permission20730039 = Valider et approuver les commandes fournisseurs sans confirmation
Permission20730040 = Approuver les commandes fournisseurs sans confirmation
Permission20730041 = Refuse les commandes fournisseurs sans confirmation
Permission20730042 = Annuler les commandes fournisseurs sans confirmation
Permission20730043 = Supprimer les lignes des commandes fournisseurs sans confirmation
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0

0 comments on commit 5b50bcb

Please sign in to comment.