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'] = '
'; + $jsData['buttons'].= ''; + $jsData['buttons'].= ''; + } + + + + ?> 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)?'