2014-05-05 12:30:08 +00:00
< ? php
2018-10-27 12:43:12 +00:00
/* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2014-05-05 15:59:43 +00:00
* Copyright ( C ) 2010 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2014-05-05 12:30:08 +00:00
* Copyright ( C ) 2012 - 2013 Christophe Battarel < christophe . battarel @ altairis . fr >
2014-11-14 15:43:49 +00:00
* Copyright ( C ) 2012 Cédric Salvador < csalvador @ gpcsolutions . fr >
2015-01-27 11:53:02 +00:00
* Copyright ( C ) 2014 Florian Henry < florian . henry @ open - concept . pro >
2014-11-14 15:43:49 +00:00
* Copyright ( C ) 2014 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2016-07-23 14:37:21 +00:00
* Copyright ( C ) 2015 - 2016 Marcos García < marcosgdf @ gmail . com >
2026-06-28 11:43:41 +00:00
* Copyright ( C ) 2018 - 2026 Frédéric France < frederic . france @ free . fr >
2024-06-18 19:24:16 +00:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
* Copyright ( C ) 2019 Nicolas ZABOURI < info @ inovea - conseil . com >
* Copyright ( C ) 2022 OpenDSI < support @ open - dsi . fr >
2024-06-18 19:29:51 +00:00
* Copyright ( C ) 2022 Gauthier VERDOL < gauthier . verdol @ atm - consulting . fr >
2024-06-18 19:25:00 +00:00
* Copyright ( C ) 2024 Alexandre Spangaro < alexandre @ inovea - conseil . com >
2026-04-13 10:50:23 +00:00
* Copyright ( C ) 2025 - 2026 MDW < mdeweerd @ users . noreply . github . com >
2025-09-07 23:37:33 +00:00
* Copyright ( C ) 2025 Lenin Rivas < lenin . rivas777 @ gmail . com >
2026-07-31 16:48:34 +00:00
* Copyright ( C ) 2026 Jose MARTINEZ < jose . martinez @ pichinov . com >
2014-05-05 12:30:08 +00:00
*
* 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
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2014-05-05 12:30:08 +00:00
*/
2025-07-18 17:50:22 +00:00
2024-11-04 22:53:20 +00:00
/**
2025-07-18 17:50:22 +00:00
* @ var Conf $conf
2025-08-17 14:32:09 +00:00
* @ var CommonObject | Facture $this
2024-11-04 22:53:20 +00:00
* @ var CommonObject $object
* @ var CommonObjectLine $line
2026-04-13 10:50:23 +00:00
* @ var ? ExtraFields $extrafields
2024-11-10 22:47:14 +00:00
* @ var Form $form
2024-11-04 22:53:20 +00:00
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
2025-07-18 17:50:22 +00:00
* @ var Societe $buyer
* @ var Societe $seller
*
* @ var string $action
* @ var string $usehm
* @ var int $dateSelector
* @ var int $forceall ( 0 by default , 1 for supplier invoices / orders )
* @ var int $senderissupplier ( 0 by default , 1 or 2 for supplier invoices / orders )
* @ var int $inputalsopricewithtax ( 0 by default , 1 to also show column with unit price including tax )
2024-11-04 22:53:20 +00:00
*/
2025-07-18 17:50:22 +00:00
2017-12-21 12:32:16 +00:00
// Protection to avoid direct call of template
2019-11-14 11:09:15 +00:00
if ( empty ( $object ) || ! is_object ( $object )) {
2019-11-30 11:49:31 +00:00
print " Error: this template page cannot be called directly as an URL " ;
exit ;
2017-12-21 12:32:16 +00:00
}
2023-01-10 20:46:11 +00:00
2025-01-13 19:04:35 +00:00
'
2025-08-17 14:32:09 +00:00
@ phan - var - force CommonObject | Facture $this
2025-01-13 19:04:35 +00:00
@ phan - var - force CommonObject $object
2025-11-01 16:47:28 +00:00
@ phan - var - force CommonObjectLine $line
2026-04-13 10:50:23 +00:00
@ phan - var - force ? ExtraFields $extrafields
2025-01-13 19:04:35 +00:00
@ phan - var - force Societe $buyer
@ phan - var - force Societe $seller
@ phan - var - force int < 0 , 1 > $usehm
' ;
2024-02-21 17:14:29 +00:00
2019-11-14 11:09:15 +00:00
$usemargins = 0 ;
2022-09-25 04:03:47 +00:00
if ( isModEnabled ( 'margin' ) && ! empty ( $object -> element ) && in_array ( $object -> element , array ( 'facture' , 'facturerec' , 'propal' , 'commande' ))) {
2019-11-30 11:49:31 +00:00
$usemargins = 1 ;
2015-11-15 17:23:42 +00:00
}
2021-02-23 21:03:23 +00:00
if ( ! isset ( $dateSelector )) {
global $dateSelector ; // Take global var only if not already defined into function calling (for example formAddObjectLine)
}
2017-09-10 23:20:15 +00:00
global $forceall , $forcetoshowtitlelines , $senderissupplier , $inputalsopricewithtax ;
2023-01-10 20:46:11 +00:00
global $mysoc ;
2022-08-13 17:30:26 +00:00
2021-02-23 21:03:23 +00:00
if ( ! isset ( $dateSelector )) {
$dateSelector = 1 ; // For backward compatibility
} elseif ( empty ( $dateSelector )) {
$dateSelector = 0 ;
}
if ( empty ( $forceall )) {
$forceall = 0 ;
}
if ( empty ( $senderissupplier )) {
$senderissupplier = 0 ;
}
if ( empty ( $inputalsopricewithtax )) {
$inputalsopricewithtax = 0 ;
}
2019-05-20 12:41:47 +00:00
// Define colspan for the button 'Add'
2019-11-14 11:09:15 +00:00
$colspan = 3 ; // Columns: total ht + col edit + col delete
2025-11-05 20:24:19 +00:00
if ( isModEnabled ( " multicurrency " ) && $this -> multicurrency_code && $this -> multicurrency_code != $conf -> currency ) {
2021-02-23 21:03:23 +00:00
$colspan ++ ; //Add column for Total (currency) if required
}
2022-02-07 13:34:27 +00:00
if ( in_array ( $object -> element , array ( 'propal' , 'commande' , 'order' , 'facture' , 'facturerec' , 'invoice' , 'supplier_proposal' , 'order_supplier' , 'invoice_supplier' , 'invoice_supplier_rec' ))) {
2021-02-23 21:03:23 +00:00
$colspan ++ ; // With this, there is a column move button
}
2022-08-30 09:43:58 +00:00
if ( isModEnabled ( 'asset' ) && $object -> element == 'invoice_supplier' ) {
2022-02-14 03:52:39 +00:00
$colspan ++ ;
}
2021-07-21 06:26:41 +00:00
2015-03-06 17:51:55 +00:00
//print $object->element;
2018-03-20 09:10:21 +00:00
// Lines for extrafield
$objectline = null ;
2021-02-23 21:03:23 +00:00
if ( ! empty ( $extrafields )) {
2019-11-14 11:09:15 +00:00
if ( $this -> table_element_line == 'commandedet' ) {
2018-03-20 09:10:21 +00:00
$objectline = new OrderLine ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'propaldet' ) {
2018-03-20 09:10:21 +00:00
$objectline = new PropaleLigne ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'supplier_proposaldet' ) {
2018-03-20 09:10:21 +00:00
$objectline = new SupplierProposalLine ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'facturedet' ) {
2018-03-20 09:10:21 +00:00
$objectline = new FactureLigne ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'contratdet' ) {
2018-03-20 09:10:21 +00:00
$objectline = new ContratLigne ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'commande_fournisseurdet' ) {
2018-03-20 09:10:21 +00:00
$objectline = new CommandeFournisseurLigne ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'facture_fourn_det' ) {
2018-03-20 09:10:21 +00:00
$objectline = new SupplierInvoiceLine ( $this -> db );
2020-05-21 13:05:19 +00:00
} elseif ( $this -> table_element_line == 'facturedet_rec' ) {
2018-03-20 09:10:21 +00:00
$objectline = new FactureLigneRec ( $this -> db );
2022-02-07 13:34:27 +00:00
} elseif ( $this -> table_element_line == 'facture_fourn_det_rec' ) {
$objectline = new FactureFournisseurLigneRec ( $this -> db );
2018-03-20 09:10:21 +00:00
}
}
2019-10-27 16:01:23 +00:00
print " <!-- BEGIN PHP TEMPLATE objectline_create.tpl.php --> \n " ;
2019-12-03 10:17:29 +00:00
$nolinesbefore = ( count ( $this -> lines ) == 0 || $forcetoshowtitlelines );
2016-07-28 13:29:46 +00:00
if ( $nolinesbefore ) {
2019-10-27 16:01:23 +00:00
?>
2023-12-04 11:07:53 +00:00
< tr class = " liste_titre<?php echo(( $nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_add_') ?> nodrag nodrop " >
2023-11-27 10:39:32 +00:00
< ? php if ( getDolGlobalString ( 'MAIN_VIEW_LINE_NUMBER' )) { ?>
2019-11-30 11:49:31 +00:00
< td class = " linecolnum center " ></ td >
< ? php } ?>
2022-11-03 15:13:35 +00:00
< td class = " linecoldescription minwidth400imp " >
2020-07-07 01:50:14 +00:00
< div id = " add " ></ div >< span class = " hideonsmartphone " >< ? php echo $langs -> trans ( 'AddNewLine' ); ?> </span>
2019-11-30 11:49:31 +00:00
</ td >
< ? php
2022-02-07 13:34:27 +00:00
if ( $object -> element == 'supplier_proposal' || $object -> element == 'order_supplier' || $object -> element == 'invoice_supplier' || $object -> element == 'invoice_supplier_rec' ) { // We must have same test in printObjectLines
2019-11-30 11:49:31 +00:00
?>
< td class = " linecolrefsupplier " >< span id = " title_fourn_ref " >< ? php echo $langs -> trans ( 'SupplierRef' ); ?> </span></td>
< ? php
2023-12-04 11:07:53 +00:00
} ?>
2019-11-30 11:49:31 +00:00
< td class = " linecolvat right " >< span id = " title_vat " >< ? php echo $langs -> trans ( 'VAT' ); ?> </span></td>
< td class = " linecoluht right " >< span id = " title_up_ht " >< ? php echo $langs -> trans ( 'PriceUHT' ); ?> </span></td>
2025-11-05 20:24:19 +00:00
< ? php if ( isModEnabled ( " multicurrency " ) && $this -> multicurrency_code && $this -> multicurrency_code != $conf -> currency ) { ?>
2025-10-14 14:27:31 +00:00
< td class = " linecoluht_currency right " >< span id = " title_up_ht_currency " >< ? php echo $langs -> trans ( 'PriceUHT' ) . ' <span class="opacitymedium">(' . $langs -> getCurrencySymbol ( $this -> multicurrency_code ) . ')</span>' ; ?> </span></td>
2019-11-30 11:49:31 +00:00
< ? php } ?>
2023-03-15 12:45:53 +00:00
< ? php if ( ! empty ( $inputalsopricewithtax ) && ! getDolGlobalInt ( 'MAIN_NO_INPUT_PRICE_WITH_TAX' )) { ?>
2019-11-30 11:49:31 +00:00
< td class = " linecoluttc right " >< span id = " title_up_ttc " >< ? php echo $langs -> trans ( 'PriceUTTC' ); ?> </span></td>
< ? php } ?>
2025-11-05 20:24:19 +00:00
< ? php if ( isModEnabled ( " multicurrency " ) && $this -> multicurrency_code && $this -> multicurrency_code != $conf -> currency && ! empty ( $inputalsopricewithtax ) && ! getDolGlobalInt ( 'MAIN_NO_INPUT_PRICE_WITH_TAX' )) { ?>
2025-10-14 14:27:31 +00:00
< td class = " linecoluttc_currency right " >< span id = " title_up_ttc_currency " >< ? php echo $langs -> trans ( 'PriceUTTC' ) . ' <span class="opacitymedium">(' . $langs -> getCurrencySymbol ( $this -> multicurrency_code ) . ')</span>' ; ?> </td>
2025-09-07 23:37:33 +00:00
< ? php } ?>
2019-11-30 11:49:31 +00:00
< td class = " linecolqty right " >< ? php echo $langs -> trans ( 'Qty' ); ?> </td>
2019-10-27 16:01:23 +00:00
< ? php
2022-12-30 11:55:53 +00:00
if ( getDolGlobalInt ( 'PRODUCT_USE_UNITS' )) {
2019-11-30 11:49:31 +00:00
print '<td class="linecoluseunit left">' ;
print '<span id="title_units">' ;
print $langs -> trans ( 'Unit' );
print '</span></td>' ;
2023-12-04 11:07:53 +00:00
} ?>
2019-11-30 11:49:31 +00:00
< td class = " linecoldiscount right " >< ? php echo $langs -> trans ( 'ReductionShort' ); ?> </td>
< ? php
// Fields for situation invoice
2025-08-17 14:32:09 +00:00
if ( property_exists ( $this , 'situation_cycle_ref' ) && isset ( $this -> situation_cycle_ref ) && $this -> situation_cycle_ref ) {
2019-12-03 10:17:29 +00:00
print '<td class="linecolcycleref right">' . $langs -> trans ( 'Progress' ) . '</td>' ;
2024-06-18 18:21:56 +00:00
if ( getDolGlobalInt ( 'INVOICE_USE_SITUATION' ) == 2 ) {
print '<td class="nobottom nowrap right"></td>' ;
}
2019-11-30 11:49:31 +00:00
print '<td class="linecolcycleref2 right"></td>' ;
2016-12-15 11:01:46 +00:00
}
2021-02-23 21:03:23 +00:00
if ( ! empty ( $usemargins )) {
2023-10-15 13:32:35 +00:00
if ( ! $user -> hasRight ( 'margins' , 'creer' )) {
2019-11-30 11:49:31 +00:00
$colspan ++ ;
2020-05-21 13:05:19 +00:00
} else {
2019-11-30 11:49:31 +00:00
print '<td class="margininfos linecolmargin1 right">' ;
2023-10-08 21:19:49 +00:00
if ( getDolGlobalString ( 'MARGIN_TYPE' ) == " 1 " ) {
2019-11-30 11:49:31 +00:00
echo $langs -> trans ( 'BuyingPrice' );
2021-02-23 21:03:23 +00:00
} else {
echo $langs -> trans ( 'CostPrice' );
}
2019-11-30 11:49:31 +00:00
echo '</td>' ;
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'DISPLAY_MARGIN_RATES' )) {
2021-02-23 21:03:23 +00:00
echo '<td class="margininfos linecolmargin2 right"><span class="np_marginRate">' . $langs -> trans ( 'MarginRate' ) . '</span></td>' ;
}
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'DISPLAY_MARK_RATES' )) {
2024-11-12 12:48:12 +00:00
echo '<td class="margininfos linecolmark1 right"><span class="np_markRate">' . $langs -> trans ( 'MarkRate' ) . '</span></td>' ;
2021-02-23 21:03:23 +00:00
}
2019-11-30 11:49:31 +00:00
}
2023-12-04 11:07:53 +00:00
} ?>
2019-11-30 11:49:31 +00:00
< td class = " linecoledit " colspan = " <?php echo $colspan ; ?> " >& nbsp ; </ td >
</ tr >
2019-10-27 16:01:23 +00:00
< ? php
2016-07-28 13:29:46 +00:00
}
?>
2019-12-03 10:17:29 +00:00
< tr class = " pair nodrag nodrop nohoverpair<?php echo ( $nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create'; ?> " >
2019-11-30 11:49:31 +00:00
< ? php
2019-12-03 10:17:29 +00:00
$coldisplay = 0 ;
2019-11-30 11:49:31 +00:00
// Adds a line numbering column
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_VIEW_LINE_NUMBER' )) {
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
echo '<td class="nobottom linecolnum center"></td>' ;
2019-10-27 16:01:23 +00:00
}
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
?>
2022-11-03 15:13:35 +00:00
< td class = " nobottom linecoldescription minwidth400imp " >
2019-11-30 11:49:31 +00:00
< ? php
$freelines = false ;
2023-11-27 10:39:32 +00:00
if ( ! getDolGlobalString ( 'MAIN_DISABLE_FREE_LINES' )) {
2019-11-30 11:49:31 +00:00
$freelines = true ;
2019-12-03 10:17:29 +00:00
$forceall = 1 ; // We always force all type for free lines (module product or service means we use predefined product or service)
2021-02-23 21:03:23 +00:00
if ( $object -> element == 'contrat' ) {
2023-11-27 10:39:32 +00:00
if ( ! isModEnabled ( 'product' ) && ! isModEnabled ( 'service' ) && ! getDolGlobalString ( 'CONTRACT_SUPPORT_PRODUCTS' )) {
2021-02-23 21:03:23 +00:00
$forceall = - 1 ; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
2023-11-27 10:39:32 +00:00
} elseif ( ! getDolGlobalString ( 'CONTRACT_SUPPORT_PRODUCTS' )) {
2021-02-23 21:03:23 +00:00
$forceall = 3 ;
}
2019-11-30 11:49:31 +00:00
}
2024-11-26 20:22:41 +00:00
2024-12-19 00:05:39 +00:00
// Select type of free line
2024-11-26 20:22:41 +00:00
$labelforempty = 1 ;
2024-12-09 20:29:15 +00:00
print '<span class="prod_entry_mode_free nowraponall">' ;
2024-11-26 20:22:41 +00:00
// Show radio for the non predefined product
2022-08-23 18:02:37 +00:00
if ( $forceall >= 0 && ( isModEnabled ( " product " ) || isModEnabled ( " service " ))) {
2024-11-26 20:22:41 +00:00
print '<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"' ;
2022-09-25 04:03:47 +00:00
//echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (!isModEnabled('product') || !isModEnabled('service')))?' checked':'') );
2024-11-26 20:22:41 +00:00
print (( GETPOST ( 'prod_entry_mode' , 'alpha' ) == 'free' || getDolGlobalString ( 'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT' )) ? ' checked' : '' );
print '> ' ;
2019-11-30 11:49:31 +00:00
// Show type selector
2024-12-19 00:05:39 +00:00
$labelforempty = $langs -> trans ( " FreeLineOfType " ) . '...' ;
2020-05-21 13:05:19 +00:00
} else {
2019-11-30 11:49:31 +00:00
echo '<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">' ;
// Show type selector
2021-02-23 21:03:23 +00:00
if ( $forceall >= 0 ) {
2022-09-25 04:03:47 +00:00
if ( ! isModEnabled ( 'product' ) || ! isModEnabled ( 'service' )) {
2024-11-26 20:22:41 +00:00
$labelforempty = $langs -> trans ( " Type " );
2021-02-23 21:03:23 +00:00
} else {
2024-11-26 20:22:41 +00:00
$labelforempty = $langs -> trans ( " FreeLineOfType " );
2021-02-23 21:03:23 +00:00
}
2019-11-30 11:49:31 +00:00
}
}
2024-11-26 20:22:41 +00:00
2025-06-26 18:00:24 +00:00
if ( $forceall >= 0 && ( isModEnabled ( " product " ) || isModEnabled ( " service " ))) {
print '<label for="prod_entry_mode_free">' ;
}
2026-01-20 01:11:14 +00:00
// Select type of line
2024-12-19 00:05:39 +00:00
$form -> select_type_of_lines ( GETPOSTISSET ( " type " ) ? GETPOST ( " type " , 'alpha' , 2 ) : - 1 , 'type' , $labelforempty , 1 , $forceall , 'minwidth200' , 0 );
2026-01-20 01:11:14 +00:00
2025-06-26 18:00:24 +00:00
if ( $forceall >= 0 && ( isModEnabled ( " product " ) || isModEnabled ( " service " ))) {
print '</label>' ;
}
2024-11-26 20:22:41 +00:00
print '</span>' ;
2019-11-30 11:49:31 +00:00
}
// Predefined product/service
2022-08-23 18:02:37 +00:00
if ( isModEnabled ( " product " ) || isModEnabled ( " service " )) {
2024-11-26 20:22:41 +00:00
print '<span class="nowraponall">' ;
2021-02-23 21:03:23 +00:00
if ( $forceall >= 0 && $freelines ) {
2024-11-26 20:22:41 +00:00
print '<br><span class="prod_entry_mode_predef paddingtop">' ;
2021-02-23 21:03:23 +00:00
} else {
2024-11-26 20:22:41 +00:00
print '<span class="prod_entry_mode_predef">' ;
2021-02-23 21:03:23 +00:00
}
2024-11-26 20:22:41 +00:00
print '<label for="prod_entry_mode_predef">' ;
print '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"' . ( GETPOST ( 'prod_entry_mode' ) == 'predef' ? ' checked' : '' ) . '> ' ;
2021-02-15 13:19:05 +00:00
$labelforradio = '' ;
if ( empty ( $conf -> dol_optimize_smallscreen )) {
2024-05-06 16:50:11 +00:00
if ( isModEnabled ( " product " ) && ! isModEnabled ( 'service' )) {
$labelforradio = $langs -> trans ( 'PredefinedProducts' );
} elseif (( ! isModEnabled ( 'product' ) && isModEnabled ( 'service' )) || ( $object -> element == 'contrat' && ! getDolGlobalString ( 'CONTRACT_SUPPORT_PRODUCTS' ))) {
$labelforradio = $langs -> trans ( 'PredefinedServices' );
2021-02-15 13:19:05 +00:00
} else {
2024-05-06 16:50:11 +00:00
$labelforradio = $langs -> trans ( 'PredefinedProductsAndServices' );
2021-02-15 13:19:05 +00:00
}
2020-05-21 13:05:19 +00:00
} else {
2021-02-15 13:19:05 +00:00
$labelforradio = $langs -> trans ( 'PredefinedItem' );
2019-11-30 11:49:31 +00:00
}
2024-11-26 20:22:41 +00:00
if ( empty ( $senderissupplier )) { // TODO Move this into the placeholder
//print '<span class="textradioforitem">'.$labelforradio.'</span>';
}
print '</label>' ;
//print ' ';
2019-12-03 10:17:29 +00:00
$filtertype = '' ;
2023-11-27 10:39:32 +00:00
if ( ! empty ( $object -> element ) && $object -> element == 'contrat' && ! getDolGlobalString ( 'CONTRACT_SUPPORT_PRODUCTS' )) {
2021-02-23 21:03:23 +00:00
$filtertype = '1' ;
}
if ( empty ( $senderissupplier )) {
2019-11-30 11:49:31 +00:00
$statustoshow = 1 ;
2022-10-28 21:14:50 +00:00
$statuswarehouse = 'warehouseopen,warehouseinternal' ;
2023-12-04 11:07:53 +00:00
if ( getDolGlobalString ( 'ENTREPOT_WAREHOUSEINTERNAL_NOT_SELL' )) {
$statuswarehouse = 'warehouseopen' ;
}
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'ENTREPOT_EXTRA_STATUS' )) {
2019-11-30 11:49:31 +00:00
// hide products in closed warehouse, but show products for internal transfer
2025-09-15 23:23:16 +00:00
$form -> select_produits ( GETPOSTINT ( 'idprod' ), 'idprod' , $filtertype , getDolGlobalInt ( 'PRODUIT_LIMIT_SIZE' ), $buyer -> price_level , $statustoshow , 2 , '' , 1 , array (), $buyer -> id , $labelforradio , 0 , 'maxwidth500 widthcentpercentminusx' , 0 , $statuswarehouse , GETPOST ( 'combinations' , 'array:alphanohtml' ));
2020-05-21 13:05:19 +00:00
} else {
2025-09-15 23:23:16 +00:00
$form -> select_produits ( GETPOSTINT ( 'idprod' ), 'idprod' , $filtertype , getDolGlobalInt ( 'PRODUIT_LIMIT_SIZE' ), $buyer -> price_level , $statustoshow , 2 , '' , 1 , array (), $buyer -> id , $labelforradio , 0 , 'maxwidth500 widthcentpercentminusx' , 0 , '' , GETPOST ( 'combinations' , 'array:alphanohtml' ));
2019-11-30 11:49:31 +00:00
}
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS' )) {
2019-11-30 14:22:25 +00:00
?>
2020-08-16 20:03:11 +00:00
< script >
2024-12-19 00:05:39 +00:00
$ ( document ) . ready ( function () {
2019-11-30 11:49:31 +00:00
// On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
$ ( document ) . on ( 'focus' , '.select2-selection.select2-selection--single' , function ( e ) {
2024-12-19 00:05:39 +00:00
console . log ( " focus on a select2 because of MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS " );
2019-11-30 11:49:31 +00:00
if ( $ ( this ) . attr ( 'aria-labelledby' ) == 'select2-idprod-container' )
{
console . log ( 'open combo' );
$ ( '#idprod' ) . select2 ( 'open' );
}
});
});
</ script >
2019-11-30 14:22:25 +00:00
< ? php
}
2020-05-21 13:05:19 +00:00
} else {
2021-02-10 01:17:01 +00:00
// $senderissupplier=2 is the same as 1 but disables test on minimum qty, disable autofill qty with minimum and autofill unit price
2021-02-23 21:03:23 +00:00
if ( $senderissupplier != 2 ) {
2019-12-03 10:17:29 +00:00
$ajaxoptions = array (
2024-03-08 11:34:25 +00:00
'update' => array ( 'qty' => 'qty' , 'remise_percent' => 'discount' , 'idprod' => 'idprod' ), // html id tags that will be edited with each ajax json response key
2021-02-10 01:17:01 +00:00
'option_disabled' => 'idthatdoesnotexists' , // html id to disable once select is done
'warning' => $langs -> trans ( " NoPriceDefinedForThisSupplier " ) // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
2019-11-30 14:22:25 +00:00
);
2019-12-03 10:17:29 +00:00
$alsoproductwithnosupplierprice = 0 ;
2020-05-21 13:05:19 +00:00
} else {
2019-11-30 14:22:25 +00:00
$ajaxoptions = array (
2022-10-13 12:31:08 +00:00
// Disabled: This is useless because setting discount and price_ht after a selection is already managed
2024-01-13 18:48:20 +00:00
// by this page itself with a .change on the combolist '#idprodfournprice'
2022-10-13 12:31:08 +00:00
//'update' => array('remise_percent' => 'discount', 'price_ht' => 'price_ht') // html id tags that will be edited with each ajax json response key
2019-11-30 14:22:25 +00:00
);
2019-12-03 10:17:29 +00:00
$alsoproductwithnosupplierprice = 1 ;
2019-11-30 14:22:25 +00:00
}
2024-11-26 20:22:41 +00:00
2026-01-21 11:44:12 +00:00
$socid = 0 ;
if ( property_exists ( $object , 'socid' )) {
2026-01-21 12:22:02 +00:00
// @phan-suppress-next-line PhanUndeclaredProperty
2026-01-21 11:44:12 +00:00
$socid = $object -> socid ;
}
$form -> select_produits_fournisseurs ( $socid , GETPOST ( 'idprodfournprice' ), 'idprodfournprice' , '' , '' , $ajaxoptions , 1 , $alsoproductwithnosupplierprice , 'minwidth100 maxwidth500 widthcentpercentminusx' , $labelforradio );
2024-11-26 20:22:41 +00:00
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS' )) {
2019-11-30 14:22:25 +00:00
?>
2020-08-16 20:03:11 +00:00
< script >
2019-11-30 11:49:31 +00:00
$ ( document ) . ready ( function (){
// On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
$ ( document ) . on ( 'focus' , '.select2-selection.select2-selection--single' , function ( e ) {
2024-12-19 00:05:39 +00:00
//console.log('focus on a select2 because of MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS');
2019-11-30 11:49:31 +00:00
if ( $ ( this ) . attr ( 'aria-labelledby' ) == 'select2-idprodfournprice-container' )
{
$ ( '#idprodfournprice' ) . select2 ( 'open' );
}
});
});
</ script >
2019-11-30 14:22:25 +00:00
< ? php
}
2019-11-30 11:49:31 +00:00
}
2023-10-10 19:29:19 +00:00
Fix: GETPOST(...,'int') to GETPOSTINT(...) (#28448)
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: GETPOST(...,'int') to GETPOSTINT(...)
# Fix: GETPOST(...,'int') to GETPOSTINT(...)
Converted using Phan plugin
* Fix: Update spelling exceptions
* Qual: Ignore Phan Notice
2024-02-27 13:05:53 +00:00
$parentId = GETPOSTINT ( 'parentId' );
2023-10-10 19:29:19 +00:00
2023-10-10 20:10:37 +00:00
$addproducton = ( isModEnabled ( 'product' ) && $user -> hasRight ( 'produit' , 'creer' ));
$addserviceon = ( isModEnabled ( 'service' ) && $user -> hasRight ( 'service' , 'creer' ));
if ( $addproducton || $addserviceon ) {
if ( $addproducton && $addserviceon ) {
echo '<div id="dropdownAddProductAndService" class="dropdown inline-block">' ;
echo '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" id="dropdownAddProductAndServiceLink" aria-haspopup="true" aria-expanded="false">' ;
echo '<span class="fa fa-plus-circle valignmiddle paddingleft"></span>' ;
echo '</a>' ;
echo '<div class="dropdown-menu" aria-labelledby="dropdownAddProductAndServiceLink" style="top:auto; left:auto;">' ;
echo '<a class="dropdown-item" href="' . DOL_URL_ROOT . '/product/card.php?action=create&type=0&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ) . '"> ' . $langs -> trans ( " NewProduct " ) . '</a>' ;
echo '<a class="dropdown-item" href="' . DOL_URL_ROOT . '/product/card.php?action=create&type=1&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ) . '"> ' . $langs -> trans ( " NewService " ) . '</a>' ;
echo '</div>' ;
echo '</div>' ;
} else {
if ( $addproducton ) {
2026-07-31 16:48:34 +00:00
$url = '/product/card.php?leftmenu=product&action=create&type=0&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id );
2023-10-10 20:10:37 +00:00
$newbutton = '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " NewProduct " ) . '"></span>' ;
if ( getDolGlobalInt ( 'MAIN_FEATURES_LEVEL' ) >= 2 ) {
2026-07-31 16:48:34 +00:00
// The popup child page (product/card.php) reloads the parent itself after a successful creation
print dolButtonToOpenUrlInDialogPopup ( 'addproduct' , $langs -> transnoentitiesnoconv ( 'AddProduct' ), $newbutton , $url );
2023-10-10 20:10:37 +00:00
} else {
print '<a href="' . DOL_URL_ROOT . '/product/card.php?action=create&type=0&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ) . '" title="' . dol_escape_htmltag ( $langs -> trans ( " NewProduct " )) . '"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>' ;
}
}
if ( $addserviceon ) {
2026-07-31 16:48:34 +00:00
$url = '/product/card.php?leftmenu=product&action=create&type=1&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id );
2023-10-10 20:10:37 +00:00
$newbutton = '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " NewService " ) . '"></span>' ;
if ( getDolGlobalInt ( 'MAIN_FEATURES_LEVEL' ) >= 2 ) {
2026-07-31 16:48:34 +00:00
// The popup child page (product/card.php) reloads the parent itself after a successful creation
print dolButtonToOpenUrlInDialogPopup ( 'addproduct' , $langs -> transnoentitiesnoconv ( 'AddService' ), $newbutton , $url );
2023-10-10 20:10:37 +00:00
} else {
print '<a href="' . DOL_URL_ROOT . '/product/card.php?action=create&type=1&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ) . '" title="' . dol_escape_htmltag ( $langs -> trans ( " NewService " )) . '"><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>' ;
}
}
}
2024-11-26 20:22:41 +00:00
}
print '</span>' ;
?>
2023-10-10 19:29:19 +00:00
< script >
$ ( document ) . ready ( function (){
$ ( " #dropdownAddProductAndService .dropdown-toggle " ) . on ( " click " , function ( event ) {
console . log ( " toggle addproduct dropdown " );
event . preventDefault ();
$ ( " #dropdownAddProductAndService " ) . toggleClass ( " open " );
});
});
</ script >
< ? php
2019-11-30 11:49:31 +00:00
echo '<input type="hidden" name="pbq" id="pbq" value="">' ;
echo '</span>' ;
2014-11-28 01:05:40 +00:00
}
2021-11-16 13:09:18 +00:00
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_ADD_LINE_AT_POSITION' )) {
2021-11-22 15:13:46 +00:00
echo '<br>' . $langs -> trans ( 'AddLineOnPosition' ) . ' : <input type="number" name="rank" step="1" min="0" style="width: 5em;">' ;
2021-11-16 13:09:18 +00:00
}
2021-02-23 21:03:23 +00:00
if ( is_object ( $hookmanager ) && empty ( $senderissupplier )) {
2024-03-08 11:34:25 +00:00
$parameters = array ( 'fk_parent_line' => GETPOSTINT ( 'fk_parent_line' ));
2019-12-03 10:17:29 +00:00
$reshook = $hookmanager -> executeHooks ( 'formCreateProductOptions' , $parameters , $object , $action );
2019-11-30 11:49:31 +00:00
if ( ! empty ( $hookmanager -> resPrint )) {
print $hookmanager -> resPrint ;
}
2014-05-05 15:59:43 +00:00
}
2021-02-23 21:03:23 +00:00
if ( is_object ( $hookmanager ) && ! empty ( $senderissupplier )) {
2024-03-08 11:34:25 +00:00
$parameters = array ( 'htmlname' => 'addproduct' );
2019-12-03 10:17:29 +00:00
$reshook = $hookmanager -> executeHooks ( 'formCreateProductSupplierOptions' , $parameters , $object , $action );
2019-11-30 11:49:31 +00:00
if ( ! empty ( $hookmanager -> resPrint )) {
print $hookmanager -> resPrint ;
}
2014-05-05 15:59:43 +00:00
}
2022-08-23 18:02:37 +00:00
if ( isModEnabled ( " product " ) || isModEnabled ( " service " )) {
2021-02-10 17:03:45 +00:00
echo '<br>' ;
2022-09-25 04:03:47 +00:00
if ( isModEnabled ( 'variants' )) {
2019-11-30 11:49:31 +00:00
echo '<div id="attributes_box"></div>' ;
}
}
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2019-12-03 10:17:29 +00:00
$nbrows = ROWS_2 ;
2024-09-10 13:32:26 +00:00
$enabled = getDolGlobalString ( 'FCKEDITOR_ENABLE_DETAILS' , '0' );
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_INPUT_DESC_HEIGHT' )) {
2024-01-05 03:18:53 +00:00
$nbrows = getDolGlobalString ( 'MAIN_INPUT_DESC_HEIGHT' );
2021-02-23 21:03:23 +00:00
}
2019-12-03 10:17:29 +00:00
$toolbarname = 'dolibarr_details' ;
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'FCKEDITOR_ENABLE_DETAILS_FULL' )) {
2021-02-23 21:03:23 +00:00
$toolbarname = 'dolibarr_notes' ;
}
2024-09-10 13:32:26 +00:00
$doleditor = new DolEditor ( 'dp_desc' , GETPOST ( 'dp_desc' , 'restricthtml' ), '' , getDolGlobalInt ( 'MAIN_DOLEDITOR_HEIGHT' , 100 ), $toolbarname , '' , false , true , $enabled , $nbrows , '98%' );
2019-11-30 11:49:31 +00:00
$doleditor -> Create ();
// Show autofill date for recurring invoices
2022-08-23 18:02:37 +00:00
if ( isModEnabled ( " service " ) && ( $object -> element == 'facturerec' || $object -> element == 'invoice_supplier_rec' )) {
2019-11-30 11:49:31 +00:00
echo '<div class="divlinefordates"><br>' ;
echo $langs -> trans ( 'AutoFillDateFrom' ) . ' ' ;
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'INVOICE_REC_DATE_TO_YES' )) {
2022-06-21 08:06:26 +00:00
$line -> date_start_fill = 1 ;
$line -> date_end_fill = 1 ;
}
2019-11-30 11:49:31 +00:00
echo $form -> selectyesno ( 'date_start_fill' , $line -> date_start_fill , 1 );
echo ' - ' ;
echo $langs -> trans ( 'AutoFillDateTo' ) . ' ' ;
echo $form -> selectyesno ( 'date_end_fill' , $line -> date_end_fill , 1 );
echo '</div>' ;
}
2026-04-13 10:50:23 +00:00
if ( is_object ( $objectline ) && $extrafields instanceof ExtraFields ) {
2025-03-15 15:34:35 +00:00
$temps = $objectline -> showOptionals ( $extrafields , 'create' , array (), '' , '' , '1' , 'line' );
2022-02-25 19:36:40 +00:00
2021-01-16 13:10:37 +00:00
if ( ! empty ( $temps )) {
print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">' ;
print $temps ;
print '</div>' ;
}
2020-12-22 11:52:01 +00:00
}
2019-11-30 11:49:31 +00:00
echo '</td>' ;
2022-02-07 13:34:27 +00:00
if ( $object -> element == 'supplier_proposal' || $object -> element == 'order_supplier' || $object -> element == 'invoice_supplier' || $object -> element == 'invoice_supplier_rec' ) { // We must have same test in printObjectLines
2023-12-04 11:07:53 +00:00
$coldisplay ++ ; ?>
< td class = " nobottom linecolrefsupplier " >< input id = " fourn_ref " name = " fourn_ref " class = " flat minwidth50 maxwidth100 maxwidth125onsmartphone " value = " <?php echo(GETPOSTISSET( " fourn_ref " ) ? GETPOST( " fourn_ref " , 'alpha', 2) : ''); ?> " ></ td >
2024-03-08 11:34:25 +00:00
< ? php
2023-12-04 11:07:53 +00:00
}
2019-11-30 14:22:25 +00:00
print '<td class="nobottom linecolvat right">' ;
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
2025-01-13 19:04:35 +00:00
$type_tva = 0 ;
2023-01-10 04:00:24 +00:00
if ( $object -> element == 'propal' || $object -> element == 'commande' || $object -> element == 'facture' || $object -> element == 'facturerec' ) {
$type_tva = 1 ;
2023-01-10 04:02:08 +00:00
} elseif ( $object -> element == 'supplier_proposal' || $object -> element == 'order_supplier' || $object -> element == 'invoice_supplier' || $object -> element == 'invoice_supplier_rec' ) {
2023-01-10 04:00:24 +00:00
$type_tva = 2 ;
}
2021-02-23 21:03:23 +00:00
if ( $seller -> tva_assuj == " 0 " ) {
2024-09-05 14:05:37 +00:00
echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">' . vatrate ( '0' , true );
2021-02-23 21:03:23 +00:00
} else {
2023-01-10 04:00:24 +00:00
echo $form -> load_tva ( 'tva_tx' , ( GETPOSTISSET ( " tva_tx " ) ? GETPOST ( " tva_tx " , 'alpha' , 2 ) : - 1 ), $seller , $buyer , 0 , 0 , '' , false , 1 , $type_tva );
2021-02-23 21:03:23 +00:00
}
2019-11-30 11:49:31 +00:00
?>
2014-05-05 12:30:08 +00:00
</ td >
2019-04-30 16:11:35 +00:00
< td class = " nobottom linecoluht right " >< ? php $coldisplay ++ ; ?>
2024-04-22 22:54:44 +00:00
< input type = " text " name = " price_ht " id = " price_ht " class = " flat right width50 " value = " <?php echo(GETPOSTISSET( " price_ht " ) ? GETPOST( " price_ht " , 'alpha', 2) : ''); ?> " >
2014-05-05 12:30:08 +00:00
</ td >
2017-06-23 09:20:29 +00:00
2020-01-01 21:58:26 +00:00
< ? php
2025-11-05 20:24:19 +00:00
if ( isModEnabled ( " multicurrency " ) && $this -> multicurrency_code && $this -> multicurrency_code != $conf -> currency ) {
2023-12-04 11:07:53 +00:00
$coldisplay ++ ; ?>
2019-11-30 11:49:31 +00:00
< td class = " nobottom linecoluht_currency right " >
2024-04-22 22:54:44 +00:00
< input type = " text " name = " multicurrency_price_ht " id = " multicurrency_price_ht " class = " flat right width50 " value = " <?php echo(GETPOSTISSET( " multicurrency_price_ht " ) ? GETPOST( " multicurrency_price_ht " , 'alpha', 2) : ''); ?> " >
2019-11-30 11:49:31 +00:00
</ td >
2020-01-01 22:14:13 +00:00
< ? php
2020-01-01 21:58:26 +00:00
}
2023-03-11 18:38:39 +00:00
if ( ! empty ( $inputalsopricewithtax ) && ! getDolGlobalInt ( 'MAIN_NO_INPUT_PRICE_WITH_TAX' )) {
2023-12-04 11:07:53 +00:00
$coldisplay ++ ; ?>
2019-11-30 11:49:31 +00:00
< td class = " nobottom linecoluttc right " >
2024-04-22 22:54:44 +00:00
< input type = " text " name = " price_ttc " id = " price_ttc " class = " flat right width50 " value = " <?php echo(GETPOSTISSET( " price_ttc " ) ? GETPOST( " price_ttc " , 'alpha', 2) : ''); ?> " >
2019-11-30 11:49:31 +00:00
</ td >
2025-01-13 19:04:35 +00:00
< ? php
2020-01-01 21:58:26 +00:00
}
2025-11-05 20:24:19 +00:00
if ( isModEnabled ( " multicurrency " ) && $this -> multicurrency_code && $this -> multicurrency_code != $conf -> currency && ! empty ( $inputalsopricewithtax ) && ! getDolGlobalInt ( 'MAIN_NO_INPUT_PRICE_WITH_TAX' )) {
2025-09-07 23:37:33 +00:00
$coldisplay ++ ; ?>
< td class = " nobottom linecoluttc_currency right " >
< input type = " text " name = " multicurrency_price_ttc " id = " multicurrency_price_ttc " class = " flat right width50 " value = " <?php echo(GETPOSTISSET( " multicurrency_price_ttc " ) ? GETPOST( " multicurrency_price_ttc " , 'alpha', 2) : ''); ?> " >
</ td >
2025-11-01 16:47:28 +00:00
< ? php
2025-09-07 23:37:33 +00:00
}
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
2019-04-30 16:11:35 +00:00
?>
2022-10-25 10:22:43 +00:00
< td class = " nobottom linecolqty right " >
2023-11-27 10:39:32 +00:00
< ? php $default_qty = ( ! getDolGlobalString ( 'MAIN_OBJECTLINE_CREATE_EMPTY_QTY_BY_DEFAULT' ) ? 1 : '' ); ?>
2023-12-04 11:07:53 +00:00
< input type = " text " name = " qty " id = " qty " class = " flat width40 right " value = " <?php echo(GETPOSTISSET( " qty " ) ? GETPOST( " qty " , 'alpha', 2) : $default_qty ); ?> " >
2014-05-05 12:30:08 +00:00
</ td >
2019-11-30 11:49:31 +00:00
< ? php
2022-12-30 11:55:53 +00:00
if ( getDolGlobalInt ( 'PRODUCT_USE_UNITS' )) {
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
print '<td class="nobottom linecoluseunit left">' ;
2025-02-05 11:55:10 +00:00
print $form -> selectUnits ( empty ( $line -> fk_unit ) ? getDolGlobalInt ( 'PRODUCT_USE_UNITS' ) : $line -> fk_unit , " units " );
2019-11-30 11:49:31 +00:00
print '</td>' ;
}
$remise_percent = $buyer -> remise_percent ;
2020-01-01 21:58:26 +00:00
if ( $object -> element == 'supplier_proposal' || $object -> element == 'order_supplier' || $object -> element == 'invoice_supplier' ) {
2019-11-30 11:49:31 +00:00
$remise_percent = $seller -> remise_supplier_percent ;
}
2019-10-27 16:01:23 +00:00
$coldisplay ++ ;
2019-11-30 11:49:31 +00:00
?>
2022-10-25 10:22:43 +00:00
2023-12-04 11:07:53 +00:00
< td class = " nobottom nowrap linecoldiscount right " >< input type = " text " name = " remise_percent " id = " remise_percent " class = " flat width40 right " value = " <?php echo(GETPOSTISSET( " remise_percent " ) ? GETPOST( " remise_percent " , 'alpha', 2) : ( $remise_percent ? $remise_percent : '')); ?> " >< span class = " opacitymedium hideonsmartphone " >%</ span ></ td >
2019-11-30 11:49:31 +00:00
< ? php
2021-06-28 18:00:10 +00:00
if ( isset ( $this -> situation_cycle_ref ) && $this -> situation_cycle_ref ) {
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
2024-01-13 18:48:20 +00:00
print '<td class="nobottom nowrap right"><input class="flat right" type="text" size="1" value="" name="progress"><span class="opacitymedium hideonsmartphone">%</span></td>' ;
2024-06-18 18:21:56 +00:00
if ( getDolGlobalInt ( 'INVOICE_USE_SITUATION' ) == 2 ) {
$coldisplay ++ ;
print '<td class="nobottom nowrap right"></td>' ;
}
2019-11-30 11:49:31 +00:00
$coldisplay ++ ;
print '<td></td>' ;
}
2020-01-01 21:58:26 +00:00
if ( ! empty ( $usemargins )) {
2023-10-15 13:32:35 +00:00
if ( $user -> hasRight ( 'margins' , 'creer' )) {
2023-12-04 11:07:53 +00:00
$coldisplay ++ ; ?>
2019-10-23 01:50:48 +00:00
< td class = " nobottom margininfos linecolmargin right " >
<!-- For predef product -->
2025-01-13 19:04:35 +00:00
< ? php if ( isModEnabled ( " product " ) || isModEnabled ( " service " )) { ?>
2020-12-31 14:05:17 +00:00
< select id = " fournprice_predef " name = " fournprice_predef " class = " flat minwidth75imp maxwidth150 " style = " display: none; " ></ select >
2025-01-13 19:04:35 +00:00
< ? php } ?>
2019-10-23 01:50:48 +00:00
<!-- For free product -->
2023-12-04 11:07:53 +00:00
< input type = " text " id = " buying_price " name = " buying_price " class = " flat maxwidth75 right " value = " <?php echo(GETPOSTISSET( " buying_price " ) ? GETPOST( " buying_price " , 'alpha', 2) : ''); ?> " >
2019-10-23 01:50:48 +00:00
</ td >
2025-01-13 19:04:35 +00:00
< ? php
if ( getDolGlobalString ( 'DISPLAY_MARGIN_RATES' )) {
echo '<td class="nobottom nowraponall margininfos right"><input class="flat right width40" type="text" id="np_marginRate" name="np_marginRate" value="' . ( GETPOSTISSET ( " np_marginRate " ) ? GETPOST ( " np_marginRate " , 'alpha' , 2 ) : '' ) . '"><span class="np_marginRate opacitymedium hideonsmartphone">%</span></td>' ;
$coldisplay ++ ;
}
if ( getDolGlobalString ( 'DISPLAY_MARK_RATES' )) {
2025-03-15 15:34:35 +00:00
echo '<td class="nobottom nowraponall margininfos right"><input class="flat right width40" type="text" id="np_markRate" name="np_markRate" value="' . ( GETPOSTISSET ( " np_markRate " ) ? GETPOST ( " np_markRate " , 'alpha' , 2 ) : '' ) . '"><span class="np_markRate opacitymedium hideonsmartphone">%</span></td>' ;
$coldisplay ++ ;
2025-01-13 19:04:35 +00:00
}
2014-05-05 12:30:08 +00:00
}
}
2019-12-03 10:17:29 +00:00
$coldisplay += $colspan ;
2019-11-30 11:49:31 +00:00
?>
2019-01-20 22:36:39 +00:00
< td class = " nobottom linecoledit center valignmiddle " colspan = " <?php echo $colspan ; ?> " >
2021-07-04 19:14:46 +00:00
< input type = " submit " class = " button reposition " value = " <?php echo $langs->trans ('Add'); ?> " name = " addline " id = " addline " >
2014-05-05 12:30:08 +00:00
</ td >
</ tr >
2018-03-20 09:10:21 +00:00
< ? php
2022-08-23 18:02:37 +00:00
if (( isModEnabled ( " service " ) || ( $object -> element == 'contrat' )) && $dateSelector && GETPOST ( 'type' ) != '0' ) { // We show date field if required
2024-03-08 11:34:25 +00:00
print '<tr id="trlinefordates" class="oddeven">' . " \n " ;
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_VIEW_LINE_NUMBER' )) {
2020-11-30 19:13:42 +00:00
print '<td></td>' ;
}
2024-03-08 11:34:25 +00:00
print '<td colspan="' . ( $coldisplay - ( ! getDolGlobalString ( 'MAIN_VIEW_LINE_NUMBER' ) ? 0 : 1 )) . '">' ;
2024-11-11 13:33:53 +00:00
$date_start = dol_mktime ( GETPOSTINT ( 'date_starthour' ), GETPOSTINT ( 'date_startmin' ), 0 , GETPOSTINT ( 'date_startmonth' ), GETPOSTINT ( 'date_startday' ), GETPOSTINT ( 'date_startyear' ));
$date_end = dol_mktime ( GETPOSTINT ( 'date_starthour' ), GETPOSTINT ( 'date_startmin' ), 0 , GETPOSTINT ( 'date_endmonth' ), GETPOSTINT ( 'date_endday' ), GETPOSTINT ( 'date_endyear' ));
2019-05-15 10:26:39 +00:00
2024-03-08 11:34:25 +00:00
$prefillDates = false ;
2025-01-13 19:04:35 +00:00
$date_start_prefill = 0 ;
$date_end_prefill = 0 ;
2019-05-15 10:26:39 +00:00
2023-11-27 10:39:32 +00:00
if ( getDolGlobalString ( 'MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE' ) && ! empty ( $object -> lines )) {
2021-02-23 21:03:23 +00:00
for ( $i = count ( $object -> lines ) - 1 ; $i >= 0 ; $i -- ) {
2020-09-07 08:18:17 +00:00
$lastline = $object -> lines [ $i ];
2019-05-15 10:26:39 +00:00
2021-02-23 21:03:23 +00:00
if ( $lastline -> product_type == Product :: TYPE_SERVICE && ( ! empty ( $lastline -> date_start ) || ! empty ( $lastline -> date_end ))) {
2020-09-07 08:18:17 +00:00
$date_start_prefill = $lastline -> date_start ;
$date_end_prefill = $lastline -> date_end ;
2019-05-15 10:26:39 +00:00
2020-09-07 08:18:17 +00:00
$prefillDates = true ;
break ;
}
}
}
2019-05-15 10:26:39 +00:00
2021-02-23 21:03:23 +00:00
if ( ! empty ( $object -> element ) && $object -> element == 'contrat' ) {
2020-01-01 21:45:47 +00:00
print $langs -> trans ( " DateStartPlanned " ) . ' ' ;
print $form -> selectDate ( $date_start , " date_start " , $usehm , $usehm , 1 , " addproduct " );
print ' ' . $langs -> trans ( " DateEndPlanned " ) . ' ' ;
print $form -> selectDate ( $date_end , " date_end " , $usehm , $usehm , 1 , " addproduct " );
2020-05-21 13:05:19 +00:00
} else {
2020-01-01 21:45:47 +00:00
print $langs -> trans ( 'ServiceLimitedDuration' ) . ' ' . $langs -> trans ( 'From' ) . ' ' ;
2025-10-23 12:59:19 +00:00
print $form -> selectDate ( $date_start , 'date_start' , getDolGlobalInt ( 'MAIN_USE_HOURMIN_IN_DATE_RANGE' ), getDolGlobalInt ( 'MAIN_USE_HOURMIN_IN_DATE_RANGE' ), 1 , " addproduct " , 1 , 0 );
2020-01-01 21:45:47 +00:00
print ' ' . $langs -> trans ( 'to' ) . ' ' ;
2025-10-23 12:59:19 +00:00
print $form -> selectDate ( $date_end , 'date_end' , getDolGlobalInt ( 'MAIN_USE_HOURMIN_IN_DATE_RANGE' ), getDolGlobalInt ( 'MAIN_USE_HOURMIN_IN_DATE_RANGE' ), 1 , " addproduct " , 1 , 0 );
2022-12-30 17:43:43 +00:00
}
2019-05-15 10:26:39 +00:00
2021-02-23 21:03:23 +00:00
if ( $prefillDates ) {
2020-09-08 19:27:28 +00:00
echo ' <span class="small"><a href="#" id="prefill_service_dates">' . $langs -> trans ( 'FillWithLastServiceDates' ) . '</a></span>' ;
2020-09-07 08:18:17 +00:00
}
2019-05-15 10:26:39 +00:00
2024-03-08 11:34:25 +00:00
print '<script>' ;
2019-05-15 10:26:39 +00:00
2021-02-23 21:03:23 +00:00
if ( $prefillDates ) {
2020-08-11 10:42:27 +00:00
?>
2021-02-23 21:03:23 +00:00
function prefill_service_dates ()
{
2022-10-25 10:22:43 +00:00
$ ( '#date_start' ) . val ( " <?php echo dol_escape_js(dol_print_date( $date_start_prefill , 'day')); ?> " ) . trigger ( 'change' );
$ ( '#date_end' ) . val ( " <?php echo dol_escape_js(dol_print_date( $date_end_prefill , 'day')); ?> " ) . trigger ( 'change' );
2019-05-15 10:26:39 +00:00
2021-02-23 21:03:23 +00:00
return false ; // Prevent default link behaviour (which is go to href URL)
}
2019-05-15 10:26:39 +00:00
2021-02-23 21:03:23 +00:00
$ ( document ) . ready ( function ()
{
$ ( '#prefill_service_dates' ) . click ( prefill_service_dates );
});
2019-05-15 10:26:39 +00:00
2020-08-11 10:42:27 +00:00
< ? php
2019-05-15 10:26:39 +00:00
}
2020-01-01 21:45:47 +00:00
if ( ! $date_start ) {
2025-07-18 17:50:22 +00:00
if ( getDolGlobalString ( 'MAIN_DEFAULT_DATE_START_HOUR' ) != '' ) {
2023-10-15 13:32:35 +00:00
print 'jQuery("#date_starthour").val("' . getDolGlobalString ( 'MAIN_DEFAULT_DATE_START_HOUR' ) . '");' ;
2016-03-03 15:11:42 +00:00
}
2025-07-18 17:50:22 +00:00
if ( getDolGlobalString ( 'MAIN_DEFAULT_DATE_START_MIN' ) != '' ) {
2023-10-15 13:32:35 +00:00
print 'jQuery("#date_startmin").val("' . getDolGlobalString ( 'MAIN_DEFAULT_DATE_START_MIN' ) . '");' ;
2016-03-03 15:11:42 +00:00
}
2020-01-01 21:45:47 +00:00
}
if ( ! $date_end ) {
2025-07-18 17:50:22 +00:00
if ( getDolGlobalString ( 'MAIN_DEFAULT_DATE_END_HOUR' )) {
2023-10-15 13:32:35 +00:00
print 'jQuery("#date_endhour").val("' . getDolGlobalString ( 'MAIN_DEFAULT_DATE_END_HOUR' ) . '");' ;
2016-03-03 15:11:42 +00:00
}
2025-07-18 17:50:22 +00:00
if ( getDolGlobalString ( 'MAIN_DEFAULT_DATE_END_MIN' )) {
2023-10-15 13:32:35 +00:00
print 'jQuery("#date_endmin").val("' . getDolGlobalString ( 'MAIN_DEFAULT_DATE_END_MIN' ) . '");' ;
2020-01-01 21:45:47 +00:00
}
}
2024-03-08 11:34:25 +00:00
print '</script>' ;
print '</td>' ;
print '</tr>' . " \n " ;
2019-11-30 14:22:25 +00:00
}
2014-05-10 18:10:59 +00:00
2026-01-21 13:24:30 +00:00
$langs -> load ( 'stocks' );
$jsConf = [
'conf' => [
'freelines' => ( bool ) $freelines ,
'usemargins' => ( bool ) $usemargins ,
'DISPLAY_MARGIN_RATES' => ( bool ) getDolGlobalInt ( 'DISPLAY_MARGIN_RATES' ),
'MARGIN_TYPE' => getDolGlobalString ( 'MARGIN_TYPE' ),
'DISPLAY_MARK_RATES' => ( bool ) getDolGlobalInt ( 'DISPLAY_MARK_RATES' ),
'PRODUCT_USE_UNITS' => ( bool ) getDolGlobalInt ( 'PRODUCT_USE_UNITS' ),
'inputalsopricewithtax' => ( int ) $inputalsopricewithtax ,
'MAIN_NO_INPUT_PRICE_WITH_TAX' => ( bool ) getDolGlobalInt ( 'MAIN_NO_INPUT_PRICE_WITH_TAX' ),
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA' => ( bool ) getDolGlobalInt ( 'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA' ),
'PRODUIT_CUSTOMER_PRICES_BY_QTY' => ( bool ) getDolGlobalInt ( 'PRODUIT_CUSTOMER_PRICES_BY_QTY' ),
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES' => ( bool ) getDolGlobalInt ( 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES' ),
'MAIN_DISABLE_EDIT_PREDEF_PRICEHT' => ( bool ) getDolGlobalInt ( 'MAIN_DISABLE_EDIT_PREDEF_PRICEHT' ),
'MAIN_DISABLE_EDIT_PREDEF_PRICETTC' => ( bool ) getDolGlobalInt ( 'MAIN_DISABLE_EDIT_PREDEF_PRICETTC' ),
'FCKEDITOR_ENABLE_DETAILS' => ( bool ) getDolGlobalInt ( 'FCKEDITOR_ENABLE_DETAILS' ),
'PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES' => ( bool ) getDolGlobalInt ( 'PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES' ),
'PRODUIT_AUTOFILL_DESC' => getDolGlobalInt ( 'PRODUIT_AUTOFILL_DESC' ),
'MAIN_MULTILANGS' => getDolGlobalInt ( 'MAIN_MULTILANGS' ),
'PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE' => ( bool ) getDolGlobalString ( 'PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE' ), // todo check if getDolGlobalString is really needed
'newtoken' => newToken (),
'token' => currentToken (),
'currency' => $conf -> currency ,
'prod_entry_mode_is_predef' => GETPOST ( 'prod_entry_mode' ) == 'predef' ,
'noGetPostType' => ! GETPOSTISSET ( " type " )
],
'modules' => [
'multicurrency' => isModEnabled ( 'multicurrency' )
],
'url' => [
'fetchProductUrl' => DOL_URL_ROOT . '/product/ajax/products.php?action=fetch' ,
'getSupplierPrices' => DOL_URL_ROOT . '/fourn/ajax/getSupplierPrices.php?bestpricefirst=1'
],
'mySoc' => [
2026-04-13 10:50:23 +00:00
'country_code' => $mysoc -> country_code ,
'state_code' => $mysoc -> state_code ,
2026-01-21 13:24:30 +00:00
],
'docObject' => [
'table_element_line' => $this -> table_element_line ,
'element' => $object -> element ,
'thirdparty' => false ,
'socid' => ( property_exists ( $object , 'socid' ) ? ( int ) $object -> socid : 0 ), // @phan-suppress-current-line PhanUndeclaredProperty
'senderissupplier' => ( bool ) $senderissupplier ,
'seller_tva_assuj' => ( bool ) $seller -> tva_assuj ,
'multicurrency_code' => $object -> multicurrency_code ,
],
'userRight' => [
'margins' => [
'creer' => ( bool ) $user -> hasRight ( 'margins' , 'creer' )
]
],
// TODO move to Dolibarr context lang tool when it will be included
'langs' => [
'rateMustBeNumeric' => dol_escape_js ( $langs -> trans ( " rateMustBeNumeric " )),
'markRateShouldBeLesserThan100' => dol_escape_js ( $langs -> trans ( " markRateShouldBeLesserThan100 " ))
]
];
2026-04-13 10:50:23 +00:00
if ( ! empty ( $object -> thirdparty )) {
2026-01-21 13:24:30 +00:00
$jsConf [ 'docObject' ][ 'thirdparty' ] = [
'state_code' => $object -> thirdparty -> state_code ,
'country_code' => $object -> thirdparty -> country_code ,
];
}
2014-05-05 12:30:08 +00:00
2026-02-08 13:25:27 +00:00
//var_dump($jsConf);
2024-12-19 00:05:39 +00:00
2026-01-21 13:24:30 +00:00
?>
< script nonce = " <?php print getNonce(); ?> " >
/**
* First Step of factoring js part in goal of remove printed js to migrate to js files this class with hooks
* STOP USING PHP in js use a const container with php data passed as JSON
* The goal is to extract JS to migrate it in a js file and one day create init tests on js too
*
* @ typedef { Object } JsConf
* @ property { Object } conf
* @ property { boolean } conf . freelines
* @ property { string } conf . MARGIN_TYPE
* @ property { string } conf . currency
* @ property { boolean } conf . usemargins
* @ property { boolean } conf . prod_entry_mode_is_predef
* @ property { boolean } conf . DISPLAY_MARGIN_RATES
* @ property { boolean } conf . DISPLAY_MARK_RATES
* @ property { boolean } conf . PRODUCT_USE_UNITS
* @ property { number } conf . inputalsopricewithtax
* @ property { boolean } conf . MAIN_NO_INPUT_PRICE_WITH_TAX
* @ property { boolean } conf . FCKEDITOR_ENABLE_DETAILS
* @ property { boolean } conf . MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA
* @ property { boolean } conf . PRODUIT_CUSTOMER_PRICES_BY_QTY
* @ property { boolean } conf . PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES
* @ property { boolean } conf . PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES
* @ property { boolean } conf . MAIN_DISABLE_EDIT_PREDEF_PRICEHT
* @ property { boolean } conf . MAIN_MULTILANGS
* @ property { boolean } conf . PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE
* @ property { int } conf . PRODUIT_AUTOFILL_DESC
* @ property { string } conf . token
* @ property { string } conf . newtoken
*
* @ property { Object } url
* @ property { string } url . fetchProductUrl
* @ property { string } url . getSupplierPrices
*
* @ property { Object } modules
* @ property { boolean } modules . multicurrency
*
* @ property { Object } mySoc
* @ property { string | null } mySoc . country_code
* @ property { string | null } mySoc . state_code
*
* @ property { Object } docObject
* @ property { string } docObject . table_element_line
* @ property { string } docObject . element
* @ property { string } docObject . multicurrency_code
* @ property { Object | false } docObject . thirdparty
* @ property { string } docObject . thirdparty . country_code
* @ property { string } docObject . thirdparty . state_code
* @ property { number } docObject . socid
* @ property { boolean } docObject . senderissupplier
*
* @ property { Object } userRight
* @ property { Object } userRight . margins
* @ property { boolean } userRight . margins . creer
*
* @ property { Object } langs
* @ property { string } langs . rateMustBeNumeric
* @ property { string } langs . markRateShouldBeLesserThan100
*/
/** @type {JsConf} */
const jsConf = < ? php print json_encode ( $jsConf ); ?> ;
if ( jsConf . conf . usemargins && jsConf . userRight . margins . creer ){
/* Some js test when we click on button "Add" */
$ ( function () {
if ( jsConf . conf . DISPLAY_MARGIN_RATES ) {
$ ( " input[name='np_marginRate']:first " ) . on ( 'blur' , function ( e ) {
console . log ( " np_marginRate blur " );
return checkFreeLine ( e , " np_marginRate " );
});
}
2014-05-05 12:30:08 +00:00
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . DISPLAY_MARK_RATES ) {
$ ( " input[name='np_markRate']:first " ) . on ( 'blur' , function ( e ) {
console . log ( " np_markRate blur " );
return checkFreeLine ( e , " np_markRate " );
});
}
});
2019-03-06 12:01:01 +00:00
2026-01-21 13:24:30 +00:00
/* TODO This does not work for number with thousand separator that is , */
function checkFreeLine ( e , npRate )
{
var buying_price = $ ( " input[name='buying_price']:first " );
var remise = $ ( " input[name='remise_percent']:first " );
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
var rate = $ ( " input[name=' " + npRate + " ']:first " );
if ( rate . val () == '' ) {
return true ;
}
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
const rateValue = rate . val () . replace ( ',' , '.' ) . trim ();
if ( rateValue === '' || isNaN ( Number ( rateValue )))
{
alert ( jsConf . langs . rateMustBeNumeric ); // TODO move to Dolibarr context tool setEventMessage when it will be included
e . stopPropagation ();
setTimeout ( function () { rate . focus () }, 50 );
return false ;
}
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
if ( npRate == " np_markRate " && rate . val () >= 100 )
{
alert ( jsConf . langs . markRateShouldBeLesserThan100 );
e . stopPropagation ();
setTimeout ( function () { rate . focus () }, 50 );
return false ;
2025-12-17 12:41:35 +00:00
}
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
var price = 0 ;
remisejs = price2numjs ( remise . val ());
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
if ( remisejs != 100 ) // If a discount not 100 or no discount
{
if ( remisejs == '' ) remisejs = 0 ;
bpjs = price2numjs ( buying_price . val ());
ratejs = price2numjs ( rate . val ());
if ( npRate == " np_marginRate " ) {
price = (( bpjs * ( 1 + ratejs / 100 )) / ( 1 - remisejs / 100 ));
}
else if ( npRate == " np_markRate " ) {
price = (( bpjs / ( 1 - ratejs / 100 )) / ( 1 - remisejs / 100 ));
}
}
2020-02-19 02:07:12 +00:00
2026-01-21 13:24:30 +00:00
$ ( " input[name='price_ht']:first " ) . val ( price ); // TODO Must use a function like php price to have here a formatted value
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
return true ;
}
2020-01-01 21:45:47 +00:00
}
2024-12-19 00:05:39 +00:00
/* Function to set focus on description */
function setFocusOnDescription () {
console . log ( " Set focus on description field " );
/* this focus code works on a standard textarea but not if field was replaced with CKEDITOR */
jQuery ( '#dp_desc' ) . focus ();
/* this focus code works for CKEDITOR */
if ( typeof CKEDITOR == " object " && typeof CKEDITOR . instances != " undefined " ) {
var editor = CKEDITOR . instances [ 'dp_desc' ];
if ( editor ) {
editor . focus ();
}
}
}
2026-08-13 03:41:17 +00:00
/* Function to set the value of an extrafield of a line, whatever the type of the field is */
function setExtrafieldValueOnLine ( field , key , value ) {
/* For a radio, there is no field with id=key. Each choice is an input with name=key */
if ( field . length == 0 ) {
jQuery ( 'input:radio[name="' + key + '"]' ) . filter ( function () {
return this . value == value ;
}) . prop ( 'checked' , true ) . trigger ( 'change' );
return ;
}
/* For a checkbox, val() sets the value attribute only, it does not tick the box */
if ( field . is ( ':checkbox' )) {
field . prop ( 'checked' , ( value == 1 )) . trigger ( 'change' );
return ;
}
/* A multiple select (type checkbox or chkbxlst) stores its value as a string like "1,3" */
if ( field . is ( 'select' )) {
field . val ( field . prop ( 'multiple' ) ? String ( value ) . split ( ',' ) : value ) . trigger ( 'change' );
return ;
}
/* For a field of type html, the textarea is managed by CKEditor */
if ( field . is ( 'textarea' ) && typeof CKEDITOR == " object " && typeof CKEDITOR . instances != " undefined " && CKEDITOR . instances [ key ]) {
CKEDITOR . instances [ key ] . setData ( value ? value : '' );
return ;
}
/* For a date, the value posted by the form is the one of the hidden day/month/year fields */
if ( jQuery ( " # " + key + " day " ) . length > 0 ) {
if ( value ) {
var thedate = new Date ( value * 1000 );
jQuery ( " # " + key + " day " ) . val ( thedate . getDate ());
jQuery ( " # " + key + " month " ) . val ( thedate . getMonth () + 1 );
jQuery ( " # " + key + " year " ) . val ( thedate . getFullYear ());
jQuery ( " # " + key + " hour " ) . val ( thedate . getHours ());
jQuery ( " # " + key + " min " ) . val ( thedate . getMinutes ());
/* The format to show is the one given to dpChangeDay by the date input itself */
var formatofdate = / dpChangeDay\ ([ ^ ,] * , \s * '([^' ] + ) '/.exec(field.attr(' onchange ') || ' ' );
if ( formatofdate ) {
field . val ( formatDate ( thedate , formatofdate [ 1 ]));
}
} else {
jQuery ( " # " + key + " day, # " + key + " month, # " + key + " year " ) . val ( '' );
field . val ( '' );
}
return ;
}
field . val ( value );
}
2020-01-01 21:45:47 +00:00
/* JQuery for product free or predefined select */
jQuery ( document ) . ready ( function () {
2020-02-19 02:07:12 +00:00
jQuery ( " #price_ht " ) . keyup ( function ( event ) {
// console.log(event.which); // discard event tag and arrows
if ( event . which != 9 && ( event . which < 37 || event . which > 40 ) && jQuery ( " #price_ht " ) . val () != '' ) {
2024-12-19 00:05:39 +00:00
jQuery ( " #price_ttc " ) . val ( '' );
jQuery ( " #multicurrency_subprice " ) . val ( '' );
jQuery ( " #multicurrency_price_ht " ) . val ( '' );
2026-03-06 00:16:16 +00:00
jQuery ( " #multicurrency_price_ttc " ) . val ( '' );
2024-12-19 00:05:39 +00:00
}
});
2020-01-01 21:45:47 +00:00
2024-12-19 00:05:39 +00:00
jQuery ( " #price_ttc " ) . keyup ( function ( event ) {
// console.log(event.which); // discard event tag and arrows
if ( event . which != 9 && ( event . which < 37 || event . which > 40 ) && jQuery ( " #price_ttc " ) . val () != '' ) {
jQuery ( " #price_ht " ) . val ( '' );
jQuery ( " #multicurrency_subprice " ) . val ( '' );
jQuery ( " #multicurrency_price_ht " ) . val ( '' );
2026-03-06 00:16:16 +00:00
jQuery ( " #multicurrency_price_ttc " ) . val ( '' );
2021-02-10 01:17:01 +00:00
}
2024-12-19 00:05:39 +00:00
});
jQuery ( " #multicurrency_subprice " ) . keyup ( function ( event ) {
// console.log(event.which); // discard event tag and arrows
if ( event . which != 9 && ( event . which < 37 || event . which > 40 ) && jQuery ( " #multicurrency_subprice " ) . val () != '' ) {
jQuery ( " #price_ht " ) . val ( '' );
jQuery ( " #price_ttc " ) . val ( '' );
2026-03-06 00:16:16 +00:00
jQuery ( " #multicurrency_price_ttc " ) . val ( '' );
2024-12-19 00:05:39 +00:00
}
});
jQuery ( " #multicurrency_price_ht " ) . keyup ( function ( event ) {
// console.log(event.which); // discard event tag and arrows
if ( event . which != 9 && ( event . which < 37 || event . which > 40 ) && jQuery ( " #multicurrency_price_ht " ) . val () != '' ) {
jQuery ( " #price_ht " ) . val ( '' );
jQuery ( " #price_ttc " ) . val ( '' );
2026-03-06 00:16:16 +00:00
jQuery ( " #multicurrency_price_ttc " ) . val ( '' );
}
});
jQuery ( " #multicurrency_price_ttc " ) . keyup ( function ( event ) {
// console.log(event.which); // discard event tag and arrows
if ( event . which != 9 && ( event . which < 37 || event . which > 40 ) && jQuery ( " #multicurrency_price_ttc " ) . val () != '' ) {
jQuery ( " #price_ht " ) . val ( '' );
jQuery ( " #price_ttc " ) . val ( '' );
jQuery ( " #multicurrency_price_ht " ) . val ( '' );
2024-12-19 00:05:39 +00:00
}
});
2022-03-26 10:44:36 +00:00
2024-12-19 00:05:39 +00:00
$ ( " #select_type " ) . change ( function ()
2021-02-10 01:17:01 +00:00
{
2024-12-19 00:05:39 +00:00
setforfree ();
2020-01-01 21:45:47 +00:00
2024-12-19 00:05:39 +00:00
console . log ( " Hide/show date according to product type select_type= " + jQuery ( '#select_type' ) . val ());
if ( jQuery ( '#select_type' ) . val () == '0' )
{
jQuery ( '#trlinefordates' ) . hide ();
jQuery ( '.divlinefordates' ) . hide ();
}
else
{
jQuery ( '#trlinefordates' ) . show ();
jQuery ( '.divlinefordates' ) . show ();
}
if ( jQuery ( " #select_type " ) . val () != '-1' ) {
2026-01-21 13:24:30 +00:00
console . log ( " we remove class " );
2024-12-19 00:05:39 +00:00
jQuery ( " #select_type " ) . removeClass ( " placeholder " );
setFocusOnDescription ();
} else {
2026-01-21 13:24:30 +00:00
console . log ( " we add class " );
2024-12-19 00:05:39 +00:00
jQuery ( " #select_type " ) . addClass ( " placeholder " );
}
});
$ ( " #prod_entry_mode_free " ) . on ( " click " , function () {
setforfree ();
});
$ ( " #prod_entry_mode_predef " ) . on ( " click " , function () {
console . log ( " click prod_entry_mode_predef " );
jQuery ( " #select_type " ) . addClass ( " placeholder " );
setforpredef ();
jQuery ( '#trlinefordates' ) . show ();
});
2020-01-01 21:45:47 +00:00
2026-02-08 13:25:27 +00:00
if ( ! jsConf . conf . freelines ) {
2026-01-20 01:11:14 +00:00
console . log ( " emulate click on prod_entry_mode_predef " );
2024-12-19 00:05:39 +00:00
jQuery ( " #prod_entry_mode_predef " ) . click ();
2026-01-21 13:24:30 +00:00
} else if ( jsConf . conf . noGetPostType ){
2026-01-20 01:11:14 +00:00
console . log ( " add class placeholder " );
2024-12-19 00:05:39 +00:00
jQuery ( " #select_type " ) . addClass ( " placeholder " );
}
2021-07-21 06:26:41 +00:00
2026-01-21 13:24:30 +00:00
if ([ 'propaldet' , 'commandedet' , 'facturedet' ] . includes ( jsConf . docObject . table_element_line )) {
$ ( " #date_start, #date_end " ) . focusout ( function () {
console . log ( " focusout of date " );
let type = $ ( this ) . attr ( 'type' );
let mandatoryP = $ ( this ) . attr ( 'mandatoryperiod' );
if ( type == 1 && mandatoryP == 1 ) {
if ( $ ( this ) . val () == '' && ! $ ( this ) . hasClass ( 'inputmandatory' )) {
$ ( this ) . addClass ( 'inputmandatory' );
} else {
$ ( this ) . removeClass ( 'inputmandatory' );
}
2024-12-19 00:05:39 +00:00
}
2026-01-21 13:24:30 +00:00
});
}
2020-01-01 21:45:47 +00:00
2024-12-19 00:05:39 +00:00
/* When changing predefined product, we reload list of supplier prices required for margin combo */
$ ( " #idprod, #idprodfournprice " ) . change ( function ()
{
2026-01-21 13:24:30 +00:00
console . log ( " objectline_create.tpl Call method change() after change on #idprod or #idprodfournprice (senderissupplier= " + jsConf . docObject . senderissupplier + " ). this.val = " + $ ( this ) . val ());
2022-12-07 11:36:37 +00:00
2024-12-19 00:05:39 +00:00
setforpredef (); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva(product)
2018-03-01 01:37:18 +00:00
2024-12-19 00:05:39 +00:00
jQuery ( '#trlinefordates' ) . show ();
2020-07-06 13:34:26 +00:00
2026-01-21 13:24:30 +00:00
if ( ! jsConf . conf . MAIN_DISABLE_EDIT_PREDEF_PRICEHT && ! jsConf . docObject . senderissupplier ) {
2024-12-19 00:05:39 +00:00
var pbq = parseInt ( $ ( 'option:selected' , this ) . attr ( 'data-pbq' )); /* If product was selected with a HTML select */
if ( isNaN ( pbq )) { pbq = jQuery ( '#idprod' ) . attr ( 'data-pbq' ); } /* If product was selected with a HTML input with autocomplete */
2021-07-20 09:23:35 +00:00
2026-01-21 13:24:30 +00:00
if (( jQuery ( '#idprod' ) . val () > 0 || jQuery ( '#idprodfournprice' ) . val ()) && ! isNaN ( pbq ) && pbq > 0 ) {
2024-12-19 00:05:39 +00:00
console . log ( " objectline_create.tpl We are in a price per qty context, we do not call ajax/product, init of fields is done few lines later " );
} else {
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . PRODUIT_CUSTOMER_PRICES_BY_QTY || jsConf . conf . PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES ) {
2024-12-19 00:05:39 +00:00
if ( isNaN ( pbq )) { console . log ( " We use experimental option PRODUIT_CUSTOMER_PRICES_BY_QTY or PRODUIT_CUSTOMER_PRICES_BY_QTY but we could not get the id of pbq from product combo list, so load of price may be 0 if product has different prices " ); }
2026-01-21 13:24:30 +00:00
}
2026-04-20 20:01:27 +00:00
let idProdFournPrice = $ ( this ) . val ();
2024-12-19 00:05:39 +00:00
// Get the price for the product and display it
2026-01-21 13:24:30 +00:00
console . log ( " Load unit price and set it into #price_ht or #price_ttc for product id= " + $ ( this ) . val () + " socid= " + jsConf . docObject . socid );
$ . post ( jsConf . url . fetchProductUrl ,
{ 'id' : $ ( this ) . val (), 'socid' : jsConf . docObject . socid , 'token' : jsConf . conf . newtoken , 'addalsovatforthirdpartyid' : 1 },
2024-12-19 00:05:39 +00:00
function ( data ) {
console . log ( " objectline_create.tpl Load unit price ends, we got value ht= " + data . price_ht + " ttc= " + data . price_ttc + " pricebasetype= " + data . pricebasetype );
$ ( '#date_start' ) . removeAttr ( 'type' );
$ ( '#date_end' ) . removeAttr ( 'type' );
$ ( '#date_start' ) . attr ( 'type' , data . type );
$ ( '#date_end' ) . attr ( 'type' , data . type );
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . PRODUCT_USE_UNITS ) {
2025-09-11 10:13:46 +00:00
console . log ( " objectline_create.tpl set content of units " );
jQuery ( " #units " ) . val ( data . default_unit ) . change ();
}
2024-12-19 00:05:39 +00:00
$ ( '#date_start' ) . removeAttr ( 'mandatoryperiod' );
$ ( '#date_end' ) . removeAttr ( 'mandatoryperiod' );
$ ( '#date_start' ) . attr ( 'mandatoryperiod' , data . mandatory_period );
$ ( '#date_end' ) . attr ( 'mandatoryperiod' , data . mandatory_period );
// service and we set mandatory_period to true
if ( data . mandatory_period == 1 && data . type == 1 ) {
jQuery ( '#date_start' ) . addClass ( 'inputmandatory' );
jQuery ( '#date_end' ) . addClass ( 'inputmandatory' );
} else {
jQuery ( '#date_start' ) . removeClass ( 'inputmandatory' );
jQuery ( '#date_end' ) . removeClass ( 'inputmandatory' );
}
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . inputalsopricewithtax == 1 && data . pricebasetype == 'TTC' && jsConf . conf . MAIN_NO_INPUT_PRICE_WITH_TAX ) {
2024-12-19 00:05:39 +00:00
console . log ( " objectline_create.tpl set content of price_ttc " );
jQuery ( " #price_ttc " ) . val ( data . price_ttc );
} else {
console . log ( " objectline_create.tpl set content of price_ht " );
jQuery ( " #price_ht " ) . val ( data . price_ht );
}
2022-12-07 11:36:37 +00:00
2026-06-08 23:09:47 +00:00
// useful to retrieve percent from customer specific price
2026-06-08 22:47:44 +00:00
if ( typeof data . discount !== 'undefined' && data . discount !== null && data . discount !== '' ) {
var remisePercentInput = jQuery ( '#remise_percent' );
if ( remisePercentInput . length > 0 ) {
console . log ( " Remise spécifique client trouvée : " + data . discount + " % " );
remisePercentInput
. val ( data . discount )
. trigger ( 'input' )
. trigger ( 'change' );
} else {
console . warn ( " Champ #remise_percent introuvable, remise non appliquée " );
}
}
2024-12-19 00:05:39 +00:00
// Set values for any fields in the form options_SOMETHING
for ( var key in data . array_options ) {
if ( data . array_options . hasOwnProperty ( key )) {
2026-08-13 03:41:17 +00:00
console . log ( " objectline_create.tpl set content of " + key );
setExtrafieldValueOnLine ( jQuery ( " # " + key ), key , data . array_options [ key ]);
2024-02-12 04:38:51 +00:00
}
}
2024-12-19 00:05:39 +00:00
var tva_tx = data . tva_tx ;
var default_vat_code = data . default_vat_code ;
// Now set the VAT
var stringforvatrateselection = tva_tx ;
if ( typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '' ) {
stringforvatrateselection = stringforvatrateselection + ' (' + default_vat_code + ')' ;
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA ) {
2024-12-19 00:05:39 +00:00
console . log ( " MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA is on so we check if we need to autoswith the vat code " );
2026-01-21 13:24:30 +00:00
console . log ( " mysoc->country_code= " + jsConf . mySoc . country_code + " thirdparty->country_code= " + jsConf . docObject . thirdparty . country_code );
2024-12-19 00:05:39 +00:00
new_default_vat_code = default_vat_code ;
2026-01-21 13:24:30 +00:00
if ( jsConf . mySoc . country_code === 'IN'
&& jsConf . docObject . thirdparty
&& jsConf . docObject . thirdparty . country_code === 'IN'
) {
if ( jsConf . mySoc . state_code === jsConf . docObject . thirdparty . state_code ) {
console . log ( " Countries are both IN and states are same, so we revert I into CS in default_vat_code= " + default_vat_code );
new_default_vat_code = default_vat_code . replace ( /^ I\ -/ , 'C+S-' );
}
else {
console . log ( " Countries are both IN and states differs, so we revert CS into I in default_vat_code= " + default_vat_code );
new_default_vat_code = default_vat_code . replace ( /^ C\ + S\ -/ , 'I-' );
}
}
2024-12-19 00:05:39 +00:00
if ( new_default_vat_code != default_vat_code && jQuery ( '#tva_tx option:contains("' + new_default_vat_code + '")' ) . val ()) {
console . log ( " We found en entry into VAT with new default_vat_code, we will use it " );
stringforvatrateselection = jQuery ( '#tva_tx option:contains("' + new_default_vat_code + '")' ) . val ();
}
2026-01-21 13:24:30 +00:00
}
2024-12-19 00:05:39 +00:00
}
2026-04-13 11:25:05 +00:00
// Set vat rate: handle both input box and combo cases
if ( $ ( '#tva_tx option' ) . length ) {
// It is a combo: try exact match first (rate + code), fallback to numeric match
if ( $ ( '#tva_tx option[value="' + stringforvatrateselection + '"]' ) . length ) {
$ ( '#tva_tx' ) . val ( stringforvatrateselection );
} else {
$ ( '#tva_tx option' ) . filter ( function () {
return parseFloat ( $ ( this ) . val ()) === parseFloat ( tva_tx );
}) . first () . prop ( 'selected' , true );
}
} else {
// It is an input box
$ ( '#tva_tx' ) . val ( tva_tx );
}
2024-12-19 00:05:39 +00:00
2026-06-01 21:34:40 +00:00
// Sync the measuring unit dropdown with the product's default fk_unit
2026-06-08 22:04:20 +00:00
// (issue #34610). Without this, the dropdown keeps the static initial
2026-06-01 21:34:40 +00:00
// value (the first c_units row, typically "Kg") regardless of what
// the selected product is configured with.
if ( typeof data . fk_unit != 'undefined' && data . fk_unit != null && $ ( " #units " ) . length ) {
$ ( " #units " ) . val ( data . fk_unit ) . trigger ( 'change' );
2026-06-08 22:04:20 +00:00
} else if ( typeof data . default_unit != 'undefined' && data . default_unit != null && $ ( " #units " ) . length ) {
$ ( " #units " ) . val ( data . default_unit ) . trigger ( 'change' );
2026-06-01 21:34:40 +00:00
}
2026-06-08 22:27:55 +00:00
if ( jsConf . conf . PRODUIT_AUTOFILL_DESC == 1 ) {
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . MAIN_MULTILANGS && jsConf . conf . PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE ) {
var proddesc = data . desc_trans ;
2026-06-08 22:27:55 +00:00
} else {
2026-01-21 13:24:30 +00:00
var proddesc = data . desc ;
}
console . log ( " objectline_create.tpl Load description into text area : " + proddesc );
2026-06-08 22:27:55 +00:00
if ( jsConf . conf . FCKEDITOR_ENABLE_DETAILS ) {
if ( typeof CKEDITOR == " object " && typeof CKEDITOR . instances != " undefined " ) {
2026-01-21 13:24:30 +00:00
var editor = CKEDITOR . instances [ 'dp_desc' ];
if ( editor ) {
editor . setData ( proddesc );
}
}
} else {
jQuery ( '#dp_desc' ) . text ( proddesc );
2024-12-19 00:05:39 +00:00
}
}
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . PRODUCT_LOAD_EXTRAFIELD_INTO_OBJECTLINES ) {
2024-12-19 00:05:39 +00:00
jQuery . each ( data . array_options , function ( key , value ) {
2026-08-13 03:41:17 +00:00
setExtrafieldValueOnLine ( jQuery ( 'div[class*="det' + key . replace ( 'options_' , '_extras_' ) + '"] > #' + key ), key , value );
2024-12-19 00:05:39 +00:00
});
2026-01-21 13:24:30 +00:00
}
2026-04-20 20:01:27 +00:00
// Execute js context Dolibarr Hooks
if ( typeof Dolibarr != 'undefined' ) {
Dolibarr . executeHook ( 'objectLineCreate:LoadUnitPrice' , { idProdFournPrice , 'socid' : jsConf . docObject . socid , ajaxResultData : data , jsConf });
}
2024-12-19 00:05:39 +00:00
},
'json'
);
}
2020-02-19 02:07:12 +00:00
}
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . usemargins && jsConf . userRight . margins . creer ){
2016-07-23 14:37:21 +00:00
2024-12-19 00:05:39 +00:00
/* Code for margin */
$ ( " #fournprice_predef " ) . find ( " option " ) . remove ();
$ ( " #fournprice_predef " ) . hide ();
$ ( " #buying_price " ) . val ( " " ) . show ();
2026-04-20 20:01:27 +00:00
let idProd = $ ( this ) . val ();
2020-03-03 23:38:43 +00:00
2024-12-19 00:05:39 +00:00
/* Call post to load content of combo list fournprice_predef */
2026-01-21 13:24:30 +00:00
var token = jsConf . conf . token ; // For AJAX Call we use old 'token' and not 'newtoken'
2026-04-20 20:01:27 +00:00
$ . post ( jsConf . url . getSupplierPrices , { 'idprod' : idProd , 'token' : token }, function ( data ) {
2024-12-19 00:05:39 +00:00
if ( data && data . length > 0 )
{
var options = '' ; var defaultkey = '' ; var defaultprice = '' ; var bestpricefound = 0 ;
2016-07-23 14:37:21 +00:00
2024-12-19 00:05:39 +00:00
var bestpriceid = 0 ; var bestpricevalue = 0 ;
var pmppriceid = 0 ; var pmppricevalue = 0 ;
var costpriceid = 0 ; var costpricevalue = 0 ;
2019-09-07 11:12:39 +00:00
2024-12-19 00:05:39 +00:00
/* setup of margin calculation */
2026-01-21 13:24:30 +00:00
const defaultbuypriceMap = {
" 1 " : " bestsupplierprice " ,
" pmp " : " pmp " ,
" costprice " : " costprice "
};
let defaultbuyprice = defaultbuypriceMap [ jsConf . conf . MARGIN_TYPE ] || " " ;
2024-12-19 00:05:39 +00:00
console . log ( " objectline_create.tpl we will set the field for margin. defaultbuyprice= " + defaultbuyprice );
2020-03-03 23:38:43 +00:00
2024-12-19 00:05:39 +00:00
var i = 0 ;
$ ( data ) . each ( function () {
/* Warning: Lines must be processed in order: best supplier price, then pmpprice line then costprice */
if ( this . id != 'pmpprice' && this . id != 'costprice' )
2020-03-03 23:38:43 +00:00
{
2024-12-19 00:05:39 +00:00
i ++ ;
this . price = parseFloat ( this . price ); // to fix when this.price >0
// If margin is calculated on best supplier price, we set it by default (but only if value is not 0)
//console.log("id="+this.id+"-price="+this.price+"-"+(this.price > 0));
if ( bestpricefound == 0 && this . price > 0 ) { defaultkey = this . id ; defaultprice = this . price ; bestpriceid = this . id ; bestpricevalue = this . price ; bestpricefound = 1 ; } // bestpricefound is used to take the first price > 0
}
if ( this . id == 'pmpprice' )
{
// If margin is calculated on PMP, we set it by default (but only if value is not 0)
console . log ( " id= " + this . id + " -price= " + this . price );
if ( 'pmp' == defaultbuyprice || 'costprice' == defaultbuyprice )
{
if ( this . price > 0 ) {
defaultkey = this . id ; defaultprice = this . price ; pmppriceid = this . id ; pmppricevalue = this . price ;
//console.log("pmppricevalue="+pmppricevalue);
}
2020-03-03 23:38:43 +00:00
}
}
2024-12-19 00:05:39 +00:00
if ( this . id == 'costprice' )
2020-03-03 23:38:43 +00:00
{
2024-12-19 00:05:39 +00:00
// If margin is calculated on Cost price, we set it by default (but only if value is not 0)
console . log ( " id= " + this . id + " -price= " + this . price + " -pmppricevalue= " + pmppricevalue );
if ( 'costprice' == defaultbuyprice )
{
if ( this . price > 0 ) { defaultkey = this . id ; defaultprice = this . price ; costpriceid = this . id ; costpricevalue = this . price ; }
else if ( pmppricevalue > 0 ) { defaultkey = 'pmpprice' ; defaultprice = pmppricevalue ; }
}
2020-03-03 23:38:43 +00:00
}
2024-12-19 00:05:39 +00:00
options += '<option value="' + this . id + '" price="' + this . price + '">' + this . label + '</option>' ;
});
options += '<option value="inputprice" price="' + defaultprice + '"><?php echo dol_escape_js($langs->trans("InputPrice").' ... '); ?></option>' ;
2019-11-30 11:49:31 +00:00
2024-12-19 00:05:39 +00:00
console . log ( " finally selected defaultkey= " + defaultkey + " defaultprice for buying price= " + defaultprice );
2019-11-30 11:49:31 +00:00
2024-12-19 00:05:39 +00:00
$ ( " #fournprice_predef " ) . html ( options ) . show ();
if ( defaultkey != '' )
{
$ ( " #fournprice_predef " ) . val ( defaultkey );
}
2019-11-30 11:49:31 +00:00
2024-12-19 00:05:39 +00:00
/* At loading, no product are yet selected, so we hide field of buying_price */
$ ( " #buying_price " ) . hide ();
2019-11-30 11:49:31 +00:00
2024-12-19 00:05:39 +00:00
/* Define default price at loading */
var defaultprice = $ ( " #fournprice_predef " ) . find ( 'option:selected' ) . attr ( " price " );
$ ( " #buying_price " ) . val ( defaultprice );
2020-01-01 21:45:47 +00:00
2024-12-19 00:05:39 +00:00
$ ( " #fournprice_predef " ) . change ( function () {
console . log ( " change on fournprice_predef " );
/* Hide field buying_price according to choice into list (if 'inputprice' or not) */
var linevalue = $ ( this ) . find ( 'option:selected' ) . val ();
var pricevalue = $ ( this ) . find ( 'option:selected' ) . attr ( " price " );
if ( linevalue != 'inputprice' && linevalue != 'pmpprice' ) {
$ ( " #buying_price " ) . val ( pricevalue ) . hide (); /* We set value then hide field */
}
if ( linevalue == 'inputprice' ) {
$ ( '#buying_price' ) . show ();
}
if ( linevalue == 'pmpprice' ) {
$ ( " #buying_price " ) . val ( pricevalue );
$ ( '#buying_price' ) . hide ();
}
});
2026-04-20 20:01:27 +00:00
// Execute js context Dolibarr Hooks
if ( typeof Dolibarr != 'undefined' ) {
Dolibarr . executeHook ( 'objectLineCreate:GetSupplierPrices' , { 'idprod' : idProd , ajaxResultData : data , jsConf });
}
2026-06-12 17:25:23 +00:00
2026-06-10 20:13:21 +00:00
< ? php if ( getDolGlobalString ( 'PRODUCT_USE_UNITS' )) { ?>
// Sync the measuring unit dropdown with the product's default fk_unit
// for the supplier-side line picker (issue #38636), mirroring the
// customer-side behaviour from issue #34610. Look at the first
// non-pmp/non-cost row of the AJAX response (all rows for a given
// product carry the same fk_unit since it comes from llx_product).
var firstFkUnit = null ;
$ ( data ) . each ( function () {
if ( this . id != 'pmpprice' && this . id != 'costprice' && typeof this . fk_unit != 'undefined' && this . fk_unit != null && firstFkUnit === null ) {
firstFkUnit = this . fk_unit ;
}
});
if ( firstFkUnit !== null && $ ( " #units " ) . length ) {
$ ( " #units " ) . val ( firstFkUnit ) . trigger ( 'change' );
}
< ? php } ?>
2024-12-19 00:05:39 +00:00
}
},
'json' );
}
2022-12-07 11:36:37 +00:00
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . PRODUIT_CUSTOMER_PRICES_BY_QTY || jsConf . conf . PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES ) {
2024-12-19 00:05:39 +00:00
/* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */
var pbq = parseInt ( $ ( 'option:selected' , this ) . attr ( 'data-pbq' )); // When select is done from HTML select
if ( isNaN ( pbq )) { pbq = jQuery ( '#idprod' ) . attr ( 'data-pbq' ); } // When select is done from HTML input with autocomplete
var pbqup = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-pbqup' ));
if ( isNaN ( pbqup )) { pbqup = jQuery ( '#idprod' ) . attr ( 'data-pbqup' ); }
var pbqbase = $ ( 'option:selected' , this ) . attr ( 'data-pbqbase' );
if ( isNaN ( pbqbase )) { pbqbase = jQuery ( '#idprod' ) . attr ( 'data-pbqbase' ); }
var pbqqty = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-pbqqty' ));
if ( isNaN ( pbqqty )) { pbqqty = jQuery ( '#idprod' ) . attr ( 'data-pbqqty' ); }
var pbqpercent = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-pbqpercent' ));
if ( isNaN ( pbqpercent )) { pbqpercent = jQuery ( '#idprod' ) . attr ( 'data-pbqpercent' ); }
if (( jQuery ( '#idprod' ) . val () > 0 ) && ! isNaN ( pbq ) && pbq > 0 )
{
var pbqupht = pbqup ; /* TODO support of price per qty TTC not yet available */
console . log ( " We choose a price by quanty price_by_qty id = " + pbq + " price_by_qty upht = " + pbqupht + " price_by_qty qty = " + pbqqty + " price_by_qty percent = " + pbqpercent );
jQuery ( " #pbq " ) . val ( pbq );
jQuery ( " #price_ht " ) . val ( pbqupht );
if ( jQuery ( " #qty " ) . val () < pbqqty )
{
jQuery ( " #qty " ) . val ( pbqqty );
}
if ( jQuery ( " #remise_percent " ) . val () < pbqpercent )
{
jQuery ( " #remise_percent " ) . val ( pbqpercent );
}
} else { jQuery ( " #pbq " ) . val ( '' ); }
2026-04-20 20:01:27 +00:00
// Execute js context Dolibarr Hooks
if ( typeof Dolibarr != 'undefined' ) {
Dolibarr . executeHook ( 'objectLineCreate:CustomerPriceByQty' , { pbq , pbqup , pbqbase , pbqqty , pbqpercent });
}
2024-12-19 00:05:39 +00:00
}
2022-12-16 11:04:37 +00:00
2024-12-19 00:05:39 +00:00
// Deal with supplier ref price (idprodfournprice = int)
2026-05-18 00:22:16 +00:00
var supplierVal = jQuery ( '#idprodfournprice' ) . val ();
if ( supplierVal && supplierVal !== '-1' && ( supplierVal > 0 || supplierVal . indexOf ( 'idprod_' ) === 0 ))
2024-12-19 00:05:39 +00:00
{
console . log ( " objectline_create.tpl #idprodfournprice is an ID > 0, so we set some properties into page " );
var up = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-up' )); // When select is done from HTML select
if ( isNaN ( up )) { up = parseFloat ( jQuery ( '#idprodfournprice' ) . attr ( 'data-up' ));} // When select is done from HTML input with ajax autocomplete
2022-10-13 12:31:08 +00:00
2024-12-19 00:05:39 +00:00
var up_locale = $ ( 'option:selected' , this ) . attr ( 'data-up-locale' ); // When select is done from HTML select
if ( typeof up_locale === 'undefined' ) { up_locale = jQuery ( '#idprodfournprice' ) . attr ( 'data-up-locale' );} // When select is done from HTML input with ajax autocomplete
2022-10-13 12:31:08 +00:00
2024-12-19 00:05:39 +00:00
var qty = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-qty' ));
if ( isNaN ( qty )) { qty = parseFloat ( jQuery ( '#idprodfournprice' ) . attr ( 'data-qty' ));}
2020-10-26 15:31:07 +00:00
2024-12-19 00:05:39 +00:00
var discount = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-discount' ));
if ( isNaN ( discount )) { discount = parseFloat ( jQuery ( '#idprodfournprice' ) . attr ( 'data-discount' ));}
2020-10-26 15:31:07 +00:00
2024-12-19 00:05:39 +00:00
var tva_tx = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-tvatx' )); // When select is done from HTML select
if ( isNaN ( tva_tx )) { tva_tx = parseFloat ( jQuery ( '#idprodfournprice' ) . attr ( 'data-tvatx' ));} // When select is done from HTML input with ajax autocomplete
2020-10-26 15:31:07 +00:00
2024-12-19 00:05:39 +00:00
var default_vat_code = $ ( 'option:selected' , this ) . attr ( 'data-default-vat-code' ); // When select is done from HTML select
if ( typeof default_vat_code === 'undefined' ) { default_vat_code = jQuery ( '#idprodfournprice' ) . attr ( 'data-default-vat-code' );} // When select is done from HTML input with ajax autocomplete
2022-05-20 17:08:26 +00:00
2024-12-19 00:05:39 +00:00
var supplier_ref = $ ( 'option:selected' , this ) . attr ( 'data-supplier-ref' ); // When select is done from HTML select
if ( typeof supplier_ref === 'undefined' ) { supplier_ref = jQuery ( '#idprodfournprice' ) . attr ( 'data-supplier-ref' ); } // When select is done from HTML input with ajax autocomplete
2022-12-04 14:16:45 +00:00
2026-01-21 13:24:30 +00:00
const supplierElements = [
" supplier_proposal " ,
" order_supplier " ,
" invoice_supplier " ,
" invoice_supplier_rec "
];
2026-06-28 11:43:41 +00:00
// seller.tva_assuj -> to inject into jsConf or elsewhere
2026-01-21 13:24:30 +00:00
if ( supplierElements . includes ( jsConf . docObject . element ) && ! jsConf . docObject . seller_tva_assuj ) {
if ( tva_tx !== 0 ) {
tva_tx = 0 ;
2024-12-19 00:05:39 +00:00
default_vat_code = null ;
}
2026-01-21 13:24:30 +00:00
}
2024-05-02 22:30:01 +00:00
2024-12-19 00:05:39 +00:00
var stringforvatrateselection = tva_tx ;
if ( typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '' ) {
stringforvatrateselection = stringforvatrateselection + ' (' + default_vat_code + ')' ;
2024-05-02 22:30:01 +00:00
}
2024-12-19 00:05:39 +00:00
var has_multicurrency_up = false ;
2026-01-21 13:24:30 +00:00
if ( jsConf . modules . multicurrency && jsConf . docObject . multicurrency_code !== jsConf . conf . currency ) {
var object_multicurrency_code = jsConf . docObject . multicurrency_code ;
2022-12-04 14:16:45 +00:00
2024-12-19 00:05:39 +00:00
var multicurrency_code = $ ( 'option:selected' , this ) . attr ( 'data-multicurrency-code' ); // When select is done from HTML select
if ( multicurrency_code == undefined ) { multicurrency_code = jQuery ( '#idprodfournprice' ) . attr ( 'data-multicurrency-code' ); } // When select is done from HTML input with ajax autocomplete
2020-10-26 15:31:07 +00:00
2024-12-19 00:05:39 +00:00
var multicurrency_up = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-multicurrency-unitprice' )); // When select is done from HTML select
if ( isNaN ( multicurrency_up )) { multicurrency_up = parseFloat ( jQuery ( '#idprodfournprice' ) . attr ( 'data-multicurrency-unitprice' )); } // When select is done from HTML input with ajax autocomplete
2024-02-10 00:09:24 +00:00
2024-12-19 00:05:39 +00:00
if ( multicurrency_code == object_multicurrency_code ) {
has_multicurrency_up = true ;
jQuery ( " #multicurrency_price_ht " ) . val ( multicurrency_up );
}
2024-02-10 00:09:24 +00:00
2024-12-19 00:05:39 +00:00
console . log ( " objectline_create.tpl Multicurrency values : object_multicurrency_code = " + object_multicurrency_code + " , multicurrency_code = " + multicurrency_code + " , multicurrency_up = " + multicurrency_up );
2024-02-10 00:09:24 +00:00
}
2024-12-19 00:05:39 +00:00
console . log ( " objectline_create.tpl We find supplier price : up = " + up + " , up_locale = " + up_locale + " , has_multicurrency_up = " + has_multicurrency_up + " , supplier_ref = " + supplier_ref + " qty = " + qty + " , tva_tx = " + tva_tx + " , default_vat_code = " + default_vat_code + " , stringforvatrateselection= " + stringforvatrateselection + " , discount = " + discount + " for product supplier ref id = " + jQuery ( '#idprodfournprice' ) . val ());
2024-02-10 00:09:24 +00:00
2024-12-19 00:05:39 +00:00
if ( has_multicurrency_up === false ) {
if ( typeof up_locale === 'undefined' ) {
2026-06-25 11:06:51 +00:00
if ( ! Number . isNaN ( up )) {
jQuery ( " #price_ht " ) . val ( up );
}
2024-12-19 00:05:39 +00:00
} else {
2026-06-25 11:06:51 +00:00
if ( ! Number . isNaN ( up_locale )) {
jQuery ( " #price_ht " ) . val ( up_locale );
}
2024-12-19 00:05:39 +00:00
}
2024-02-10 00:09:24 +00:00
}
2022-05-20 20:24:06 +00:00
2024-12-19 00:05:39 +00:00
// Set supplier_ref
$ ( '#fourn_ref' ) . val ( supplier_ref );
// Set vat rate if field is an input box
$ ( '#tva_tx' ) . val ( tva_tx );
// Set vat rate by selecting the combo
//$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options
$ ( '#tva_tx option' ) . removeAttr ( 'selected' );
console . log ( " stringforvatrateselection= " + stringforvatrateselection + " -> value of option label for this key= " + $ ( '#tva_tx option[value="' + stringforvatrateselection + '"]' ) . val ());
$ ( '#tva_tx option[value="' + stringforvatrateselection + '"]' ) . prop ( 'selected' , true );
if ( jQuery ( " #qty " ) . val () < qty ) {
jQuery ( " #qty " ) . val ( qty );
}
if ( jQuery ( " #remise_percent " ) . val () < discount ) {
jQuery ( " #remise_percent " ) . val ( discount );
}
2020-10-28 15:37:41 +00:00
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . PRODUIT_AUTOFILL_DESC === 1 ) {
var description = $ ( 'option:selected' , this ) . attr ( 'data-description' );
2024-12-19 00:05:39 +00:00
2026-01-21 13:24:30 +00:00
if ( typeof description == 'undefined' ) { description = jQuery ( '#idprodfournprice' ) . attr ( 'data-description' ); }
console . log ( " Load description into text area : " + description );
if ( jsConf . conf . FCKEDITOR_ENABLE_DETAILS ) {
if ( typeof CKEDITOR == " object " && typeof CKEDITOR . instances != " undefined " )
{
var editor = CKEDITOR . instances [ 'dp_desc' ];
if ( editor ) {
editor . setData ( description );
}
}
2024-12-19 00:05:39 +00:00
} else {
2026-01-21 13:24:30 +00:00
jQuery ( '#dp_desc' ) . text ( description );
2024-12-19 00:05:39 +00:00
}
}
} else if ( jQuery ( '#idprodfournprice' ) . length > 0 ) {
console . log ( " objectline_create.tpl #idprodfournprice is not an int but is a string so we set only few properties into page " );
2022-12-16 11:04:37 +00:00
2024-12-19 00:05:39 +00:00
var tva_tx = parseFloat ( $ ( 'option:selected' , this ) . attr ( 'data-tvatx' )); // When select is done from HTML select
if ( isNaN ( tva_tx )) { tva_tx = parseFloat ( jQuery ( '#idprodfournprice' ) . attr ( 'data-tvatx' ));} // When select is done from HTML input with ajax autocomplete
2022-12-16 11:04:37 +00:00
2024-12-19 00:05:39 +00:00
var default_vat_code = $ ( 'option:selected' , this ) . attr ( 'data-default-vat-code' ); // When select is done from HTML select
if ( typeof default_vat_code === 'undefined' ) { default_vat_code = jQuery ( '#idprodfournprice' ) . attr ( 'data-default-vat-code' );} // When select is done from HTML input with ajax autocomplete
2022-12-16 11:04:37 +00:00
2024-12-19 00:05:39 +00:00
var supplier_ref = $ ( 'option:selected' , this ) . attr ( 'data-supplier-ref' ); // When select is done from HTML select
if ( typeof supplier_ref === 'undefined' ) { supplier_ref = jQuery ( '#idprodfournprice' ) . attr ( 'data-supplier-ref' ); } // When select is done from HTML input with ajax autocomplete
2024-05-02 22:30:01 +00:00
2024-12-19 00:05:39 +00:00
var stringforvatrateselection = tva_tx ;
if ( typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '' ) {
stringforvatrateselection = stringforvatrateselection + ' (' + default_vat_code + ')' ;
}
2022-12-16 11:04:37 +00:00
2024-12-19 00:05:39 +00:00
console . log ( " objectline_create.tpl We find data for price : tva_tx = " + tva_tx + " , default_vat_code = " + default_vat_code + " , supplier_ref = " + supplier_ref + " , stringforvatrateselection= " + stringforvatrateselection + " for product id = " + jQuery ( '#idprodfournprice' ) . val ());
2024-05-02 22:30:01 +00:00
2024-12-19 00:05:39 +00:00
// Set supplier_ref
$ ( '#fourn_ref' ) . val ( supplier_ref );
// Set vat rate if field is an input box
$ ( '#tva_tx' ) . val ( tva_tx );
// Set vat rate by selecting the combo
//$('#tva_tx option').val(tva_tx); // This is bugged, it replaces the vat key of all options
$ ( '#tva_tx option' ) . removeAttr ( 'selected' );
console . log ( " stringforvatrateselection= " + stringforvatrateselection + " -> value of option label for this key= " + $ ( '#tva_tx option[value="' + stringforvatrateselection + '"]' ) . val ());
$ ( '#tva_tx option[value="' + stringforvatrateselection + '"]' ) . prop ( 'selected' , true );
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . PRODUIT_AUTOFILL_DESC === 1 ) {
if ( jsConf . conf . FCKEDITOR_ENABLE_DETAILS ) {
if ( typeof CKEDITOR == " object " && typeof CKEDITOR . instances != " undefined " )
{
var editor = CKEDITOR . instances [ 'dp_desc' ];
if ( editor ) {
editor . setData ( '' );
}
}
2024-12-19 00:05:39 +00:00
} else {
2026-01-21 13:24:30 +00:00
jQuery ( '#dp_desc' ) . text ( '' );
2024-12-19 00:05:39 +00:00
}
2020-10-28 15:37:41 +00:00
}
2022-12-16 11:04:37 +00:00
}
2020-01-01 16:15:26 +00:00
2020-10-28 15:37:41 +00:00
2024-12-19 00:05:39 +00:00
/* To set focus */
if ( jQuery ( '#idprod' ) . val () > 0 || jQuery ( '#idprodfournprice' ) . val () > 0 )
2020-01-01 16:15:26 +00:00
{
2024-12-19 00:05:39 +00:00
console . log ( " Try to set focus on desc " );
/* this focus code works on a standard textarea but not if field was replaced with CKEDITOR */
jQuery ( '#dp_desc' ) . focus ();
/* this focus code works for CKEDITOR */
if ( typeof CKEDITOR == " object " && typeof CKEDITOR . instances != " undefined " )
{
var editor = CKEDITOR . instances [ 'dp_desc' ];
if ( editor ) {
editor . focus ();
}
}
2020-01-01 16:15:26 +00:00
}
2024-12-19 00:05:39 +00:00
});
2020-01-01 21:45:47 +00:00
2026-01-21 13:24:30 +00:00
if ( jsConf . conf . prod_entry_mode_is_predef ) { // When we submit with a predef product and it fails we must start with predef?>
setforpredef ();
}
2024-12-19 00:05:39 +00:00
2026-04-20 20:01:27 +00:00
// Execute js context Dolibarr Hooks
if ( typeof Dolibarr != 'undefined' ) {
Dolibarr . executeHook ( 'objectLineCreate:ProductSelectionChange' );
}
2020-01-01 21:45:47 +00:00
});
2023-01-10 20:46:11 +00:00
/* Function to set fields visibility after selecting a free product */
2020-01-01 21:45:47 +00:00
function setforfree () {
2022-10-13 12:31:08 +00:00
console . log ( " objectline_create.tpl::setforfree. We show most fields " );
2020-01-01 21:45:47 +00:00
jQuery ( " #idprodfournprice " ) . val ( '0' ); // Set cursor on not selected product
jQuery ( " #prod_entry_mode_free " ) . prop ( 'checked' , true ) . change ();
jQuery ( " #prod_entry_mode_predef " ) . prop ( 'checked' , false ) . change ();
jQuery ( " #search_idprod, #idprod, #search_idprodfournprice, #buying_price " ) . val ( '' );
2022-01-10 02:24:01 +00:00
jQuery ( " #price_ht, #multicurrency_price_ht, #price_ttc, #multicurrency_price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_fourn_ref, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency " ) . show ();
2020-01-01 21:45:47 +00:00
jQuery ( " #np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units " ) . show ();
jQuery ( " #fournprice_predef " ) . hide ();
}
2021-07-20 09:23:35 +00:00
2020-01-01 21:45:47 +00:00
function setforpredef () {
2022-10-13 12:31:08 +00:00
console . log ( " objectline_create.tpl::setforpredef We hide some fields, show dates " );
2024-12-19 00:05:39 +00:00
2020-01-01 21:45:47 +00:00
jQuery ( " #select_type " ) . val ( - 1 );
2024-12-19 00:05:39 +00:00
jQuery ( " #select_type " ) . addClass ( " placeholder " );
2024-12-23 22:22:47 +00:00
/* jQuery("#select_type").trigger("change"); // Disabled. This create troubles. Never mind if the rester of combo is not done when using an ajax select_type combo. We don't use it because we are not able to call a focus on a change event of this combo. */
2024-12-19 00:05:39 +00:00
2020-01-01 21:45:47 +00:00
jQuery ( " #prod_entry_mode_free " ) . prop ( 'checked' , false ) . change ();
jQuery ( " #prod_entry_mode_predef " ) . prop ( 'checked' , true ) . change ();
2026-01-21 13:24:30 +00:00
if ( ! jsConf . conf . MAIN_DISABLE_EDIT_PREDEF_PRICEHT ) {
2020-01-01 21:45:47 +00:00
jQuery ( " #price_ht " ) . val ( '' ) . show ();
jQuery ( " #multicurrency_price_ht " ) . val ( '' ) . show ();
2020-05-03 07:15:12 +00:00
jQuery ( " #title_up_ht, #title_up_ht_currency " ) . show ();
2026-01-21 13:24:30 +00:00
} else {
2022-03-26 10:22:54 +00:00
//jQuery("#price_ht").val('').hide();
2020-01-01 21:45:47 +00:00
jQuery ( " #multicurrency_price_ht " ) . val ( '' ) . hide ();
2020-05-03 07:15:12 +00:00
jQuery ( " #title_up_ht, #title_up_ht_currency " ) . hide ();
2026-01-21 13:24:30 +00:00
}
if ( ! jsConf . conf . MAIN_DISABLE_EDIT_PREDEF_PRICETTC ) {
2022-01-10 02:24:01 +00:00
jQuery ( " #price_ttc " ) . val ( '' ) . show ();
jQuery ( " #multicurrency_price_ttc " ) . val ( '' ) . show ();
jQuery ( " #title_up_ttc, #title_up_ttc_currency " ) . show ();
2026-01-21 13:24:30 +00:00
} else {
2022-03-26 10:22:54 +00:00
jQuery ( " #price_ttc " ) . val ( '' ) . hide ();
jQuery ( " #multicurrency_price_ttc " ) . val ( '' ) . hide ();
jQuery ( " #title_up_ttc, #title_up_ttc_currency " ) . hide ();
2026-01-21 13:24:30 +00:00
}
2023-01-10 20:46:11 +00:00
/* jQuery("#tva_tx, #title_vat").hide(); */
2022-01-10 02:24:01 +00:00
/* jQuery("#title_fourn_ref").hide(); */
2026-01-21 13:24:30 +00:00
if ( ! jsConf . conf . DISPLAY_MARGIN_RATES ) {
2024-09-10 12:54:37 +00:00
jQuery ( " #np_marginRate, .np_marginRate " ) . hide ();
2026-01-21 13:24:30 +00:00
}
if ( ! jsConf . conf . DISPLAY_MARK_RATES ) {
2024-09-10 12:54:37 +00:00
jQuery ( " #np_markRate, .np_markRate " ) . hide ();
2026-01-21 13:24:30 +00:00
}
2026-06-10 18:03:47 +00:00
jQuery ( " #units, #title_units, .linecoluseunit .selection " ) . hide ();
2020-01-01 21:45:47 +00:00
jQuery ( " #buying_price " ) . show ();
jQuery ( '#trlinefordates, .divlinefordates' ) . show ();
}
2026-01-21 13:24:30 +00:00
</ script >
2020-01-01 16:15:26 +00:00
< ? php
2020-01-01 21:45:47 +00:00
2024-12-19 00:05:39 +00:00
//print '<span onclick="setFocusOnDescription();">Click</span>';
2020-01-01 16:15:26 +00:00
print " <!-- END PHP TEMPLATE objectline_create.tpl.php --> \n " ;