2004-10-20 22:06:49 +02:00
< ? php
2019-10-03 17:53:59 +02:00
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 Eric Seigne < eric . seigne @ ryxeo . com >
* Copyright ( C ) 2005 - 2015 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
* Copyright ( C ) 2006 Auguria SARL < info @ auguria . org >
* Copyright ( C ) 2010 - 2015 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2013 - 2016 Marcos García < marcosgdf @ gmail . com >
* Copyright ( C ) 2012 - 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2020-03-01 05:09:57 +01:00
* Copyright ( C ) 2011 - 2020 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2019-10-03 17:53:59 +02:00
* Copyright ( C ) 2014 Cédric Gross < c . gross @ kreiz - it . fr >
* Copyright ( C ) 2014 - 2015 Ferran Marcet < fmarcet @ 2 byte . es >
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
* Copyright ( C ) 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
* Copyright ( C ) 2016 Charlie Benke < charlie @ patas - monkey . com >
* Copyright ( C ) 2016 Meziane Sof < virtualsof @ yahoo . fr >
* Copyright ( C ) 2017 Josep Lluís Amador < joseplluis @ lliuretic . cat >
2021-01-13 15:16:43 +01:00
* Copyright ( C ) 2019 - 2021 Frédéric France < frederic . france @ netlogic . fr >
2020-02-11 20:11:37 +01:00
* Copyright ( C ) 2019 - 2020 Thibault FOUCART < support @ ptibogxiv . net >
2020-04-16 13:26:55 +02:00
* Copyright ( C ) 2020 Pierre Ardoin < mapiolca @ me . com >
2002-05-04 23:28:42 +02: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
2002-05-04 23:28:42 +02: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 />.
2002-05-04 23:28:42 +02:00
*/
2005-02-01 17:57:45 +01:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / product / card . php
2006-12-15 13:03:24 +01:00
* \ingroup product
2010-12-18 18:51:15 +01:00
* \brief Page to show product
2006-12-15 13:03:24 +01:00
*/
2004-08-29 17:22:57 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2016-02-08 15:49:38 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
2020-09-14 10:57:51 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2014-05-25 17:14:33 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/genericobject.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2015-04-18 03:07:49 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2018-05-25 11:26:50 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/modules/product/modules_product.class.php' ;
2016-02-04 16:21:27 +01:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> propal -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
}
if ( ! empty ( $conf -> facture -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
}
if ( ! empty ( $conf -> commande -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
}
if ( ! empty ( $conf -> accounting -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php' ;
}
if ( ! empty ( $conf -> accounting -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php' ;
}
if ( ! empty ( $conf -> accounting -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php' ;
}
2002-05-04 23:28:42 +02:00
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'products' , 'other' ));
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> stock -> enabled )) {
$langs -> load ( " stocks " );
}
if ( ! empty ( $conf -> facture -> enabled )) {
$langs -> load ( " bills " );
}
if ( ! empty ( $conf -> productbatch -> enabled )) {
$langs -> load ( " productbatch " );
}
2019-11-12 00:15:34 +01:00
$mesg = '' ; $error = 0 ; $errors = array ();
$refalreadyexists = 0 ;
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
2019-12-03 11:17:29 +01:00
$type = ( GETPOST ( 'type' , 'int' ) !== '' ) ? GETPOST ( 'type' , 'int' ) : Product :: TYPE_PRODUCT ;
2019-11-12 00:15:34 +01:00
$action = ( GETPOST ( 'action' , 'alpha' ) ? GETPOST ( 'action' , 'alpha' ) : 'view' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$socid = GETPOST ( 'socid' , 'int' );
2019-04-25 00:11:08 +02:00
$duration_value = GETPOST ( 'duration_value' , 'int' );
$duration_unit = GETPOST ( 'duration_unit' , 'alpha' );
2020-10-01 09:40:11 +02:00
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
$accountancy_code_sell_intra = GETPOST ( 'accountancy_code_sell_intra' , 'alpha' );
$accountancy_code_sell_export = GETPOST ( 'accountancy_code_sell_export' , 'alpha' );
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
$accountancy_code_buy_intra = GETPOST ( 'accountancy_code_buy_intra' , 'alpha' );
$accountancy_code_buy_export = GETPOST ( 'accountancy_code_buy_export' , 'alpha' );
2020-12-08 09:30:31 +01:00
// by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html
$label_security_check = empty ( $conf -> global -> MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML ) ? 'alphanohtml' : 'restricthtml' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $user -> socid )) {
$socid = $user -> socid ;
}
2011-08-23 00:04:21 +02:00
$object = new Product ( $db );
2019-11-12 00:15:34 +01:00
$object -> type = $type ; // so test later to fill $usercancxxx is correct
2011-08-23 00:04:21 +02:00
$extrafields = new ExtraFields ( $db );
2013-03-30 16:58:49 +01:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-03-30 16:58:49 +01:00
2021-02-26 14:25:17 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2020-09-07 10:18:17 +02:00
$result = $object -> fetch ( $id , $ref );
2016-02-08 15:49:38 +01:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> product -> enabled )) {
$upload_dir = $conf -> product -> multidir_output [ $object -> entity ] . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'product' ) . dol_sanitizeFileName ( $object -> ref );
} elseif ( ! empty ( $conf -> service -> enabled )) {
$upload_dir = $conf -> service -> multidir_output [ $object -> entity ] . '/' . get_exdir ( 0 , 0 , 0 , 0 , $object , 'product' ) . dol_sanitizeFileName ( $object -> ref );
}
2016-02-08 15:49:38 +01:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_OLD_PATH_FOR_PHOTO )) { // For backward compatiblity, we scan also old dirs
if ( ! empty ( $conf -> product -> enabled )) {
$upload_dirold = $conf -> product -> multidir_output [ $object -> entity ] . '/' . substr ( substr ( " 000 " . $object -> id , - 2 ), 1 , 1 ) . '/' . substr ( substr ( " 000 " . $object -> id , - 2 ), 0 , 1 ) . '/' . $object -> id . " /photos " ;
} else {
$upload_dirold = $conf -> service -> multidir_output [ $object -> entity ] . '/' . substr ( substr ( " 000 " . $object -> id , - 2 ), 1 , 1 ) . '/' . substr ( substr ( " 000 " . $object -> id , - 2 ), 0 , 1 ) . '/' . $object -> id . " /photos " ;
}
2020-09-07 10:18:17 +02:00
}
2013-01-15 11:23:24 +01:00
}
2016-07-28 13:53:17 +02:00
2019-11-12 00:15:34 +01:00
$modulepart = 'product' ;
2013-01-15 11:23:24 +01:00
2011-08-23 00:04:21 +02:00
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
2019-11-12 00:15:34 +01:00
$canvas = ! empty ( $object -> canvas ) ? $object -> canvas : GETPOST ( " canvas " );
$objcanvas = null ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $canvas )) {
2020-09-07 10:18:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
$objcanvas = new Canvas ( $db , $action );
$objcanvas -> getCanvas ( 'product' , 'card' , $canvas );
2011-08-23 00:04:21 +02:00
}
2011-04-25 22:18:09 +02:00
2009-04-27 22:37:50 +02:00
// Security check
2019-11-12 00:15:34 +01:00
$fieldvalue = ( ! empty ( $id ) ? $id : ( ! empty ( $ref ) ? $ref : '' ));
$fieldtype = ( ! empty ( $id ) ? 'rowid' : 'ref' );
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 );
}
2002-05-04 23:28:42 +02: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-12 00:15:34 +01:00
$hookmanager -> initHooks ( array ( 'productcard' , 'globalcard' ));
2010-05-02 16:29:16 +02:00
2003-08-06 14:25:49 +02:00
2009-05-27 17:11:24 +02:00
2005-03-10 17:30:56 +01:00
/*
2009-05-27 17:11:24 +02:00
* Actions
2006-12-15 14:17:22 +01:00
*/
2009-05-27 17:11:24 +02:00
2021-02-26 14:25:17 +01:00
if ( $cancel ) {
$action = '' ;
}
2015-05-03 20:07:16 +02:00
2018-02-11 13:27:02 +01: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 ));
$usercandelete = (( $object -> type == Product :: TYPE_PRODUCT && $user -> rights -> produit -> supprimer ) || ( $object -> type == Product :: TYPE_SERVICE && $user -> rights -> service -> supprimer ));
2019-11-12 00:15:34 +01:00
$createbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> creer_advance )) {
$createbarcode = 0 ;
}
2014-03-16 17:37:54 +01:00
2019-11-12 00:15:34 +01:00
$parameters = array ( 'id' => $id , 'ref' => $ref , 'objcanvas' => $objcanvas );
$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' );
}
2011-08-27 19:25:09 +02:00
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
2020-09-07 10:18:17 +02:00
// Type
2021-02-26 14:25:17 +01:00
if ( $action == 'setfk_product_type' && $usercancreate ) {
2020-09-07 10:18:17 +02:00
$result = $object -> setValueFrom ( 'fk_product_type' , GETPOST ( 'fk_product_type' ), '' , null , 'text' , '' , $user , 'PRODUCT_MODIFY' );
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
// Actions to build doc
$upload_dir = $conf -> product -> dir_output ;
$permissiontoadd = $usercancreate ;
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php' ;
// Barcode type
2021-02-26 14:25:17 +01:00
if ( $action == 'setfk_barcode_type' && $createbarcode ) {
2020-09-07 10:18:17 +02:00
$result = $object -> setValueFrom ( 'fk_barcode_type' , GETPOST ( 'fk_barcode_type' ), '' , null , 'text' , '' , $user , 'PRODUCT_MODIFY' );
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
// Barcode value
2021-02-26 14:25:17 +01:00
if ( $action == 'setbarcode' && $createbarcode ) {
2020-09-07 10:18:17 +02:00
$result = $object -> check_barcode ( GETPOST ( 'barcode' ), GETPOST ( 'barcode_type_code' ));
2014-02-19 01:51:19 +01:00
2021-02-26 14:25:17 +01:00
if ( $result >= 0 ) {
2020-09-07 10:18:17 +02:00
$result = $object -> setValueFrom ( 'barcode' , GETPOST ( 'barcode' ), '' , null , 'text' , '' , $user , 'PRODUCT_MODIFY' );
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2014-02-19 01:51:19 +01:00
$langs -> load ( " errors " );
2021-02-26 14:25:17 +01:00
if ( $result == - 1 ) {
$errors [] = 'ErrorBadBarCodeSyntax' ;
} elseif ( $result == - 2 ) {
$errors [] = 'ErrorBarCodeRequired' ;
} elseif ( $result == - 3 ) {
$errors [] = 'ErrorBarCodeAlreadyUsed' ;
} else {
$errors [] = 'FailedToValidateBarCode' ;
}
2014-02-19 01:51:19 +01:00
$error ++ ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $errors , null , 'errors' );
2014-02-19 01:51:19 +01:00
}
2020-09-07 10:18:17 +02:00
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Add a product or service
2021-02-26 14:25:17 +01:00
if ( $action == 'add' && $usercancreate ) {
2020-09-07 10:18:17 +02:00
$error = 0 ;
2017-06-07 16:44:04 +02:00
2021-02-26 14:25:17 +01:00
if ( ! GETPOST ( 'label' , $label_security_check )) {
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Label' )), null , 'errors' );
$action = " create " ;
$error ++ ;
}
if ( empty ( $ref )) {
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Ref' )), null , 'errors' );
$action = " create " ;
$error ++ ;
}
if ( ! empty ( $duration_value ) && empty ( $duration_unit )) {
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Unit' )), null , 'errors' );
$action = " create " ;
$error ++ ;
}
if ( ! $error ) {
2020-09-07 10:18:17 +02:00
$units = GETPOST ( 'units' , 'int' );
2021-02-26 14:25:17 +01:00
$object -> ref = $ref ;
$object -> label = GETPOST ( 'label' , $label_security_check );
$object -> price_base_type = GETPOST ( 'price_base_type' , 'aZ09' );
2020-09-07 10:18:17 +02:00
2021-02-26 14:25:17 +01:00
if ( $object -> price_base_type == 'TTC' ) {
2020-09-07 10:18:17 +02:00
$object -> price_ttc = GETPOST ( 'price' );
2021-02-26 14:25:17 +01:00
} else {
$object -> price = GETPOST ( 'price' );
}
if ( $object -> price_base_type == 'TTC' ) {
2020-09-07 10:18:17 +02:00
$object -> price_min_ttc = GETPOST ( 'price_min' );
2021-02-26 14:25:17 +01:00
} else {
$object -> price_min = GETPOST ( 'price_min' );
}
2020-09-07 10:18:17 +02:00
$tva_tx_txt = GETPOST ( 'tva_tx' , 'alpha' ); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
// We must define tva_tx, npr and local taxes
$vatratecode = '' ;
$tva_tx = preg_replace ( '/[^0-9\.].*$/' , '' , $tva_tx_txt ); // keep remove all after the numbers and dot
$npr = preg_match ( '/\*/' , $tva_tx_txt ) ? 1 : 0 ;
$localtax1 = 0 ; $localtax2 = 0 ; $localtax1_type = '0' ; $localtax2_type = '0' ;
// If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
2020-09-20 02:57:15 +02:00
$reg = array ();
2021-02-26 14:25:17 +01:00
if ( preg_match ( '/\((.*)\)/' , $tva_tx_txt , $reg )) {
2020-09-07 10:18:17 +02:00
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
$vatratecode = $reg [ 1 ];
// Get record from code
$sql = " SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " c_tva as t, " . MAIN_DB_PREFIX . " c_country as c " ;
2020-09-20 02:57:15 +02:00
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = ' " . $db -> escape ( $mysoc -> country_code ) . " ' " ;
2020-09-07 10:18:17 +02:00
$sql .= " AND t.taux = " . (( float ) $tva_tx ) . " AND t.active = 1 " ;
2020-09-20 02:57:15 +02:00
$sql .= " AND t.code = ' " . $db -> escape ( $vatratecode ) . " ' " ;
2020-09-07 10:18:17 +02:00
$resql = $db -> query ( $sql );
2021-02-26 14:25:17 +01:00
if ( $resql ) {
2020-09-07 10:18:17 +02:00
$obj = $db -> fetch_object ( $resql );
$npr = $obj -> recuperableonly ;
$localtax1 = $obj -> localtax1 ;
$localtax2 = $obj -> localtax2 ;
$localtax1_type = $obj -> localtax1_type ;
$localtax2_type = $obj -> localtax2_type ;
}
}
2013-01-15 11:23:24 +01:00
2020-09-07 10:18:17 +02:00
$object -> default_vat_code = $vatratecode ;
$object -> tva_tx = $tva_tx ;
$object -> tva_npr = $npr ;
$object -> localtax1_tx = $localtax1 ;
$object -> localtax2_tx = $localtax2 ;
$object -> localtax1_type = $localtax1_type ;
$object -> localtax2_type = $localtax2_type ;
$object -> type = $type ;
$object -> status = GETPOST ( 'statut' );
2021-06-14 15:37:02 +02:00
$object -> status_buy = GETPOST ( 'statut_buy' );
2019-11-12 00:15:34 +01:00
$object -> status_batch = GETPOST ( 'status_batch' );
2021-04-13 16:13:57 +02:00
$object -> batch_mask = GETPOST ( 'batch_mask' );
2014-02-10 00:24:20 +01:00
2021-06-14 15:37:02 +02:00
$object -> barcode_type = GETPOST ( 'fk_barcode_type' );
2020-09-07 10:18:17 +02:00
$object -> barcode = GETPOST ( 'barcode' );
// Set barcode_type_xxx from barcode_type id
$stdobject = new GenericObject ( $db );
$stdobject -> element = 'product' ;
$stdobject -> barcode_type = GETPOST ( 'fk_barcode_type' );
$result = $stdobject -> fetch_barcode ();
2021-02-26 14:25:17 +01:00
if ( $result < 0 ) {
2020-09-07 10:18:17 +02:00
$error ++ ;
$mesg = 'Failed to get bar code type information ' ;
setEventMessages ( $mesg . $stdobject -> error , $mesg . $stdobject -> errors , 'errors' );
}
$object -> barcode_type_code = $stdobject -> barcode_type_code ;
$object -> barcode_type_coder = $stdobject -> barcode_type_coder ;
$object -> barcode_type_label = $stdobject -> barcode_type_label ;
2020-09-18 01:29:17 +02:00
$object -> description = dol_htmlcleanlastbr ( GETPOST ( 'desc' , 'restricthtml' ));
2020-09-07 10:18:17 +02:00
$object -> url = GETPOST ( 'url' );
2020-09-18 01:29:17 +02:00
$object -> note_private = dol_htmlcleanlastbr ( GETPOST ( 'note_private' , 'restricthtml' ));
2020-09-07 10:18:17 +02:00
$object -> note = $object -> note_private ; // deprecated
$object -> customcode = GETPOST ( 'customcode' , 'alphanohtml' );
2020-10-07 15:01:28 +02:00
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2021-04-28 17:08:17 +02:00
$object -> lifetime = GETPOST ( 'lifetime' , 'int' );
$object -> qc_frequency = GETPOST ( 'qc_frequency' , 'int' );
2020-09-07 10:18:17 +02:00
$object -> duration_value = $duration_value ;
$object -> duration_unit = $duration_unit ;
$object -> fk_default_warehouse = GETPOST ( 'fk_default_warehouse' );
$object -> seuil_stock_alerte = GETPOST ( 'seuil_stock_alerte' ) ? GETPOST ( 'seuil_stock_alerte' ) : 0 ;
$object -> desiredstock = GETPOST ( 'desiredstock' ) ? GETPOST ( 'desiredstock' ) : 0 ;
$object -> canvas = GETPOST ( 'canvas' );
$object -> net_measure = GETPOST ( 'net_measure' );
$object -> net_measure_units = GETPOST ( 'net_measure_units' ); // This is not the fk_unit but the power of unit
$object -> weight = GETPOST ( 'weight' );
$object -> weight_units = GETPOST ( 'weight_units' ); // This is not the fk_unit but the power of unit
$object -> length = GETPOST ( 'size' );
$object -> length_units = GETPOST ( 'size_units' ); // This is not the fk_unit but the power of unit
$object -> width = GETPOST ( 'sizewidth' );
$object -> height = GETPOST ( 'sizeheight' );
$object -> surface = GETPOST ( 'surface' );
$object -> surface_units = GETPOST ( 'surface_units' ); // This is not the fk_unit but the power of unit
$object -> volume = GETPOST ( 'volume' );
$object -> volume_units = GETPOST ( 'volume_units' ); // This is not the fk_unit but the power of unit
2020-10-31 14:32:18 +01:00
$finished = GETPOST ( 'finished' , 'int' );
2020-10-14 15:54:48 +02:00
if ( $finished > 0 ) {
$object -> finished = $finished ;
} else {
$object -> finished = null ;
}
$units = GETPOST ( 'units' , 'int' );
if ( $units > 0 ) {
$object -> fk_unit = $units ;
} else {
$object -> fk_unit = null ;
}
2020-09-07 10:18:17 +02:00
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
$accountancy_code_sell_intra = GETPOST ( 'accountancy_code_sell_intra' , 'alpha' );
$accountancy_code_sell_export = GETPOST ( 'accountancy_code_sell_export' , 'alpha' );
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
2020-03-01 04:52:12 +01:00
$accountancy_code_buy_intra = GETPOST ( 'accountancy_code_buy_intra' , 'alpha' );
$accountancy_code_buy_export = GETPOST ( 'accountancy_code_buy_export' , 'alpha' );
2015-12-22 07:31:59 +01:00
2021-02-26 14:25:17 +01:00
if ( $accountancy_code_sell <= 0 ) {
$object -> accountancy_code_sell = '' ;
} else {
$object -> accountancy_code_sell = $accountancy_code_sell ;
}
if ( $accountancy_code_sell_intra <= 0 ) {
$object -> accountancy_code_sell_intra = '' ;
} else {
$object -> accountancy_code_sell_intra = $accountancy_code_sell_intra ;
}
if ( $accountancy_code_sell_export <= 0 ) {
$object -> accountancy_code_sell_export = '' ;
} else {
$object -> accountancy_code_sell_export = $accountancy_code_sell_export ;
}
if ( $accountancy_code_buy <= 0 ) {
$object -> accountancy_code_buy = '' ;
} else {
$object -> accountancy_code_buy = $accountancy_code_buy ;
}
if ( $accountancy_code_buy_intra <= 0 ) {
$object -> accountancy_code_buy_intra = '' ;
} else {
$object -> accountancy_code_buy_intra = $accountancy_code_buy_intra ;
}
if ( $accountancy_code_buy_export <= 0 ) {
$object -> accountancy_code_buy_export = '' ;
} else {
$object -> accountancy_code_buy_export = $accountancy_code_buy_export ;
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// MultiPrix
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
for ( $i = 2 ; $i <= $conf -> global -> PRODUIT_MULTIPRICES_LIMIT ; $i ++ ) {
if ( GETPOSTISSET ( " price_ " . $i )) {
2021-03-25 16:59:47 +01:00
$object -> multiprices [ " $i " ] = price2num ( GETPOST ( " price_ " . $i ), 'MU' );
$object -> multiprices_base_type [ " $i " ] = GETPOST ( " multiprices_base_type_ " . $i );
2020-09-07 10:18:17 +02:00
} else {
$object -> multiprices [ " $i " ] = " " ;
}
}
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2012-03-03 19:02:44 +01:00
2021-02-26 14:25:17 +01:00
if ( ! $error ) {
2020-09-07 10:18:17 +02:00
$id = $object -> create ( $user );
2015-02-26 14:25:30 +01:00
}
2011-10-01 12:48:31 +02:00
2021-02-26 14:25:17 +01:00
if ( $id > 0 ) {
2015-04-18 03:07:49 +02:00
// Category association
2017-09-18 01:39:39 +02:00
$categories = GETPOST ( 'categories' , 'array' );
2015-09-30 18:46:51 +02:00
$object -> setCategories ( $categories );
2015-04-21 15:49:58 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $backtopage )) {
2019-11-12 00:15:34 +01:00
$backtopage = preg_replace ( '/--IDFORBACKTOPAGE--/' , $object -> id , $backtopage ); // New method to autoselect project after a New on another form object creation
2021-02-26 14:25:17 +01:00
if ( preg_match ( '/\?/' , $backtopage )) {
$backtopage .= '&socid=' . $object -> id ; // Old method
}
2019-10-21 14:43:39 +02:00
header ( " Location: " . $backtopage );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2020-09-07 10:18:17 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $id );
exit ;
2019-10-21 14:43:39 +02:00
}
2020-09-07 10:18:17 +02:00
} else {
2021-02-26 14:25:17 +01:00
if ( count ( $object -> errors )) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
} else {
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
}
2020-09-07 10:18:17 +02:00
$action = " create " ;
}
}
}
2004-07-14 12:25:14 +02:00
2020-09-07 10:18:17 +02:00
// Update a product or service
2021-02-26 14:25:17 +01:00
if ( $action == 'update' && $usercancreate ) {
if ( GETPOST ( 'cancel' , 'alpha' )) {
2020-09-07 10:18:17 +02:00
$action = '' ;
} else {
2021-02-26 14:25:17 +01:00
if ( $object -> id > 0 ) {
2019-11-12 00:15:34 +01:00
$object -> oldcopy = clone $object ;
2012-06-09 13:16:55 +02:00
2020-09-07 10:18:17 +02:00
$object -> ref = $ref ;
2020-12-08 22:27:27 +01:00
$object -> label = GETPOST ( 'label' , $label_security_check );
2021-01-07 12:39:51 +01:00
$desc = dol_htmlcleanlastbr ( preg_replace ( '/ $/' , '' , GETPOST ( 'desc' , 'restricthtml' )));
$object -> description = $desc ;
2020-09-07 10:18:17 +02:00
$object -> url = GETPOST ( 'url' );
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB )) {
2020-09-18 01:29:17 +02:00
$object -> note_private = dol_htmlcleanlastbr ( GETPOST ( 'note_private' , 'restricthtml' ));
2020-09-07 10:18:17 +02:00
$object -> note = $object -> note_private ;
}
$object -> customcode = GETPOST ( 'customcode' , 'alpha' );
2020-09-14 11:01:11 +02:00
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> state_id = GETPOST ( 'state_id' , 'int' );
2021-04-28 17:08:17 +02:00
$object -> lifetime = GETPOST ( 'lifetime' , 'int' );
$object -> qc_frequency = GETPOST ( 'qc_frequency' , 'int' );
2020-09-07 10:18:17 +02:00
$object -> status = GETPOST ( 'statut' , 'int' );
$object -> status_buy = GETPOST ( 'statut_buy' , 'int' );
$object -> status_batch = GETPOST ( 'status_batch' , 'aZ09' );
2021-04-13 16:13:57 +02:00
$object -> batch_mask = GETPOST ( 'batch_mask' , 'alpha' );
2020-09-07 10:18:17 +02:00
$object -> fk_default_warehouse = GETPOST ( 'fk_default_warehouse' );
2021-01-07 12:39:51 +01:00
// removed from update view so GETPOST always empty
2020-09-07 10:18:17 +02:00
/*
2021-02-26 14:25:17 +01:00
$object -> seuil_stock_alerte = GETPOST ( 'seuil_stock_alerte' );
$object -> desiredstock = GETPOST ( 'desiredstock' );
*/
2020-09-07 10:18:17 +02:00
$object -> duration_value = GETPOST ( 'duration_value' , 'int' );
$object -> duration_unit = GETPOST ( 'duration_unit' , 'alpha' );
$object -> canvas = GETPOST ( 'canvas' );
$object -> net_measure = GETPOST ( 'net_measure' );
$object -> net_measure_units = GETPOST ( 'net_measure_units' ); // This is not the fk_unit but the power of unit
$object -> weight = GETPOST ( 'weight' );
$object -> weight_units = GETPOST ( 'weight_units' ); // This is not the fk_unit but the power of unit
$object -> length = GETPOST ( 'size' );
$object -> length_units = GETPOST ( 'size_units' ); // This is not the fk_unit but the power of unit
$object -> width = GETPOST ( 'sizewidth' );
$object -> height = GETPOST ( 'sizeheight' );
$object -> surface = GETPOST ( 'surface' );
$object -> surface_units = GETPOST ( 'surface_units' ); // This is not the fk_unit but the power of unit
$object -> volume = GETPOST ( 'volume' );
$object -> volume_units = GETPOST ( 'volume_units' ); // This is not the fk_unit but the power of unit
2020-10-31 14:32:18 +01:00
$finished = GETPOST ( 'finished' , 'int' );
2020-10-14 15:54:48 +02:00
if ( $finished >= 0 ) {
$object -> finished = $finished ;
} else {
$object -> finished = null ;
}
2020-09-07 10:18:17 +02:00
2020-10-14 15:54:48 +02:00
$units = GETPOST ( 'units' , 'int' );
2020-09-07 10:18:17 +02:00
if ( $units > 0 ) {
$object -> fk_unit = $units ;
} else {
$object -> fk_unit = null ;
}
$object -> barcode_type = GETPOST ( 'fk_barcode_type' );
$object -> barcode = GETPOST ( 'barcode' );
// Set barcode_type_xxx from barcode_type id
$stdobject = new GenericObject ( $db );
$stdobject -> element = 'product' ;
$stdobject -> barcode_type = GETPOST ( 'fk_barcode_type' );
$result = $stdobject -> fetch_barcode ();
2021-02-26 14:25:17 +01:00
if ( $result < 0 ) {
2020-09-07 10:18:17 +02:00
$error ++ ;
$mesg = 'Failed to get bar code type information ' ;
setEventMessages ( $mesg . $stdobject -> error , $mesg . $stdobject -> errors , 'errors' );
}
$object -> barcode_type_code = $stdobject -> barcode_type_code ;
$object -> barcode_type_coder = $stdobject -> barcode_type_coder ;
$object -> barcode_type_label = $stdobject -> barcode_type_label ;
$accountancy_code_sell = GETPOST ( 'accountancy_code_sell' , 'alpha' );
$accountancy_code_sell_intra = GETPOST ( 'accountancy_code_sell_intra' , 'alpha' );
$accountancy_code_sell_export = GETPOST ( 'accountancy_code_sell_export' , 'alpha' );
$accountancy_code_buy = GETPOST ( 'accountancy_code_buy' , 'alpha' );
$accountancy_code_buy_intra = GETPOST ( 'accountancy_code_buy_intra' , 'alpha' );
$accountancy_code_buy_export = GETPOST ( 'accountancy_code_buy_export' , 'alpha' );
2017-05-21 15:24:16 +02:00
2021-02-26 14:25:17 +01:00
if ( $accountancy_code_sell <= 0 ) {
$object -> accountancy_code_sell = '' ;
} else {
$object -> accountancy_code_sell = $accountancy_code_sell ;
}
if ( $accountancy_code_sell_intra <= 0 ) {
$object -> accountancy_code_sell_intra = '' ;
} else {
$object -> accountancy_code_sell_intra = $accountancy_code_sell_intra ;
}
if ( $accountancy_code_sell_export <= 0 ) {
$object -> accountancy_code_sell_export = '' ;
} else {
$object -> accountancy_code_sell_export = $accountancy_code_sell_export ;
}
if ( $accountancy_code_buy <= 0 ) {
$object -> accountancy_code_buy = '' ;
} else {
$object -> accountancy_code_buy = $accountancy_code_buy ;
}
if ( $accountancy_code_buy_intra <= 0 ) {
$object -> accountancy_code_buy_intra = '' ;
} else {
$object -> accountancy_code_buy_intra = $accountancy_code_buy_intra ;
}
if ( $accountancy_code_buy_export <= 0 ) {
$object -> accountancy_code_buy_export = '' ;
} else {
$object -> accountancy_code_buy_export = $accountancy_code_buy_export ;
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2012-03-03 19:02:44 +01:00
2021-02-26 14:25:17 +01:00
if ( ! $error && $object -> check ()) {
if ( $object -> update ( $object -> id , $user ) > 0 ) {
2015-04-18 03:07:49 +02:00
// Category association
2017-09-18 01:39:39 +02:00
$categories = GETPOST ( 'categories' , 'array' );
2015-09-30 18:46:51 +02:00
$object -> setCategories ( $categories );
2015-04-21 15:49:58 +02:00
2020-09-07 10:18:17 +02:00
$action = 'view' ;
} else {
2021-02-26 14:25:17 +01:00
if ( count ( $object -> errors )) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
} else {
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
}
2020-09-07 10:18:17 +02:00
$action = 'edit' ;
}
} else {
2021-02-26 14:25:17 +01:00
if ( count ( $object -> errors )) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
} else {
setEventMessages ( $langs -> trans ( " ErrorProductBadRefOrLabel " ), null , 'errors' );
}
2020-09-07 10:18:17 +02:00
$action = 'edit' ;
}
}
}
}
2004-07-14 14:22:27 +02:00
2020-09-07 10:18:17 +02:00
// Action clone object
2021-02-26 14:25:17 +01:00
if ( $action == 'confirm_clone' && $confirm != 'yes' ) {
$action = '' ;
}
if ( $action == 'confirm_clone' && $confirm == 'yes' && $usercancreate ) {
if ( ! GETPOST ( 'clone_content' ) && ! GETPOST ( 'clone_prices' )) {
2020-09-07 10:18:17 +02:00
setEventMessages ( $langs -> trans ( " NoCloneOptionsSpecified " ), null , 'errors' );
} else {
$db -> begin ();
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$originalId = $id ;
2021-02-26 14:25:17 +01:00
if ( $object -> id > 0 ) {
2020-09-07 10:18:17 +02:00
$object -> ref = GETPOST ( 'clone_ref' , 'alphanohtml' );
$object -> status = 0 ;
$object -> status_buy = 0 ;
$object -> id = null ;
$object -> barcode = - 1 ;
2011-10-01 12:48:31 +02:00
2021-02-26 14:25:17 +01:00
if ( $object -> check ()) {
2020-09-07 10:18:17 +02:00
$object -> context [ 'createfromclone' ] = 'createfromclone' ;
$id = $object -> create ( $user );
2021-02-26 14:25:17 +01:00
if ( $id > 0 ) {
if ( GETPOST ( 'clone_composition' )) {
2020-09-07 10:18:17 +02:00
$result = $object -> clone_associations ( $originalId , $id );
2021-02-26 14:25:17 +01:00
if ( $result < 1 ) {
2020-09-07 10:18:17 +02:00
$db -> rollback ();
setEventMessages ( $langs -> trans ( 'ErrorProductClone' ), null , 'errors' );
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $originalId );
exit ;
}
}
2021-02-26 14:25:17 +01:00
if ( GETPOST ( 'clone_categories' )) {
2020-09-07 10:18:17 +02:00
$result = $object -> cloneCategories ( $originalId , $id );
2021-02-26 14:25:17 +01:00
if ( $result < 1 ) {
2020-09-07 10:18:17 +02:00
$db -> rollback ();
setEventMessages ( $langs -> trans ( 'ErrorProductClone' ), null , 'errors' );
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $originalId );
exit ;
}
}
if ( GETPOST ( 'clone_prices' )) {
$result = $object -> clone_price ( $originalId , $id );
if ( $result < 1 ) {
$db -> rollback ();
setEventMessages ( $langs -> trans ( 'ErrorProductClone' ), null , 'errors' );
header ( 'Location: ' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $originalId );
exit ();
}
}
// $object->clone_fournisseurs($originalId, $id);
$db -> commit ();
$db -> close ();
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id );
exit ;
} else {
$id = $originalId ;
2021-02-26 14:25:17 +01:00
if ( $object -> error == 'ErrorProductAlreadyExists' ) {
2020-09-07 10:18:17 +02:00
$db -> rollback ();
$refalreadyexists ++ ;
$action = " " ;
$mesg = $langs -> trans ( " ErrorProductAlreadyExists " , $object -> ref );
$mesg .= ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?ref=' . $object -> ref . '">' . $langs -> trans ( " ShowCardHere " ) . '</a>.' ;
setEventMessages ( $mesg , null , 'errors' );
$object -> fetch ( $id );
} else {
$db -> rollback ();
2021-02-26 14:25:17 +01:00
if ( count ( $object -> errors )) {
2020-09-07 10:18:17 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
dol_print_error ( $db , $object -> errors );
} else {
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
dol_print_error ( $db , $object -> error );
}
}
}
2006-04-07 14:39:22 +02:00
2020-09-07 10:18:17 +02:00
unset ( $object -> context [ 'createfromclone' ]);
}
} else {
$db -> rollback ();
dol_print_error ( $db , $object -> error );
}
}
}
// Delete a product
2021-02-26 14:25:17 +01:00
if ( $action == 'confirm_delete' && $confirm != 'yes' ) {
$action = '' ;
}
if ( $action == 'confirm_delete' && $confirm == 'yes' && $usercandelete ) {
2018-02-11 13:27:02 +01:00
$result = $object -> delete ( $user );
2013-10-23 16:24:31 +02:00
2021-02-26 14:25:17 +01:00
if ( $result > 0 ) {
2020-09-07 10:18:17 +02:00
header ( 'Location: ' . DOL_URL_ROOT . '/product/list.php?type=' . $object -> type . '&delprod=' . urlencode ( $object -> ref ));
exit ;
} else {
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
$reload = 0 ;
$action = '' ;
}
}
2006-04-07 14:39:22 +02:00
2005-06-26 20:13:17 +02:00
2020-09-07 10:18:17 +02:00
// Add product into object
2021-02-26 14:25:17 +01:00
if ( $object -> id > 0 && $action == 'addin' ) {
2020-09-07 10:18:17 +02:00
$thirpdartyid = 0 ;
2021-02-26 14:25:17 +01:00
if ( GETPOST ( 'propalid' ) > 0 ) {
2020-09-07 10:18:17 +02:00
$propal = new Propal ( $db );
$result = $propal -> fetch ( GETPOST ( 'propalid' ));
2021-02-26 14:25:17 +01:00
if ( $result <= 0 ) {
2020-09-07 10:18:17 +02:00
dol_print_error ( $db , $propal -> error );
exit ;
}
$thirpdartyid = $propal -> socid ;
2021-02-26 14:25:17 +01:00
} elseif ( GETPOST ( 'commandeid' ) > 0 ) {
2020-09-07 10:18:17 +02:00
$commande = new Commande ( $db );
$result = $commande -> fetch ( GETPOST ( 'commandeid' ));
2021-02-26 14:25:17 +01:00
if ( $result <= 0 ) {
2020-09-07 10:18:17 +02:00
dol_print_error ( $db , $commande -> error );
exit ;
}
$thirpdartyid = $commande -> socid ;
2021-02-26 14:25:17 +01:00
} elseif ( GETPOST ( 'factureid' ) > 0 ) {
2020-09-07 10:18:17 +02:00
$facture = new Facture ( $db );
$result = $facture -> fetch ( GETPOST ( 'factureid' ));
2021-02-26 14:25:17 +01:00
if ( $result <= 0 ) {
2020-09-07 10:18:17 +02:00
dol_print_error ( $db , $facture -> error );
exit ;
}
$thirpdartyid = $facture -> socid ;
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
if ( $thirpdartyid > 0 ) {
$soc = new Societe ( $db );
$result = $soc -> fetch ( $thirpdartyid );
if ( $result <= 0 ) {
dol_print_error ( $db , $soc -> error );
exit ;
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$desc = $object -> description ;
$tva_tx = get_default_tva ( $mysoc , $soc , $object -> id );
$tva_npr = get_default_npr ( $mysoc , $soc , $object -> id );
2021-02-26 14:25:17 +01:00
if ( empty ( $tva_tx )) {
$tva_npr = 0 ;
}
2020-09-07 10:18:17 +02:00
$localtax1_tx = get_localtax ( $tva_tx , 1 , $soc , $mysoc , $tva_npr );
$localtax2_tx = get_localtax ( $tva_tx , 2 , $soc , $mysoc , $tva_npr );
$pu_ht = $object -> price ;
$pu_ttc = $object -> price_ttc ;
$price_base_type = $object -> price_base_type ;
// If multiprice
if ( $conf -> global -> PRODUIT_MULTIPRICES && $soc -> price_level ) {
$pu_ht = $object -> multiprices [ $soc -> price_level ];
$pu_ttc = $object -> multiprices_ttc [ $soc -> price_level ];
$price_base_type = $object -> multiprices_base_type [ $soc -> price_level ];
} elseif ( ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES )) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php' ;
$prodcustprice = new Productcustomerprice ( $db );
$filter = array ( 't.fk_product' => $object -> id , 't.fk_soc' => $soc -> id );
$result = $prodcustprice -> fetch_all ( '' , '' , 0 , 0 , $filter );
if ( $result ) {
if ( count ( $prodcustprice -> lines ) > 0 ) {
$pu_ht = price ( $prodcustprice -> lines [ 0 ] -> price );
$pu_ttc = price ( $prodcustprice -> lines [ 0 ] -> price_ttc );
$price_base_type = $prodcustprice -> lines [ 0 ] -> price_base_type ;
$tva_tx = $prodcustprice -> lines [ 0 ] -> tva_tx ;
}
}
}
2015-09-13 00:09:32 +02:00
2017-03-04 21:45:19 +01:00
$tmpvat = price2num ( preg_replace ( '/\s*\(.*\)/' , '' , $tva_tx ));
$tmpprodvat = price2num ( preg_replace ( '/\s*\(.*\)/' , '' , $prod -> tva_tx ));
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ( $tmpvat != $tmpprodvat ) {
if ( $price_base_type != 'HT' ) {
$pu_ht = price2num ( $pu_ttc / ( 1 + ( $tmpvat / 100 )), 'MU' );
} else {
$pu_ttc = price2num ( $pu_ht * ( 1 + ( $tmpvat / 100 )), 'MU' );
}
}
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
if ( GETPOST ( 'propalid' ) > 0 ) {
// Define cost price for margin calculation
$buyprice = 0 ;
2021-02-26 14:25:17 +01:00
if (( $result = $propal -> defineBuyPrice ( $pu_ht , price2num ( GETPOST ( 'remise_percent' ), 2 ), $object -> id )) < 0 ) {
2020-09-07 10:18:17 +02:00
dol_syslog ( $langs -> trans ( 'FailedToGetCostPrice' ));
setEventMessages ( $langs -> trans ( 'FailedToGetCostPrice' ), null , 'errors' );
} else {
$buyprice = $result ;
}
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
$result = $propal -> addline (
$desc ,
$pu_ht ,
2021-01-31 12:48:40 +01:00
price2num ( GETPOST ( 'qty' ), 'MS' ),
2020-09-07 10:18:17 +02:00
$tva_tx ,
$localtax1_tx , // localtax1
$localtax2_tx , // localtax2
$object -> id ,
2021-01-31 12:48:40 +01:00
price2num ( GETPOST ( 'remise_percent' ), 2 ),
2020-09-07 10:18:17 +02:00
$price_base_type ,
$pu_ttc ,
0 ,
0 ,
- 1 ,
0 ,
0 ,
0 ,
$buyprice ,
'' ,
'' ,
'' ,
0 ,
$object -> fk_unit
);
if ( $result > 0 ) {
header ( " Location: " . DOL_URL_ROOT . " /comm/propal/card.php?id= " . $propal -> id );
return ;
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
setEventMessages ( $langs -> trans ( " ErrorUnknown " ) . " : $result " , null , 'errors' );
} elseif ( GETPOST ( 'commandeid' ) > 0 ) {
// Define cost price for margin calculation
$buyprice = 0 ;
2021-02-26 14:25:17 +01:00
if (( $result = $commande -> defineBuyPrice ( $pu_ht , GETPOST ( 'remise_percent' , 2 ), $object -> id )) < 0 ) {
2020-09-07 10:18:17 +02:00
dol_syslog ( $langs -> trans ( 'FailedToGetCostPrice' ));
setEventMessages ( $langs -> trans ( 'FailedToGetCostPrice' ), null , 'errors' );
} else {
$buyprice = $result ;
}
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
$result = $commande -> addline (
$desc ,
$pu_ht ,
2021-01-31 12:48:40 +01:00
price2num ( GETPOST ( 'qty' ), 'MS' ),
2020-09-07 10:18:17 +02:00
$tva_tx ,
$localtax1_tx , // localtax1
$localtax2_tx , // localtax2
$object -> id ,
2021-01-31 12:48:40 +01:00
price2num ( GETPOST ( 'remise_percent' ), 2 ),
2020-09-07 10:18:17 +02:00
'' ,
'' ,
$price_base_type ,
$pu_ttc ,
'' ,
'' ,
0 ,
- 1 ,
0 ,
0 ,
null ,
$buyprice ,
'' ,
0 ,
$object -> fk_unit
);
if ( $result > 0 ) {
header ( " Location: " . DOL_URL_ROOT . " /commande/card.php?id= " . $commande -> id );
exit ;
}
} elseif ( GETPOST ( 'factureid' ) > 0 ) {
// Define cost price for margin calculation
$buyprice = 0 ;
2021-02-26 14:25:17 +01:00
if (( $result = $facture -> defineBuyPrice ( $pu_ht , GETPOST ( 'remise_percent' , 2 ), $object -> id )) < 0 ) {
2020-09-07 10:18:17 +02:00
dol_syslog ( $langs -> trans ( 'FailedToGetCostPrice' ));
setEventMessages ( $langs -> trans ( 'FailedToGetCostPrice' ), null , 'errors' );
} else {
$buyprice = $result ;
}
2016-11-27 20:02:57 +01:00
2020-09-07 10:18:17 +02:00
$result = $facture -> addline (
$desc ,
$pu_ht ,
2021-04-20 10:17:08 +02:00
price2num ( GETPOST ( 'qty' ), 'MS' ),
2020-09-07 10:18:17 +02:00
$tva_tx ,
$localtax1_tx ,
$localtax2_tx ,
$object -> id ,
2021-01-31 12:48:40 +01:00
price2num ( GETPOST ( 'remise_percent' ), 2 ),
2020-09-07 10:18:17 +02:00
'' ,
'' ,
'' ,
'' ,
'' ,
$price_base_type ,
$pu_ttc ,
Facture :: TYPE_STANDARD ,
- 1 ,
0 ,
'' ,
0 ,
0 ,
null ,
$buyprice ,
'' ,
0 ,
100 ,
'' ,
$object -> fk_unit
);
if ( $result > 0 ) {
header ( " Location: " . DOL_URL_ROOT . " /compta/facture/card.php?facid= " . $facture -> id );
exit ;
}
}
} else {
$action = " " ;
setEventMessages ( $langs -> trans ( " WarningSelectOneDocument " ), null , 'warnings' );
}
}
2003-07-23 18:31:55 +02:00
}
2004-07-14 12:25:14 +02:00
2007-06-30 15:06:03 +02:00
2008-10-25 19:27:15 +02:00
/*
* View
*/
2007-06-30 15:06:03 +02:00
2021-03-30 02:13:57 +02:00
$form = new Form ( $db );
$formfile = new FormFile ( $db );
$formproduct = new FormProduct ( $db );
$formcompany = new FormCompany ( $db );
if ( ! empty ( $conf -> accounting -> enabled )) {
$formaccounting = new FormAccounting ( $db );
}
2016-08-10 07:40:40 +02:00
$title = $langs -> trans ( 'ProductServiceCard' );
2021-03-30 02:13:57 +02:00
$help_url = '' ;
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-12 00:15:34 +01:00
$title = $langs -> trans ( 'Product' ) . " " . $shortlabel . " - " . $langs -> trans ( 'Card' );
2021-03-30 02:13:57 +02:00
$help_url = '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-12 00:15:34 +01:00
$title = $langs -> trans ( 'Service' ) . " " . $shortlabel . " - " . $langs -> trans ( 'Card' );
2021-03-30 02:13:57 +02:00
$help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen' ;
2016-08-10 07:40:40 +02:00
}
2012-07-27 21:27:03 +02:00
2021-03-30 02:13:57 +02:00
llxHeader ( '' , $title , $help_url );
2008-10-25 19:27:15 +02:00
2016-11-29 12:06:58 +01:00
// Load object modBarCodeProduct
2019-11-12 00:15:34 +01:00
$res = 0 ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> barcode -> enabled ) && ! empty ( $conf -> global -> BARCODE_PRODUCT_ADDON_NUM )) {
2019-11-12 00:15:34 +01:00
$module = strtolower ( $conf -> global -> BARCODE_PRODUCT_ADDON_NUM );
$dirbarcode = array_merge ( array ( '/core/modules/barcode/' ), $conf -> modules_parts [ 'barcode' ]);
2021-02-26 14:25:17 +01:00
foreach ( $dirbarcode as $dirroot ) {
2019-11-12 00:15:34 +01:00
$res = dol_include_once ( $dirroot . $module . '.php' );
2021-02-26 14:25:17 +01:00
if ( $res ) {
break ;
}
2016-11-29 12:06:58 +01:00
}
2021-02-26 14:25:17 +01:00
if ( $res > 0 ) {
2019-11-12 00:15:34 +01:00
$modBarCodeProduct = new $module ();
2016-11-29 12:06:58 +01:00
}
}
2011-12-07 19:22:12 +01:00
2021-02-26 14:25:17 +01:00
if ( is_object ( $objcanvas ) && $objcanvas -> displayCanvasExists ( $action )) {
2013-06-02 00:37:33 +02:00
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
2021-02-26 14:25:17 +01:00
if ( empty ( $object -> error ) && $id ) {
2019-11-12 00:15:34 +01:00
$result = $object -> fetch ( $id );
2021-02-26 14:25:17 +01:00
if ( $result <= 0 ) {
dol_print_error ( '' , $object -> error );
}
2013-06-02 00:37:33 +02:00
}
2019-11-12 00:15:34 +01:00
$objcanvas -> assign_values ( $action , $object -> id , $object -> ref ); // Set value for templates
$objcanvas -> display_canvas ( $action ); // Show template
2020-09-14 11:01:11 +02:00
} else {
2020-09-07 10:18:17 +02:00
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
2021-02-26 14:25:17 +01:00
if ( $action == 'create' && $usercancreate ) {
2020-09-07 10:18:17 +02:00
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2020-09-14 11:01:11 +02:00
print '<script type="text/javascript">' ;
2020-09-14 10:57:51 +02:00
print ' $ ( document ) . ready ( function () {
$ ( " #selectcountry_id " ) . change ( function () {
document . formprod . action . value = " create " ;
document . formprod . submit ();
});
}); ' ;
print '</script>' . " \n " ;
2012-08-15 09:06:36 +02:00
2012-08-09 01:41:55 +02:00
// Load object modCodeProduct
2020-09-07 10:18:17 +02:00
$module = ( ! empty ( $conf -> global -> PRODUCT_CODEPRODUCT_ADDON ) ? $conf -> global -> PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard' );
2021-02-26 14:25:17 +01:00
if ( substr ( $module , 0 , 16 ) == 'mod_codeproduct_' && substr ( $module , - 3 ) == 'php' ) {
2020-09-07 10:18:17 +02:00
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
$result = dol_include_once ( '/core/modules/product/' . $module . '.php' );
2021-02-26 14:25:17 +01:00
if ( $result > 0 ) {
2020-09-07 10:18:17 +02:00
$modCodeProduct = new $module ();
}
2012-07-27 21:27:03 +02:00
2020-09-07 10:18:17 +02:00
dol_set_focus ( 'input[name="ref"]' );
2017-06-21 11:37:34 +02:00
2020-09-14 10:57:51 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST" name="formprod">' ;
2020-09-07 10:18:17 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="add">' ;
print '<input type="hidden" name="type" value="' . $type . '">' . " \n " ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $modCodeProduct -> code_auto )) {
2012-09-16 21:12:55 +02:00
print '<input type="hidden" name="code_auto" value="1">' ;
2021-02-26 14:25:17 +01:00
}
if ( ! empty ( $modBarCodeProduct -> code_auto )) {
2014-01-30 18:21:04 +01:00
print '<input type="hidden" name="barcode_auto" value="1">' ;
2021-02-26 14:25:17 +01:00
}
2019-10-21 14:43:39 +02:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2014-02-10 00:24:20 +01:00
2020-04-12 21:36:57 +02:00
if ( $type == 1 ) {
$picto = 'service' ;
$title = $langs -> trans ( " NewService " );
2020-05-21 15:05:19 +02:00
} else {
2020-04-12 21:36:57 +02:00
$picto = 'product' ;
$title = $langs -> trans ( " NewProduct " );
}
2020-09-07 10:18:17 +02:00
$linkback = " " ;
print load_fiche_titre ( $title , $linkback , $picto );
2011-10-01 12:48:31 +02:00
2020-10-07 15:01:28 +02:00
// We set country_id, country_code and country for the selected country
$object -> country_id = GETPOSTISSET ( 'country_id' ) ? GETPOST ( 'country_id' , 'int' ) : null ;
2021-02-26 14:25:17 +01:00
if ( $object -> country_id > 0 ) {
2020-10-07 15:01:28 +02:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
}
2015-04-12 17:08:14 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( '' );
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '<table class="border centpercent">' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '<tr>' ;
$tmpcode = '' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $modCodeProduct -> code_auto )) {
$tmpcode = $modCodeProduct -> getNextValue ( $object , $type );
}
2021-06-10 20:04:21 +02:00
print '<td class="titlefieldcreate fieldrequired">' . $langs -> trans ( " Ref " ) . '</td><td><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="' . dol_escape_htmltag ( GETPOSTISSET ( 'ref' ) ? GETPOST ( 'ref' , 'alphanohtml' ) : $tmpcode ) . '">' ;
2021-02-26 14:25:17 +01:00
if ( $refalreadyexists ) {
2020-09-07 10:18:17 +02:00
print $langs -> trans ( " RefAlreadyExists " );
}
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Label
2021-06-10 20:04:21 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="' . dol_escape_htmltag ( GETPOST ( 'label' , $label_security_check )) . '"></td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// On sell
2021-06-10 20:04:21 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Sell " ) . ')</td><td>' ;
2020-09-07 10:18:17 +02:00
$statutarray = array ( '1' => $langs -> trans ( " OnSell " ), '0' => $langs -> trans ( " NotOnSell " ));
print $form -> selectarray ( 'statut' , $statutarray , GETPOST ( 'statut' ));
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// To buy
2021-06-10 20:04:21 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Buy " ) . ')</td><td>' ;
2020-09-07 10:18:17 +02:00
$statutarray = array ( '1' => $langs -> trans ( " ProductStatusOnBuy " ), '0' => $langs -> trans ( " ProductStatusNotOnBuy " ));
print $form -> selectarray ( 'statut_buy' , $statutarray , GETPOST ( 'statut_buy' ));
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Batch number management
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> productbatch -> enabled )) {
2021-04-09 13:40:37 +02:00
print '<tr><td>' . $langs -> trans ( " ManageLotSerial " ) . '</td><td>' ;
2021-03-04 15:40:23 +01:00
$statutarray = array ( '0' => $langs -> trans ( " ProductStatusNotOnBatch " ), '1' => $langs -> trans ( " ProductStatusOnBatch " ), '2' => $langs -> trans ( " ProductStatusOnSerial " ));
2019-01-27 11:55:16 +01:00
print $form -> selectarray ( 'status_batch' , $statutarray , GETPOST ( 'status_batch' ));
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2021-04-09 13:40:37 +02:00
// Product specific batch number management
$status_batch = GETPOST ( 'status_batch' );
2021-04-12 17:56:57 +02:00
if ( $status_batch !== '0' ) {
2021-04-09 13:40:37 +02:00
$tooltip = $langs -> trans ( " GenericMaskCodes " , $langs -> transnoentities ( " Batch " ), $langs -> transnoentities ( " Batch " ));
$tooltip .= $langs -> trans ( " GenericMaskCodes2 " );
$tooltip .= $langs -> trans ( " GenericMaskCodes3 " );
$tooltip .= $langs -> trans ( " GenericMaskCodes4a " , $langs -> transnoentities ( " Batch " ), $langs -> transnoentities ( " Batch " ));
$tooltip .= $langs -> trans ( " GenericMaskCodes5 " );
2021-06-10 20:04:21 +02:00
if (( $conf -> global -> PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced' )
|| ( $conf -> global -> PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' )) {
print '<tr><td id="mask_option">' . $langs -> trans ( " ManageLotMask " ) . '</td>' ;
2021-04-12 17:56:57 +02:00
$inherited_mask_lot = $conf -> global -> LOT_ADVANCED_MASK ;
$inherited_mask_sn = $conf -> global -> SN_ADVANCED_MASK ;
print '<td id="field_mask">' ;
2021-06-13 01:27:04 +02:00
print $form -> textwithpicto ( '<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">' , $tooltip , 1 , 1 );
2021-04-13 16:13:57 +02:00
print ' < script type = " text/javascript " >
$ ( document ) . ready ( function () {
2021-04-12 17:56:57 +02:00
$ ( " #field_mask, #mask_option " ) . addClass ( " hideobject " );
2021-04-13 16:13:57 +02:00
$ ( " #status_batch " ) . on ( " change " , function () {
2021-06-10 20:04:21 +02:00
console . log ( " We change batch status " );
2021-04-13 16:13:57 +02:00
var optionSelected = $ ( " option:selected " , this );
var valueSelected = this . value ;
$ ( " #field_mask, #mask_option " ) . addClass ( " hideobject " );
2021-06-10 20:04:21 +02:00
' ;
if ( $conf -> global -> PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced' ) {
print '
2021-04-13 16:13:57 +02:00
if ( this . value == 1 ) {
$ ( " #field_mask, #mask_option " ) . toggleClass ( " hideobject " );
$ ( " #batch_mask_input " ) . val ( " '. $inherited_mask_lot .' " );
}
2021-06-10 20:04:21 +02:00
' ;
}
if ( $conf -> global -> PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' ) {
print '
2021-04-13 16:13:57 +02:00
if ( this . value == 2 ) {
$ ( " #field_mask, #mask_option " ) . toggleClass ( " hideobject " );
$ ( " #batch_mask_input " ) . val ( " '. $inherited_mask_sn .' " );
}
2021-06-10 20:04:21 +02:00
' ;
}
print '
2021-04-13 16:13:57 +02:00
})
2021-04-12 17:56:57 +02:00
})
2021-04-13 16:13:57 +02:00
</ script > ' ;
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2021-04-13 16:13:57 +02:00
}
2021-04-09 13:40:37 +02:00
}
2014-03-04 18:55:55 +01:00
}
2020-09-07 10:18:17 +02:00
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) {
$showbarcode = 0 ;
}
2014-02-10 00:24:20 +01:00
2021-02-26 14:25:17 +01:00
if ( $showbarcode ) {
print '<tr><td>' . $langs -> trans ( 'BarcodeType' ) . '</td><td>' ;
if ( GETPOSTISSET ( 'fk_barcode_type' )) {
$fk_barcode_type = GETPOST ( 'fk_barcode_type' );
2020-09-07 10:18:17 +02:00
} else {
2021-02-26 14:25:17 +01:00
if ( empty ( $fk_barcode_type ) && ! empty ( $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE )) {
$fk_barcode_type = $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE ;
}
2020-09-07 10:18:17 +02:00
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
$formbarcode = new FormBarCode ( $db );
print $formbarcode -> selectBarcodeType ( $fk_barcode_type , 'fk_barcode_type' , 1 );
print '</td>' ;
2021-06-10 20:04:21 +02:00
print '</tr><tr>' ;
2020-09-07 10:18:17 +02:00
print '<td>' . $langs -> trans ( " BarcodeValue " ) . '</td><td>' ;
2020-11-30 14:47:07 +01:00
$tmpcode = GETPOSTISSET ( 'barcode' ) ? GETPOST ( 'barcode' ) : $object -> barcode ;
2021-02-26 14:25:17 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modBarCodeProduct -> code_auto )) {
$tmpcode = $modBarCodeProduct -> getNextValue ( $object , $fk_barcode_type );
}
2020-09-07 10:18:17 +02:00
print '<input class="maxwidth100" type="text" name="barcode" value="' . dol_escape_htmltag ( $tmpcode ) . '">' ;
print '</td></tr>' ;
}
2014-02-10 00:24:20 +01:00
2020-09-07 10:18:17 +02:00
// Description (used in invoice, propal...)
2021-06-10 20:04:21 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
2014-01-28 19:11:22 +01:00
2020-09-18 01:29:17 +02:00
$doleditor = new DolEditor ( 'desc' , GETPOST ( 'desc' , 'restricthtml' ), '' , 160 , 'dolibarr_details' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_4 , '90%' );
2020-09-07 10:18:17 +02:00
$doleditor -> Create ();
2014-01-28 19:11:22 +01:00
2020-09-07 10:18:17 +02:00
print " </td></tr> " ;
2014-01-28 19:11:22 +01:00
2020-09-07 10:18:17 +02:00
// Public URL
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " PublicUrl " ) . '</td><td>' ;
print img_picto ( '' , 'globe' , 'class="pictofixedwidth"' );
2016-08-28 16:17:23 +02:00
print '<input type="text" name="url" class="quatrevingtpercent" value="' . GETPOST ( 'url' ) . '">' ;
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2021-02-26 14:25:17 +01:00
if ( $type != 1 && ! empty ( $conf -> stock -> enabled )) {
2020-09-07 10:18:17 +02:00
// Default warehouse
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
2021-05-19 13:56:13 +02:00
print img_picto ( $langs -> trans ( " DefaultWarehouse " ), 'stock' , 'class="pictofixedwidth"' );
2021-06-10 20:04:21 +02:00
print $formproduct -> selectWarehouses ( GETPOST ( 'fk_default_warehouse' , 'int' ), 'fk_default_warehouse' , 'warehouseopen' , 1 , 0 , 0 , '' , 0 , 0 , array (), 'minwidth300 widthcentpercentminusxx maxwidth500' );
2020-09-07 10:18:17 +02:00
print ' <a href="' . DOL_URL_ROOT . '/product/stock/card.php?action=create&backtopage=' . urlencode ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit' ) . '">' ;
print '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " AddWarehouse " ) . '"></span>' ;
print '</a>' ;
print '</td>' ;
print '</tr>' ;
// Stock min level
print '<tr><td>' . $form -> textwithpicto ( $langs -> trans ( " StockLimit " ), $langs -> trans ( " StockLimitDesc " ), 1 ) . '</td><td>' ;
print '<input name="seuil_stock_alerte" class="maxwidth50" value="' . GETPOST ( 'seuil_stock_alerte' ) . '">' ;
print '</td>' ;
2021-06-10 20:04:21 +02:00
print '</tr><tr>' ;
2020-09-07 10:18:17 +02:00
// Stock desired level
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $form -> textwithpicto ( $langs -> trans ( " DesiredStock " ), $langs -> trans ( " DesiredStockDesc " ), 1 ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="desiredstock" class="maxwidth50" value="' . GETPOST ( 'desiredstock' ) . '">' ;
print '</td></tr>' ;
} else {
print '<input name="seuil_stock_alerte" type="hidden" value="0">' ;
print '<input name="desiredstock" type="hidden" value="0">' ;
}
2013-10-23 16:24:31 +02:00
2020-09-07 10:18:17 +02:00
// Duration
2021-02-26 14:25:17 +01:00
if ( $type == 1 ) {
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Duration " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="duration_value" size="4" value="' . GETPOST ( 'duration_value' , 'int' ) . '">' ;
print $formproduct -> selectMeasuringUnits ( " duration_unit " , " time " , GETPOST ( 'duration_value' , 'alpha' ), 0 , 1 );
print '</td></tr>' ;
}
2011-10-01 12:48:31 +02:00
2021-02-26 14:25:17 +01:00
if ( $type != 1 ) { // Nature, Weight and volume only applies to products and not to services
2020-09-07 10:18:17 +02:00
// Nature
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $form -> textwithpicto ( $langs -> trans ( " NatureOfProductShort " ), $langs -> trans ( " NatureOfProductDesc " )) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
$statutarray = array ( '1' => $langs -> trans ( " Finished " ), '0' => $langs -> trans ( " RowMaterial " ));
print $form -> selectarray ( 'finished' , $statutarray , GETPOST ( 'finished' , 'alpha' ), 1 );
print '</td></tr>' ;
// Brut Weight
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Weight " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="weight" size="4" value="' . GETPOST ( 'weight' ) . '">' ;
print $formproduct -> selectMeasuringUnits ( " weight_units " , " weight " , GETPOSTISSET ( 'weight_units' ) ? GETPOST ( 'weight_units' , 'alpha' ) : ( empty ( $conf -> global -> MAIN_WEIGHT_DEFAULT_UNIT ) ? 0 : $conf -> global -> MAIN_WEIGHT_DEFAULT_UNIT ), 0 , 2 );
print '</td></tr>' ;
// Brut Length
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SIZE )) {
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Length " ) . ' x ' . $langs -> trans ( " Width " ) . ' x ' . $langs -> trans ( " Height " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="size" class="width50" value="' . GETPOST ( 'size' ) . '"> x ' ;
print '<input name="sizewidth" class="width50" value="' . GETPOST ( 'sizewidth' ) . '"> x ' ;
print '<input name="sizeheight" class="width50" value="' . GETPOST ( 'sizeheight' ) . '">' ;
print $formproduct -> selectMeasuringUnits ( " size_units " , " size " , GETPOSTISSET ( 'size_units' ) ? GETPOST ( 'size_units' , 'alpha' ) : '0' , 0 , 2 );
print '</td></tr>' ;
}
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE )) {
2020-09-07 10:18:17 +02:00
// Brut Surface
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Surface " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="surface" size="4" value="' . GETPOST ( 'surface' ) . '">' ;
print $formproduct -> selectMeasuringUnits ( " surface_units " , " surface " , GETPOSTISSET ( 'surface_units' ) ? GETPOST ( 'surface_units' , 'alpha' ) : '0' , 0 , 2 );
print '</td></tr>' ;
}
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME )) {
2020-09-07 10:18:17 +02:00
// Brut Volume
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Volume " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="volume" size="4" value="' . GETPOST ( 'volume' ) . '">' ;
print $formproduct -> selectMeasuringUnits ( " volume_units " , " volume " , GETPOSTISSET ( 'volume_units' ) ? GETPOST ( 'volume_units' , 'alpha' ) : '0' , 0 , 2 );
print '</td></tr>' ;
}
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_ADD_NET_MEASURE )) {
2020-09-07 10:18:17 +02:00
// Net Measure
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " NetMeasure " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="net_measure" size="4" value="' . GETPOST ( 'net_measure' ) . '">' ;
print $formproduct -> selectMeasuringUnits ( " net_measure_units " , '' , GETPOSTISSET ( 'net_measure_units' ) ? GETPOST ( 'net_measure_units' , 'alpha' ) : ( empty ( $conf -> global -> MAIN_WEIGHT_DEFAULT_UNIT ) ? 0 : $conf -> global -> MAIN_WEIGHT_DEFAULT_UNIT ), 0 , 0 );
print '</td></tr>' ;
}
}
// Units
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2020-09-07 10:18:17 +02:00
print '<tr><td>' . $langs -> trans ( 'DefaultUnitToShow' ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td>' ;
2020-09-07 10:18:17 +02:00
print $form -> selectUnits ( empty ( $line -> fk_unit ) ? $conf -> global -> PRODUCT_USE_UNITS : $line -> fk_unit , 'units' );
print '</td></tr>' ;
}
// Custom code
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_CUSTOM_INFO ) && empty ( $type )) {
2021-06-10 20:04:21 +02:00
print '<tr><td class="wordbreak">' . $langs -> trans ( " CustomCode " ) . '</td><td><input name="customcode" class="maxwidth100onsmartphone" value="' . GETPOST ( 'customcode' ) . '"></td></tr>' ;
2020-09-14 10:57:51 +02:00
2020-09-07 10:18:17 +02:00
// Origin country
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " CountryOrigin " ) . '</td>' ;
2020-09-07 10:18:17 +02:00
print '<td>' ;
2020-10-07 15:01:28 +02:00
print img_picto ( '' , 'globe-americas' , 'class="paddingrightonly"' );
print $form -> select_country (( GETPOSTISSET ( 'country_id' ) ? GETPOST ( 'country_id' ) : $object -> country_id ), 'country_id' , '' , 0 , 'minwidth300 widthcentpercentminusx' );
2021-02-26 14:25:17 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2019-10-21 14:43:39 +02:00
2020-10-07 15:01:28 +02:00
// State
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_STATE )) {
2021-06-10 20:04:21 +02:00
print '<tr>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT ) && ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 2 )) {
2021-06-10 20:04:21 +02:00
print '<td>' . $form -> editfieldkey ( 'RegionStateOrigin' , 'state_id' , '' , $object , 0 ) . '</td><td>' ;
2020-10-07 15:01:28 +02:00
} else {
2021-06-10 20:04:21 +02:00
print '<td>' . $form -> editfieldkey ( 'StateOrigin' , 'state_id' , '' , $object , 0 ) . '</td><td>' ;
2020-10-07 15:01:28 +02:00
}
2010-05-26 17:03:11 +02:00
2020-09-14 11:01:11 +02:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code );
2020-10-07 15:01:28 +02:00
print '</tr>' ;
}
2020-09-07 10:18:17 +02:00
}
2021-05-11 21:45:37 +02:00
// Quality control
if ( ! empty ( $conf -> global -> PRODUCT_LOT_ENABLE_QUALITY_CONTROL )) {
2021-04-23 14:51:02 +02:00
print '<tr><td>' . $langs -> trans ( " LifeTime " ) . '</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="' . GETPOST ( 'lifetime' ) . '"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " QCFrequency " ) . '</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="' . GETPOST ( 'qc_frequency' ) . '"></td></tr>' ;
}
2010-11-02 12:22:41 +01:00
2020-09-07 10:18:17 +02:00
// Other attributes
2021-06-10 20:04:21 +02:00
$parameters = array ( 'colspan' => ' colspan="2"' , 'cols' => 2 );
2020-09-07 10:18:17 +02:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
2020-09-07 10:18:17 +02:00
print $object -> showOptionals ( $extrafields , 'edit' , $parameters );
}
2012-02-06 17:18:19 +01:00
2020-09-07 10:18:17 +02:00
// Note (private, no output on invoices, propales...)
//if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode
//{
2021-06-10 20:04:21 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " NoteNotVisibleOnBill " ) . '</td><td>' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
2020-09-18 01:29:17 +02:00
$doleditor = new DolEditor ( 'note_private' , GETPOST ( 'note_private' , 'restricthtml' ), '' , 140 , 'dolibarr_details' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_8 , '90%' );
2020-09-07 10:18:17 +02:00
$doleditor -> Create ();
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print " </td></tr> " ;
//}
2017-06-07 16:44:04 +02:00
2018-02-04 14:34:31 +01:00
if ( $conf -> categorie -> enabled ) {
2015-06-19 14:30:23 +02:00
// Categories
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2015-06-19 14:30:23 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PRODUCT , '' , 'parent' , 64 , 0 , 1 );
2020-12-03 14:34:15 +01:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , GETPOST ( 'categories' , 'array' ), '' , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2015-06-19 14:30:23 +02:00
print " </td></tr> " ;
}
2015-02-26 14:15:33 +01:00
2020-09-07 10:18:17 +02:00
print '</table>' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
print '<hr>' ;
2010-05-26 17:03:11 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
2020-09-07 10:18:17 +02:00
// We do no show price array on create when multiprices enabled.
// We must set them on prices tab.
print '<table class="border centpercent">' ;
// VAT
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " VATRate " ) . '</td><td>' ;
$defaultva = get_default_tva ( $mysoc , $mysoc );
print $form -> load_tva ( " tva_tx " , $defaultva , $mysoc , $mysoc , 0 , 0 , '' , false , 1 );
print '</td></tr>' ;
print '</table>' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
print '<br>' ;
} else {
print '<table class="border centpercent">' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
// Price
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " SellingPrice " ) . '</td>' ;
print '<td><input name="price" class="maxwidth50" value="' . $object -> price . '">' ;
print $form -> selectPriceBaseType ( $conf -> global -> PRODUCT_PRICE_BASE_TYPE , " price_base_type " );
print '</td></tr>' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
// Min price
print '<tr><td>' . $langs -> trans ( " MinPrice " ) . '</td>' ;
print '<td><input name="price_min" class="maxwidth50" value="' . $object -> price_min . '">' ;
print '</td></tr>' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
// VAT
print '<tr><td>' . $langs -> trans ( " VATRate " ) . '</td><td>' ;
$defaultva = get_default_tva ( $mysoc , $mysoc );
print $form -> load_tva ( " tva_tx " , $defaultva , $mysoc , $mysoc , 0 , 0 , '' , false , 1 );
print '</td></tr>' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
print '</table>' ;
2010-05-26 17:03:11 +02:00
2020-09-07 10:18:17 +02:00
print '<br>' ;
}
2014-02-10 00:24:20 +01:00
2020-09-07 10:18:17 +02:00
// Accountancy codes
2021-06-10 20:04:21 +02:00
print '<!-- accountancy codes -->' . " \n " ;
2020-09-07 10:18:17 +02:00
print '<table class="border centpercent">' ;
2017-05-21 15:24:16 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td>' ;
2020-09-07 10:18:17 +02:00
if ( $type == 0 ) {
$accountancy_code_sell = ( GETPOSTISSET ( 'accountancy_code_sell' ) ? GETPOST ( 'accountancy_code_sell' , 'alpha' ) : $conf -> global -> ACCOUNTING_PRODUCT_SOLD_ACCOUNT );
} else {
$accountancy_code_sell = ( GETPOSTISSET ( 'accountancy_code_sell' ) ? GETPOST ( 'accountancy_code_sell' , 'alpha' ) : $conf -> global -> ACCOUNTING_SERVICE_SOLD_ACCOUNT );
}
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $accountancy_code_sell , 'accountancy_code_sell' , 1 , null , 1 , 1 , 'minwidth150 maxwidth300' , 1 );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2019-01-23 22:14:13 +01:00
// Accountancy_code_sell_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2019-01-23 22:14:13 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
2017-11-06 09:30:30 +01:00
print '<td>' ;
2020-09-07 10:18:17 +02:00
if ( $type == 0 ) {
$accountancy_code_sell_intra = ( GETPOSTISSET ( 'accountancy_code_sell_intra' ) ? GETPOST ( 'accountancy_code_sell_intra' , 'alpha' ) : $conf -> global -> ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT );
} else {
$accountancy_code_sell_intra = ( GETPOSTISSET ( 'accountancy_code_sell_intra' ) ? GETPOST ( 'accountancy_code_sell_intra' , 'alpha' ) : $conf -> global -> ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT );
}
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $accountancy_code_sell_intra , 'accountancy_code_sell_intra' , 1 , null , 1 , 1 , 'minwidth150 maxwidth300' , 1 );
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
2017-11-06 09:30:30 +01:00
}
2017-11-01 07:19:36 +01:00
2019-01-23 22:14:13 +01:00
// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
print '<td>' ;
2021-02-26 14:25:17 +01:00
if ( $type == 0 ) {
2020-09-07 10:18:17 +02:00
$accountancy_code_sell_export = ( GETPOST ( 'accountancy_code_sell_export' ) ? GETPOST ( 'accountancy_code_sell_export' , 'alpha' ) : $conf -> global -> ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT );
} else {
$accountancy_code_sell_export = ( GETPOST ( 'accountancy_code_sell_export' ) ? GETPOST ( 'accountancy_code_sell_export' , 'alpha' ) : $conf -> global -> ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT );
}
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $accountancy_code_sell_export , 'accountancy_code_sell_export' , 1 , null , 1 , 1 , 'minwidth150 maxwidth300' , 1 );
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
2019-01-23 22:14:13 +01:00
2017-11-01 07:19:36 +01:00
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td>' ;
2021-03-10 20:40:34 +01:00
if ( $type == 0 ) {
$accountancy_code_buy = ( GETPOST ( 'accountancy_code_buy' , 'alpha' ) ? ( GETPOST ( 'accountancy_code_buy' , 'alpha' )) : $conf -> global -> ACCOUNTING_PRODUCT_BUY_ACCOUNT );
} else {
$accountancy_code_buy = ( GETPOST ( 'accountancy_code_buy' , 'alpha' ) ? ( GETPOST ( 'accountancy_code_buy' , 'alpha' )) : $conf -> global -> ACCOUNTING_SERVICE_BUY_ACCOUNT );
}
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $accountancy_code_buy , 'accountancy_code_buy' , 1 , null , 1 , 1 , 'minwidth150 maxwidth300' , 1 );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2020-03-01 04:52:12 +01:00
// Accountancy_code_buy_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2020-03-01 04:52:12 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyIntraCode " ) . '</td>' ;
print '<td>' ;
if ( $type == 0 ) {
$accountancy_code_buy_intra = ( GETPOSTISSET ( 'accountancy_code_buy_intra' ) ? GETPOST ( 'accountancy_code_buy_intra' , 'alpha' ) : $conf -> global -> ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT );
} else {
$accountancy_code_buy_intra = ( GETPOSTISSET ( 'accountancy_code_buy_intra' ) ? GETPOST ( 'accountancy_code_buy_intra' , 'alpha' ) : $conf -> global -> ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT );
}
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $accountancy_code_buy_intra , 'accountancy_code_buy_intra' , 1 , null , 1 , 1 , 'minwidth150 maxwidth300' , 1 );
2020-03-01 04:52:12 +01:00
print '</td></tr>' ;
}
// Accountancy_code_buy_export
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyExportCode " ) . '</td>' ;
print '<td>' ;
2021-02-26 14:25:17 +01:00
if ( $type == 0 ) {
2020-03-01 04:52:12 +01:00
$accountancy_code_buy_export = ( GETPOST ( 'accountancy_code_buy_export' ) ? GETPOST ( 'accountancy_code_buy_export' , 'alpha' ) : $conf -> global -> ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT );
} else {
$accountancy_code_buy_export = ( GETPOST ( 'accountancy_code_buy_export' ) ? GETPOST ( 'accountancy_code_buy_export' , 'alpha' ) : $conf -> global -> ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT );
}
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $accountancy_code_buy_export , 'accountancy_code_buy_export' , 1 , null , 1 , 1 , 'minwidth150 maxwidth300' , 1 );
2020-03-01 04:52:12 +01:00
print '</td></tr>' ;
2021-06-10 20:04:21 +02:00
} else { // For external software
2021-02-26 14:25:17 +01:00
if ( ! empty ( $accountancy_code_sell )) {
$object -> accountancy_code_sell = $accountancy_code_sell ;
}
if ( ! empty ( $accountancy_code_sell_intra )) {
$object -> accountancy_code_sell_intra = $accountancy_code_sell_intra ;
}
if ( ! empty ( $accountancy_code_sell_export )) {
$object -> accountancy_code_sell_export = $accountancy_code_sell_export ;
}
if ( ! empty ( $accountancy_code_buy )) {
$object -> accountancy_code_buy = $accountancy_code_buy ;
}
if ( ! empty ( $accountancy_code_buy_intra )) {
$object -> accountancy_code_buy_intra = $accountancy_code_buy_intra ;
}
if ( ! empty ( $accountancy_code_buy_export )) {
$object -> accountancy_code_buy_export = $accountancy_code_buy_export ;
}
2020-10-01 09:40:11 +02:00
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="' . $object -> accountancy_code_sell . '">' ;
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2014-02-02 18:26:17 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy_code_sell_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2019-04-25 01:16:29 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="' . $object -> accountancy_code_sell_intra . '">' ;
2017-11-06 09:30:30 +01:00
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="' . $object -> accountancy_code_sell_export . '">' ;
2019-04-25 01:16:29 +02:00
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="' . $object -> accountancy_code_buy . '">' ;
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2020-03-01 04:52:12 +01:00
// Accountancy_code_buy_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2020-03-01 04:52:12 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyIntraCode " ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="' . $object -> accountancy_code_buy_intra . '">' ;
2020-03-01 04:52:12 +01:00
print '</td></tr>' ;
}
// Accountancy_code_buy_export
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyExportCode " ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="' . $object -> accountancy_code_buy_export . '">' ;
2020-03-01 04:52:12 +01:00
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
}
2015-12-17 06:16:29 +01:00
print '</table>' ;
2010-05-05 11:05:50 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-04-12 17:08:14 +02:00
2016-08-12 22:53:30 +02:00
print '<div class="center">' ;
2019-11-12 00:15:34 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Create " ) . '">' ;
2017-11-01 07:19:36 +01:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input type="button" class="button button-cancel" value="' . $langs -> trans ( " Cancel " ) . '" onClick="javascript:history.go(-1)">' ;
2016-08-12 22:53:30 +02:00
print '</div>' ;
2006-12-15 16:13:38 +01:00
2017-11-01 07:19:36 +01:00
print '</form>' ;
2020-09-07 10:18:17 +02:00
} elseif ( $object -> id > 0 ) {
/*
2021-02-26 14:25:17 +01:00
* Product card
*/
2021-03-30 02:13:57 +02:00
2020-09-07 10:18:17 +02:00
// Fiche en mode edition
2021-02-26 14:25:17 +01:00
if ( $action == 'edit' && $usercancreate ) {
2020-09-07 10:18:17 +02:00
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2020-09-14 11:01:11 +02:00
print '<script type="text/javascript">' ;
2020-09-14 10:57:51 +02:00
print ' $ ( document ) . ready ( function () {
2020-09-16 01:01:00 +02:00
$ ( " #selectcountry_id " ) . change ( function () {
2020-09-14 10:57:51 +02:00
document . formprod . action . value = " edit " ;
document . formprod . submit ();
});
2020-09-16 01:01:00 +02:00
}); ' ;
2020-09-14 10:57:51 +02:00
print '</script>' . " \n " ;
2020-09-14 11:01:11 +02:00
// We set country_id, country_code and country for the selected country
$object -> country_id = GETPOST ( 'country_id' ) ? GETPOST ( 'country_id' ) : $object -> country_id ;
2021-02-26 14:25:17 +01:00
if ( $object -> country_id ) {
2020-09-14 11:01:11 +02:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
}
2012-07-27 21:27:03 +02:00
2020-09-07 10:18:17 +02:00
$type = $langs -> trans ( 'Product' );
2021-02-26 14:25:17 +01:00
if ( $object -> isService ()) {
$type = $langs -> trans ( 'Service' );
}
2020-09-07 10:18:17 +02:00
//print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
2015-05-03 15:51:55 +02:00
2020-09-07 10:18:17 +02:00
// Main official, simple, and not duplicated code
2020-09-14 10:57:51 +02:00
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '" method="POST" name="formprod">' . " \n " ;
2020-09-07 10:18:17 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="update">' ;
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
print '<input type="hidden" name="canvas" value="' . $object -> canvas . '">' ;
2015-05-03 15:51:55 +02:00
2020-09-07 10:18:17 +02:00
$head = product_prepare_head ( $object );
$titre = $langs -> trans ( " CardProduct " . $object -> type );
$picto = ( $object -> type == Product :: TYPE_SERVICE ? 'service' : 'product' );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $titre , 0 , $picto );
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
print '<table class="border allwidth">' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Ref
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs -> trans ( " Ref " ) . '</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="' . dol_escape_htmltag ( $object -> ref ) . '"></td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Label
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="' . dol_escape_htmltag ( $object -> label ) . '"></td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Status To sell
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Sell " ) . ')</td><td colspan="3">' ;
print '<select class="flat" name="statut">' ;
2021-02-26 14:25:17 +01:00
if ( $object -> status ) {
2020-09-07 10:18:17 +02:00
print '<option value="1" selected>' . $langs -> trans ( " OnSell " ) . '</option>' ;
print '<option value="0">' . $langs -> trans ( " NotOnSell " ) . '</option>' ;
} else {
print '<option value="1">' . $langs -> trans ( " OnSell " ) . '</option>' ;
print '<option value="0" selected>' . $langs -> trans ( " NotOnSell " ) . '</option>' ;
}
print '</select>' ;
print '</td></tr>' ;
// Status To Buy
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Buy " ) . ')</td><td colspan="3">' ;
print '<select class="flat" name="statut_buy">' ;
2021-02-26 14:25:17 +01:00
if ( $object -> status_buy ) {
2020-09-07 10:18:17 +02:00
print '<option value="1" selected>' . $langs -> trans ( " ProductStatusOnBuy " ) . '</option>' ;
print '<option value="0">' . $langs -> trans ( " ProductStatusNotOnBuy " ) . '</option>' ;
} else {
print '<option value="1">' . $langs -> trans ( " ProductStatusOnBuy " ) . '</option>' ;
print '<option value="0" selected>' . $langs -> trans ( " ProductStatusNotOnBuy " ) . '</option>' ;
}
print '</select>' ;
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2014-03-04 18:55:55 +01:00
// Batch number managment
2021-02-26 14:25:17 +01:00
if ( $conf -> productbatch -> enabled ) {
if ( $object -> isProduct () || ! empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES )) {
2021-04-08 18:03:46 +02:00
print '<tr><td>' . $langs -> trans ( " ManageLotSerial " ) . '</td><td>' ;
2021-03-04 15:40:23 +01:00
$statutarray = array ( '0' => $langs -> trans ( " ProductStatusNotOnBatch " ), '1' => $langs -> trans ( " ProductStatusOnBatch " ), '2' => $langs -> trans ( " ProductStatusOnSerial " ));
2019-01-27 11:55:16 +01:00
print $form -> selectarray ( 'status_batch' , $statutarray , $object -> status_batch );
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2021-04-12 17:56:57 +02:00
if ( $object -> status_batch !== '0' ) {
2021-04-08 18:03:46 +02:00
$tooltip = $langs -> trans ( " GenericMaskCodes " , $langs -> transnoentities ( " Batch " ), $langs -> transnoentities ( " Batch " ));
$tooltip .= $langs -> trans ( " GenericMaskCodes2 " );
$tooltip .= $langs -> trans ( " GenericMaskCodes3 " );
$tooltip .= $langs -> trans ( " GenericMaskCodes4a " , $langs -> transnoentities ( " Batch " ), $langs -> transnoentities ( " Batch " ));
$tooltip .= $langs -> trans ( " GenericMaskCodes5 " );
2021-06-10 20:04:21 +02:00
print '<tr><td id="mask_option">' . $langs -> trans ( " ManageLotMask " ) . '</td>' ;
2021-04-12 17:56:57 +02:00
if ( $object -> status_batch == '1' && $conf -> global -> PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced' ) {
2021-06-14 15:37:02 +02:00
$mask = ! empty ( $object -> batch_mask ) ? $object -> batch_mask : $conf -> global -> LOT_ADVANCED_MASK ;
2021-04-12 17:56:57 +02:00
}
if ( $object -> status_batch == '2' && $conf -> global -> PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' ) {
2021-06-14 15:37:02 +02:00
$mask = ! empty ( $object -> batch_mask ) ? $object -> batch_mask : $conf -> global -> SN_ADVANCED_MASK ;
2021-04-12 17:56:57 +02:00
}
$inherited_mask_lot = $conf -> global -> LOT_ADVANCED_MASK ;
2021-04-13 11:21:41 +02:00
$inherited_mask_sn = $conf -> global -> SN_ADVANCED_MASK ;
2021-04-12 17:56:57 +02:00
print '<td id="field_mask">' ;
2021-06-13 01:27:04 +02:00
print $form -> textwithpicto ( '<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="' . $mask . '">' , $tooltip , 1 , 1 );
2021-04-13 11:21:41 +02:00
2021-04-12 17:56:57 +02:00
print ' < script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( " #field_mask, #mask_option " ) . addClass ( " hideobject " );
var preselect = $ ( " #status_batch option:selected " );
if ( preselect !== " 0 " ) {
$ ( " #field_mask, #mask_option " ) . toggleClass ( " hideobject " );
}
$ ( " #status_batch " ) . on ( " change " , function () {
2021-06-10 20:04:21 +02:00
console . log ( " We change batch status " );
2021-04-12 17:56:57 +02:00
var optionSelected = $ ( " option:selected " , this );
var valueSelected = this . value ;
$ ( " #field_mask, #mask_option " ) . addClass ( " hideobject " );
2021-06-10 20:04:21 +02:00
' ;
if ( $conf -> global -> PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced' ) {
print '
2021-04-12 17:56:57 +02:00
if ( this . value == 1 ) {
$ ( " #field_mask, #mask_option " ) . toggleClass ( " hideobject " );
$ ( " #batch_mask_input " ) . val ( " '. $inherited_mask_lot .' " );
}
2021-06-10 20:04:21 +02:00
' ;
}
if ( $conf -> global -> PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' ) {
print '
2021-04-12 17:56:57 +02:00
if ( this . value == 2 ) {
$ ( " #field_mask, #mask_option " ) . toggleClass ( " hideobject " );
$ ( " #batch_mask_input " ) . val ( " '. $inherited_mask_sn .' " );
}
2021-06-10 20:04:21 +02:00
' ;
}
print '
2021-04-12 17:56:57 +02:00
})
})
</ script > ' ;
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2021-04-08 18:03:46 +02:00
}
2018-04-03 20:23:47 +02:00
}
2014-03-04 18:55:55 +01:00
}
2020-09-07 10:18:17 +02:00
// Barcode
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) {
$showbarcode = 0 ;
}
2020-09-07 10:18:17 +02:00
2021-02-26 14:25:17 +01:00
if ( $showbarcode ) {
2020-09-07 10:18:17 +02:00
print '<tr><td>' . $langs -> trans ( 'BarcodeType' ) . '</td><td>' ;
2020-11-30 14:47:07 +01:00
if ( GETPOSTISSET ( 'fk_barcode_type' )) {
2021-02-26 14:25:17 +01:00
$fk_barcode_type = GETPOST ( 'fk_barcode_type' );
2020-09-07 10:18:17 +02:00
} else {
$fk_barcode_type = $object -> barcode_type ;
2021-02-26 14:25:17 +01:00
if ( empty ( $fk_barcode_type ) && ! empty ( $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE )) {
$fk_barcode_type = $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE ;
}
2020-09-07 10:18:17 +02:00
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
$formbarcode = new FormBarCode ( $db );
print $formbarcode -> selectBarcodeType ( $fk_barcode_type , 'fk_barcode_type' , 1 );
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( " BarcodeValue " ) . '</td><td>' ;
2020-11-30 14:47:07 +01:00
$tmpcode = GETPOSTISSET ( 'barcode' ) ? GETPOST ( 'barcode' ) : $object -> barcode ;
2021-02-26 14:25:17 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modBarCodeProduct -> code_auto )) {
$tmpcode = $modBarCodeProduct -> getNextValue ( $object , $fk_barcode_type );
}
2021-06-10 20:04:21 +02:00
print '<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="' . dol_escape_htmltag ( $tmpcode ) . '">' ;
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
}
// Description (used in invoice, propal...)
2021-06-10 20:04:21 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
// We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF.
$doleditor = new DolEditor ( 'desc' , $object -> description , '' , 160 , 'dolibarr_details' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_4 , '90%' );
$doleditor -> Create ();
print " </td></tr> " ;
print " \n " ;
// Public Url
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " PublicUrl " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input type="text" name="url" class="quatrevingtpercent" value="' . $object -> url . '">' ;
print '</td></tr>' ;
// Stock
2021-02-26 14:25:17 +01:00
if ( $object -> isProduct () && ! empty ( $conf -> stock -> enabled )) {
2020-09-07 10:18:17 +02:00
// Default warehouse
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print $formproduct -> selectWarehouses ( $object -> fk_default_warehouse , 'fk_default_warehouse' , 'warehouseopen' , 1 );
print ' <a href="' . DOL_URL_ROOT . '/product/stock/card.php?action=create&backtopage=' . urlencode ( $_SERVER [ 'PHP_SELF' ] . '?action=create&type=' . GETPOST ( 'type' , 'int' )) . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " AddWarehouse " ) . '"></span></a>' ;
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
/*
2021-02-26 14:25:17 +01:00
print " <tr> " . '<td>' . $langs -> trans ( " StockLimit " ) . '</td><td>' ;
print '<input name="seuil_stock_alerte" size="4" value="' . $object -> seuil_stock_alerte . '">' ;
print '</td>' ;
2013-10-23 16:24:31 +02:00
2021-02-26 14:25:17 +01:00
print '<td>' . $langs -> trans ( " DesiredStock " ) . '</td><td>' ;
print '<input name="desiredstock" size="4" value="' . $object -> desiredstock . '">' ;
print '</td></tr>' ;
*/
2020-09-07 10:18:17 +02:00
}
/*
2021-02-26 14:25:17 +01:00
else
2020-09-07 10:18:17 +02:00
{
2021-02-26 14:25:17 +01:00
print '<input name="seuil_stock_alerte" type="hidden" value="' . $object -> seuil_stock_alerte . '">' ;
print '<input name="desiredstock" type="hidden" value="' . $object -> desiredstock . '">' ;
} */
if ( $object -> isService ()) {
2020-09-07 10:18:17 +02:00
// Duration
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Duration " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="duration_value" size="5" value="' . $object -> duration_value . '"> ' ;
print $formproduct -> selectMeasuringUnits ( " duration_unit " , " time " , $object -> duration_unit , 0 , 1 );
print '</td></tr>' ;
} else {
// Nature
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $form -> textwithpicto ( $langs -> trans ( " NatureOfProductShort " ), $langs -> trans ( " NatureOfProductDesc " )) . '</td><td>' ;
2020-10-14 15:54:48 +02:00
print $formproduct -> selectProductNature ( 'finished' , $object -> finished );
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
2019-10-16 14:17:53 +02:00
2020-09-07 10:18:17 +02:00
// Brut Weight
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Weight " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="weight" size="5" value="' . $object -> weight . '"> ' ;
print $formproduct -> selectMeasuringUnits ( " weight_units " , " weight " , $object -> weight_units , 0 , 2 );
print '</td></tr>' ;
2019-10-21 14:43:39 +02:00
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SIZE )) {
2019-10-20 11:59:21 +02:00
// Brut Length
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Length " ) . ' x ' . $langs -> trans ( " Width " ) . ' x ' . $langs -> trans ( " Height " ) . '</td><td>' ;
2019-10-20 11:59:21 +02:00
print '<input name="size" size="5" value="' . $object -> length . '">x' ;
print '<input name="sizewidth" size="5" value="' . $object -> width . '">x' ;
print '<input name="sizeheight" size="5" value="' . $object -> height . '"> ' ;
print $formproduct -> selectMeasuringUnits ( " size_units " , " size " , $object -> length_units , 0 , 2 );
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
}
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE )) {
2020-09-07 10:18:17 +02:00
// Brut Surface
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Surface " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="surface" size="5" value="' . $object -> surface . '"> ' ;
print $formproduct -> selectMeasuringUnits ( " surface_units " , " surface " , $object -> surface_units , 0 , 2 );
print '</td></tr>' ;
}
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME )) {
2020-09-07 10:18:17 +02:00
// Brut Volume
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Volume " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="volume" size="5" value="' . $object -> volume . '"> ' ;
print $formproduct -> selectMeasuringUnits ( " volume_units " , " volume " , $object -> volume_units , 0 , 2 );
print '</td></tr>' ;
}
2019-10-21 14:43:39 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_ADD_NET_MEASURE )) {
2020-09-07 10:18:17 +02:00
// Net Measure
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " NetMeasure " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print '<input name="net_measure" size="5" value="' . $object -> net_measure . '"> ' ;
print $formproduct -> selectMeasuringUnits ( " net_measure_units " , " " , $object -> net_measure_units , 0 , 0 );
2019-10-20 11:59:21 +02:00
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
}
}
// Units
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2020-09-07 10:18:17 +02:00
print '<tr><td>' . $langs -> trans ( 'DefaultUnitToShow' ) . '</td>' ;
2021-06-10 20:04:21 +02:00
print '<td>' ;
2020-09-07 10:18:17 +02:00
print $form -> selectUnits ( $object -> fk_unit , 'units' );
print '</td></tr>' ;
}
2019-10-21 14:43:39 +02:00
2020-09-07 10:18:17 +02:00
// Custom code
2021-02-26 14:25:17 +01:00
if ( ! $object -> isService () && empty ( $conf -> global -> PRODUCT_DISABLE_CUSTOM_INFO )) {
2021-06-10 20:04:21 +02:00
print '<tr><td class="wordbreak">' . $langs -> trans ( " CustomCode " ) . '</td><td><input name="customcode" class="maxwidth100onsmartphone" value="' . $object -> customcode . '"></td></tr>' ;
2020-09-14 11:01:11 +02:00
// Origin country
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " CountryOrigin " ) . '</td>' ;
2020-09-14 11:01:11 +02:00
print '<td>' ;
print img_picto ( '' , 'globe-americas' , 'class="paddingrightonly"' );
2020-09-07 10:18:17 +02:00
print $form -> select_country ( $object -> country_id , 'country_id' , '' , 0 , 'minwidth100 maxwidthonsmartphone' );
2021-02-26 14:25:17 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2021-06-10 20:04:21 +02:00
print '</td></tr>' ;
2020-09-14 11:01:11 +02:00
// State
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_STATE )) {
2021-06-10 20:04:21 +02:00
print '<tr>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT ) && ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 2 )) {
2021-06-10 20:04:21 +02:00
print '<td>' . $form -> editfieldkey ( 'RegionStateOrigin' , 'state_id' , '' , $object , 0 ) . '</td><td>' ;
2020-09-14 11:01:11 +02:00
} else {
2021-06-10 20:04:21 +02:00
print '<td>' . $form -> editfieldkey ( 'StateOrigin' , 'state_id' , '' , $object , 0 ) . '</td><td>' ;
2020-09-14 11:01:11 +02:00
}
2020-09-14 10:57:51 +02:00
2020-09-14 11:01:11 +02:00
print $formcompany -> select_state ( $object -> state_id , $object -> country_code );
print '</td>' ;
2021-06-10 20:04:21 +02:00
print '</tr>' ;
2020-09-14 11:01:11 +02:00
}
}
2020-09-07 10:18:17 +02:00
2021-05-11 21:45:37 +02:00
// Quality control
if ( ! empty ( $conf -> global -> PRODUCT_LOT_ENABLE_QUALITY_CONTROL )) {
2021-04-28 16:36:15 +02:00
print '<tr><td>' . $langs -> trans ( " LifeTime " ) . '</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="' . $object -> lifetime . '"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " QCFrequency " ) . '</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="' . $object -> qc_frequency . '"></td></tr>' ;
}
2020-09-07 10:18:17 +02:00
// Other attributes
2021-06-10 20:04:21 +02:00
$parameters = array ( 'colspan' => ' colspan="2"' , 'cols' => 2 );
2020-09-07 10:18:17 +02:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
2020-09-07 10:18:17 +02:00
print $object -> showOptionals ( $extrafields , 'edit' , $parameters );
}
2012-02-06 17:18:19 +01:00
2015-11-06 18:57:35 +01:00
// Tags-Categories
2021-02-26 14:25:17 +01:00
if ( $conf -> categorie -> enabled ) {
2021-06-10 20:04:21 +02:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2015-06-19 14:30:23 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PRODUCT , '' , 'parent' , 64 , 0 , 1 );
$c = new Categorie ( $db );
2019-01-27 11:55:16 +01:00
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_PRODUCT );
2019-11-12 00:15:34 +01:00
$arrayselected = array ();
2020-03-12 12:42:34 +01:00
if ( is_array ( $cats )) {
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2015-06-19 14:30:23 +02:00
}
2020-12-03 14:34:15 +01:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , $arrayselected , '' , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2015-06-19 14:30:23 +02:00
print " </td></tr> " ;
2015-04-18 03:07:49 +02:00
}
2015-06-27 23:01:05 +02:00
2020-09-07 10:18:17 +02:00
// Note private
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB )) {
2021-06-10 20:04:21 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " NoteNotVisibleOnBill " ) . '</td><td>' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
$doleditor = new DolEditor ( 'note_private' , $object -> note_private , '' , 140 , 'dolibarr_notes' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_4 , '90%' );
$doleditor -> Create ();
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print " </td></tr> " ;
2016-07-28 13:53:17 +02:00
}
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '</table>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
print '<br>' ;
2014-02-10 00:24:20 +01:00
2020-09-07 10:18:17 +02:00
print '<table class="border centpercent">' ;
2015-12-17 06:16:29 +01:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
2017-11-01 07:19:36 +01:00
print '<td>' ;
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_sell , 'accountancy_code_sell' , 1 , '' , 1 , 1 , 'minwidth150 maxwidth300' );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2014-02-10 00:24:20 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy_code_sell_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
2017-11-06 09:30:30 +01:00
print '<td>' ;
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_sell_intra , 'accountancy_code_sell_intra' , 1 , '' , 1 , 1 , 'minwidth150 maxwidth300' );
2017-11-06 09:30:30 +01:00
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy_code_sell_export
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
2019-04-25 01:16:29 +02:00
print '<td>' ;
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_sell_export , 'accountancy_code_sell_export' , 1 , '' , 1 , 1 , 'minwidth150 maxwidth300' );
2019-04-25 01:16:29 +02:00
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td>' ;
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_buy , 'accountancy_code_buy' , 1 , '' , 1 , 1 , 'minwidth150 maxwidth300' );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2020-03-01 04:52:12 +01:00
// Accountancy_code_buy_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyIntraCode " ) . '</td>' ;
2020-03-01 04:52:12 +01:00
print '<td>' ;
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_buy_intra , 'accountancy_code_buy_intra' , 1 , '' , 1 , 1 , 'minwidth150 maxwidth300' );
2020-03-01 04:52:12 +01:00
print '</td></tr>' ;
}
// Accountancy_code_buy_export
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyExportCode " ) . '</td>' ;
2020-03-01 04:52:12 +01:00
print '<td>' ;
2021-06-10 20:04:21 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_buy_export , 'accountancy_code_buy_export' , 1 , '' , 1 , 1 , 'minwidth150 maxwidth300' );
2020-03-01 04:52:12 +01:00
print '</td></tr>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-09-07 10:18:17 +02:00
// For external software
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
2017-11-01 07:19:36 +01:00
print '<td><input name="accountancy_code_sell" class="maxwidth200" value="' . $object -> accountancy_code_sell . '">' ;
print '</td></tr>' ;
2014-02-10 00:24:20 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy_code_sell_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
2019-04-25 01:16:29 +02:00
print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="' . $object -> accountancy_code_sell_intra . '">' ;
2017-11-06 09:30:30 +01:00
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy_code_sell_export
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
2019-04-25 01:16:29 +02:00
print '<td><input name="accountancy_code_sell_export" class="maxwidth200" value="' . $object -> accountancy_code_sell_export . '">' ;
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td><input name="accountancy_code_buy" class="maxwidth200" value="' . $object -> accountancy_code_buy . '">' ;
print '</td></tr>' ;
2020-03-01 04:52:12 +01:00
// Accountancy_code_buy_intra
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyIntraCode " ) . '</td>' ;
2020-03-01 04:52:12 +01:00
print '<td><input name="accountancy_code_buy_intra" class="maxwidth200" value="' . $object -> accountancy_code_buy_intra . '">' ;
print '</td></tr>' ;
}
// Accountancy_code_buy_export
2021-03-10 11:08:39 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancyBuyExportCode " ) . '</td>' ;
2020-03-01 04:52:12 +01:00
print '<td><input name="accountancy_code_buy_export" class="maxwidth200" value="' . $object -> accountancy_code_buy_export . '">' ;
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
}
2015-12-17 06:16:29 +01:00
print '</table>' ;
2014-02-10 00:24:20 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-05-03 15:51:55 +02:00
2017-11-01 07:19:36 +01:00
print '<div class="center">' ;
2020-11-19 20:23:38 +01:00
print '<input type="submit" class="button button-save" value="' . $langs -> trans ( " Save " ) . '">' ;
2014-11-25 20:13:43 +01:00
print ' ' ;
2020-11-23 15:12:52 +01:00
print '<input type="submit" class="button button-cancel" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2014-11-25 20:13:43 +01:00
print '</div>' ;
2011-10-01 12:48:31 +02:00
2017-11-01 07:19:36 +01:00
print '</form>' ;
2020-05-23 21:07:47 +02:00
} else {
2020-09-07 10:18:17 +02:00
// Fiche en mode visu
2021-02-27 02:00:00 +01:00
2020-09-07 10:18:17 +02:00
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) {
$showbarcode = 0 ;
}
2011-05-14 00:04:52 +02:00
2020-09-07 10:18:17 +02:00
$head = product_prepare_head ( $object );
$titre = $langs -> trans ( " CardProduct " . $object -> type );
$picto = ( $object -> type == Product :: TYPE_SERVICE ? 'service' : 'product' );
2017-06-07 16:44:04 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $titre , - 1 , $picto );
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/product/list.php?restore_lastsearch_values=1&type=' . $object -> type . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
$object -> next_prev_filter = " fk_product_type = " . $object -> type ;
2016-12-10 22:54:13 +01:00
2020-09-07 10:18:17 +02: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
2020-09-07 10:18:17 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , $shownav , 'ref' );
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '<div class="underbanner clearboth"></div>' ;
2021-06-08 11:40:50 +02:00
print '<table class="border tableforfield centpercent">' ;
2017-06-07 16:44:04 +02:00
2018-02-11 12:09:12 +01:00
// Type
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> product -> enabled ) && ! empty ( $conf -> service -> enabled )) {
2019-11-12 00:15:34 +01:00
$typeformat = 'select;0:' . $langs -> trans ( " Product " ) . ',1:' . $langs -> trans ( " Service " );
2019-09-19 15:21:52 +02:00
print '<tr><td class="titlefield">' ;
2019-10-01 14:41:25 +02:00
print ( empty ( $conf -> global -> PRODUCT_DENY_CHANGE_PRODUCT_TYPE )) ? $form -> editfieldkey ( " Type " , 'fk_product_type' , $object -> type , $object , $usercancreate , $typeformat ) : $langs -> trans ( 'Type' );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2018-02-11 13:29:37 +01:00
print $form -> editfieldval ( " Type " , 'fk_product_type' , $object -> type , $object , $usercancreate , $typeformat );
2018-02-11 12:09:12 +01:00
print '</td></tr>' ;
}
2014-07-04 15:06:45 +02:00
2021-02-26 14:25:17 +01:00
if ( $showbarcode ) {
2020-09-07 10:18:17 +02:00
// Barcode type
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
print $langs -> trans ( " BarcodeType " );
print '</td>' ;
2021-02-26 14:25:17 +01:00
if (( $action != 'editbarcodetype' ) && $usercancreate && $createbarcode ) {
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editbarcodetype&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'Edit' ), 1 ) . '</a></td>' ;
}
2020-09-07 10:18:17 +02:00
print '</tr></table>' ;
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $action == 'editbarcodetype' || $action == 'editbarcode' ) {
2020-09-07 10:18:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
$formbarcode = new FormBarCode ( $db );
2018-04-03 20:23:47 +02:00
}
2021-01-11 17:15:46 +01:00
2021-06-14 15:37:02 +02:00
$fk_barcode_type = '' ;
2021-02-26 14:25:17 +01:00
if ( $action == 'editbarcodetype' ) {
2020-09-07 10:18:17 +02:00
print $formbarcode -> formBarcodeType ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> barcode_type , 'fk_barcode_type' );
2021-01-11 17:17:43 +01:00
$fk_barcode_type = $object -> barcode_type ;
2020-09-07 10:18:17 +02:00
} else {
$object -> fetch_barcode ();
2021-01-11 17:17:43 +01:00
$fk_barcode_type = $object -> barcode_type ;
2020-09-07 10:18:17 +02:00
print $object -> barcode_type_label ? $object -> barcode_type_label : ( $object -> barcode ? '<div class="warning">' . $langs -> trans ( " SetDefaultBarcodeType " ) . '<div>' : '' );
}
print '</td></tr>' . " \n " ;
2011-12-07 12:58:39 +01:00
2020-09-07 10:18:17 +02:00
// Barcode value
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
print $langs -> trans ( " BarcodeValue " );
print '</td>' ;
2021-02-26 14:25:17 +01:00
if (( $action != 'editbarcode' ) && $usercancreate && $createbarcode ) {
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editbarcode&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'Edit' ), 1 ) . '</a></td>' ;
}
2020-09-07 10:18:17 +02:00
print '</tr></table>' ;
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $action == 'editbarcode' ) {
2020-11-30 14:47:07 +01:00
$tmpcode = GETPOSTISSET ( 'barcode' ) ? GETPOST ( 'barcode' ) : $object -> barcode ;
2021-02-26 14:25:17 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modBarCodeProduct -> code_auto )) {
$tmpcode = $modBarCodeProduct -> getNextValue ( $object , $fk_barcode_type );
}
2018-01-22 21:07:10 +01:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2018-01-22 21:07:10 +01:00
print '<input type="hidden" name="action" value="setbarcode">' ;
print '<input type="hidden" name="barcode_type_code" value="' . $object -> barcode_type_code . '">' ;
print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="' . $tmpcode . '">' ;
print ' <input type="submit" class="button" value="' . $langs -> trans ( " Modify " ) . '">' ;
print '</form>' ;
2020-09-07 10:18:17 +02:00
} else {
2021-02-27 02:00:00 +01:00
print showValueWithClipboardCPButton ( $object -> barcode );
2020-09-07 10:18:17 +02:00
}
print '</td></tr>' . " \n " ;
}
2011-12-07 12:58:39 +01:00
2021-06-08 11:40:50 +02:00
// Batch number management (to batch)
if ( ! empty ( $conf -> productbatch -> enabled )) {
if ( $object -> isProduct () || ! empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES )) {
print '<tr><td>' . $langs -> trans ( " ManageLotSerial " ) . '</td><td>' ;
print $object -> getLibStatut ( 0 , 2 );
print '</td></tr>' ;
2021-06-14 15:37:02 +02:00
if ((( $object -> status_batch == '1' && $conf -> global -> PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf -> global -> PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced' )
2021-06-08 11:40:50 +02:00
|| ( $object -> status_batch == '2' && $conf -> global -> PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf -> global -> PRODUCTBATCH_SN_USE_PRODUCT_MASKS ))) {
2021-06-09 17:50:21 +02:00
print '<tr><td>' . $langs -> trans ( " ManageLotMask " ) . '</td><td>' ;
print $object -> batch_mask ;
print '</td></tr>' ;
}
2021-06-08 11:40:50 +02:00
}
}
2017-11-01 07:19:36 +01:00
// Accountancy sell code
2015-12-17 12:57:08 +01:00
print '<tr><td class="nowrap">' ;
2017-11-01 07:19:36 +01:00
print $langs -> trans ( " ProductAccountancySellCode " );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
if ( ! empty ( $object -> accountancy_code_sell )) {
2018-08-29 21:07:00 +02:00
$accountingaccount = new AccountingAccount ( $db );
2019-01-27 11:55:16 +01:00
$accountingaccount -> fetch ( '' , $object -> accountancy_code_sell , 1 );
2017-05-21 15:24:16 +02:00
2019-01-27 11:55:16 +01:00
print $accountingaccount -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
2018-08-29 21:07:00 +02:00
}
2017-11-01 07:19:36 +01:00
} else {
2016-04-23 07:05:16 +02:00
print $object -> accountancy_code_sell ;
}
print '</td></tr>' ;
2014-02-10 00:24:20 +01:00
2019-04-25 01:16:29 +02:00
// Accountancy sell code intra-community
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2017-11-06 09:30:30 +01:00
print '<tr><td class="nowrap">' ;
2019-04-25 01:16:29 +02:00
print $langs -> trans ( " ProductAccountancySellIntraCode " );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
if ( ! empty ( $object -> accountancy_code_sell_intra )) {
2019-04-25 01:16:29 +02:00
$accountingaccount2 = new AccountingAccount ( $db );
$accountingaccount2 -> fetch ( '' , $object -> accountancy_code_sell_intra , 1 );
2017-11-01 07:19:36 +01:00
2019-04-25 01:16:29 +02:00
print $accountingaccount2 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
2018-08-29 21:07:00 +02:00
}
2017-11-06 09:30:30 +01:00
} else {
2019-04-25 01:16:29 +02:00
print $object -> accountancy_code_sell_intra ;
2017-11-06 09:30:30 +01:00
}
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
}
2019-04-25 01:16:29 +02:00
// Accountancy sell code export
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancySellExportCode " );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
if ( ! empty ( $object -> accountancy_code_sell_export )) {
2019-04-25 01:16:29 +02:00
$accountingaccount3 = new AccountingAccount ( $db );
$accountingaccount3 -> fetch ( '' , $object -> accountancy_code_sell_export , 1 );
print $accountingaccount3 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
} else {
print $object -> accountancy_code_sell_export ;
}
print '</td></tr>' ;
2017-11-01 07:19:36 +01:00
// Accountancy buy code
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancyBuyCode " );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
if ( ! empty ( $object -> accountancy_code_buy )) {
2018-08-29 21:07:00 +02:00
$accountingaccount4 = new AccountingAccount ( $db );
2019-01-27 11:55:16 +01:00
$accountingaccount4 -> fetch ( '' , $object -> accountancy_code_buy , 1 );
2017-11-01 07:19:36 +01:00
2019-01-27 11:55:16 +01:00
print $accountingaccount4 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
2018-08-29 21:07:00 +02:00
}
2017-11-01 07:19:36 +01:00
} else {
2016-04-23 07:05:16 +02:00
print $object -> accountancy_code_buy ;
}
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-03-01 04:52:12 +01:00
// Accountancy buy code intra-community
2021-02-26 14:25:17 +01:00
if ( $mysoc -> isInEEC ()) {
2020-03-01 04:52:12 +01:00
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancyBuyIntraCode " );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
if ( ! empty ( $object -> accountancy_code_buy_intra )) {
2020-03-01 04:52:12 +01:00
$accountingaccount5 = new AccountingAccount ( $db );
$accountingaccount5 -> fetch ( '' , $object -> accountancy_code_buy_intra , 1 );
print $accountingaccount5 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
} else {
print $object -> accountancy_code_buy_intra ;
}
print '</td></tr>' ;
}
// Accountancy buy code export
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancyBuyExportCode " );
2021-06-08 11:40:50 +02:00
print '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
if ( ! empty ( $object -> accountancy_code_buy_export )) {
2020-03-01 04:52:12 +01:00
$accountingaccount6 = new AccountingAccount ( $db );
$accountingaccount6 -> fetch ( '' , $object -> accountancy_code_buy_export , 1 );
print $accountingaccount6 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
} else {
print $object -> accountancy_code_buy_export ;
}
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
// Description
2021-06-08 11:40:50 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' . ( dol_textishtml ( $object -> description ) ? $object -> description : dol_nl2br ( $object -> description , 1 , true )) . '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Public URL
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " PublicUrl " ) . '</td><td>' ;
2014-03-14 13:51:46 +01:00
print dol_print_url ( $object -> url );
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
2014-03-14 13:51:46 +01:00
2020-09-07 10:18:17 +02:00
// Default warehouse
2021-02-26 14:25:17 +01:00
if ( $object -> isProduct () && ! empty ( $conf -> stock -> enabled )) {
2020-09-07 10:18:17 +02:00
$warehouse = new Entrepot ( $db );
$warehouse -> fetch ( $object -> fk_default_warehouse );
2018-03-28 11:54:21 +02:00
2020-09-07 10:18:17 +02:00
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print ( ! empty ( $warehouse -> id ) ? $warehouse -> getNomUrl ( 1 ) : '' );
print '</td>' ;
}
2018-03-28 11:54:21 +02:00
2020-09-07 10:18:17 +02:00
// Parent product.
if ( ! empty ( $conf -> variants -> enabled ) && ( $object -> isProduct () || $object -> isService ())) {
$combination = new ProductCombination ( $db );
2016-07-23 16:37:21 +02:00
2020-09-07 10:18:17 +02:00
if ( $combination -> fetchByFkProductChild ( $object -> id ) > 0 ) {
$prodstatic = new Product ( $db );
$prodstatic -> fetch ( $combination -> fk_product_parent );
2016-07-23 16:37:21 +02:00
2020-09-07 10:18:17 +02:00
// Parent product
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " ParentProduct " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print $prodstatic -> getNomUrl ( 1 );
print '</td></tr>' ;
}
}
2016-07-23 16:37:21 +02:00
2020-09-07 10:18:17 +02:00
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '<div class="underbanner clearboth"></div>' ;
2021-06-08 11:40:50 +02:00
print '<table class="border tableforfield centpercent">' ;
2017-06-07 16:44:04 +02:00
2021-02-26 14:25:17 +01:00
if ( $object -> isService ()) {
2020-09-07 10:18:17 +02:00
// Duration
2021-06-08 11:40:50 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Duration " ) . '</td><td>' . $object -> duration_value . ' ' ;
2021-02-26 14:25:17 +01:00
if ( $object -> duration_value > 1 ) {
2020-09-07 10:18:17 +02:00
$dur = array ( " i " => $langs -> trans ( " Minute " ), " h " => $langs -> trans ( " Hours " ), " d " => $langs -> trans ( " Days " ), " w " => $langs -> trans ( " Weeks " ), " m " => $langs -> trans ( " Months " ), " y " => $langs -> trans ( " Years " ));
2021-02-26 14:25:17 +01:00
} elseif ( $object -> duration_value > 0 ) {
2020-09-07 10:18:17 +02:00
$dur = array ( " i " => $langs -> trans ( " Minute " ), " h " => $langs -> trans ( " Hour " ), " d " => $langs -> trans ( " Day " ), " w " => $langs -> trans ( " Week " ), " m " => $langs -> trans ( " Month " ), " y " => $langs -> trans ( " Year " ));
}
print ( ! empty ( $object -> duration_unit ) && isset ( $dur [ $object -> duration_unit ]) ? $langs -> trans ( $dur [ $object -> duration_unit ]) : '' ) . " " ;
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
print '</td></tr>' ;
} else {
// Nature
2021-06-08 11:40:50 +02:00
print '<tr><td class="titlefield">' . $form -> textwithpicto ( $langs -> trans ( " NatureOfProductShort " ), $langs -> trans ( " NatureOfProductDesc " )) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
print $object -> getLibFinished ();
print '</td></tr>' ;
2019-10-16 14:17:53 +02:00
2020-09-07 10:18:17 +02:00
// Brut Weight
2021-06-08 11:40:50 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Weight " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $object -> weight != '' ) {
2020-09-07 10:18:17 +02:00
print $object -> weight . " " . measuringUnitString ( 0 , " weight " , $object -> weight_units );
} else {
print ' ' ;
}
print " </td></tr> \n " ;
2019-10-21 14:43:39 +02:00
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SIZE )) {
2020-09-07 10:18:17 +02:00
// Brut Length
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " Length " ) . ' x ' . $langs -> trans ( " Width " ) . ' x ' . $langs -> trans ( " Height " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $object -> length != '' || $object -> width != '' || $object -> height != '' ) {
2020-09-07 10:18:17 +02:00
print $object -> length ;
2021-02-26 14:25:17 +01:00
if ( $object -> width ) {
print " x " . $object -> width ;
}
if ( $object -> height ) {
print " x " . $object -> height ;
}
2020-09-07 10:18:17 +02:00
print ' ' . measuringUnitString ( 0 , " size " , $object -> length_units );
} else {
print ' ' ;
}
print " </td></tr> \n " ;
}
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE )) {
2020-09-07 10:18:17 +02:00
// Brut Surface
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " Surface " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $object -> surface != '' ) {
2020-09-07 10:18:17 +02:00
print $object -> surface . " " . measuringUnitString ( 0 , " surface " , $object -> surface_units );
} else {
print ' ' ;
}
print " </td></tr> \n " ;
}
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME )) {
2020-09-07 10:18:17 +02:00
// Brut Volume
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " Volume " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $object -> volume != '' ) {
2020-09-07 10:18:17 +02:00
print $object -> volume . " " . measuringUnitString ( 0 , " volume " , $object -> volume_units );
} else {
print ' ' ;
}
print " </td></tr> \n " ;
}
2019-10-21 14:43:39 +02:00
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_ADD_NET_MEASURE )) {
2020-09-07 10:18:17 +02:00
// Net Measure
2021-06-08 11:40:50 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " NetMeasure " ) . '</td><td>' ;
2021-02-26 14:25:17 +01:00
if ( $object -> net_measure != '' ) {
2020-09-07 10:18:17 +02:00
print $object -> net_measure . " " . measuringUnitString ( $object -> net_measure_units );
} else {
print ' ' ;
}
2021-06-08 11:40:50 +02:00
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
}
}
2010-05-26 16:52:32 +02:00
2015-02-26 14:15:33 +01:00
// Unit
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2015-04-21 15:49:58 +02:00
$unit = $object -> getLabelOfUnit ();
2015-02-26 14:15:33 +01:00
2015-07-12 18:05:56 +02:00
print '<tr><td>' . $langs -> trans ( 'DefaultUnitToShow' ) . '</td><td>' ;
2015-02-26 14:15:33 +01:00
if ( $unit !== '' ) {
print $langs -> trans ( $unit );
}
print '</td></tr>' ;
}
2020-09-07 10:18:17 +02:00
// Custom code
2021-02-26 14:25:17 +01:00
if ( ! $object -> isService () && empty ( $conf -> global -> PRODUCT_DISABLE_CUSTOM_INFO )) {
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " CustomCode " ) . '</td><td>' . $object -> customcode . '</td>' ;
2011-05-14 00:04:52 +02:00
2020-09-07 10:18:17 +02:00
// Origin country code
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " Origin " ) . '</td><td>' . getCountry ( $object -> country_id , 0 , $db );
2021-02-26 14:25:17 +01:00
if ( ! empty ( $object -> state_id )) {
print ' - ' . getState ( $object -> state_id , 0 , $db );
}
2020-09-14 11:01:11 +02:00
print '</td>' ;
2020-09-07 10:18:17 +02:00
}
2010-11-02 12:22:41 +01:00
2021-05-11 21:45:37 +02:00
// Quality Control
if ( ! empty ( $conf -> global -> PRODUCT_LOT_ENABLE_QUALITY_CONTROL )) {
2021-06-08 11:40:50 +02:00
print '<tr><td>' . $langs -> trans ( " LifeTime " ) . '</td><td">' . $object -> lifetime . '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( " QCFrequency " ) . '</td><td>' . $object -> qc_frequency . '</td></tr>' ;
2021-04-28 16:36:15 +02:00
}
2020-09-07 10:18:17 +02:00
// Other attributes
2021-06-08 11:40:50 +02:00
$parameters = array ();
2020-09-07 10:18:17 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2010-05-08 18:29:37 +02:00
2015-04-18 03:07:49 +02:00
// Categories
2019-11-12 00:15:34 +01:00
if ( $conf -> categorie -> enabled ) {
2021-06-08 11:40:50 +02:00
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_PRODUCT , 1 );
2015-06-19 14:30:23 +02:00
print " </td></tr> " ;
}
2015-06-27 23:01:05 +02:00
2020-09-07 10:18:17 +02:00
// Note private
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB )) {
2020-09-07 10:18:17 +02:00
print '<!-- show Note --> ' . " \n " ;
2021-06-08 11:40:50 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " NotePrivate " ) . '</td><td>' . ( dol_textishtml ( $object -> note_private ) ? $object -> note_private : dol_nl2br ( $object -> note_private , 1 , true )) . '</td></tr>' . " \n " ;
2020-09-07 10:18:17 +02:00
print '<!-- End show Note --> ' . " \n " ;
2016-07-28 13:53:17 +02:00
}
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print " </table> \n " ;
print '</div>' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '</div></div>' ;
print '<div style="clear:both"></div>' ;
2017-06-07 16:44:04 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2020-09-07 10:18:17 +02:00
}
2021-02-26 14:25:17 +01:00
} elseif ( $action != 'create' ) {
2020-09-07 10:18:17 +02:00
exit ;
}
2002-06-29 00:46:44 +02:00
}
2005-02-18 01:34:59 +01:00
2015-07-21 12:29:09 +02:00
// Load object modCodeProduct
2019-11-12 00:15:34 +01:00
$module = ( ! empty ( $conf -> global -> PRODUCT_CODEPRODUCT_ADDON ) ? $conf -> global -> PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard' );
2021-02-26 14:25:17 +01:00
if ( substr ( $module , 0 , 16 ) == 'mod_codeproduct_' && substr ( $module , - 3 ) == 'php' ) {
2020-09-07 10:18:17 +02:00
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
2015-07-21 12:29:09 +02:00
}
2019-11-12 00:15:34 +01:00
$result = dol_include_once ( '/core/modules/product/' . $module . '.php' );
2021-02-26 14:25:17 +01:00
if ( $result > 0 ) {
2015-07-21 12:29:09 +02:00
$modCodeProduct = new $module ();
}
2019-11-12 00:15:34 +01:00
$tmpcode = '' ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $modCodeProduct -> code_auto )) {
$tmpcode = $modCodeProduct -> getNextValue ( $object , $object -> type );
}
2009-05-27 17:11:24 +02:00
2020-10-31 14:32:18 +01:00
$formconfirm = '' ;
2012-06-08 21:33:12 +02:00
// Confirm delete product
2019-11-12 00:15:34 +01:00
if (( $action == 'delete' && ( empty ( $conf -> use_javascript_ajax ) || ! empty ( $conf -> dol_use_jmobile ))) // Output when action = clone if jmobile or no js
2021-02-26 14:25:17 +01:00
|| ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile ))) { // Always output when not jmobile nor js
2020-07-31 15:23:26 +02:00
$formconfirm = $form -> formconfirm ( " card.php?id= " . $object -> id , $langs -> trans ( " DeleteProduct " ), $langs -> trans ( " ConfirmDeleteProduct " ), " confirm_delete " , '' , 0 , " action-delete " );
2009-05-27 17:11:24 +02:00
}
2012-06-08 21:33:12 +02:00
// Clone confirmation
2019-11-12 00:15:34 +01:00
if (( $action == 'clone' && ( empty ( $conf -> use_javascript_ajax ) || ! empty ( $conf -> dol_use_jmobile ))) // Output when action = clone if jmobile or no js
2021-02-26 14:25:17 +01:00
|| ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile ))) { // Always output when not jmobile nor js
2020-07-31 15:23:26 +02:00
// Define confirmation messages
$formquestionclone = array (
'text' => $langs -> trans ( " ConfirmClone " ),
array ( 'type' => 'text' , 'name' => 'clone_ref' , 'label' => $langs -> trans ( " NewRefForClone " ), 'value' => empty ( $tmpcode ) ? $langs -> trans ( " CopyOf " ) . ' ' . $object -> ref : $tmpcode , 'size' => 24 ),
array ( 'type' => 'checkbox' , 'name' => 'clone_content' , 'label' => $langs -> trans ( " CloneContentProduct " ), 'value' => 1 ),
array ( 'type' => 'checkbox' , 'name' => 'clone_categories' , 'label' => $langs -> trans ( " CloneCategoriesProduct " ), 'value' => 1 ),
);
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
$formquestionclone [] = array ( 'type' => 'checkbox' , 'name' => 'clone_prices' , 'label' => $langs -> trans ( " ClonePricesProduct " ) . ' (' . $langs -> trans ( " CustomerPrices " ) . ')' , 'value' => 0 );
}
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_SOUSPRODUITS )) {
2020-07-31 15:23:26 +02:00
$formquestionclone [] = array ( 'type' => 'checkbox' , 'name' => 'clone_composition' , 'label' => $langs -> trans ( 'CloneCompositionProduct' ), 'value' => 1 );
}
2020-10-27 19:45:12 +01:00
$formconfirm .= $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ToClone' ), $langs -> trans ( 'ConfirmCloneProduct' , $object -> ref ), 'confirm_clone' , $formquestionclone , 'yes' , 'action-clone' , 350 , 600 );
2012-06-08 21:33:12 +02:00
}
2020-07-31 15:23:26 +02:00
// Call Hook formConfirm
$parameters = array ( 'formConfirm' => $formconfirm , 'object' => $object );
$reshook = $hookmanager -> executeHooks ( 'formConfirm' , $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 )) {
$formconfirm .= $hookmanager -> resPrint ;
} elseif ( $reshook > 0 ) {
$formconfirm = $hookmanager -> resPrint ;
}
2020-07-31 15:23:26 +02:00
// Print form confirm
print $formconfirm ;
2009-05-27 17:11:24 +02:00
2021-03-16 04:22:43 +01:00
/*
* Action bar
*/
2021-02-26 14:25:17 +01:00
if ( $action != 'create' && $action != 'edit' ) {
2020-09-07 10:18:17 +02:00
print " \n " . '<div class="tabsAction">' . " \n " ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02: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 ) {
if ( ! isset ( $object -> no_button_edit ) || $object -> no_button_edit <> 1 ) {
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=edit&id=' . $object -> id . '">' . $langs -> trans ( " Modify " ) . '</a>' ;
}
2017-06-07 16:44:04 +02:00
2021-02-26 14:25:17 +01:00
if ( ! isset ( $object -> no_button_copy ) || $object -> no_button_copy <> 1 ) {
if ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile )) {
2020-09-07 10:18:17 +02:00
print '<span id="action-clone" class="butAction">' . $langs -> trans ( 'ToClone' ) . '</span>' . " \n " ;
} else {
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=clone&id=' . $object -> id . '">' . $langs -> trans ( " ToClone " ) . '</a>' ;
}
}
}
$object_is_used = $object -> isObjectUsed ( $object -> id );
2017-06-07 16:44:04 +02:00
2021-02-26 14:25:17 +01:00
if ( $usercandelete ) {
if ( empty ( $object_is_used ) && ( ! isset ( $object -> no_button_delete ) || $object -> no_button_delete <> 1 )) {
if ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile )) {
2020-09-07 10:18:17 +02:00
print '<span id="action-delete" class="butActionDelete">' . $langs -> trans ( 'Delete' ) . '</span>' . " \n " ;
} else {
2020-10-01 10:50:54 +02:00
print '<a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?action=delete&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
2020-09-07 10:18:17 +02:00
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " ProductIsUsed " ) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotEnoughPermissions " ) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
}
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print " \n </div> \n " ;
2003-11-18 10:32:24 +01:00
}
2003-11-09 18:24:14 +01:00
2009-10-29 02:46:01 +01:00
/*
* All the " Add to " areas
*/
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_ADD_FORM_ADD_TO ) && $object -> id && ( $action == '' || $action == 'view' ) && $object -> status ) {
2020-09-07 10:18:17 +02:00
//Variable used to check if any text is going to be printed
$html = '' ;
2013-06-02 00:37:33 +02:00
//print '<div class="fichecenter"><div class="fichehalfleft">';
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Propals
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> creer ) {
2020-09-07 10:18:17 +02:00
$propal = new Propal ( $db );
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$langs -> load ( " propal " );
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$otherprop = $propal -> liste_array ( 2 , 1 , 0 );
2015-05-03 20:07:16 +02:00
2021-02-26 14:25:17 +01:00
if ( is_array ( $otherprop ) && count ( $otherprop )) {
2020-09-07 10:18:17 +02:00
$html .= '<tr><td style="width: 200px;">' ;
$html .= $langs -> trans ( " AddToDraftProposals " ) . '</td><td>' ;
$html .= $form -> selectarray ( " propalid " , $otherprop , 0 , 1 );
$html .= '</td></tr>' ;
} else {
$html .= '<tr><td style="width: 200px;">' ;
$html .= $langs -> trans ( " AddToDraftProposals " ) . '</td><td>' ;
$html .= $langs -> trans ( " NoDraftProposals " );
$html .= '</td></tr>' ;
}
}
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
// Commande
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> creer ) {
2020-09-07 10:18:17 +02:00
$commande = new Commande ( $db );
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$langs -> load ( " orders " );
2011-10-01 12:48:31 +02:00
2020-09-07 10:18:17 +02:00
$othercom = $commande -> liste_array ( 2 , 1 , null );
2021-02-26 14:25:17 +01:00
if ( is_array ( $othercom ) && count ( $othercom )) {
2020-09-07 10:18:17 +02:00
$html .= '<tr><td style="width: 200px;">' ;
$html .= $langs -> trans ( " AddToDraftOrders " ) . '</td><td>' ;
$html .= $form -> selectarray ( " commandeid " , $othercom , 0 , 1 );
$html .= '</td></tr>' ;
} else {
$html .= '<tr><td style="width: 200px;">' ;
$html .= $langs -> trans ( " AddToDraftOrders " ) . '</td><td>' ;
$html .= $langs -> trans ( " NoDraftOrders " );
$html .= '</td></tr>' ;
}
}
// Factures
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> creer ) {
2020-09-07 10:18:17 +02:00
$invoice = new Facture ( $db );
$langs -> load ( " bills " );
$otherinvoice = $invoice -> liste_array ( 2 , 1 , null );
2021-02-26 14:25:17 +01:00
if ( is_array ( $otherinvoice ) && count ( $otherinvoice )) {
2020-09-07 10:18:17 +02:00
$html .= '<tr><td style="width: 200px;">' ;
$html .= $langs -> trans ( " AddToDraftInvoices " ) . '</td><td>' ;
$html .= $form -> selectarray ( " factureid " , $otherinvoice , 0 , 1 );
$html .= '</td></tr>' ;
} else {
$html .= '<tr><td style="width: 200px;">' ;
$html .= $langs -> trans ( " AddToDraftInvoices " ) . '</td><td>' ;
$html .= $langs -> trans ( " NoDraftInvoices " );
$html .= '</td></tr>' ;
}
}
//If any text is going to be printed, then we show the table
2021-02-26 14:25:17 +01:00
if ( ! empty ( $html )) {
2020-09-07 10:18:17 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="addin">' ;
print load_fiche_titre ( $langs -> trans ( " AddToDraft " ), '' , '' );
2017-06-07 16:44:04 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( '' );
2015-05-03 20:07:16 +02:00
2020-09-07 10:18:17 +02:00
$html .= '<tr><td class="nowrap">' . $langs -> trans ( " Quantity " ) . ' ' ;
$html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td>' ;
$html .= '<td class="nowrap">' . $langs -> trans ( " ReductionShort " ) . '(%) ' ;
$html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">' ;
$html .= '</td></tr>' ;
2015-05-03 20:07:16 +02:00
2020-09-07 10:18:17 +02:00
print '<table width="100%" class="border">' ;
print $html ;
print '</table>' ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '<div class="center">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print '</div>' ;
2015-05-03 20:07:16 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2016-02-08 15:49:38 +01:00
2020-09-07 10:18:17 +02:00
print '</form>' ;
}
2003-06-28 15:55:12 +02:00
}
2002-05-04 23:28:42 +02:00
2016-02-08 15:49:38 +01:00
/*
2021-03-16 04:04:18 +01:00
* Generated documents
2016-02-08 15:49:38 +01:00
*/
2017-04-07 11:01:12 +02:00
2021-02-26 14:25:17 +01:00
if ( $action != 'create' && $action != 'edit' && $action != 'delete' ) {
2020-09-07 10:18:17 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
2016-02-08 15:49:38 +01:00
2020-09-07 10:18:17 +02:00
// Documents
$objectref = dol_sanitizeFileName ( $object -> ref );
$relativepath = $comref . '/' . $objectref . '.pdf' ;
2020-10-04 23:30:41 +02:00
if ( ! empty ( $conf -> product -> multidir_output [ $object -> entity ])) {
2020-10-07 15:01:28 +02:00
$filedir = $conf -> product -> multidir_output [ $object -> entity ] . '/' . $objectref ; //Check repertories of current entities
2020-10-04 23:30:41 +02:00
} else {
$filedir = $conf -> product -> dir_output . '/' . $objectref ;
}
2020-09-07 10:18:17 +02:00
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
$genallowed = $usercanread ;
$delallowed = $usercancreate ;
2016-02-08 15:49:38 +01:00
2020-09-07 10:18:17 +02:00
print $formfile -> showdocuments ( $modulepart , $object -> ref , $filedir , $urlsource , $genallowed , $delallowed , '' , 0 , 0 , 0 , 28 , 0 , '' , 0 , '' , $object -> default_lang , '' , $object );
$somethingshown = $formfile -> numoffiles ;
2017-06-07 16:44:04 +02:00
2020-09-07 10:18:17 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2016-02-08 15:49:38 +01:00
2020-09-07 10:18:17 +02:00
$MAXEVENT = 10 ;
2017-11-12 13:40:05 +01:00
2020-09-07 10:18:17 +02:00
$morehtmlright = '<a href="' . DOL_URL_ROOT . '/product/agenda.php?id=' . $object -> id . '">' ;
$morehtmlright .= $langs -> trans ( " SeeAll " );
$morehtmlright .= '</a>' ;
2017-11-26 20:21:01 +01:00
2020-09-07 10:18:17 +02:00
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
$somethingshown = $formactions -> showactions ( $object , 'product' , 0 , 1 , '' , $MAXEVENT , '' , $morehtmlright ); // Show all action for product
2017-11-12 13:40:05 +01:00
2020-09-07 10:18:17 +02:00
print '</div></div></div>' ;
2016-02-08 15:49:38 +01:00
}
2018-08-15 12:48:13 +02:00
// End of page
2012-03-04 09:43:56 +01:00
llxFooter ();
2012-07-08 23:22:22 +02:00
$db -> close ();