diff --git a/ChangeLog.md b/ChangeLog.md index 01101171..b0268691 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file. # [Unreleased] - +- NEW : Use v20 dropdown for action buttons & fix buttons orders - *01/10/2024* - 3.27.0 + Use SUBTOTAL_FORCE_EXPLODE_ACTION_BTN hidden conf to disable behavior +- FIX : Compat V20 : Document col missing for title for NC - *16/09/2024* - 3.26.1 +- NEW : Add more order to invoice massaction option - *04/09/2024* - 3.26.0 + Allow adding list of shipping ref to title block # Release 3.25 - 24/07/2024 diff --git a/class/actions_subtotal.class.php b/class/actions_subtotal.class.php index c3b74445..7516485d 100644 --- a/class/actions_subtotal.class.php +++ b/class/actions_subtotal.class.php @@ -333,25 +333,47 @@ function printNewFormat(&$object, &$conf, &$langs, $idvar) 'conf' => array( 'SUBTOTAL_USE_NEW_FORMAT' => getDolGlobalInt('SUBTOTAL_USE_NEW_FORMAT'), 'MAIN_VIEW_LINE_NUMBER' => getDolGlobalInt('MAIN_VIEW_LINE_NUMBER'), - 'token' => ((float) DOL_VERSION < 11.0) ? $_SESSION['newtoken'] : newToken() + 'token' => ((float) DOL_VERSION < 11.0) ? $_SESSION['newtoken'] : newToken(), + 'groupBtn' => intval(DOL_VERSION) < 20.0 || getDolGlobalInt('SUBTOTAL_FORCE_EXPLODE_ACTION_BTN') ? 0 : 1 ), 'langs' => array( 'Level' => $langs->trans('Level'), - 'Position' => $langs->transnoentities('Position') + 'Position' => $langs->transnoentities('Position'), + 'AddTitle' => $langs->trans('AddTitle'), + 'AddSubTotal' => $langs->trans('AddSubTotal'), + 'AddFreeText' => $langs->trans('AddFreeText'), ) ); + + $jsData['buttons'] = dolGetButtonAction('', $langs->trans('SubtotalsAndTitlesActionBtnLabel'), 'default', [ + ['attr' => [ 'rel' => 'add_title_line'], 'id' => 'add_title_line', 'urlraw' =>'#', 'label' => $langs->trans('AddTitle'), 'perm' => 1], + ['attr' => [ 'rel' => 'add_total_line'], 'id' => 'add_total_line', 'urlraw' =>'#', 'label' => $langs->trans('AddSubTotal'), 'perm' => 1], + ['attr' => [ 'rel' => 'add_free_text'], 'id' => 'add_free_text', 'urlraw' =>'#', 'label' => $langs->trans('AddFreeText'), 'perm' => 1], + ], 'subtotal-actions-buttons-dropdown'); + + if(empty($jsData['conf']['groupBtn'])) { + $jsData['buttons'] = '
'.$langs->trans('AddTitle').'
'; + $jsData['buttons'].= '
'.$langs->trans('AddSubTotal').'
'; + $jsData['buttons'].= '
'.$langs->trans('AddFreeText').'
'; + } + + + + ?> diff --git a/class/subtotal.class.php b/class/subtotal.class.php index ebe3474f..73e2c34a 100644 --- a/class/subtotal.class.php +++ b/class/subtotal.class.php @@ -101,10 +101,11 @@ static function showQtyForObjectLine($line, $show_by_default = false) { * @param string $label * @param int $qty * @param int $rang + * @param string $desc * @return int * */ - static function addSubTotalLine(&$object, $label, $qty, $rang=-1) { + static function addSubTotalLine(&$object, $label, $qty, $rang=-1, $desc = '') { $res = 0; @@ -124,7 +125,6 @@ static function addSubTotalLine(&$object, $label, $qty, $rang=-1) { } else { - $desc = ''; $TNotElements = array ('invoice_supplier', 'order_supplier'); if ((float) DOL_VERSION < 6 || $qty==50 && !in_array($object->element, $TNotElements)) { @@ -269,16 +269,17 @@ public static function addSubtotalMissing(&$object, $level_new_title) } } - public static function addTitle(&$object, $label, $level, $rang=-1) + public static function addTitle(&$object, $label, $level, $rang=-1, $desc = '') /** * @param CommonObject $object * @param string $label * @param int $level * @param int $rang + * @param string $desc * @return int */ { - return self::addSubTotalLine($object, $label, $level, $rang); + return self::addSubTotalLine($object, $label, $level, $rang, $desc); } public static function addTotal(&$object, $label, $level, $rang=-1) diff --git a/core/modules/modSubtotal.class.php b/core/modules/modSubtotal.class.php index 3fae07af..0570a90a 100644 --- a/core/modules/modSubtotal.class.php +++ b/core/modules/modSubtotal.class.php @@ -67,7 +67,7 @@ public function __construct($db) // Possible values for version are: 'development', 'experimental' or version - $this->version = '3.25.2'; + $this->version = '3.27.0'; // Url to the file with your last numberversion of this module diff --git a/core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php b/core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php index 3d2df9ec..ff1849f2 100644 --- a/core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php +++ b/core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php @@ -340,10 +340,16 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf } $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label); + $desc = ''; + + if(GETPOST('subtotal_add_shipping_list_to_title_desc', 'int')){ + $desc = $this->getShippingList($commande->id); + } + if(!empty($current_fk_commande)) { $subtotal_skip = true; - TSubtotal::addTitle($facture, $label, 1, $rang); + TSubtotal::addTitle($facture, $label, 1, $rang, $desc); $rang++; } } @@ -1010,4 +1016,91 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf return 0; } + + + + + /** + * List BL ref + * @param int $orderId + * @return string + */ + private function getShippingList($orderId) + { + $refBlList = array(); + $refExpList = array(); + + if(!function_exists('isModEnabled')){ + return ''; + } + + if (!isModEnabled('expedition')) { + return ''; + } + + // LIST SHIPPING LINKED TO ORDER + $sqlShip = "SELECT fk_target FROM `".MAIN_DB_PREFIX."element_element` WHERE `targettype` = 'shipping' AND sourcetype = 'commande' AND fk_source=".intval($orderId)." ORDER BY `fk_source` ASC"; + + $resultShip = $this->db->query($sqlShip); + if ($resultShip) + { + while ($shipping = $this->db->fetch_object($resultShip) ) + { + + if (isModEnabled('delivery')) { + + // SELECT LIVRAISON LINKED TO SHIPPING + $sqlBl = "SELECT liv.ref + FROM `".MAIN_DB_PREFIX."element_element` el + JOIN `".MAIN_DB_PREFIX."livraison` liv ON ( el.fk_target = liv.rowid ) + WHERE el.`targettype` = 'delivery' + AND el.sourcetype = 'shipping' + AND el.fk_source=".$shipping->fk_target." + AND liv.fk_statut = 1 + ORDER BY el.`fk_target` ASC"; + + $resultDelivery = $this->db->query($sqlBl); + if ($resultDelivery) + { + while ($delivery = $this->db->fetch_object($resultDelivery) ) + { + $refBlList[] = $delivery->ref; + } + } + + } + + + // SELECT SHIPPING REF + $sqlExp = "SELECT exp.ref + FROM `" . MAIN_DB_PREFIX . "expedition` exp + WHERE exp.`rowid` =" . $shipping->fk_target; + + $resultExp = $this->db->query($sqlExp); + if ($resultExp) { + $exp = $this->db->fetch_object($resultExp); + $refExpList[] = $exp->ref; + } + + } + } + + global $langs; + $langs->load('subtotal@subtotal'); + $refList = array_merge($refBlList,$refExpList); + $output = ''; + + + if(!empty($refExpList)){ + $objectLabel = count($refExpList)>1?$langs->trans('LinkedShippings'):$langs->trans('LinkedShipping'); + $output.= (!empty($output)?'
':'').''.$objectLabel.' : '.implode(', ', $refList) ; + } + + if(!empty($refBlList)){ + $objectLabel = count($refBlList)>1?$langs->trans('LinkedDeliveries'):$langs->trans('LinkedDelivery'); + $output.= (!empty($output)?'
':'').''.$objectLabel.' : '.implode(', ', $refList) ; + } + + return $output; + } } diff --git a/langs/en_US/subtotal.lang b/langs/en_US/subtotal.lang index 112e19f6..02d3625b 100644 --- a/langs/en_US/subtotal.lang +++ b/langs/en_US/subtotal.lang @@ -135,3 +135,13 @@ SUBTOTAL_DISABLE_SUMMARY = Disable document "quick summary menu" (appears in lef Subtotal_HideAll=Hide all lines Subtotal_ShowAll=Show all lines DISPLAY_MARGIN_ON_SUBTOTALS=Displays margin on subtotals lines + +LinkedShippings = Linked shipping orders +LinkedShipping = Linked shipping order +LinkedDeliveries = Linked delivery notes +LinkedDelivery = Linked delivery note +SubtotalOptions = Subtotal options +AddShippingListToTile = Add the reference list of related delivery or shipping notes to the title block description. +UseHiddenConfToAutoCheck = To pre-set the default, you can activate the settings + +SubtotalsAndTitlesActionBtnLabel = Title & Sub total diff --git a/langs/es_ES/subtotal.lang b/langs/es_ES/subtotal.lang index 622f2d29..a2889537 100644 --- a/langs/es_ES/subtotal.lang +++ b/langs/es_ES/subtotal.lang @@ -131,3 +131,11 @@ SubtotalExperimentalZone = Configuraciones experimentales u obsoletas SUBTOTAL_HIDE_OPTIONS_TITLE=Ocultar opciones de título SUBTOTAL_HIDE_OPTIONS_BREAK_PAGE_BEFORE=Ocultar la opción de salto de página SUBTOTAL_HIDE_OPTIONS_BUILD_DOC=Ocultar las opciones de generación de documentos + +LinkedShippings = Órdenes de envío vinculadas +LinkedShipping = Orden de envío vinculada +LinkedDeliveries = Albaranes vinculados +LinkedDelivery = Albarán vinculado +SubtotalOptions = Parámetros Subtotal +AddShippingListToTile = Añada la lista de referencia de los albaranes o notas de entrega relacionados a la descripción del bloque de título. +UseHiddenConfToAutoCheck = Para que la casilla se marque por defecto, puede activar el siguiente ajuste en "Ótras configuraciones" diff --git a/langs/fr_FR/subtotal.lang b/langs/fr_FR/subtotal.lang index 2b44a8fc..1b07ce85 100644 --- a/langs/fr_FR/subtotal.lang +++ b/langs/fr_FR/subtotal.lang @@ -143,4 +143,12 @@ DISPLAY_MARGIN_ON_SUBTOTALS=Afficher les marges sur les lignes de sous-totaux HideSubtitleOnFold = Cacher les lignes de titre et sous total enfant KeepSubtitleDisplayOnFold = Afficher les lignes de titre et sous total enfant SUBTOTAL_BLOC_FOLD_MODE = Comportement à adopter lorsque l'on cache un bloc de titre +LinkedShippings = Bons d'expéditions liés +LinkedShipping = Bon d'expédition lié +LinkedDeliveries = Bons de livraison liés +LinkedDelivery = Bon de livraison lié +SubtotalOptions = Options sous-total +AddShippingListToTile = Ajouter à la description du bloc titre la liste des références des bons d'expédition ou de livraison liés +UseHiddenConfToAutoCheck = Pour précocher par défaut vous pouvez activer la configuration divers ErrorClassXNotExists = ERREUR : la classe php %s n'est pas chargée +SubtotalsAndTitlesActionBtnLabel = Titre & Sous total