2004-11-16 17:47:56 +01:00
< ? php
2007-01-02 16:27:51 +01:00
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2021-09-21 16:32:32 +02:00
* Copyright ( C ) 2004 - 2021 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-07-12 11:06:25 +02:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2012-11-30 17:58:12 +01:00
* Copyright ( C ) 2010 - 2012 Juanjo Menent < jmenent @ 2 byte . es >
2012-07-19 15:36:25 +02:00
* Copyright ( C ) 2012 Christophe Battarel < christophe . battarel @ altairis . fr >
2015-01-18 18:44:22 +01:00
* Copyright ( C ) 2014 Ion Agorria < ion @ agorria . com >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2015 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2016-01-27 12:13:31 +01:00
* Copyright ( C ) 2016 Ferran Marcet < fmarcet @ 2 byte . es >
2019-09-04 15:16:29 +02:00
* Copyright ( C ) 2019 Frédéric France < frederic . france @ netlogic . fr >
* Copyright ( C ) 2019 Tim Otte < otte @ meuser . it >
2020-03-25 19:01:56 +01:00
* Copyright ( C ) 2020 Pierre Ardoin < mapiolca @ me . com >
2004-11-16 17:47:56 +01: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2004-11-16 17:47:56 +01:00
* ( 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 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2004-11-16 17:47:56 +01:00
*/
2005-04-02 15:56:33 +02:00
/**
2009-08-06 15:21:23 +02:00
* \file htdocs / product / fournisseurs . php
* \ingroup product
2011-06-17 20:52:33 +02:00
* \brief Page of tab suppliers for products
2009-08-06 15:21:23 +02:00
*/
2004-11-16 17:47:56 +01:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php' ;
2018-02-23 11:06:07 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2019-09-04 15:13:42 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php' ;
2015-03-14 16:50:02 +01:00
require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_expression.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> barcode -> enabled )) {
dol_include_once ( '/core/class/html.formbarcode.class.php' );
}
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
2020-08-21 04:58:21 +02:00
$langs -> loadLangs ( array ( 'products' , 'suppliers' , 'bills' , 'margins' , 'stocks' ));
2004-11-16 17:47:56 +01:00
2012-02-11 11:44:15 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
2019-11-08 10:53:31 +01:00
$rowid = GETPOST ( 'rowid' , 'int' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-08 10:53:31 +01:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'pricesuppliercard' ;
2018-03-31 18:48:27 +02:00
2019-11-08 10:53:31 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2021-09-21 16:32:32 +02:00
$cost_price = price2num ( GETPOST ( 'cost_price' , 'alpha' ), '' , 2 );
$pmp = price2num ( GETPOST ( 'pmp' , 'alpha' ), '' , 2 );
2019-11-08 10:53:31 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
$error = 0 ;
2011-10-04 01:26:07 +02:00
2019-09-04 15:13:42 +02:00
$extrafields = new ExtraFields ( $db );
2009-08-28 03:14:35 +02:00
// If socid provided by ajax company selector
2022-01-10 03:24:01 +01:00
if ( GETPOST ( 'search_fourn_id' , 'int' )) {
2021-03-30 03:55:17 +02:00
$_GET [ 'id_fourn' ] = GETPOST ( 'search_fourn_id' , 'int' );
$_POST [ 'id_fourn' ] = GETPOST ( 'search_fourn_id' , 'int' );
2009-08-28 03:14:35 +02:00
}
2009-04-27 22:37:50 +02:00
// Security check
2019-11-08 10:53:31 +01:00
$fieldvalue = ( ! empty ( $id ) ? $id : ( ! empty ( $ref ) ? $ref : '' ));
$fieldtype = ( ! empty ( $ref ) ? 'ref' : 'rowid' );
2021-02-26 14:25:17 +01:00
if ( $user -> socid ) {
$socid = $user -> socid ;
}
2012-03-01 16:51:59 +01:00
2021-02-26 14:25:17 +01:00
if ( empty ( $user -> rights -> fournisseur -> lire )) {
accessforbidden ();
}
2012-03-01 16:51:59 +01:00
2019-11-08 10:53:31 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2019-11-08 10:53:31 +01:00
$page = ( GETPOST ( " page " , 'int' ) ? GETPOST ( " page " , 'int' ) : 0 );
2021-02-26 14:25:17 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2018-01-25 20:57:51 +01:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2021-02-26 14:25:17 +01:00
if ( ! $sortfield ) {
$sortfield = " s.nom " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2018-01-25 20:57:51 +01:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2019-11-08 10:53:31 +01:00
$hookmanager -> initHooks ( array ( 'pricesuppliercard' , 'globalcard' ));
2015-10-17 12:01:17 +02:00
$object = new ProductFournisseur ( $db );
2021-02-26 14:25:17 +01:00
if ( $id > 0 || $ref ) {
2020-10-31 14:32:18 +01:00
$object -> fetch ( $id , $ref );
2015-10-17 12:01:17 +02:00
}
2014-02-04 10:48:35 +01:00
2021-08-09 20:01:06 +02:00
$usercanread = (( $object -> type == Product :: TYPE_PRODUCT && $user -> rights -> produit -> lire ) || ( $object -> type == Product :: TYPE_SERVICE && $user -> rights -> service -> lire ));
$usercancreate = (( $object -> type == Product :: TYPE_PRODUCT && $user -> rights -> produit -> creer ) || ( $object -> type == Product :: TYPE_SERVICE && $user -> rights -> service -> creer ));
2021-05-21 15:54:11 +02:00
if ( $object -> id > 0 ) {
if ( $object -> type == $object :: TYPE_PRODUCT ) {
restrictedArea ( $user , 'produit' , $object -> id , 'product&product' , '' , '' );
}
if ( $object -> type == $object :: TYPE_SERVICE ) {
restrictedArea ( $user , 'service' , $object -> id , 'product&product' , '' , '' );
}
} else {
restrictedArea ( $user , 'produit|service' , $fieldvalue , 'product&product' , '' , '' , $fieldtype );
2021-02-26 14:25:17 +01:00
}
2021-04-01 11:01:07 +02:00
2004-11-16 17:47:56 +01:00
2005-06-11 13:39:38 +02:00
/*
* Actions
*/
2014-04-02 14:53:42 +02:00
2021-02-26 14:25:17 +01:00
if ( $cancel ) {
$action = '' ;
}
2015-04-08 12:22:52 +02:00
2019-11-08 10:53:31 +01:00
$parameters = array ( 'socid' => $socid , 'id_prod' => $id );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 14:25:17 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
if ( empty ( $reshook )) {
if ( $action == 'setcost_price' ) {
if ( $id ) {
2019-11-08 10:53:31 +01:00
$result = $object -> fetch ( $id );
2017-06-11 10:37:58 +02:00
$object -> cost_price = price2num ( $cost_price );
2019-11-08 10:53:31 +01:00
$result = $object -> update ( $object -> id , $user );
2021-02-26 14:25:17 +01:00
if ( $result > 0 ) {
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( " RecordSaved " ), null , 'mesgs' );
2020-10-31 14:32:18 +01:00
$action = '' ;
2020-05-21 15:05:19 +02:00
} else {
2015-11-30 21:20:45 +01:00
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
}
2021-09-21 16:32:32 +02:00
if ( $action == 'setpmp' ) {
if ( $id ) {
$result = $object -> fetch ( $id );
$object -> pmp = price2num ( $pmp );
$sql = " UPDATE " . MAIN_DB_PREFIX . " product SET pmp = " . (( float ) $object -> pmp ) . " WHERE rowid = " . (( int ) $id );
$resql = $db -> query ( $sql );
//$result = $object->update($object->id, $user);
if ( $resql ) {
setEventMessages ( $langs -> trans ( " RecordSaved " ), null , 'mesgs' );
$action = '' ;
} else {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
}
2017-06-11 10:37:58 +02:00
2021-02-26 14:25:17 +01:00
if ( $action == 'confirm_remove_pf' ) {
if ( $rowid ) { // id of product supplier price to remove
2015-10-17 12:01:17 +02:00
$action = '' ;
2019-11-08 10:53:31 +01:00
$result = $object -> remove_product_fournisseur_price ( $rowid );
if ( $result > 0 ) {
2021-09-21 16:32:32 +02:00
$db -> query ( " DELETE FROM " . MAIN_DB_PREFIX . " product_fournisseur_price_extrafields WHERE fk_object = " . (( int ) $rowid ));
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( " PriceRemoved " ), null , 'mesgs' );
2019-11-08 10:53:31 +01:00
} else {
2015-10-21 10:07:53 +02:00
$error ++ ;
2015-11-30 21:20:45 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-10-21 10:07:53 +02:00
}
2007-07-09 00:23:03 +02:00
}
2009-08-06 15:21:23 +02:00
}
2005-06-26 17:37:57 +02:00
2021-02-26 14:25:17 +01:00
if ( $action == 'save_price' ) {
2019-11-08 10:53:31 +01:00
$id_fourn = GETPOST ( " id_fourn " );
2021-02-26 14:25:17 +01:00
if ( empty ( $id_fourn )) {
$id_fourn = GETPOST ( " search_id_fourn " );
}
2019-11-08 10:53:31 +01:00
$ref_fourn = GETPOST ( " ref_fourn " );
2021-02-26 14:25:17 +01:00
if ( empty ( $ref_fourn )) {
$ref_fourn = GETPOST ( " search_ref_fourn " );
}
2019-11-08 10:53:31 +01:00
$ref_fourn_old = GETPOST ( " ref_fourn_old " );
2021-02-26 14:25:17 +01:00
if ( empty ( $ref_fourn_old )) {
$ref_fourn_old = $ref_fourn ;
}
2022-06-13 10:44:20 +02:00
$quantity = price2num ( GETPOST ( " qty " , 'alphanohtml' ), 'MS' );
2019-11-08 10:53:31 +01:00
$remise_percent = price2num ( GETPOST ( 'remise_percent' , 'alpha' ));
2021-02-10 01:10:31 +01:00
2021-01-31 12:48:40 +01:00
$npr = preg_match ( '/\*/' , GETPOST ( 'tva_tx' , 'alpha' )) ? 1 : 0 ;
2019-01-27 11:55:16 +01:00
$tva_tx = str_replace ( '*' , '' , GETPOST ( 'tva_tx' , 'alpha' ));
2021-02-10 01:10:31 +01:00
if ( ! preg_match ( '/\((.*)\)/' , $tva_tx )) {
$tva_tx = price2num ( $tva_tx );
}
2015-04-08 12:22:52 +02:00
$price_expression = GETPOST ( 'eid' , 'int' ) ? GETPOST ( 'eid' , 'int' ) : '' ; // Discard expression if not in expression mode
$delivery_time_days = GETPOST ( 'delivery_time_days' , 'int' ) ? GETPOST ( 'delivery_time_days' , 'int' ) : '' ;
2016-04-04 15:06:54 +02:00
$supplier_reputation = GETPOST ( 'supplier_reputation' );
2020-10-27 19:06:41 +01:00
$supplier_description = GETPOST ( 'supplier_description' , 'restricthtml' );
2020-10-31 14:32:18 +01:00
$barcode = GETPOST ( 'barcode' , 'alpha' );
$fk_barcode_type = GETPOST ( 'fk_barcode_type' , 'int' );
2020-10-12 13:05:18 +02:00
$packaging = price2num ( GETPOST ( " packaging " , 'alphanohtml' ), 'MS' );
2015-04-08 12:22:52 +02:00
2021-02-26 14:25:17 +01:00
if ( $tva_tx == '' ) {
2015-01-17 19:28:27 +01:00
$error ++ ;
2015-04-08 12:22:52 +02:00
$langs -> load ( " errors " );
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " VATRateForSupplierProduct " )), null , 'errors' );
2015-01-17 19:28:27 +01:00
}
2021-02-26 14:25:17 +01:00
if ( ! is_numeric ( $tva_tx )) {
2015-04-08 12:22:52 +02:00
$error ++ ;
$langs -> load ( " errors " );
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldMustBeANumeric " , $langs -> transnoentities ( " VATRateForSupplierProduct " )), null , 'errors' );
2015-04-08 12:22:52 +02:00
}
2021-02-26 14:25:17 +01:00
if ( empty ( $quantity )) {
2015-04-08 12:22:52 +02:00
$error ++ ;
$langs -> load ( " errors " );
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Qty " )), null , 'errors' );
2015-04-08 12:22:52 +02:00
}
2021-02-26 14:25:17 +01:00
if ( empty ( $ref_fourn )) {
2015-04-08 12:22:52 +02:00
$error ++ ;
$langs -> load ( " errors " );
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " RefSupplier " )), null , 'errors' );
2015-04-08 12:22:52 +02:00
}
2021-02-26 14:25:17 +01:00
if ( $id_fourn <= 0 ) {
2015-04-08 12:22:52 +02:00
$error ++ ;
$langs -> load ( " errors " );
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Supplier " )), null , 'errors' );
2015-04-08 12:22:52 +02:00
}
2021-03-25 16:59:47 +01:00
if ( price2num ( GETPOST ( " price " )) < 0 || GETPOST ( " price " ) == '' ) {
2021-02-26 14:25:17 +01:00
if ( $price_expression === '' ) { // Return error of missing price only if price_expression not set
2015-04-08 12:22:52 +02:00
$error ++ ;
$langs -> load ( " errors " );
2015-10-17 17:09:34 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Price " )), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2015-04-08 12:22:52 +02:00
$_POST [ " price " ] = 0 ;
}
2009-12-10 00:40:30 +01:00
}
2020-11-22 11:36:07 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
2021-03-16 10:19:56 +01:00
if ( ! GETPOST ( " multicurrency_code " )) {
2020-10-31 14:32:18 +01:00
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Currency " )), null , 'errors' );
}
2021-03-16 10:19:56 +01:00
if ( price2num ( GETPOST ( " multicurrency_tx " )) <= 0 || GETPOST ( " multicurrency_tx " ) == '' ) {
2020-10-31 14:32:18 +01:00
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " CurrencyRate " )), null , 'errors' );
}
2021-03-16 10:19:56 +01:00
if ( price2num ( GETPOST ( " multicurrency_price " )) < 0 || GETPOST ( " multicurrency_price " ) == '' ) {
2020-10-31 14:32:18 +01:00
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " PriceCurrency " )), null , 'errors' );
}
}
2015-04-07 03:00:11 +02:00
2021-02-26 14:25:17 +01:00
if ( ! $error ) {
2015-01-18 17:13:42 +01:00
$db -> begin ();
2012-07-19 15:36:25 +02:00
2021-02-26 14:25:17 +01:00
if ( ! $error ) {
2019-11-08 10:53:31 +01:00
$ret = $object -> add_fournisseur ( $user , $id_fourn , $ref_fourn_old , $quantity ); // This insert record with no value for price. Values are update later with update_buyprice
2021-02-26 14:25:17 +01:00
if ( $ret == - 3 ) {
2015-01-17 19:28:27 +01:00
$error ++ ;
2009-12-13 23:29:13 +01:00
2022-11-25 23:15:01 +01:00
$tmpobject = new Product ( $db );
$tmpobject -> fetch ( $object -> product_id_already_linked );
$productLink = $tmpobject -> getNomUrl ( 1 , 'supplier' );
2009-12-13 23:29:13 +01:00
2022-11-25 23:15:01 +01:00
$texttoshow = $langs -> trans ( " ReferenceSupplierIsAlreadyAssociatedWithAProduct " , '{s1}' );
$texttoshow = str_replace ( '{s1}' , $productLink , $texttoshow );
setEventMessages ( $texttoshow , null , 'errors' );
2021-02-26 14:25:17 +01:00
} elseif ( $ret < 0 ) {
2015-01-17 19:28:27 +01:00
$error ++ ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
}
2009-12-10 00:40:30 +01:00
}
2009-12-13 23:29:13 +01:00
2021-02-26 14:25:17 +01:00
if ( ! $error ) {
2019-11-08 10:53:31 +01:00
$supplier = new Fournisseur ( $db );
$result = $supplier -> fetch ( $id_fourn );
2019-11-14 21:30:16 +01:00
if ( GETPOSTISSET ( 'ref_fourn_price_id' )) {
2019-11-14 21:16:18 +01:00
$object -> fetch_product_fournisseur_price ( GETPOST ( 'ref_fourn_price_id' , 'int' ));
2019-11-14 21:30:16 +01:00
}
2019-11-08 10:53:31 +01:00
$extralabels = $extrafields -> fetch_name_optionals_label ( " product_fournisseur_price " );
2019-09-04 15:13:42 +02:00
$extrafield_values = $extrafields -> getOptionalsFromPost ( " product_fournisseur_price " );
2019-11-02 18:11:18 +01:00
2019-01-27 11:55:16 +01:00
$newprice = price2num ( GETPOST ( " price " , " alpha " ));
2018-08-29 20:12:38 +02:00
2021-02-26 14:25:17 +01:00
if ( empty ( $packaging )) {
$packaging = 1 ;
}
2022-03-17 18:53:50 +01:00
/* We can have a puchase ref that need to buy 100 min for a given price and with a packaging of 50.
2021-02-26 14:25:17 +01:00
if ( $packaging < $quantity ) {
$packaging = $quantity ;
2022-03-17 18:53:50 +01:00
} */
2020-10-12 11:44:12 +02:00
$object -> packaging = $packaging ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
2020-10-31 14:32:18 +01:00
$multicurrency_tx = price2num ( GETPOST ( " multicurrency_tx " , 'alpha' ));
$multicurrency_price = price2num ( GETPOST ( " multicurrency_price " , 'alpha' ));
$multicurrency_code = GETPOST ( " multicurrency_code " , 'alpha' );
2018-08-29 20:12:38 +02:00
2022-06-21 16:34:23 +02:00
$ret = $object -> update_buyprice ( $quantity , $newprice , $user , GETPOST ( " price_base_type " ), $supplier , GETPOST ( " oselDispo " ), $ref_fourn , $tva_tx , GETPOST ( " charges " ), $remise_percent , 0 , $npr , $delivery_time_days , $supplier_reputation , array (), '' , $multicurrency_price , GETPOST ( " multicurrency_price_base_type " ), $multicurrency_tx , $multicurrency_code , $supplier_description , $barcode , $fk_barcode_type , $extrafield_values );
2020-10-31 14:32:18 +01:00
} else {
2022-06-21 16:34:23 +02:00
$ret = $object -> update_buyprice ( $quantity , $newprice , $user , GETPOST ( " price_base_type " ), $supplier , GETPOST ( " oselDispo " ), $ref_fourn , $tva_tx , GETPOST ( " charges " ), $remise_percent , 0 , $npr , $delivery_time_days , $supplier_reputation , array (), '' , 0 , 'HT' , 1 , '' , $supplier_description , $barcode , $fk_barcode_type , $extrafield_values );
2020-10-31 14:32:18 +01:00
}
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
2015-01-17 19:28:27 +01:00
$error ++ ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> dynamicprices -> enabled ) && $price_expression !== '' ) {
2015-01-18 18:44:22 +01:00
//Check the expression validity by parsing it
2020-10-31 14:32:18 +01:00
$priceparser = new PriceParser ( $db );
$object -> fk_supplier_price_expression = $price_expression ;
$price_result = $priceparser -> parseProductSupplier ( $object );
2015-01-18 18:44:22 +01:00
if ( $price_result < 0 ) { //Expression is not valid
$error ++ ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $priceparser -> translatedError (), null , 'errors' );
2015-01-18 18:44:22 +01:00
}
}
2021-02-26 14:25:17 +01:00
if ( ! $error && ! empty ( $conf -> dynamicprices -> enabled )) {
2016-02-14 14:50:10 +01:00
//Set the price expression for this supplier price
2019-11-08 10:53:31 +01:00
$ret = $object -> setSupplierPriceExpression ( $price_expression );
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
2015-01-18 18:44:22 +01:00
$error ++ ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-18 18:44:22 +01:00
}
2014-11-29 06:31:35 +01:00
}
}
2009-06-08 20:14:37 +02:00
}
2021-02-26 14:25:17 +01:00
if ( ! $error ) {
2015-01-17 19:28:27 +01:00
$db -> commit ();
2019-11-08 10:53:31 +01:00
$action = '' ;
2020-05-21 15:05:19 +02:00
} else {
2015-01-17 19:28:27 +01:00
$db -> rollback ();
2009-06-08 20:14:37 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2015-04-08 12:22:52 +02:00
$action = 'add_price' ;
}
2015-01-17 19:28:27 +01:00
}
2004-11-16 17:47:56 +01:00
}
2004-11-22 09:06:13 +01:00
/*
2010-03-13 23:27:37 +01:00
* view
2004-11-22 09:06:13 +01:00
*/
2010-03-13 23:27:37 +01:00
2021-02-27 02:44:52 +01:00
$form = new Form ( $db );
2016-08-10 07:40:40 +02:00
$title = $langs -> trans ( 'ProductServiceCard' );
$helpurl = '' ;
2019-01-27 11:55:16 +01:00
$shortlabel = dol_trunc ( $object -> label , 16 );
2021-02-26 14:25:17 +01:00
if ( GETPOST ( " type " ) == '0' || ( $object -> type == Product :: TYPE_PRODUCT )) {
2019-11-08 10:53:31 +01:00
$title = $langs -> trans ( 'Product' ) . " " . $shortlabel . " - " . $langs -> trans ( 'BuyingPrices' );
2022-03-21 10:49:37 +01:00
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte' ;
2016-08-10 07:40:40 +02:00
}
2021-02-26 14:25:17 +01:00
if ( GETPOST ( " type " ) == '1' || ( $object -> type == Product :: TYPE_SERVICE )) {
2019-11-08 10:53:31 +01:00
$title = $langs -> trans ( 'Service' ) . " " . $shortlabel . " - " . $langs -> trans ( 'BuyingPrices' );
2022-03-21 10:49:37 +01:00
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Lesitungen' ;
2016-08-10 07:40:40 +02:00
}
2020-12-27 16:53:15 +01:00
llxHeader ( '' , $title , $helpurl , '' , 0 , 0 , '' , '' , '' , 'classforhorizontalscrolloftabs' );
2016-07-28 12:17:00 +02:00
2021-02-26 14:25:17 +01:00
if ( $id > 0 || $ref ) {
if ( $result ) {
2016-05-06 09:21:21 +02:00
if ( $action == 'ask_remove_pf' ) {
$form = new Form ( $db );
2019-11-08 10:53:31 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '&rowid=' . $rowid , $langs -> trans ( 'DeleteProductBuyPrice' ), $langs -> trans ( 'ConfirmDeleteProductBuyPrice' ), 'confirm_remove_pf' , '' , 0 , 1 );
2016-05-06 09:21:21 +02:00
echo $formconfirm ;
}
2017-06-11 10:37:58 +02:00
2021-06-11 19:42:36 +02:00
if ( $action != 'edit' && $action != 're-edit' ) {
2019-11-08 10:53:31 +01:00
$head = product_prepare_head ( $object );
$titre = $langs -> trans ( " CardProduct " . $object -> type );
$picto = ( $object -> type == Product :: TYPE_SERVICE ? 'service' : 'product' );
2017-06-11 10:37:58 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'suppliers' , $titre , - 1 , $picto );
2017-06-11 10:37:58 +02:00
2017-10-03 16:00:52 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/product/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2020-10-31 14:32:18 +01:00
$object -> next_prev_filter = " fk_product_type = " . $object -> type ;
2017-06-12 16:26:25 +02:00
2020-10-31 14:32:18 +01:00
$shownav = 1 ;
2021-02-26 14:25:17 +01:00
if ( $user -> socid && ! in_array ( 'product' , explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL ))) {
$shownav = 0 ;
}
2017-06-12 16:26:25 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , $shownav , 'ref' );
2017-06-11 10:37:58 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="fichecenter">' ;
2017-06-11 10:37:58 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="underbanner clearboth"></div>' ;
2021-02-16 19:01:00 +01:00
print '<table class="border tableforfield centpercent">' ;
2009-06-08 20:14:37 +02:00
2021-08-09 20:01:06 +02:00
// Type
if ( ! empty ( $conf -> product -> enabled ) && ! empty ( $conf -> service -> enabled )) {
$typeformat = 'select;0:' . $langs -> trans ( " Product " ) . ',1:' . $langs -> trans ( " Service " );
print '<tr><td class="">' ;
print ( empty ( $conf -> global -> PRODUCT_DENY_CHANGE_PRODUCT_TYPE )) ? $form -> editfieldkey ( " Type " , 'fk_product_type' , $object -> type , $object , 0 , $typeformat ) : $langs -> trans ( 'Type' );
print '</td><td>' ;
print $form -> editfieldval ( " Type " , 'fk_product_type' , $object -> type , $object , 0 , $typeformat );
print '</td></tr>' ;
}
2015-11-30 21:20:45 +01:00
// Cost price. Can be used for margin module for option "calculate margin on explicit cost price
2020-10-31 14:32:18 +01:00
print '<tr><td>' ;
2019-11-08 10:53:31 +01:00
$textdesc = $langs -> trans ( " CostPriceDescription " );
$textdesc .= " <br> " . $langs -> trans ( " CostPriceUsage " );
$text = $form -> textwithpicto ( $langs -> trans ( " CostPrice " ), $textdesc , 1 , 'help' , '' );
2019-05-10 11:23:19 +02:00
print $form -> editfieldkey ( $text , 'cost_price' , $object -> cost_price , $object , $usercancreate , 'amount:6' );
2021-08-09 20:01:06 +02:00
print '</td><td>' ;
2020-10-31 14:32:18 +01:00
print $form -> editfieldval ( $text , 'cost_price' , $object -> cost_price , $object , $usercancreate , 'amount:6' );
print '</td></tr>' ;
// PMP
2021-09-21 16:32:32 +02:00
$usercaneditpmp = 0 ;
if ( ! empty ( $conf -> global -> PRODUCT_CAN_EDIT_WAP )) {
$usercaneditpmp = $usercancreate ;
}
print '<tr><td class="titlefieldcreate">' ;
$textdesc = $langs -> trans ( " AverageUnitPricePMPDesc " );
$text = $form -> textwithpicto ( $langs -> trans ( " AverageUnitPricePMPShort " ), $textdesc , 1 , 'help' , '' );
print $form -> editfieldkey ( $text , 'pmp' , $object -> pmp , $object , $usercaneditpmp , 'amount:6' );
print '</td><td>' ;
print $form -> editfieldval ( $text , 'pmp' , ( $object -> pmp > 0 ? $object -> pmp : '' ), $object , $usercaneditpmp , 'amount:6' );
if ( $object -> pmp > 0 ) {
print ' ' . $langs -> trans ( " HT " );
}
/*
. $form -> textwithpicto ( $langs -> trans ( " AverageUnitPricePMPShort " ), $langs -> trans ( " AverageUnitPricePMPDesc " )) . '</td>' ;
2020-10-31 14:32:18 +01:00
print '<td>' ;
2021-02-26 14:25:17 +01:00
if ( $object -> pmp > 0 ) {
print price ( $object -> pmp ) . ' ' . $langs -> trans ( " HT " );
2021-09-21 16:32:32 +02:00
} */
2020-10-31 14:32:18 +01:00
print '</td>' ;
print '</tr>' ;
// Best buying Price
2021-02-16 19:01:00 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " BuyingPriceMin " ) . '</td>' ;
2021-08-09 20:01:06 +02:00
print '<td>' ;
2020-10-31 14:32:18 +01:00
$product_fourn = new ProductFournisseur ( $db );
2021-02-26 14:25:17 +01:00
if ( $product_fourn -> find_min_price_product_fournisseur ( $object -> id ) > 0 ) {
if ( $product_fourn -> product_fourn_price_id > 0 ) {
print $product_fourn -> display_price_product_fournisseur ();
} else {
print $langs -> trans ( " NotDefined " );
}
2020-10-31 14:32:18 +01:00
}
print '</td></tr>' ;
print '</table>' ;
print '</div>' ;
print '<div style="clear:both"></div>' ;
2017-06-11 10:37:58 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2017-06-11 10:37:58 +02:00
2007-03-21 00:08:26 +01:00
2008-08-29 09:40:45 +02:00
// Form to add or update a price
2021-02-26 14:25:17 +01:00
if (( $action == 'add_price' || $action == 'update_price' ) && $usercancreate ) {
2007-03-21 00:08:26 +01:00
$langs -> load ( " suppliers " );
2009-06-08 20:14:37 +02:00
2022-08-10 14:32:26 +02:00
print " <!-- form to add a supplier price --> \n " ;
print '<br>' ;
2021-02-26 14:25:17 +01:00
if ( $rowid ) {
2015-10-17 12:01:17 +02:00
$object -> fetch_product_fournisseur_price ( $rowid , 1 ); //Ignore the math expression when getting the price
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " ChangeSupplierPrice " ));
2020-05-21 15:05:19 +02:00
} else {
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " AddSupplierPrice " ));
2009-06-08 20:14:37 +02:00
}
2011-10-04 01:26:07 +02:00
2015-10-17 12:01:17 +02:00
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-09-05 09:47:40 +02:00
print '<input type="hidden" name="action" value="save_price">' ;
2017-06-11 10:37:58 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ();
2009-06-08 20:14:37 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2011-10-04 01:26:07 +02:00
2016-04-08 22:18:36 +02:00
// Supplier
2022-08-10 05:06:58 +02:00
print '<tr><td class="titlefield fieldrequired">' . $langs -> trans ( " Supplier " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $rowid ) {
2019-11-08 10:53:31 +01:00
$supplier = new Fournisseur ( $db );
2011-10-05 12:51:55 +02:00
$supplier -> fetch ( $socid );
2008-02-11 22:17:22 +01:00
print $supplier -> getNomUrl ( 1 );
2011-10-05 12:51:55 +02:00
print '<input type="hidden" name="id_fourn" value="' . $socid . '">' ;
2012-07-25 12:53:02 +02:00
print '<input type="hidden" name="ref_fourn_price_id" value="' . $rowid . '">' ;
2015-04-08 12:22:52 +02:00
print '<input type="hidden" name="rowid" value="' . $rowid . '">' ;
print '<input type="hidden" name="socid" value="' . $socid . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-08 10:53:31 +01:00
$events = array ();
$events [] = array ( 'method' => 'getVatRates' , 'url' => dol_buildpath ( '/core/ajax/vatrates.php' , 1 ), 'htmlname' => 'tva_tx' , 'params' => array ());
2022-01-10 03:24:01 +01:00
print img_picto ( '' , 'company' , 'class="pictofixedwidth"' ) . $form -> select_company ( GETPOST ( " id_fourn " , 'alpha' ), 'id_fourn' , 'fournisseur=1' , 'SelectThirdParty' , 0 , 0 , $events );
2012-05-23 10:50:38 +02:00
2019-11-08 10:53:31 +01:00
$parameters = array ( 'filtre' => " fournisseur=1 " , 'html_name' => 'id_fourn' , 'selected' => GETPOST ( " id_fourn " ), 'showempty' => 1 , 'prod_id' => $object -> id );
2020-10-31 14:32:18 +01:00
$reshook = $hookmanager -> executeHooks ( 'formCreateThirdpartyOptions' , $parameters , $object , $action );
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
if ( empty ( $form -> result )) {
2022-03-14 11:29:17 +01:00
print '<a href="' . DOL_URL_ROOT . '/societe/card.php?action=create&type=f&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=' . $action ) . '">' ;
print img_picto ( $langs -> trans ( " CreateDolibarrThirdPartySupplier " ), 'add' , 'class="marginleftonly"' );
print '</a>' ;
2014-04-16 00:06:16 +02:00
}
2012-02-29 14:32:22 +01:00
}
2007-03-21 00:08:26 +01:00
}
2008-02-11 22:17:22 +01:00
print '</td></tr>' ;
2009-06-08 20:14:37 +02:00
2011-08-21 01:56:03 +02:00
// Ref supplier
2012-10-02 00:30:23 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " SupplierRef " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $rowid ) {
2020-10-31 14:32:18 +01:00
print '<input type="hidden" name="ref_fourn_old" value="' . $object -> ref_supplier . '">' ;
2022-09-24 18:47:35 +02:00
print '<input class="flat width150" maxlength="128" name="ref_fourn" value="' . $object -> ref_supplier . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2022-09-24 18:47:35 +02:00
print '<input class="flat width150" maxlength="128" name="ref_fourn" value="' . ( GETPOST ( " ref_fourn " ) ? GETPOST ( " ref_fourn " ) : '' ) . '">' ;
2007-07-09 00:23:03 +02:00
}
2007-05-14 02:31:23 +02:00
print '</td>' ;
2008-02-11 22:17:22 +01:00
print '</tr>' ;
2012-05-23 10:50:38 +02:00
2011-08-21 01:56:03 +02:00
// Availability
2022-08-30 17:01:31 +02:00
if ( getDolGlobalInt ( 'FOURN_PRODUCT_AVAILABILITY' )) {
2011-10-06 11:54:36 +02:00
$langs -> load ( " propal " );
2012-10-02 00:30:23 +02:00
print '<tr><td>' . $langs -> trans ( " Availability " ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
$form -> selectAvailabilityDelay ( $object -> fk_availability , " oselDispo " , 1 );
2011-08-17 17:22:39 +02:00
print '</td></tr>' . " \n " ;
}
2011-08-21 01:56:03 +02:00
// Qty min
2008-02-11 22:17:22 +01:00
print '<tr>' ;
2012-03-15 16:52:18 +01:00
print '<td class="fieldrequired">' . $langs -> trans ( " QtyMin " ) . '</td>' ;
print '<td>' ;
2022-06-13 10:44:20 +02:00
$quantity = GETPOSTISSET ( 'qty' ) ? price2num ( GETPOST ( 'qty' , 'alphanohtml' ), 'MS' ) : " 1 " ;
2021-02-26 14:25:17 +01:00
if ( $rowid ) {
2015-10-17 12:01:17 +02:00
print '<input type="hidden" name="qty" value="' . $object -> fourn_qty . '">' ;
print $object -> fourn_qty ;
2020-05-21 15:05:19 +02:00
} else {
2007-07-09 00:23:03 +02:00
print '<input class="flat" name="qty" size="5" value="' . $quantity . '">' ;
}
2020-10-31 14:32:18 +01:00
// Units
2020-11-25 18:07:52 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2020-10-31 14:32:18 +01:00
$unit = $object -> getLabelOfUnit ();
if ( $unit !== '' ) {
print ' ' . $langs -> trans ( $unit );
}
}
2015-04-07 03:00:11 +02:00
print '</td></tr>' ;
2012-10-02 00:30:23 +02:00
2020-10-12 11:10:49 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_SUPPLIER_PACKAGING )) {
2022-08-23 13:39:06 +02:00
// Packaging/Conditionnement
2020-10-12 11:10:49 +02:00
print '<tr>' ;
print '<td class="fieldrequired">' . $form -> textwithpicto ( $langs -> trans ( " PackagingForThisProduct " ), $langs -> trans ( " PackagingForThisProductDesc " )) . '</td>' ;
print '<td>' ;
2022-06-13 10:44:20 +02:00
$packaging = GETPOSTISSET ( 'packaging' ) ? price2num ( GETPOST ( 'packaging' , 'alphanohtml' ), 'MS' ) : (( empty ( $rowid )) ? " 1 " : price2num ( $object -> packaging , 'MS' ));
2020-10-12 11:44:12 +02:00
print '<input class="flat" name="packaging" size="5" value="' . $packaging . '">' ;
2020-10-12 11:10:49 +02:00
// Units
2020-11-25 18:07:52 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2020-10-12 11:10:49 +02:00
$unit = $object -> getLabelOfUnit ();
if ( $unit !== '' ) {
print ' ' . $langs -> trans ( $unit );
}
}
}
2012-10-02 00:30:23 +02:00
// Vat rate
2019-11-08 10:53:31 +01:00
$default_vat = '' ;
2012-10-02 00:30:23 +02:00
// We don't have supplier, so we try to guess.
2012-10-08 20:47:10 +02:00
// For this we build a fictive supplier with same properties than user but using vat)
2015-09-24 16:32:48 +02:00
$mysoc2 = clone $mysoc ;
2019-11-08 10:53:31 +01:00
$mysoc2 -> name = 'Fictive seller with same country' ;
$mysoc2 -> tva_assuj = 1 ;
$default_vat = get_default_tva ( $mysoc2 , $mysoc , $object -> id , 0 );
$default_npr = get_default_npr ( $mysoc2 , $mysoc , $object -> id , 0 );
2021-02-26 14:25:17 +01:00
if ( empty ( $default_vat )) {
$default_npr = $default_vat ;
}
2017-06-11 10:37:58 +02:00
2012-10-02 00:30:23 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " VATRateForSupplierProduct " ) . '</td>' ;
print '<td>' ;
2015-10-17 12:01:17 +02:00
//print $form->load_tva('tva_tx',$object->tva_tx,$supplier,$mysoc); // Do not use list here as it may be any vat rates for any country
2021-02-26 14:25:17 +01:00
if ( ! empty ( $rowid )) { // If we have a supplier, it is an update, we must show the vat of current supplier price
2020-10-31 14:32:18 +01:00
$tmpproductsupplier = new ProductFournisseur ( $db );
$tmpproductsupplier -> fetch_product_fournisseur_price ( $rowid , 1 );
2019-11-08 10:53:31 +01:00
$default_vat = $tmpproductsupplier -> fourn_tva_tx ;
$default_npr = $tmpproductsupplier -> fourn_tva_npr ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-26 14:25:17 +01:00
if ( empty ( $default_vat )) {
2020-10-31 14:32:18 +01:00
$default_vat = $object -> tva_tx ;
}
2012-10-02 00:30:23 +02:00
}
2022-02-14 23:02:43 +01:00
$vattosuggest = ( GETPOSTISSET ( " tva_tx " ) ? vatrate ( GETPOST ( " tva_tx " )) : ( $default_vat != '' ? vatrate ( $default_vat ) : '' ));
2019-11-08 10:53:31 +01:00
$vattosuggest = preg_replace ( '/\s*\(.*\)$/' , '' , $vattosuggest );
2017-09-26 10:53:24 +02:00
print '<input type="text" class="flat" size="5" name="tva_tx" value="' . $vattosuggest . '">' ;
2012-10-02 00:30:23 +02:00
print '</td></tr>' ;
2012-05-23 10:50:38 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> dynamicprices -> enabled )) { //Only show price mode and expression selector if module is enabled
2014-11-29 06:31:35 +01:00
// Price mode selector
print '<tr><td class="fieldrequired">' . $langs -> trans ( " PriceMode " ) . '</td><td>' ;
$price_expression = new PriceExpression ( $db );
$price_expression_list = array ( 0 => $langs -> trans ( " PriceNumeric " )); //Put the numeric mode as first option
foreach ( $price_expression -> list_price_expression () as $entry ) {
$price_expression_list [ $entry -> id ] = $entry -> title ;
}
2015-10-17 12:01:17 +02:00
$price_expression_preselection = GETPOST ( 'eid' ) ? GETPOST ( 'eid' ) : ( $object -> fk_supplier_price_expression ? $object -> fk_supplier_price_expression : '0' );
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'eid' , $price_expression_list , $price_expression_preselection );
2014-11-29 06:31:35 +01:00
print ' <div id="expression_editor" class="button">' . $langs -> trans ( " PriceExpressionEditor " ) . '</div>' ;
print '</td></tr>' ;
// This code hides the numeric price input if is not selected, loads the editor page if editor button is pressed
print ' < script type = " text/javascript " >
jQuery ( document ) . ready ( run );
function run () {
jQuery ( " #expression_editor " ) . click ( on_click );
jQuery ( " #eid " ) . change ( on_change );
on_change ();
}
function on_click () {
2016-03-04 13:03:07 +01:00
window . location = " '.DOL_URL_ROOT.'/product/dynamic_price/editor.php?id='. $id .'&tab=fournisseurs&eid= " + $ ( " #eid " ) . val ();
2014-11-29 06:31:35 +01:00
}
function on_change () {
2015-12-12 01:38:24 +01:00
if ( $ ( " #eid " ) . val () == 0 ) {
2014-11-29 06:31:35 +01:00
jQuery ( " #price_numeric " ) . show ();
} else {
jQuery ( " #price_numeric " ) . hide ();
}
}
</ script > ' ;
}
2020-12-01 02:41:19 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
// Currency
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Currency " ) . '</td>' ;
print '<td>' ;
2021-09-16 13:17:00 +02:00
$currencycodetouse = GETPOST ( 'multicurrency_code' ) ? GETPOST ( 'multicurrency_code' ) : ( isset ( $object -> fourn_multicurrency_code ) ? $object -> fourn_multicurrency_code : '' );
2021-02-26 14:25:17 +01:00
if ( empty ( $currencycodetouse ) && $object -> fourn_multicurrency_tx == 1 ) {
$currencycodetouse = $conf -> currency ;
}
2020-12-01 02:41:19 +01:00
print $form -> selectMultiCurrency ( $currencycodetouse , " multicurrency_code " , 1 );
2022-08-10 05:06:58 +02:00
print ' ' . $langs -> trans ( " CurrencyRate " ) . ' ' ;
2020-12-01 02:41:19 +01:00
print '<input class="flat" name="multicurrency_tx" size="4" value="' . vatrate ( GETPOST ( 'multicurrency_tx' ) ? GETPOST ( 'multicurrency_tx' ) : ( isset ( $object -> fourn_multicurrency_tx ) ? $object -> fourn_multicurrency_tx : '' )) . '">' ;
print '</td>' ;
print '</tr>' ;
2020-10-31 14:32:18 +01:00
// Currency price qty min
2022-03-14 11:29:17 +01:00
print '<tr><td class="fieldrequired">' . $form -> textwithpicto ( $langs -> trans ( " PriceQtyMinCurrency " ), $langs -> transnoentitiesnoconv ( " WithoutDiscount " )) . '</td>' ;
2021-09-16 13:17:00 +02:00
$pricesupplierincurrencytouse = ( GETPOST ( 'multicurrency_price' ) ? GETPOST ( 'multicurrency_price' ) : ( isset ( $object -> fourn_multicurrency_price ) ? $object -> fourn_multicurrency_price : '' ));
2020-10-31 14:32:18 +01:00
print '<td><input class="flat" name="multicurrency_price" size="8" value="' . price ( $pricesupplierincurrencytouse ) . '">' ;
print ' ' ;
print $form -> selectPriceBaseType (( GETPOST ( 'multicurrency_price_base_type' ) ? GETPOST ( 'multicurrency_price_base_type' ) : 'HT' ), " multicurrency_price_base_type " ); // We keep 'HT' here, multicurrency_price_base_type is not yet supported for supplier prices
print '</td></tr>' ;
// Price qty min
2022-03-14 11:29:17 +01:00
print '<tr><td class="fieldrequired">' . $form -> textwithpicto ( $langs -> trans ( " PriceQtyMin " ), $langs -> transnoentitiesnoconv ( " WithoutDiscount " )) . '</td>' ;
2020-10-31 14:32:18 +01:00
print '<td><input class="flat" name="disabled_price" size="8" value="">' ;
print '<input type="hidden" name="price" value="">' ;
print '<input type="hidden" name="price_base_type" value="">' ;
print ' ' ;
print $form -> selectPriceBaseType ( '' , " disabled_price_base_type " );
print '</td></tr>' ;
$currencies = array ();
2021-09-30 15:59:47 +02:00
$sql = " SELECT rowid FROM " . MAIN_DB_PREFIX . " multicurrency WHERE entity = " . (( int ) $conf -> entity );
2020-10-31 14:32:18 +01:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$currency = new MultiCurrency ( $db );
while ( $obj = $db -> fetch_object ( $resql )) {
$currency -> fetch ( $obj -> rowid );
2021-09-16 13:17:00 +02:00
$currencies [ $currency -> code ] = (( float ) $currency -> rate -> rate );
2020-10-31 14:32:18 +01:00
}
}
$currencies = json_encode ( $currencies );
2018-02-23 11:06:07 +01:00
2020-11-07 19:39:51 +01:00
print <<< END
2021-09-16 13:17:00 +02:00
<!-- javascript to autocalculate the minimum price -->
2018-02-23 11:06:07 +01:00
< script type = " text/javascript " >
function update_price_from_multicurrency () {
2021-09-16 13:17:00 +02:00
console . log ( " update_price_from_multicurrency " );
var multicurrency_price = price2numjs ( $ ( 'input[name="multicurrency_price"]' ) . val ());
var multicurrency_tx = price2numjs ( $ ( 'input[name="multicurrency_tx"]' ) . val ());
if ( multicurrency_tx != 0 ) {
$ ( 'input[name="price"]' ) . val ( multicurrency_price / multicurrency_tx );
$ ( 'input[name="disabled_price"]' ) . val ( multicurrency_price / multicurrency_tx );
} else {
$ ( 'input[name="price"]' ) . val ( '' );
$ ( 'input[name="disabled_price"]' ) . val ( '' );
}
2018-02-23 11:06:07 +01:00
}
2021-09-16 13:17:00 +02:00
2018-02-23 11:06:07 +01:00
jQuery ( document ) . ready ( function () {
$ ( 'input[name="disabled_price"]' ) . prop ( 'disabled' , true );
$ ( 'select[name="disabled_price_base_type"]' ) . prop ( 'disabled' , true );
update_price_from_multicurrency ();
2018-03-07 14:13:46 +01:00
2021-09-16 13:17:00 +02:00
$ ( 'input[name="multicurrency_price"], input[name="multicurrency_tx"]' ) . keyup ( function () {
2018-02-23 11:06:07 +01:00
update_price_from_multicurrency ();
});
2021-09-16 13:17:00 +02:00
$ ( 'input[name="multicurrency_price"], input[name="multicurrency_tx"]' ) . change ( function () {
2018-02-23 11:06:07 +01:00
update_price_from_multicurrency ();
2021-09-16 13:17:00 +02:00
});
$ ( 'input[name="multicurrency_price"], input[name="multicurrency_tx"]' ) . on ( 'paste' , function () {
2018-02-23 11:06:07 +01:00
update_price_from_multicurrency ();
});
2018-03-07 14:13:46 +01:00
2018-02-23 11:06:07 +01:00
$ ( 'select[name="multicurrency_price_base_type"]' ) . change ( function () {
$ ( 'input[name="price_base_type"]' ) . val ( $ ( this ) . val ());
$ ( 'select[name="disabled_price_base_type"]' ) . val ( $ ( this ) . val ());
});
2018-03-07 14:13:46 +01:00
2018-02-23 11:06:07 +01:00
var currencies_array = $currencies ;
$ ( 'select[name="multicurrency_code"]' ) . change ( function () {
2021-09-16 13:17:00 +02:00
console . log ( " We change the currency " );
2018-02-23 11:06:07 +01:00
$ ( 'input[name="multicurrency_tx"]' ) . val ( currencies_array [ $ ( this ) . val ()]);
2021-09-16 13:17:00 +02:00
update_price_from_multicurrency ();
2018-02-23 11:06:07 +01:00
});
});
</ script >
2020-11-07 19:39:51 +01:00
END ;
2020-10-31 14:32:18 +01:00
} else {
// Price qty min
print '<tr><td class="fieldrequired">' . $langs -> trans ( " PriceQtyMin " ) . '</td>' ;
print '<td><input class="flat" name="price" size="8" value="' . ( GETPOST ( 'price' ) ? price ( GETPOST ( 'price' )) : ( isset ( $object -> fourn_price ) ? price ( $object -> fourn_price ) : '' )) . '">' ;
print ' ' ;
2021-01-31 12:48:40 +01:00
print $form -> selectPriceBaseType (( GETPOSTISSET ( 'price_base_type' ) ? GETPOST ( 'price_base_type' ) : 'HT' ), " price_base_type " ); // We keep 'HT' here, price_base_type is not yet supported for supplier prices
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
}
2018-02-23 11:06:07 +01:00
2012-10-01 11:25:17 +02:00
// Discount qty min
2012-10-02 00:30:23 +02:00
print '<tr><td>' . $langs -> trans ( " DiscountQtyMin " ) . '</td>' ;
2021-09-08 22:09:02 +02:00
print '<td><input class="flat" name="remise_percent" size="4" value="' . ( GETPOSTISSET ( 'remise_percent' ) ? vatrate ( price2num ( GETPOST ( 'remise_percent' ), '' , 2 )) : ( isset ( $object -> fourn_remise_percent ) ? vatrate ( $object -> fourn_remise_percent ) : '' )) . '"> %' ;
2012-10-01 11:25:17 +02:00
print '</td>' ;
2008-02-11 22:17:22 +01:00
print '</tr>' ;
2009-06-08 20:14:37 +02:00
2015-10-17 12:01:17 +02:00
// Delivery delay in days
2015-02-06 16:07:22 +01:00
print '<tr>' ;
print '<td>' . $langs -> trans ( 'NbDaysToDelivery' ) . '</td>' ;
2015-10-17 12:01:17 +02:00
print '<td><input class="flat" name="delivery_time_days" size="4" value="' . ( $rowid ? $object -> delivery_time_days : '' ) . '"> ' . $langs -> trans ( 'days' ) . '</td>' ;
2015-02-06 16:07:22 +01:00
print '</tr>' ;
2016-04-08 22:18:36 +02:00
// Reputation
2020-11-05 12:56:20 +01:00
print '<tr><td>' . $langs -> trans ( " ReferenceReputation " ) . '</td><td>' ;
2022-05-11 15:06:11 +02:00
echo $form -> selectarray ( 'supplier_reputation' , $object -> reputations , ! empty ( $supplier_reputation ) ? $supplier_reputation : $object -> supplier_reputation );
2016-04-08 22:18:36 +02:00
print '</td></tr>' ;
2019-02-20 16:14:24 +01:00
2019-05-14 10:31:11 +02:00
// Barcode
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> barcode -> enabled )) {
2020-10-31 14:32:18 +01:00
$formbarcode = new FormBarCode ( $db );
// Barcode type
print '<tr>' ;
2022-12-01 11:46:48 +01:00
print '<td>' . $langs -> trans ( 'GencodBuyPrice' ) . '</td>' ;
2020-10-31 14:32:18 +01:00
print '<td>' ;
2022-12-01 11:46:48 +01:00
print img_picto ( '' , 'barcode' , 'class="pictofixedwidth"' );
print $formbarcode -> selectBarcodeType (( GETPOSTISSET ( 'fk_barcode_type' ) ? GETPOST ( 'fk_barcode_type' , 'int' ) : ( $rowid ? $object -> supplier_fk_barcode_type : getDolGlobalint ( " PRODUIT_DEFAULT_BARCODE_TYPE " ))), 'fk_barcode_type' , 1 );
print ' <input class="flat" name="barcode" value="' . ( GETPOSTISSET ( 'barcode' ) ? GETPOST ( 'barcode' ) : ( $rowid ? $object -> supplier_barcode : '' )) . '"></td>' ;
2021-10-02 12:58:15 +02:00
print '</tr>' ;
2020-10-31 14:32:18 +01:00
}
2019-05-14 10:31:11 +02:00
2015-11-30 21:20:45 +01:00
// Option to define a transport cost on supplier price
2022-05-11 15:06:11 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_CHARGES )) {
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> margin -> enabled )) {
2014-12-03 00:22:48 +01:00
print '<tr>' ;
print '<td>' . $langs -> trans ( " Charges " ) . '</td>' ;
2021-10-02 12:58:15 +02:00
print '<td><input class="flat width75" name="charges" value="' . ( GETPOST ( 'charges' ) ? price ( GETPOST ( 'charges' )) : ( isset ( $object -> fourn_charges ) ? price ( $object -> fourn_charges ) : '' )) . '">' ;
2020-10-31 14:32:18 +01:00
print '</td>' ;
2014-12-03 00:22:48 +01:00
print '</tr>' ;
}
2012-07-25 11:32:48 +02:00
}
2014-04-02 14:53:42 +02:00
2018-08-06 16:26:25 +02:00
// Product description of the supplier
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_FOURN_TEXTS )) {
2020-10-31 14:32:18 +01:00
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2018-08-29 20:22:50 +02:00
2020-10-31 14:32:18 +01:00
print '<tr>' ;
print '<td>' . $langs -> trans ( 'ProductSupplierDescription' ) . '</td>' ;
print '<td>' ;
2018-08-29 20:22:50 +02:00
2022-06-22 08:36:24 +02:00
$doleditor = new DolEditor ( 'supplier_description' , $object -> desc_supplier , '' , 160 , 'dolibarr_details' , '' , false , true , getDolGlobalInt ( 'FCKEDITOR_ENABLE_PRODUCTDESC' ), ROWS_4 , '90%' );
2020-10-31 14:32:18 +01:00
$doleditor -> Create ();
2018-08-29 20:22:50 +02:00
2020-10-31 14:32:18 +01:00
print '</td>' ;
print '</tr>' ;
2018-08-06 16:26:25 +02:00
}
2018-08-29 20:22:50 +02:00
2020-10-31 14:32:18 +01:00
// Extrafields
2019-10-22 11:36:28 +02:00
$extrafields -> fetch_name_optionals_label ( " product_fournisseur_price " );
2022-05-11 15:06:11 +02:00
$extralabels = ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'label' ]) ? $extrafields -> attributes [ " product_fournisseur_price " ][ 'label' ] : '' ;
2020-10-31 14:32:18 +01:00
$extrafield_values = $extrafields -> getOptionalsFromPost ( " product_fournisseur_price " );
2019-11-05 22:27:30 +01:00
if ( ! empty ( $extralabels )) {
2020-10-31 14:32:18 +01:00
if ( empty ( $rowid )) {
foreach ( $extralabels as $key => $value ) {
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ]) && ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] == 1 || $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] == 3 || ( $action == " update_price " && $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] == 4 ))) {
2021-02-26 14:25:17 +01:00
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ])) {
$langs -> load ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ]);
}
2020-10-31 14:32:18 +01:00
print '<tr><td' . ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'required' ][ $key ] ? ' class="fieldrequired"' : '' ) . '>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ])) {
print $form -> textwithpicto ( $langs -> trans ( $value ), $langs -> trans ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ]));
} else {
print $langs -> trans ( $value );
}
2020-10-31 14:32:18 +01:00
print '</td><td>' . $extrafields -> showInputField ( $key , GETPOSTISSET ( 'options_' . $key ) ? $extrafield_values [ 'options_' . $key ] : '' , '' , '' , '' , '' , 0 , 'product_fournisseur_price' ) . '</td></tr>' ;
}
}
} else {
$sql = " SELECT " ;
$sql .= " fk_object " ;
foreach ( $extralabels as $key => $value ) {
$sql .= " , " . $key ;
}
$sql .= " FROM " . MAIN_DB_PREFIX . " product_fournisseur_price_extrafields " ;
2021-03-30 19:12:07 +02:00
$sql .= " WHERE fk_object = " . (( int ) $rowid );
2020-10-31 14:32:18 +01:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$obj = $db -> fetch_object ( $resql );
foreach ( $extralabels as $key => $value ) {
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ]) && ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] == 1 || $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] == 3 || ( $action == " update_price " && $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] == 4 ))) {
2021-02-26 14:25:17 +01:00
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ])) {
$langs -> load ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ]);
}
2020-10-31 14:32:18 +01:00
print '<tr><td' . ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'required' ][ $key ] ? ' class="fieldrequired"' : '' ) . '>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ])) {
print $form -> textwithpicto ( $langs -> trans ( $value ), $langs -> trans ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ]));
} else {
print $langs -> trans ( $value );
}
2020-10-31 14:32:18 +01:00
print '</td><td>' . $extrafields -> showInputField ( $key , GETPOSTISSET ( 'options_' . $key ) ? $extrafield_values [ 'options_' . $key ] : $obj -> { $key }, '' , '' , '' , '' , 0 , 'product_fournisseur_price' );
print '</td></tr>' ;
}
}
$db -> free ( $resql );
}
}
2019-09-04 15:13:42 +02:00
}
2021-02-26 14:25:17 +01:00
if ( is_object ( $hookmanager )) {
2022-05-11 15:06:11 +02:00
$parameters = array ( 'id_fourn' =>! empty ( $id_fourn ) ? $id_fourn : 0 , 'prod_id' => $object -> id );
2020-10-31 14:32:18 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action );
print $hookmanager -> resPrint ;
2014-01-17 09:45:57 +01:00
}
2012-07-19 15:36:25 +02:00
2011-10-04 01:26:07 +02:00
print '</table>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-08-23 07:37:38 +02:00
print '<div class="center">' ;
2020-11-19 20:23:38 +01:00
print '<input class="button button-save" type="submit" value="' . $langs -> trans ( " Save " ) . '">' ;
2015-08-23 07:37:38 +02:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input class="button button-cancel" type="submit" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2014-11-25 20:13:43 +01:00
print '</div>' ;
2008-02-11 22:17:22 +01:00
2021-06-11 19:42:36 +02:00
print '</form>' . " \n " ;
2009-06-08 20:14:37 +02:00
}
2021-06-11 19:42:36 +02:00
2015-04-08 12:22:52 +02:00
// Actions buttons
2009-06-08 20:14:37 +02:00
2021-06-11 19:42:36 +02:00
print '<div class="tabsAction">' . " \n " ;
2009-06-08 20:14:37 +02:00
2021-02-26 14:25:17 +01:00
if ( $action != 'add_price' && $action != 'update_price' ) {
2019-11-08 10:53:31 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
if ( $usercancreate ) {
2021-10-02 12:58:15 +02:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $object -> id . '&action=add_price&token=' . newToken () . '">' ;
2015-05-26 15:00:23 +02:00
print $langs -> trans ( " AddSupplierPrice " ) . '</a>' ;
}
2007-03-21 00:08:26 +01:00
}
}
2009-06-08 20:14:37 +02:00
2021-06-11 19:42:36 +02:00
print " </div> \n " ;
2007-03-21 00:08:26 +01:00
2021-02-26 14:25:17 +01:00
if ( $user -> rights -> fournisseur -> lire ) { // Duplicate ? this check is already in the head of this file
2019-11-08 10:53:31 +01:00
$param = '' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
2019-11-08 10:53:31 +01:00
$param .= '&ref=' . urlencode ( $object -> ref );
2018-01-25 20:57:51 +01:00
2017-05-17 14:45:08 +02:00
$product_fourn = new ProductFournisseur ( $db );
2018-01-25 20:57:51 +01:00
$product_fourn_list = $product_fourn -> list_product_fournisseur_price ( $object -> id , $sortfield , $sortorder , $limit , $offset );
$product_fourn_list_all = $product_fourn -> list_product_fournisseur_price ( $object -> id , $sortfield , $sortorder , 0 , 0 );
$nbtotalofrecords = count ( $product_fourn_list_all );
$num = count ( $product_fourn_list );
2021-02-26 14:25:17 +01:00
if (( $num + ( $offset * $limit )) < $nbtotalofrecords ) {
$num ++ ;
}
2018-01-25 20:57:51 +01:00
2019-09-18 10:36:13 +02:00
print_barre_liste ( $langs -> trans ( 'SupplierPrices' ), $page , $_SERVER [ 'PHP_SELF' ], $param , $sortfield , $sortorder , '' , $num , $nbtotalofrecords , 'title_accountancy.png' , 0 , '' , '' , $limit , 1 );
2017-06-11 10:37:58 +02:00
2020-09-07 15:43:36 +02:00
// Definition of fields for lists
// Some fields are missing because they are not included in the database query
$arrayfields = array (
'pfp.datec' => array ( 'label' => $langs -> trans ( " AppliedPricesFrom " ), 'checked' => 1 , 'position' => 1 ),
's.nom' => array ( 'label' => $langs -> trans ( " Suppliers " ), 'checked' => 1 , 'position' => 2 ),
2022-08-30 17:01:31 +02:00
'pfp.fk_availability' => array ( 'label' => $langs -> trans ( " Availability " ), 'enabled' => getDolGlobalInt ( 'FOURN_PRODUCT_AVAILABILITY' ), 'checked' => 0 , 'position' => 4 ),
2020-09-07 15:43:36 +02:00
'pfp.quantity' => array ( 'label' => $langs -> trans ( " QtyMin " ), 'checked' => 1 , 'position' => 5 ),
'pfp.unitprice' => array ( 'label' => $langs -> trans ( " UnitPriceHT " ), 'checked' => 1 , 'position' => 9 ),
2022-08-30 17:01:31 +02:00
'pfp.multicurrency_unitprice' => array ( 'label' => $langs -> trans ( " UnitPriceHTCurrency " ), 'enabled' => isModEnabled ( 'multicurrency' ), 'checked' => 0 , 'position' => 10 ),
2020-09-07 15:43:36 +02:00
'pfp.delivery_time_days' => array ( 'label' => $langs -> trans ( " NbDaysToDelivery " ), 'checked' => 1 , 'position' => 13 ),
'pfp.supplier_reputation' => array ( 'label' => $langs -> trans ( " ReputationForThisProduct " ), 'checked' => 1 , 'position' => 14 ),
2022-08-30 17:01:31 +02:00
'pfp.fk_barcode_type' => array ( 'label' => $langs -> trans ( " BarcodeType " ), 'enabled' => isModEnabled ( 'barcode' ), 'checked' => 0 , 'position' => 15 ),
'pfp.barcode' => array ( 'label' => $langs -> trans ( " BarcodeValue " ), 'enabled' => isModEnabled ( 'barcode' ), 'checked' => 0 , 'position' => 16 ),
'pfp.packaging' => array ( 'label' => $langs -> trans ( " PackagingForThisProduct " ), 'enabled' => getDolGlobalInt ( 'PRODUCT_USE_SUPPLIER_PACKAGING' ), 'checked' => 0 , 'position' => 17 ),
'pfp.tms' => array ( 'label' => $langs -> trans ( " DateModification " ), 'enabled' => isModEnabled ( 'barcode' ), 'checked' => 1 , 'position' => 18 ),
2020-09-07 15:43:36 +02:00
);
// fetch optionals attributes and labels
$extrafields -> fetch_name_optionals_label ( " product_fournisseur_price " );
2021-10-22 23:38:35 +02:00
if ( $extrafields -> attributes [ " product_fournisseur_price " ] && array_key_exists ( 'label' , $extrafields -> attributes [ " product_fournisseur_price " ])) {
$extralabels = $extrafields -> attributes [ " product_fournisseur_price " ][ 'label' ];
2020-09-07 15:43:36 +02:00
2021-10-22 23:38:35 +02:00
if ( ! empty ( $extralabels )) {
foreach ( $extralabels as $key => $value ) {
// Show field if not hidden
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ]) && $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] != 3 ) {
$extratitle = $langs -> trans ( $value );
$arrayfields [ 'ef.' . $key ] = array ( 'label' => $extratitle , 'checked' => 0 ,
'position' => ( end ( $arrayfields )[ 'position' ] + 1 ),
'langfile' => $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ],
'help' => $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ]);
}
2020-09-07 15:43:36 +02:00
}
}
}
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2020-09-07 15:47:26 +02:00
2020-09-07 15:43:36 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post" name="formulaire">' ;
2020-10-31 14:32:18 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2020-09-07 15:43:36 +02:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2009-10-16 15:38:01 +02:00
// Suppliers list title
2018-11-09 10:29:22 +01:00
print '<div class="div-table-responsive">' ;
2020-12-19 15:56:21 +01:00
print '<table class="liste centpercent">' ;
2011-08-21 01:56:03 +02:00
2019-11-08 10:53:31 +01:00
$param = " &id= " . $object -> id ;
2019-06-29 16:29:32 +02:00
2022-11-17 12:54:51 +01:00
$nbfields = 0 ;
2011-08-17 18:44:38 +02:00
print '<tr class="liste_titre">' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $arrayfields [ 'pfp.datec' ][ 'checked' ])) {
print_liste_field_titre ( " AppliedPricesFrom " , $_SERVER [ " PHP_SELF " ], " pfp.datec " , " " , $param , " " , $sortfield , $sortorder , '' , '' , 1 );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print_liste_field_titre ( " Suppliers " , $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , " " , $sortfield , $sortorder , '' , '' , 1 );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
2020-12-27 16:53:15 +01:00
print_liste_field_titre ( " SupplierRef " , $_SERVER [ " PHP_SELF " ], " " , " " , $param , " " , $sortfield , $sortorder , '' , '' , 1 );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $arrayfields [ 'pfp.fk_availability' ][ 'checked' ])) {
print_liste_field_titre ( " Availability " , $_SERVER [ " PHP_SELF " ], " pfp.fk_availability " , " " , $param , " " , $sortfield , $sortorder );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 'pfp.quantity' ][ 'checked' ])) {
print_liste_field_titre ( " QtyMin " , $_SERVER [ " PHP_SELF " ], " pfp.quantity " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
2019-02-24 11:18:55 +01:00
print_liste_field_titre ( " VATRate " , $_SERVER [ " PHP_SELF " ], '' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2019-02-24 11:18:55 +01:00
print_liste_field_titre ( " PriceQtyMinHT " , $_SERVER [ " PHP_SELF " ], '' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
print_liste_field_titre ( " PriceQtyMinHTCurrency " , $_SERVER [ " PHP_SELF " ], '' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 'pfp.unitprice' ][ 'checked' ])) {
print_liste_field_titre ( " UnitPriceHT " , $_SERVER [ " PHP_SELF " ], " pfp.unitprice " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 'pfp.multicurrency_unitprice' ][ 'checked' ])) {
print_liste_field_titre ( " UnitPriceHTCurrency " , $_SERVER [ " PHP_SELF " ], " pfp.multicurrency_unitprice " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $conf -> multicurrency -> enabled )) {
print_liste_field_titre ( " Currency " , $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
2019-02-24 11:18:55 +01:00
print_liste_field_titre ( " DiscountQtyMin " , $_SERVER [ " PHP_SELF " ], '' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $arrayfields [ 'pfp.delivery_time_days' ][ 'checked' ])) {
print_liste_field_titre ( " NbDaysToDelivery " , $_SERVER [ " PHP_SELF " ], " pfp.delivery_time_days " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 'pfp.supplier_reputation' ][ 'checked' ])) {
print_liste_field_titre ( " ReputationForThisProduct " , $_SERVER [ " PHP_SELF " ], " pfp.supplier_reputation " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 'pfp.fk_barcode_type' ][ 'checked' ])) {
print_liste_field_titre ( " BarcodeType " , $_SERVER [ " PHP_SELF " ], " pfp.fk_barcode_type " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
2021-10-02 12:58:15 +02:00
if ( ! empty ( $arrayfields [ 'pfp.barcode' ][ 'checked' ])) {
print_liste_field_titre ( " BarcodeValue " , $_SERVER [ " PHP_SELF " ], " pfp.barcode " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-10-02 12:58:15 +02:00
}
2021-02-26 14:25:17 +01:00
if ( ! empty ( $arrayfields [ 'pfp.packaging' ][ 'checked' ])) {
print_liste_field_titre ( " PackagingForThisProduct " , $_SERVER [ " PHP_SELF " ], " pfp.packaging " , " " , $param , 'align="center"' , $sortfield , $sortorder );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $arrayfields [ 'pfp.tms' ][ 'checked' ])) {
print_liste_field_titre ( " DateModification " , $_SERVER [ " PHP_SELF " ], " pfp.tms " , " " , $param , '' , $sortfield , $sortorder , 'right ' , '' , 1 );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-02-26 14:25:17 +01:00
}
2019-09-04 15:13:42 +02:00
// fetch optionals attributes and labels
2019-10-22 11:36:28 +02:00
$extrafields -> fetch_name_optionals_label ( " product_fournisseur_price " );
2021-10-22 23:38:35 +02:00
if ( $extrafields -> attributes [ " product_fournisseur_price " ] && array_key_exists ( 'label' , $extrafields -> attributes [ " product_fournisseur_price " ])) {
$extralabels = $extrafields -> attributes [ " product_fournisseur_price " ][ 'label' ];
2020-09-07 15:43:36 +02:00
2021-10-22 23:38:35 +02:00
if ( ! empty ( $extralabels )) {
foreach ( $extralabels as $key => $value ) {
// Show field if not hidden
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ]) && $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] != 3 ) {
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ])) {
$langs -> load ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'langfile' ][ $key ]);
}
if ( ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ])) {
$extratitle = $form -> textwithpicto ( $langs -> trans ( $value ), $langs -> trans ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'help' ][ $key ]));
} else {
$extratitle = $langs -> trans ( $value );
}
if ( ! empty ( $arrayfields [ 'ef.' . $key ][ 'checked' ])) {
print_liste_field_titre ( $extratitle , $_SERVER [ " PHP_SELF " ], 'ef.' . $key , '' , $param , '' , $sortfield , $sortorder , 'right ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2021-10-22 23:38:35 +02:00
}
2021-02-26 14:25:17 +01:00
}
2019-11-05 22:27:30 +01:00
}
2019-09-05 09:47:40 +02:00
}
2019-09-04 15:13:42 +02:00
}
2021-02-26 14:25:17 +01:00
if ( is_object ( $hookmanager )) {
2022-11-17 12:54:51 +01:00
$parameters = array ( 'id_fourn' => ( ! empty ( $id_fourn ) ? $id_fourn : '' ), 'prod_id' => $object -> id , 'nbfields' => $nbfields );
2020-10-31 14:32:18 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object , $action );
2019-08-22 12:30:14 +02:00
}
2020-09-07 15:43:36 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
2022-11-17 12:54:51 +01:00
$nbfields ++ ;
2011-08-17 18:44:38 +02:00
print " </tr> \n " ;
2007-03-21 00:08:26 +01:00
2021-02-26 14:25:17 +01:00
if ( is_array ( $product_fourn_list )) {
foreach ( $product_fourn_list as $productfourn ) {
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2011-08-21 01:56:03 +02:00
2018-11-09 10:29:22 +01:00
// Date from
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.datec' ][ 'checked' ])) {
print '<td>' . dol_print_date (( $productfourn -> fourn_date_creation ? $productfourn -> fourn_date_creation : $productfourn -> date_creation ), 'dayhour' ) . '</td>' ;
}
2017-06-11 10:37:58 +02:00
2009-10-16 15:38:01 +02:00
// Supplier
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2021-06-11 19:42:36 +02:00
print '<td class="tdoverflowmax150">' . $productfourn -> getSocNomUrl ( 1 , 'supplier' ) . '</td>' ;
2020-09-07 15:43:36 +02:00
}
2017-06-11 10:37:58 +02:00
2018-11-09 10:29:22 +01:00
// Supplier ref
2020-12-04 19:10:43 +01:00
if ( $usercancreate ) { // change required right here
2022-06-09 11:47:29 +02:00
print '<td class="tdoverflowmax150">' . $productfourn -> getNomUrl () . '</td>' ;
2020-05-21 15:05:19 +02:00
} else {
2022-06-09 11:47:29 +02:00
print '<td class="tdoverflowmax150">' . dol_escape_htmltag ( $productfourn -> fourn_ref ) . '</td>' ;
2019-01-22 16:18:25 +01:00
}
2011-08-21 01:56:03 +02:00
2016-04-08 22:18:36 +02:00
// Availability
2021-02-26 14:25:17 +01:00
if ( ! empty ( $arrayfields [ 'pfp.fk_availability' ][ 'checked' ])) {
2011-11-08 10:18:45 +01:00
$form -> load_cache_availability ();
2020-10-31 14:32:18 +01:00
$availability = $form -> cache_availability [ $productfourn -> fk_availability ][ 'label' ];
2019-01-21 10:02:11 +01:00
print '<td class="left">' . $availability . '</td>' ;
2011-08-17 17:22:39 +02:00
}
2011-08-21 01:56:03 +02:00
2009-10-16 15:38:01 +02:00
// Quantity
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.quantity' ][ 'checked' ])) {
print '<td class="right">' ;
print $productfourn -> fourn_qty ;
// Units
2020-11-25 18:07:52 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2020-09-07 15:43:36 +02:00
$unit = $object -> getLabelOfUnit ();
if ( $unit !== '' ) {
print ' ' . $langs -> trans ( $unit );
}
}
print '</td>' ;
}
2012-05-23 10:50:38 +02:00
2012-05-22 19:11:41 +02:00
// VAT rate
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2019-01-27 11:55:16 +01:00
print vatrate ( $productfourn -> fourn_tva_tx , true );
2012-03-15 16:52:18 +01:00
print '</td>' ;
2007-03-21 00:08:26 +01:00
2012-10-18 13:25:32 +02:00
// Price for the quantity
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2022-06-09 11:47:29 +02:00
print $productfourn -> fourn_price ? '<span class="amount">' . price ( $productfourn -> fourn_price ) . '</span>' : " " ;
2007-03-21 00:08:26 +01:00
print '</td>' ;
2009-06-08 20:14:37 +02:00
2020-11-22 11:36:07 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
2020-10-31 14:32:18 +01:00
// Price for the quantity in currency
print '<td class="right">' ;
2022-06-09 11:47:29 +02:00
print $productfourn -> fourn_multicurrency_price ? '<span class="amount">' . price ( $productfourn -> fourn_multicurrency_price ) . '</span>' : " " ;
2020-10-31 14:32:18 +01:00
print '</td>' ;
}
2018-02-23 11:06:07 +01:00
2009-10-16 15:38:01 +02:00
// Unit price
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.unitprice' ][ 'checked' ])) {
print '<td class="right">' ;
print price ( $productfourn -> fourn_unitprice );
//print $objp->unitprice? price($objp->unitprice) : ($objp->quantity?price($objp->price/$objp->quantity):" ");
print '</td>' ;
}
2012-10-02 00:30:23 +02:00
2020-09-07 15:43:36 +02:00
// Unit price in currency
if ( ! empty ( $arrayfields [ 'pfp.multicurrency_unitprice' ][ 'checked' ])) {
2020-10-31 18:51:30 +01:00
print '<td class="right">' ;
print price ( $productfourn -> fourn_multicurrency_unitprice );
2021-02-26 14:25:17 +01:00
print '</td>' ;
}
2018-02-23 11:06:07 +01:00
2020-09-07 15:43:36 +02:00
// Currency
2020-11-22 11:36:07 +01:00
if ( ! empty ( $conf -> multicurrency -> enabled )) {
2021-03-16 10:19:56 +01:00
print '<td class="right nowraponall">' ;
2020-10-31 18:51:30 +01:00
print $productfourn -> fourn_multicurrency_code ? currency_name ( $productfourn -> fourn_multicurrency_code ) : '' ;
print '</td>' ;
}
2018-02-23 11:06:07 +01:00
2012-10-01 11:25:17 +02:00
// Discount
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2012-10-02 00:30:23 +02:00
print price2num ( $productfourn -> fourn_remise_percent ) . '%' ;
2012-10-01 11:25:17 +02:00
print '</td>' ;
2009-06-08 20:14:37 +02:00
2015-04-08 13:00:03 +02:00
// Delivery delay
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.delivery_time_days' ][ 'checked' ])) {
print '<td class="right">' ;
print $productfourn -> delivery_time_days ;
print '</td>' ;
}
2015-04-08 13:00:03 +02:00
2016-04-08 22:18:36 +02:00
// Reputation
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.supplier_reputation' ][ 'checked' ])) {
print '<td class="center">' ;
if ( ! empty ( $productfourn -> supplier_reputation ) && ! empty ( $object -> reputations [ $productfourn -> supplier_reputation ])) {
print $object -> reputations [ $productfourn -> supplier_reputation ];
}
print '</td>' ;
2017-06-11 10:37:58 +02:00
}
2016-04-08 22:18:36 +02:00
2020-09-07 15:43:36 +02:00
// Barcode type
if ( ! empty ( $arrayfields [ 'pfp.fk_barcode_type' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="center">' ;
2020-11-20 17:16:49 +01:00
$productfourn -> barcode_type = ! empty ( $productfourn -> supplier_fk_barcode_type ) ? $productfourn -> supplier_fk_barcode_type : 0 ;
2020-10-31 14:32:18 +01:00
$productfourn -> fetch_barcode ();
2020-11-20 17:16:49 +01:00
print $productfourn -> barcode_type_label ? $productfourn -> barcode_type_label : ( $productfourn -> supplier_barcode ? '<div class="warning">' . $langs -> trans ( " SetDefaultBarcodeType " ) . '<div>' : '' );
2020-10-31 14:32:18 +01:00
print '</td>' ;
2019-03-14 18:43:09 +01:00
}
2019-02-20 16:14:24 +01:00
2021-10-02 12:58:15 +02:00
// Barcode
if ( ! empty ( $arrayfields [ 'pfp.barcode' ][ 'checked' ])) {
print '<td align="right">' ;
print $productfourn -> supplier_barcode ;
print '</td>' ;
}
2019-11-23 15:52:34 +01:00
// Packaging
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.packaging' ][ 'checked' ])) {
2019-11-23 15:52:34 +01:00
print '<td align="center">' ;
print price2num ( $productfourn -> packaging );
print '</td>' ;
}
2021-03-16 10:19:56 +01:00
// Date modification
2020-09-07 15:43:36 +02:00
if ( ! empty ( $arrayfields [ 'pfp.tms' ][ 'checked' ])) {
2021-03-16 10:19:56 +01:00
print '<td class="right nowraponall">' ;
2020-09-07 15:43:36 +02:00
print dol_print_date (( $productfourn -> fourn_date_modification ? $productfourn -> fourn_date_modification : $productfourn -> date_modification ), " dayhour " );
print '</td>' ;
}
2019-03-15 01:28:54 +01:00
2019-09-04 15:13:42 +02:00
// Extrafields
2019-11-08 10:53:31 +01:00
if ( ! empty ( $extralabels )) {
2020-10-31 14:32:18 +01:00
$sql = " SELECT " ;
$sql .= " fk_object " ;
foreach ( $extralabels as $key => $value ) {
$sql .= " , " . $key ;
}
$sql .= " FROM " . MAIN_DB_PREFIX . " product_fournisseur_price_extrafields " ;
2021-03-30 19:12:07 +02:00
$sql .= " WHERE fk_object = " . (( int ) $productfourn -> product_fourn_price_id );
2020-10-31 14:32:18 +01:00
$resql = $db -> query ( $sql );
if ( $resql ) {
if ( $db -> num_rows ( $resql ) != 1 ) {
foreach ( $extralabels as $key => $value ) {
if ( ! empty ( $arrayfields [ 'ef.' . $key ][ 'checked' ]) && ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ]) && $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] != 3 ) {
print " <td></td> " ;
}
}
} else {
$obj = $db -> fetch_object ( $resql );
foreach ( $extralabels as $key => $value ) {
if ( ! empty ( $arrayfields [ 'ef.' . $key ][ 'checked' ]) && ! empty ( $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ]) && $extrafields -> attributes [ " product_fournisseur_price " ][ 'list' ][ $key ] != 3 ) {
2021-11-29 00:49:18 +01:00
print '<td align="right">' . $extrafields -> showOutputField ( $key , $obj -> { $key }, '' , 'product_fournisseur_price' ) . " </td> " ;
2020-10-31 14:32:18 +01:00
}
}
}
$db -> free ( $resql );
}
2019-09-04 15:13:42 +02:00
}
2021-02-26 14:25:17 +01:00
if ( is_object ( $hookmanager )) {
2021-10-22 23:38:35 +02:00
$parameters = array ( 'id_pfp' => $productfourn -> product_fourn_price_id , 'id_fourn' => ( ! empty ( $id_fourn ) ? $id_fourn : '' ), 'prod_id' => $object -> id );
2020-10-31 14:32:18 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object , $action );
2014-02-04 16:55:09 +01:00
}
2012-07-19 15:36:25 +02:00
2009-10-16 15:38:01 +02:00
// Modify-Remove
2018-03-07 14:13:46 +01:00
print '<td class="center nowraponall">' ;
2020-03-23 07:01:23 +01:00
2021-02-26 14:25:17 +01:00
if ( $usercancreate ) {
2022-06-23 12:45:28 +02:00
print '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . (( int ) $object -> id ) . '&socid=' . (( int ) $productfourn -> fourn_id ) . '&action=update_price&token=' . newToken () . '&rowid=' . (( int ) $productfourn -> product_fourn_price_id ) . '">' . img_edit () . " </a> " ;
2017-02-08 13:45:42 +01:00
print ' ' ;
2022-06-23 12:45:28 +02:00
print '<a href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . (( int ) $object -> id ) . '&socid=' . (( int ) $productfourn -> fourn_id ) . '&action=ask_remove_pf&token=' . newToken () . '&rowid=' . (( int ) $productfourn -> product_fourn_price_id ) . '">' . img_picto ( $langs -> trans ( " Remove " ), 'delete' ) . '</a>' ;
2007-03-21 00:08:26 +01:00
}
print '</td>' ;
2009-06-08 20:14:37 +02:00
2007-03-21 00:08:26 +01:00
print '</tr>' ;
}
2022-11-17 12:54:51 +01:00
if ( empty ( $product_fourn_list )) {
print '<tr><td colspan="' . $nbfields . '"><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td></tr>' ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
dol_print_error ( $db );
2016-04-08 22:18:36 +02:00
}
2009-06-08 20:14:37 +02:00
2007-03-21 00:08:26 +01:00
print '</table>' ;
2016-11-27 20:02:57 +01:00
print '</div>' ;
2020-09-07 15:43:36 +02:00
print '</form>' ;
2007-03-21 00:08:26 +01:00
}
2004-11-16 17:47:56 +01:00
}
}
2020-05-21 15:05:19 +02:00
} else {
2007-03-21 00:08:26 +01:00
print $langs -> trans ( " ErrorUnknown " );
2004-11-22 09:06:13 +01:00
}
2004-11-16 17:47:56 +01:00
2012-03-15 16:52:18 +01:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-03-15 16:52:18 +01:00
$db -> close ();