2004-10-20 22:06:49 +02:00
< ? php
2017-05-21 15:24:16 +02:00
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-09-12 18:15:01 +02:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2017-05-21 15:24:16 +02:00
* Copyright ( C ) 2005 Eric Seigne < eric . seigne @ ryxeo . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2015 Regis Houssin < regis . houssin @ inodbox . com >
2014-10-02 09:30:31 +02:00
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
* Copyright ( C ) 2006 Auguria SARL < info @ auguria . org >
2015-09-13 00:09:32 +02:00
* Copyright ( C ) 2010 - 2015 Juanjo Menent < jmenent @ 2 byte . es >
2016-07-23 16:37:21 +02:00
* Copyright ( C ) 2013 - 2016 Marcos García < marcosgdf @ gmail . com >
2015-02-26 14:15:33 +01:00
* Copyright ( C ) 2012 - 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2017-11-01 07:19:36 +01:00
* Copyright ( C ) 2011 - 2017 Alexandre Spangaro < aspangaro @ zendsi . com >
2014-10-02 09:30:31 +02:00
* Copyright ( C ) 2014 Cédric Gross < c . gross @ kreiz - it . fr >
2015-06-11 10:43:12 +02:00
* Copyright ( C ) 2014 - 2015 Ferran Marcet < fmarcet @ 2 byte . es >
2016-11-29 12:19:01 +01:00
* 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 >
2017-05-21 15:24:16 +02:00
* Copyright ( C ) 2016 Meziane Sof < virtualsof @ yahoo . fr >
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
2011-08-01 01:19:04 +02:00
* along with this program . If not , see < http :// 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' ;
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
2015-12-17 06:16:29 +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' ;
2017-05-25 06:57:28 +02:00
if ( ! empty ( $conf -> accounting -> enabled )) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php' ;
2017-05-21 15:24:16 +02:00
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' ));
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> stock -> enabled )) $langs -> load ( " stocks " );
if ( ! empty ( $conf -> facture -> enabled )) $langs -> load ( " bills " );
2014-10-02 09:30:31 +02:00
if ( ! empty ( $conf -> productbatch -> enabled )) $langs -> load ( " productbatch " );
2005-06-26 17:37:57 +02:00
2015-06-12 13:21:21 +02:00
$mesg = '' ; $error = 0 ; $errors = array ();
$refalreadyexists = 0 ;
2011-08-23 00:04:21 +02:00
2012-07-24 17:52:46 +02:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$type = GETPOST ( 'type' , 'int' );
2012-04-06 22:39:40 +02:00
$action = ( GETPOST ( 'action' , 'alpha' ) ? GETPOST ( 'action' , 'alpha' ) : 'view' );
2017-09-15 10:50:50 +02:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2012-04-06 22:39:40 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2012-02-27 22:26:22 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2015-12-17 10:01:21 +01:00
$duration_value = GETPOST ( 'duration_value' );
$duration_unit = GETPOST ( 'duration_unit' );
2012-07-24 17:52:46 +02:00
if ( ! empty ( $user -> societe_id )) $socid = $user -> societe_id ;
2011-08-23 00:04:21 +02:00
$object = new Product ( $db );
2018-04-05 16:20:50 +02: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
2013-04-26 10:29:14 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-03-30 16:58:49 +01:00
2013-01-15 11:23:24 +01:00
if ( $id > 0 || ! empty ( $ref ))
{
2016-02-08 15:49:38 +01:00
$result = $object -> fetch ( $id , $ref );
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 );
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 " ;
}
2013-01-15 11:23:24 +01:00
}
2016-07-28 13:53:17 +02:00
2016-02-08 15:49:38 +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)
2013-01-15 11:23:24 +01:00
$canvas = ! empty ( $object -> canvas ) ? $object -> canvas : GETPOST ( " canvas " );
2014-11-15 16:20:03 +01:00
$objcanvas = null ;
2011-08-23 00:04:21 +02:00
if ( ! empty ( $canvas ))
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
2011-08-23 00:04:21 +02:00
$objcanvas = new Canvas ( $db , $action );
$objcanvas -> getCanvas ( 'product' , 'card' , $canvas );
}
2011-04-25 22:18:09 +02:00
2009-04-27 22:37:50 +02:00
// Security check
2012-02-11 11:44:15 +01:00
$fieldvalue = ( ! empty ( $id ) ? $id : ( ! empty ( $ref ) ? $ref : '' ));
2017-08-10 16:41:09 +02:00
$fieldtype = ( ! empty ( $id ) ? 'rowid' : 'ref' );
2018-06-18 15:48:51 +02:00
$result = 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
2014-10-06 07:20:58 +02: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
2015-05-03 20:07:16 +02:00
if ( $cancel ) $action = '' ;
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 ));
2014-03-16 17:37:54 +01:00
$createbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> creer_advance )) $createbarcode = 0 ;
2011-09-28 21:07:49 +02:00
$parameters = array ( 'id' => $id , 'ref' => $ref , 'objcanvas' => $objcanvas );
2011-08-27 19:25:09 +02:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2014-09-28 03:41:32 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2011-08-27 19:25:09 +02:00
2011-08-28 14:57:23 +02:00
if ( empty ( $reshook ))
2010-03-20 19:39:32 +01:00
{
2012-03-04 01:41:36 +01:00
// Type
2018-02-11 13:27:02 +01:00
if ( $action == 'setfk_product_type' && $usercancreate )
2012-03-04 01:41:36 +01:00
{
2016-09-12 20:16:39 +02:00
$result = $object -> setValueFrom ( 'fk_product_type' , GETPOST ( 'fk_product_type' ), '' , null , 'text' , '' , $user , 'PRODUCT_MODIFY' );
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
2012-03-04 01:41:36 +01:00
exit ;
}
2016-10-25 12:36:14 +02:00
2017-04-12 19:30:01 +02:00
// Actions to build doc
$upload_dir = $conf -> produit -> dir_output ;
2018-02-11 13:27:02 +01:00
$permissioncreate = $usercancreate ;
2017-04-12 19:30:01 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2017-06-07 16:44:04 +02:00
2017-04-12 19:30:01 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php' ;
2017-06-07 16:44:04 +02:00
2011-12-07 12:58:39 +01:00
// Barcode type
2014-03-16 17:37:54 +01:00
if ( $action == 'setfk_barcode_type' && $createbarcode )
2011-12-07 12:58:39 +01:00
{
2016-09-12 20:16:39 +02:00
$result = $object -> setValueFrom ( 'fk_barcode_type' , GETPOST ( 'fk_barcode_type' ), '' , null , 'text' , '' , $user , 'PRODUCT_MODIFY' );
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
2011-12-07 12:58:39 +01:00
exit ;
}
// Barcode value
2014-03-16 17:37:54 +01:00
if ( $action == 'setbarcode' && $createbarcode )
2011-12-07 12:58:39 +01:00
{
2014-11-22 15:47:14 +01:00
$result = $object -> check_barcode ( GETPOST ( 'barcode' ), GETPOST ( 'barcode_type_code' ));
2014-02-19 01:51:19 +01:00
if ( $result >= 0 )
{
2018-06-06 17:11:34 +02:00
$result = $object -> setValueFrom ( 'barcode' , GETPOST ( 'barcode' ), '' , null , 'text' , '' , $user , 'PRODUCT_MODIFY' );
2014-02-19 01:51:19 +01:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $object -> id );
exit ;
}
else
{
$langs -> load ( " errors " );
if ( $result == - 1 ) $errors [] = 'ErrorBadBarCodeSyntax' ;
else if ( $result == - 2 ) $errors [] = 'ErrorBarCodeRequired' ;
else if ( $result == - 3 ) $errors [] = 'ErrorBarCodeAlreadyUsed' ;
else $errors [] = 'FailedToValidateBarCode' ;
$error ++ ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $errors , null , 'errors' );
2014-02-19 01:51:19 +01:00
}
2011-12-07 12:58:39 +01:00
}
2011-08-28 14:57:23 +02:00
// Add a product or service
2018-02-11 13:27:02 +01:00
if ( $action == 'add' && $usercancreate )
2011-08-28 14:57:23 +02:00
{
2011-10-01 12:48:31 +02:00
$error = 0 ;
2015-05-04 12:58:54 +02:00
if ( ! GETPOST ( 'label' ))
2011-10-01 12:48:31 +02:00
{
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Label' )), null , 'errors' );
2011-10-01 12:48:31 +02:00
$action = " create " ;
$error ++ ;
}
if ( empty ( $ref ))
{
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Ref' )), null , 'errors' );
2011-10-01 12:48:31 +02:00
$action = " create " ;
$error ++ ;
}
2015-12-17 10:01:21 +01:00
if ( ! empty ( $duration_value ) && empty ( $duration_unit ))
2015-12-16 19:26:50 +01:00
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentities ( 'Unit' )), null , 'errors' );
2015-12-16 19:26:50 +01:00
$action = " create " ;
$error ++ ;
}
2017-06-07 16:44:04 +02:00
2011-10-01 12:48:31 +02:00
if ( ! $error )
{
2015-02-26 14:15:33 +01:00
$units = GETPOST ( 'units' , 'int' );
2014-02-02 18:26:17 +01:00
$object -> ref = $ref ;
2015-05-04 12:37:50 +02:00
$object -> label = GETPOST ( 'label' );
2014-02-02 18:26:17 +01:00
$object -> price_base_type = GETPOST ( 'price_base_type' );
2013-01-15 11:23:24 +01:00
if ( $object -> price_base_type == 'TTC' )
$object -> price_ttc = GETPOST ( 'price' );
else
$object -> price = GETPOST ( 'price' );
if ( $object -> price_base_type == 'TTC' )
$object -> price_min_ttc = GETPOST ( 'price_min' );
else
$object -> price_min = GETPOST ( 'price_min' );
2017-06-23 12:09:21 +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
if ( preg_match ( '/\((.*)\)/' , $tva_tx_txt , $reg ))
{
// 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 " ;
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = ' " . $mysoc -> country_code . " ' " ;
$sql .= " AND t.taux = " . (( float ) $tva_tx ) . " AND t.active = 1 " ;
$sql .= " AND t.code =' " . $vatratecode . " ' " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$obj = $db -> fetch_object ( $resql );
$npr = $obj -> recuperableonly ;
$localtax1 = $obj -> localtax1 ;
$localtax2 = $obj -> localtax2 ;
$localtax1_type = $obj -> localtax1_type ;
$localtax2_type = $obj -> localtax2_type ;
}
}
2011-10-01 12:48:31 +02:00
2017-06-23 12:09:21 +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 ;
2012-04-06 22:39:40 +02:00
2014-02-02 18:26:17 +01:00
$object -> type = $type ;
$object -> status = GETPOST ( 'statut' );
$object -> status_buy = GETPOST ( 'statut_buy' );
2014-03-04 18:55:55 +01:00
$object -> status_batch = GETPOST ( 'status_batch' );
2014-02-10 00:24:20 +01:00
2014-02-02 18:26:17 +01:00
$object -> barcode_type = GETPOST ( 'fk_barcode_type' );
$object -> barcode = GETPOST ( 'barcode' );
2014-05-25 17:14:33 +02:00
// Set barcode_type_xxx from barcode_type id
2014-05-26 12:32:33 +02:00
$stdobject = new GenericObject ( $db );
2014-05-25 17:14:33 +02:00
$stdobject -> element = 'product' ;
2014-05-26 12:32:33 +02:00
$stdobject -> barcode_type = GETPOST ( 'fk_barcode_type' );
$result = $stdobject -> fetch_barcode ();
if ( $result < 0 )
{
$error ++ ;
2015-12-14 20:54:55 +01:00
$mesg = 'Failed to get bar code type information ' ;
setEventMessages ( $mesg . $stdobject -> error , $mesg . $stdobject -> errors , 'errors' );
2014-05-26 12:32:33 +02:00
}
2014-05-25 17:14:33 +02:00
$object -> barcode_type_code = $stdobject -> barcode_type_code ;
$object -> barcode_type_coder = $stdobject -> barcode_type_coder ;
2014-05-26 12:32:33 +02:00
$object -> barcode_type_label = $stdobject -> barcode_type_label ;
2014-07-04 15:06:45 +02:00
2017-09-25 00:16:52 +02:00
$object -> description = dol_htmlcleanlastbr ( GETPOST ( 'desc' , 'none' ));
2015-04-21 15:49:58 +02:00
$object -> url = GETPOST ( 'url' );
2017-09-25 00:16:52 +02:00
$object -> note_private = dol_htmlcleanlastbr ( GETPOST ( 'note_private' , 'none' ));
2016-07-28 13:53:17 +02:00
$object -> note = $object -> note_private ; // deprecated
2018-06-25 14:06:09 +02:00
$object -> customcode = GETPOST ( 'customcode' , 'alpha' );
$object -> country_id = GETPOST ( 'country_id' , 'int' );
2015-12-17 10:01:21 +01:00
$object -> duration_value = $duration_value ;
$object -> duration_unit = $duration_unit ;
2018-03-28 11:54:21 +02:00
$object -> fk_default_warehouse = GETPOST ( 'fk_default_warehouse' );
2014-02-02 18:26:17 +01:00
$object -> seuil_stock_alerte = GETPOST ( 'seuil_stock_alerte' ) ? GETPOST ( 'seuil_stock_alerte' ) : 0 ;
2015-04-21 15:49:58 +02:00
$object -> desiredstock = GETPOST ( 'desiredstock' ) ? GETPOST ( 'desiredstock' ) : 0 ;
2014-02-02 18:26:17 +01:00
$object -> canvas = GETPOST ( 'canvas' );
$object -> weight = GETPOST ( 'weight' );
$object -> weight_units = GETPOST ( 'weight_units' );
$object -> length = GETPOST ( 'size' );
$object -> length_units = GETPOST ( 'size_units' );
2016-12-10 13:25:33 +01:00
$object -> width = GETPOST ( 'sizewidth' );
$object -> height = GETPOST ( 'sizeheight' );
2017-01-16 10:43:22 +01:00
$object -> surface = GETPOST ( 'surface' );
2014-02-02 18:26:17 +01:00
$object -> surface_units = GETPOST ( 'surface_units' );
$object -> volume = GETPOST ( 'volume' );
$object -> volume_units = GETPOST ( 'volume_units' );
2018-06-25 14:06:09 +02:00
$object -> finished = GETPOST ( 'finished' , 'alpha' );
$object -> fk_unit = GETPOST ( 'units' , 'alpha' );
2017-05-21 15:24:16 +02:00
2018-06-25 14:06:09 +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' );
2015-12-22 07:31:59 +01:00
if ( $accountancy_code_sell <= 0 ) { $object -> accountancy_code_sell = '' ; } else { $object -> accountancy_code_sell = $accountancy_code_sell ; }
2017-11-01 07:19:36 +01:00
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 ; }
2015-12-22 07:31:59 +01:00
if ( $accountancy_code_buy <= 0 ) { $object -> accountancy_code_buy = '' ; } else { $object -> accountancy_code_buy = $accountancy_code_buy ; }
2011-10-01 12:48:31 +02:00
// MultiPrix
2012-07-24 17:52:46 +02:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ))
2011-10-01 12:48:31 +02:00
{
for ( $i = 2 ; $i <= $conf -> global -> PRODUIT_MULTIPRICES_LIMIT ; $i ++ )
{
2012-09-16 21:12:55 +02:00
if ( isset ( $_POST [ " price_ " . $i ]))
2011-10-01 12:48:31 +02:00
{
2012-04-06 22:39:40 +02:00
$object -> multiprices [ " $i " ] = price2num ( $_POST [ " price_ " . $i ], 'MU' );
$object -> multiprices_base_type [ " $i " ] = $_POST [ " multiprices_base_type_ " . $i ];
2011-10-01 12:48:31 +02:00
}
else
{
2012-04-06 22:39:40 +02:00
$object -> multiprices [ " $i " ] = " " ;
2011-10-01 12:48:31 +02:00
}
}
}
2013-03-30 16:58:49 +01:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
2015-02-26 14:25:30 +01:00
if ( $ret < 0 ) $error ++ ;
2012-03-03 19:02:44 +01:00
2015-02-26 14:25:30 +01:00
if ( ! $error )
{
$id = $object -> create ( $user );
}
2011-10-01 12:48:31 +02: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
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . " ?id= " . $id );
2011-10-01 12:48:31 +02:00
exit ;
}
else
2014-02-19 01:51:19 +01:00
{
2015-12-14 20:54:55 +01:00
if ( count ( $object -> errors )) setEventMessages ( $object -> error , $object -> errors , 'errors' );
else setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2011-10-01 12:48:31 +02:00
$action = " create " ;
}
}
2011-08-28 14:57:23 +02:00
}
2004-07-14 12:25:14 +02:00
2011-08-28 14:57:23 +02:00
// Update a product or service
2018-02-11 13:27:02 +01:00
if ( $action == 'update' && $usercancreate )
2011-08-28 14:57:23 +02:00
{
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' ))
2011-10-01 12:48:31 +02:00
{
$action = '' ;
}
else
{
2013-01-15 11:23:24 +01:00
if ( $object -> id > 0 )
2011-10-01 12:48:31 +02:00
{
2015-09-24 16:32:48 +02:00
$object -> oldcopy = clone $object ;
2012-06-09 13:16:55 +02:00
2014-02-02 18:26:17 +01:00
$object -> ref = $ref ;
2015-05-04 12:37:50 +02:00
$object -> label = GETPOST ( 'label' );
2017-09-25 00:16:52 +02:00
$object -> description = dol_htmlcleanlastbr ( GETPOST ( 'desc' , 'none' ));
2014-03-14 13:51:46 +01:00
$object -> url = GETPOST ( 'url' );
2016-07-28 13:53:17 +02:00
if ( ! empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB ))
{
2017-09-25 00:16:52 +02:00
$object -> note_private = dol_htmlcleanlastbr ( GETPOST ( 'note_private' , 'none' ));
2016-07-28 13:53:17 +02:00
$object -> note = $object -> note_private ;
}
2018-06-25 14:06:09 +02:00
$object -> customcode = GETPOST ( 'customcode' , 'alpha' );
$object -> country_id = GETPOST ( 'country_id' , 'int' );
$object -> status = GETPOST ( 'statut' , 'int' );
$object -> status_buy = GETPOST ( 'statut_buy' , 'int' );
$object -> status_batch = GETPOST ( 'status_batch' , 'aZ09' );
2016-02-05 12:18:50 +01:00
// removed from update view so GETPOST always empty
2018-03-28 11:54:21 +02:00
$object -> fk_default_warehouse = GETPOST ( 'fk_default_warehouse' );
2016-02-03 19:52:09 +01:00
/*
2014-02-02 18:26:17 +01:00
$object -> seuil_stock_alerte = GETPOST ( 'seuil_stock_alerte' );
$object -> desiredstock = GETPOST ( 'desiredstock' );
2016-02-03 19:52:09 +01:00
*/
2014-02-02 18:26:17 +01:00
$object -> duration_value = GETPOST ( 'duration_value' );
$object -> duration_unit = GETPOST ( 'duration_unit' );
2016-02-05 12:18:50 +01:00
2014-02-02 18:26:17 +01:00
$object -> canvas = GETPOST ( 'canvas' );
$object -> weight = GETPOST ( 'weight' );
$object -> weight_units = GETPOST ( 'weight_units' );
$object -> length = GETPOST ( 'size' );
$object -> length_units = GETPOST ( 'size_units' );
2016-12-10 13:25:33 +01:00
$object -> width = GETPOST ( 'sizewidth' );
$object -> height = GETPOST ( 'sizeheight' );
2014-02-02 18:26:17 +01:00
$object -> surface = GETPOST ( 'surface' );
$object -> surface_units = GETPOST ( 'surface_units' );
$object -> volume = GETPOST ( 'volume' );
$object -> volume_units = GETPOST ( 'volume_units' );
2018-06-25 14:06:09 +02:00
$object -> finished = GETPOST ( 'finished' , 'alpha' );
2014-02-19 01:51:19 +01:00
2015-02-26 14:15:33 +01:00
$units = GETPOST ( 'units' , 'int' );
if ( $units > 0 ) {
$object -> fk_unit = $units ;
} else {
$object -> fk_unit = null ;
}
2014-02-19 01:51:19 +01:00
$object -> barcode_type = GETPOST ( 'fk_barcode_type' );
$object -> barcode = GETPOST ( 'barcode' );
2014-05-26 12:32:33 +02:00
// Set barcode_type_xxx from barcode_type id
2014-05-25 17:14:33 +02:00
$stdobject = new GenericObject ( $db );
2014-05-26 12:32:33 +02:00
$stdobject -> element = 'product' ;
$stdobject -> barcode_type = GETPOST ( 'fk_barcode_type' );
$result = $stdobject -> fetch_barcode ();
if ( $result < 0 )
{
$error ++ ;
2015-12-14 20:54:55 +01:00
$mesg = 'Failed to get bar code type information ' ;
setEventMessages ( $mesg . $stdobject -> error , $mesg . $stdobject -> errors , 'errors' );
2014-05-26 12:32:33 +02:00
}
$object -> barcode_type_code = $stdobject -> barcode_type_code ;
$object -> barcode_type_coder = $stdobject -> barcode_type_coder ;
$object -> barcode_type_label = $stdobject -> barcode_type_label ;
2014-07-04 15:06:45 +02:00
2018-06-25 14:06:09 +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' );
2017-05-21 15:24:16 +02:00
2015-12-22 07:31:59 +01:00
if ( $accountancy_code_sell <= 0 ) { $object -> accountancy_code_sell = '' ; } else { $object -> accountancy_code_sell = $accountancy_code_sell ; }
2017-11-01 07:19:36 +01:00
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 ; }
2015-12-22 07:31:59 +01:00
if ( $accountancy_code_buy <= 0 ) { $object -> accountancy_code_buy = '' ; } else { $object -> accountancy_code_buy = $accountancy_code_buy ; }
2011-10-01 12:48:31 +02:00
2013-03-30 16:58:49 +01:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
2015-02-26 14:25:30 +01:00
if ( $ret < 0 ) $error ++ ;
2012-03-03 19:02:44 +01:00
2015-02-26 14:25:30 +01:00
if ( ! $error && $object -> check ())
2011-10-01 12:48:31 +02:00
{
2012-04-06 22:39:40 +02:00
if ( $object -> update ( $object -> id , $user ) > 0 )
2011-10-01 12:48:31 +02:00
{
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
2012-05-30 03:46:06 +02:00
$action = 'view' ;
2011-10-01 12:48:31 +02:00
}
else
2014-02-19 01:51:19 +01:00
{
2015-12-14 20:54:55 +01:00
if ( count ( $object -> errors )) setEventMessages ( $object -> error , $object -> errors , 'errors' );
else setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2011-10-01 12:48:31 +02:00
$action = 'edit' ;
}
}
else
2014-02-19 01:51:19 +01:00
{
2015-12-14 20:54:55 +01:00
if ( count ( $object -> errors )) setEventMessages ( $object -> error , $object -> errors , 'errors' );
else setEventMessages ( $langs -> trans ( " ErrorProductBadRefOrLabel " ), null , 'errors' );
2011-10-01 12:48:31 +02:00
$action = 'edit' ;
}
}
}
2011-08-28 14:57:23 +02:00
}
2004-07-14 14:22:27 +02:00
2011-08-28 14:57:23 +02:00
// Action clone object
2012-06-08 21:39:44 +02:00
if ( $action == 'confirm_clone' && $confirm != 'yes' ) { $action = '' ; }
2018-02-11 13:27:02 +01:00
if ( $action == 'confirm_clone' && $confirm == 'yes' && $usercancreate )
2011-08-28 14:57:23 +02:00
{
2011-10-01 12:48:31 +02:00
if ( ! GETPOST ( 'clone_content' ) && ! GETPOST ( 'clone_prices' ) )
{
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( " NoCloneOptionsSpecified " ), null , 'errors' );
2011-10-01 12:48:31 +02:00
}
else
{
$db -> begin ();
$originalId = $id ;
2013-01-15 11:23:24 +01:00
if ( $object -> id > 0 )
2011-10-01 12:48:31 +02:00
{
2012-04-06 22:39:40 +02:00
$object -> ref = GETPOST ( 'clone_ref' );
$object -> status = 0 ;
$object -> status_buy = 0 ;
$object -> id = null ;
2014-03-16 17:37:54 +01:00
$object -> barcode = - 1 ;
2011-10-01 12:48:31 +02:00
2012-04-06 22:39:40 +02:00
if ( $object -> check ())
2011-10-01 12:48:31 +02:00
{
2012-04-06 22:39:40 +02:00
$id = $object -> create ( $user );
2011-10-01 12:48:31 +02:00
if ( $id > 0 )
{
2013-06-10 00:11:25 +02:00
if ( GETPOST ( 'clone_composition' ))
{
$result = $object -> clone_associations ( $originalId , $id );
if ( $result < 1 )
{
$db -> rollback ();
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( 'ErrorProductClone' ), null , 'errors' );
2013-06-10 00:11:25 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $originalId );
exit ;
}
}
2012-04-06 22:39:40 +02:00
// $object->clone_fournisseurs($originalId, $id);
2011-10-01 12:48:31 +02:00
$db -> commit ();
$db -> close ();
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id );
2011-10-01 12:48:31 +02:00
exit ;
}
else
{
2012-06-08 21:33:12 +02:00
$id = $originalId ;
2012-04-06 22:39:40 +02:00
if ( $object -> error == 'ErrorProductAlreadyExists' )
2011-10-01 12:48:31 +02:00
{
$db -> rollback ();
2015-06-12 13:21:21 +02:00
$refalreadyexists ++ ;
2011-10-01 12:48:31 +02:00
$action = " " ;
2014-10-16 13:57:07 +02:00
$mesg = $langs -> trans ( " ErrorProductAlreadyExists " , $object -> ref );
2012-04-06 22:39:40 +02:00
$mesg .= ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?ref=' . $object -> ref . '">' . $langs -> trans ( " ShowCardHere " ) . '</a>.' ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $mesg , null , 'errors' );
2014-10-16 13:57:07 +02:00
$object -> fetch ( $id );
2011-10-01 12:48:31 +02:00
}
else
2015-06-12 13:21:21 +02:00
{
2011-10-01 12:48:31 +02:00
$db -> rollback ();
2014-04-26 22:35:35 +02:00
if ( count ( $object -> errors ))
2014-03-16 17:37:54 +01:00
{
2015-12-14 20:54:55 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-03-16 17:37:54 +01:00
dol_print_error ( $db , $object -> errors );
}
2014-04-26 22:35:35 +02:00
else
2014-03-16 17:37:54 +01:00
{
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2014-03-16 17:37:54 +01:00
dol_print_error ( $db , $object -> error );
}
2011-10-01 12:48:31 +02:00
}
}
}
}
else
{
$db -> rollback ();
2012-06-06 23:06:17 +02:00
dol_print_error ( $db , $object -> error );
2011-10-01 12:48:31 +02:00
}
}
2011-08-28 14:57:23 +02:00
}
2006-04-07 14:39:22 +02:00
2011-08-28 14:57:23 +02:00
// Delete a product
2012-06-08 21:39:44 +02:00
if ( $action == 'confirm_delete' && $confirm != 'yes' ) { $action = '' ; }
2018-02-11 13:27:02 +01:00
if ( $action == 'confirm_delete' && $confirm == 'yes' && $usercandelete )
{
$result = $object -> delete ( $user );
2013-10-23 16:24:31 +02:00
2011-10-01 12:48:31 +02:00
if ( $result > 0 )
{
2014-09-18 20:33:37 +02:00
header ( 'Location: ' . DOL_URL_ROOT . '/product/list.php?type=' . $object -> type . '&delprod=' . urlencode ( $object -> ref ));
2011-10-01 12:48:31 +02:00
exit ;
}
else
{
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( $object -> error ), null , 'errors' );
2011-10-01 12:48:31 +02:00
$reload = 0 ;
$action = '' ;
}
2011-08-28 14:57:23 +02:00
}
2006-04-07 14:39:22 +02:00
2005-06-26 20:13:17 +02:00
2015-05-03 20:07:16 +02:00
// Add product into object
if ( $object -> id > 0 && $action == 'addin' )
2010-07-22 23:16:29 +02:00
{
2015-09-13 00:25:32 +02:00
$thirpdartyid = 0 ;
2015-05-03 20:07:16 +02:00
if ( GETPOST ( 'propalid' ) > 0 )
2011-10-01 12:48:31 +02:00
{
2015-05-03 20:07:16 +02:00
$propal = new Propal ( $db );
$result = $propal -> fetch ( GETPOST ( 'propalid' ));
if ( $result <= 0 )
{
dol_print_error ( $db , $propal -> error );
exit ;
}
$thirpdartyid = $propal -> socid ;
2011-10-01 12:48:31 +02:00
}
2015-05-03 20:07:16 +02:00
elseif ( GETPOST ( 'commandeid' ) > 0 )
2011-10-01 12:48:31 +02:00
{
2015-05-03 20:07:16 +02:00
$commande = new Commande ( $db );
$result = $commande -> fetch ( GETPOST ( 'commandeid' ));
if ( $result <= 0 )
{
dol_print_error ( $db , $commande -> error );
exit ;
}
$thirpdartyid = $commande -> socid ;
2011-10-01 12:48:31 +02:00
}
2015-05-03 20:07:16 +02:00
elseif ( GETPOST ( 'factureid' ) > 0 )
2011-10-01 12:48:31 +02:00
{
2015-05-03 20:07:16 +02:00
$facture = new Facture ( $db );
$result = $facture -> fetch ( GETPOST ( 'factureid' ));
if ( $result <= 0 )
{
dol_print_error ( $db , $facture -> error );
exit ;
}
$thirpdartyid = $facture -> socid ;
2011-10-01 12:48:31 +02:00
}
2015-09-13 00:25:32 +02:00
if ( $thirpdartyid > 0 ) {
2015-09-13 00:09:32 +02:00
$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
2015-09-13 00:09:32 +02:00
$desc = $object -> description ;
2011-08-28 14:57:23 +02:00
2015-09-13 00:09:32 +02:00
$tva_tx = get_default_tva ( $mysoc , $soc , $object -> id );
2016-02-27 11:32:49 +01:00
$tva_npr = get_default_npr ( $mysoc , $soc , $object -> id );
if ( empty ( $tva_tx )) $tva_npr = 0 ;
$localtax1_tx = get_localtax ( $tva_tx , 1 , $soc , $mysoc , $tva_npr );
$localtax2_tx = get_localtax ( $tva_tx , 2 , $soc , $mysoc , $tva_npr );
2011-08-28 14:57:23 +02:00
2015-09-13 00:09:32 +02:00
$pu_ht = $object -> price ;
$pu_ttc = $object -> price_ttc ;
$price_base_type = $object -> price_base_type ;
2014-08-01 13:25:29 +02:00
2015-09-13 00:09:32 +02:00
// 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' ;
2011-08-28 14:57:23 +02:00
2015-09-13 00:09:32 +02:00
$prodcustprice = new Productcustomerprice ( $db );
2014-08-01 13:25:29 +02:00
2015-09-13 00:09:32 +02:00
$filter = array ( 't.fk_product' => $object -> id , 't.fk_soc' => $soc -> id );
2015-05-03 20:07:16 +02:00
2015-09-13 00:09:32 +02:00
$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 ;
2016-11-05 11:09:54 +01:00
$tva_tx = $prodcustprice -> lines [ 0 ] -> tva_tx ;
2015-09-13 00:09:32 +02:00
}
}
2011-10-01 12:48:31 +02:00
}
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
2015-09-13 00:09:32 +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).
2017-03-04 21:45:19 +01:00
if ( $tmpvat != $tmpprodvat ) {
2015-09-13 00:09:32 +02:00
if ( $price_base_type != 'HT' ) {
2017-03-04 21:45:19 +01:00
$pu_ht = price2num ( $pu_ttc / ( 1 + ( $tmpvat / 100 )), 'MU' );
2015-09-13 00:09:32 +02:00
} else {
2017-03-04 21:45:19 +01:00
$pu_ttc = price2num ( $pu_ht * ( 1 + ( $tmpvat / 100 )), 'MU' );
2015-09-13 00:09:32 +02:00
}
2011-10-01 12:48:31 +02:00
}
2017-06-07 16:44:04 +02:00
2015-09-13 00:09:32 +02:00
if ( GETPOST ( 'propalid' ) > 0 ) {
2016-07-12 19:22:14 +02:00
// Define cost price for margin calculation
$buyprice = 0 ;
if (( $result = $propal -> defineBuyPrice ( $pu_ht , GETPOST ( 'remise_percent' ), $object -> id )) < 0 )
{
dol_syslog ( $langs -> trans ( 'FailedToGetCostPrice' ));
2018-07-25 15:36:50 +02:00
setEventMessages ( $langs -> trans ( 'FailedToGetCostPrice' ), null , 'errors' );
2016-07-12 19:22:14 +02:00
}
else
{
$buyprice = $result ;
}
2017-06-07 16:44:04 +02:00
2015-09-13 00:09:32 +02:00
$result = $propal -> addline (
$desc ,
$pu_ht ,
GETPOST ( 'qty' ),
$tva_tx ,
$localtax1_tx , // localtax1
$localtax2_tx , // localtax2
$object -> id ,
GETPOST ( 'remise_percent' ),
$price_base_type ,
$pu_ttc ,
0 ,
0 ,
- 1 ,
0 ,
0 ,
0 ,
2016-07-12 19:22:14 +02:00
$buyprice ,
2015-09-13 00:09:32 +02:00
'' ,
'' ,
'' ,
0 ,
$object -> fk_unit
);
if ( $result > 0 ) {
2016-04-23 15:37:22 +02:00
header ( " Location: " . DOL_URL_ROOT . " /comm/propal/card.php?id= " . $propal -> id );
2015-09-13 00:09:32 +02:00
return ;
}
2011-10-01 12:48:31 +02:00
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( " ErrorUnknown " ) . " : $result " , null , 'errors' );
2015-09-13 00:09:32 +02:00
} elseif ( GETPOST ( 'commandeid' ) > 0 ) {
2016-07-12 19:22:14 +02:00
// Define cost price for margin calculation
$buyprice = 0 ;
if (( $result = $commande -> defineBuyPrice ( $pu_ht , GETPOST ( 'remise_percent' ), $object -> id )) < 0 )
{
dol_syslog ( $langs -> trans ( 'FailedToGetCostPrice' ));
2018-07-25 15:36:50 +02:00
setEventMessages ( $langs -> trans ( 'FailedToGetCostPrice' ), null , 'errors' );
2016-07-12 19:22:14 +02:00
}
else
{
$buyprice = $result ;
}
2017-06-07 16:44:04 +02:00
2015-09-13 00:09:32 +02:00
$result = $commande -> addline (
$desc ,
$pu_ht ,
GETPOST ( 'qty' ),
$tva_tx ,
$localtax1_tx , // localtax1
$localtax2_tx , // localtax2
$object -> id ,
GETPOST ( 'remise_percent' ),
'' ,
'' ,
$price_base_type ,
$pu_ttc ,
'' ,
'' ,
0 ,
- 1 ,
0 ,
0 ,
null ,
2016-07-12 19:22:14 +02:00
$buyprice ,
2015-09-13 00:09:32 +02:00
'' ,
0 ,
$object -> fk_unit
);
if ( $result > 0 ) {
header ( " Location: " . DOL_URL_ROOT . " /commande/card.php?id= " . $commande -> id );
exit ;
}
} elseif ( GETPOST ( 'factureid' ) > 0 ) {
2016-07-12 19:22:14 +02:00
// Define cost price for margin calculation
$buyprice = 0 ;
if (( $result = $facture -> defineBuyPrice ( $pu_ht , GETPOST ( 'remise_percent' ), $object -> id )) < 0 )
{
dol_syslog ( $langs -> trans ( 'FailedToGetCostPrice' ));
2018-07-25 15:36:50 +02:00
setEventMessages ( $langs -> trans ( 'FailedToGetCostPrice' ), null , 'errors' );
2016-07-12 19:22:14 +02:00
}
else
{
$buyprice = $result ;
}
2016-11-27 20:02:57 +01:00
2015-09-13 00:09:32 +02:00
$result = $facture -> addline (
$desc ,
$pu_ht ,
GETPOST ( 'qty' ),
$tva_tx ,
$localtax1_tx ,
$localtax2_tx ,
$object -> id ,
GETPOST ( 'remise_percent' ),
'' ,
'' ,
'' ,
'' ,
'' ,
$price_base_type ,
$pu_ttc ,
Facture :: TYPE_STANDARD ,
- 1 ,
0 ,
'' ,
0 ,
0 ,
null ,
2016-07-12 19:22:14 +02:00
$buyprice ,
2015-09-13 00:09:32 +02:00
'' ,
0 ,
100 ,
'' ,
$object -> fk_unit
);
if ( $result > 0 ) {
2017-03-20 20:58:43 +01:00
header ( " Location: " . DOL_URL_ROOT . " /compta/facture/card.php?facid= " . $facture -> id );
2015-09-13 00:09:32 +02:00
exit ;
}
}
2011-10-01 12:48:31 +02:00
}
2015-09-13 00:09:32 +02:00
else {
$action = " " ;
2015-12-14 20:54:55 +01:00
setEventMessages ( $langs -> trans ( " WarningSelectOneDocument " ), null , 'warnings' );
2011-08-28 14:57:23 +02:00
}
}
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
2016-08-10 07:40:40 +02:00
$title = $langs -> trans ( 'ProductServiceCard' );
$helpurl = '' ;
$shortlabel = dol_trunc ( $object -> label , 16 );
if ( GETPOST ( " type " ) == '0' || ( $object -> type == Product :: TYPE_PRODUCT ))
{
$title = $langs -> trans ( 'Product' ) . " " . $shortlabel . " - " . $langs -> trans ( 'Card' );
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos' ;
}
if ( GETPOST ( " type " ) == '1' || ( $object -> type == Product :: TYPE_SERVICE ))
{
$title = $langs -> trans ( 'Service' ) . " " . $shortlabel . " - " . $langs -> trans ( 'Card' );
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios' ;
}
2012-07-27 21:27:03 +02:00
llxHeader ( '' , $title , $helpurl );
2011-08-31 19:36:20 +02:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2016-02-08 15:49:38 +01:00
$formfile = new FormFile ( $db );
2008-10-25 19:27:15 +02:00
$formproduct = new FormProduct ( $db );
2017-11-27 14:48:36 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) $formaccounting = new FormAccounting ( $db );
2008-10-25 19:27:15 +02:00
2016-11-29 12:06:58 +01:00
// Load object modBarCodeProduct
$res = 0 ;
if ( ! empty ( $conf -> barcode -> enabled ) && ! empty ( $conf -> global -> BARCODE_PRODUCT_ADDON_NUM ))
{
$module = strtolower ( $conf -> global -> BARCODE_PRODUCT_ADDON_NUM );
$dirbarcode = array_merge ( array ( '/core/modules/barcode/' ), $conf -> modules_parts [ 'barcode' ]);
foreach ( $dirbarcode as $dirroot )
{
$res = dol_include_once ( $dirroot . $module . '.php' );
if ( $res ) break ;
}
if ( $res > 0 )
{
$modBarCodeProduct = new $module ();
}
}
2011-12-07 19:22:12 +01:00
2011-08-27 19:25:09 +02:00
if ( is_object ( $objcanvas ) && $objcanvas -> displayCanvasExists ( $action ))
2002-12-14 17:32:49 +01:00
{
2013-06-02 00:37:33 +02:00
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
if ( empty ( $object -> error ) && $id )
{
$object = new Product ( $db );
$result = $object -> fetch ( $id );
if ( $result <= 0 ) dol_print_error ( '' , $object -> error );
}
$objcanvas -> assign_values ( $action , $object -> id , $object -> ref ); // Set value for templates
2013-04-09 23:56:52 +02:00
$objcanvas -> display_canvas ( $action ); // Show template
2011-08-27 19:25:09 +02:00
}
else
{
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
2018-02-11 13:27:02 +01:00
if ( $action == 'create' && $usercancreate )
2011-08-27 19:25:09 +02:00
{
2012-07-27 21:27:03 +02:00
//WYSIWYG Editor
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2012-08-15 09:06:36 +02:00
2012-08-09 01:41:55 +02:00
// Load object modCodeProduct
2012-08-15 09:06:36 +02:00
$module = ( ! empty ( $conf -> global -> PRODUCT_CODEPRODUCT_ADDON ) ? $conf -> global -> PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard' );
2012-08-09 01:41:55 +02:00
if ( substr ( $module , 0 , 16 ) == 'mod_codeproduct_' && substr ( $module , - 3 ) == 'php' )
{
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
2014-01-30 18:21:04 +01:00
$result = dol_include_once ( '/core/modules/product/' . $module . '.php' );
if ( $result > 0 )
{
$modCodeProduct = new $module ();
}
2012-07-27 21:27:03 +02:00
2017-06-21 11:37:34 +02:00
dol_set_focus ( 'input[name="ref"]' );
2014-03-25 19:52:04 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2011-10-01 12:48:31 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="add">' ;
2012-07-24 17:52:46 +02:00
print '<input type="hidden" name="type" value="' . $type . '">' . " \n " ;
2012-09-16 21:12:55 +02:00
if ( ! empty ( $modCodeProduct -> code_auto ))
print '<input type="hidden" name="code_auto" value="1">' ;
2014-01-30 18:21:04 +01:00
if ( ! empty ( $modBarCodeProduct -> code_auto ))
print '<input type="hidden" name="barcode_auto" value="1">' ;
2014-02-10 00:24:20 +01:00
2012-07-24 17:52:46 +02:00
if ( $type == 1 ) $title = $langs -> trans ( " NewService " );
2011-10-01 12:48:31 +02:00
else $title = $langs -> trans ( " NewProduct " );
2015-04-18 20:33:18 +02:00
$linkback = " " ;
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $title , $linkback , 'title_products.png' );
2011-10-01 12:48:31 +02:00
2015-04-12 17:08:14 +02:00
dol_fiche_head ( '' );
2016-11-27 20:02:57 +01:00
print '<table class="border centpercent">' ;
2017-06-07 16:44:04 +02:00
2011-10-01 12:48:31 +02:00
print '<tr>' ;
2012-09-16 21:12:55 +02:00
$tmpcode = '' ;
2014-01-30 18:21:04 +01:00
if ( ! empty ( $modCodeProduct -> code_auto )) $tmpcode = $modCodeProduct -> getNextValue ( $object , $type );
2017-06-21 11:37:34 +02:00
print '<td class="titlefieldcreate fieldrequired">' . $langs -> trans ( " Ref " ) . '</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="' . dol_escape_htmltag ( GETPOST ( 'ref' ) ? GETPOST ( 'ref' ) : $tmpcode ) . '">' ;
2015-06-12 13:21:21 +02:00
if ( $refalreadyexists )
2011-10-01 12:48:31 +02:00
{
print $langs -> trans ( " RefAlreadyExists " );
}
print '</td></tr>' ;
// Label
2016-11-27 20:02:57 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="' . dol_escape_htmltag ( GETPOST ( 'label' )) . '"></td></tr>' ;
2011-10-01 12:48:31 +02:00
// On sell
2014-01-28 19:11:22 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Sell " ) . ')</td><td colspan="3">' ;
2011-10-01 12:48:31 +02:00
$statutarray = array ( '1' => $langs -> trans ( " OnSell " ), '0' => $langs -> trans ( " NotOnSell " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'statut' , $statutarray , GETPOST ( 'statut' ));
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
// To buy
2014-01-28 19:11:22 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Buy " ) . ')</td><td colspan="3">' ;
2011-10-01 12:48:31 +02:00
$statutarray = array ( '1' => $langs -> trans ( " ProductStatusOnBuy " ), '0' => $langs -> trans ( " ProductStatusNotOnBuy " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'statut_buy' , $statutarray , GETPOST ( 'statut_buy' ));
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
2014-03-25 19:52:04 +01:00
// Batch number management
2014-10-02 09:30:31 +02:00
if ( ! empty ( $conf -> productbatch -> enabled ))
2014-03-25 19:52:04 +01:00
{
2014-12-03 00:42:14 +01:00
print '<tr><td>' . $langs -> trans ( " ManageLotSerial " ) . '</td><td colspan="3">' ;
2014-03-04 18:55:55 +01:00
$statutarray = array ( '0' => $langs -> trans ( " ProductStatusNotOnBatch " ), '1' => $langs -> trans ( " ProductStatusOnBatch " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'status_batch' , $statutarray , GETPOST ( 'status_batch' ));
2014-03-04 18:55:55 +01:00
print '</td></tr>' ;
}
2014-03-16 17:37:54 +01:00
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) $showbarcode = 0 ;
2014-02-10 00:24:20 +01:00
2014-01-28 19:11:22 +01:00
if ( $showbarcode )
{
2014-05-25 17:14:33 +02:00
print '<tr><td>' . $langs -> trans ( 'BarcodeType' ) . '</td><td>' ;
if ( isset ( $_POST [ 'fk_barcode_type' ]))
2014-01-28 19:11:22 +01:00
{
$fk_barcode_type = GETPOST ( 'fk_barcode_type' );
}
else
{
if ( empty ( $fk_barcode_type ) && ! empty ( $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE )) $fk_barcode_type = $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE ;
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
$formbarcode = new FormBarCode ( $db );
2018-09-10 23:50:48 +02:00
print $formbarcode -> selectBarcodeType ( $fk_barcode_type , 'fk_barcode_type' , 1 );
2014-01-28 19:11:22 +01:00
print '</td><td>' . $langs -> trans ( " BarcodeValue " ) . '</td><td>' ;
$tmpcode = isset ( $_POST [ 'barcode' ]) ? GETPOST ( 'barcode' ) : $object -> barcode ;
2014-02-19 01:51:19 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modBarCodeProduct -> code_auto )) $tmpcode = $modBarCodeProduct -> getNextValue ( $object , $type );
2016-11-27 20:02:57 +01:00
print '<input class="maxwidth100" type="text" name="barcode" value="' . dol_escape_htmltag ( $tmpcode ) . '">' ;
2014-01-28 19:11:22 +01:00
print '</td></tr>' ;
}
2014-02-10 00:24:20 +01:00
2014-01-28 19:11:22 +01:00
// Description (used in invoice, propal...)
2015-06-30 01:34:17 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td colspan="3">' ;
2014-01-28 19:11:22 +01:00
2017-09-25 00:16:52 +02:00
$doleditor = new DolEditor ( 'desc' , GETPOST ( 'desc' , 'none' ), '' , 160 , 'dolibarr_details' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_4 , '90%' );
2014-01-28 19:11:22 +01:00
$doleditor -> Create ();
print " </td></tr> " ;
2014-03-14 13:51:46 +01:00
// Public URL
2015-06-30 01:34:17 +02:00
print '<tr><td>' . $langs -> trans ( " PublicUrl " ) . '</td><td colspan="3">' ;
2016-08-28 16:17:23 +02:00
print '<input type="text" name="url" class="quatrevingtpercent" value="' . GETPOST ( 'url' ) . '">' ;
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
2012-09-15 11:21:22 +02:00
if ( $type != 1 && ! empty ( $conf -> stock -> enabled ))
2011-10-01 12:48:31 +02:00
{
2018-03-28 11:54:21 +02:00
// Default warehouse
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print $formproduct -> selectWarehouses ( GETPOST ( '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' ] . '?id=' . $object -> id . '&action=edit' ) . '">' . $langs -> trans ( " AddWarehouse " ) . '</a>' ;
print '</td>' ;
// Stock min level
2017-07-24 20:59:46 +02:00
print '<tr><td>' . $form -> textwithpicto ( $langs -> trans ( " StockLimit " ), $langs -> trans ( " StockLimitDesc " ), 1 ) . '</td><td>' ;
2016-11-27 20:02:57 +01:00
print '<input name="seuil_stock_alerte" class="maxwidth50" value="' . GETPOST ( 'seuil_stock_alerte' ) . '">' ;
2014-01-28 19:11:22 +01:00
print '</td>' ;
2013-05-30 16:32:48 +02:00
// Stock desired level
2017-07-24 20:59:46 +02:00
print '<td>' . $form -> textwithpicto ( $langs -> trans ( " DesiredStock " ), $langs -> trans ( " DesiredStockDesc " ), 1 ) . '</td><td>' ;
2016-11-27 20:02:57 +01:00
print '<input name="desiredstock" class="maxwidth50" value="' . GETPOST ( 'desiredstock' ) . '">' ;
2013-05-30 16:32:48 +02:00
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
}
else
{
print '<input name="seuil_stock_alerte" type="hidden" value="0">' ;
2013-05-30 16:32:48 +02:00
print '<input name="desiredstock" type="hidden" value="0">' ;
2011-10-01 12:48:31 +02:00
}
2013-10-23 16:24:31 +02:00
2011-10-01 12:48:31 +02:00
// Nature
2012-07-24 17:52:46 +02:00
if ( $type != 1 )
2011-10-01 12:48:31 +02:00
{
2014-01-28 19:11:22 +01:00
print '<tr><td>' . $langs -> trans ( " Nature " ) . '</td><td colspan="3">' ;
2011-10-01 12:48:31 +02:00
$statutarray = array ( '1' => $langs -> trans ( " Finished " ), '0' => $langs -> trans ( " RowMaterial " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'finished' , $statutarray , GETPOST ( 'finished' ), 1 );
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
}
2012-02-29 22:54:34 +01:00
// Duration
2012-07-24 17:52:46 +02:00
if ( $type == 1 )
2011-10-01 12:48:31 +02:00
{
2015-12-17 10:01:21 +01:00
print '<tr><td>' . $langs -> trans ( " Duration " ) . '</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="' . $duration_value . '"> ' ;
2018-06-20 12:10:25 +02:00
print '<input name="duration_unit" type="radio" value="i">' . $langs -> trans ( " Minute " ) . ' ' ;
print '<input name="duration_unit" type="radio" value="h">' . $langs -> trans ( " Hour " ) . ' ' ;
2011-10-01 12:48:31 +02:00
print '<input name="duration_unit" type="radio" value="d">' . $langs -> trans ( " Day " ) . ' ' ;
print '<input name="duration_unit" type="radio" value="w">' . $langs -> trans ( " Week " ) . ' ' ;
print '<input name="duration_unit" type="radio" value="m">' . $langs -> trans ( " Month " ) . ' ' ;
print '<input name="duration_unit" type="radio" value="y">' . $langs -> trans ( " Year " ) . ' ' ;
print '</td></tr>' ;
}
2012-07-24 17:52:46 +02:00
if ( $type != 1 ) // Le poids et le volume ne concerne que les produits et pas les services
2011-10-01 12:48:31 +02:00
{
// Weight
2014-01-28 19:11:22 +01:00
print '<tr><td>' . $langs -> trans ( " Weight " ) . '</td><td colspan="3">' ;
2012-07-24 17:52:46 +02:00
print '<input name="weight" size="4" value="' . GETPOST ( 'weight' ) . '">' ;
2011-10-01 12:48:31 +02:00
print $formproduct -> select_measuring_units ( " weight_units " , " weight " );
print '</td></tr>' ;
// Length
2016-12-10 13:25:33 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ))
2016-02-22 13:11:46 +01:00
{
2017-01-16 10:43:22 +01:00
print '<tr><td>' . $langs -> trans ( " Length " ) . ' x ' . $langs -> trans ( " Width " ) . ' x ' . $langs -> trans ( " Height " ) . '</td><td colspan="3">' ;
print '<input name="size" size="4" value="' . GETPOST ( 'size' ) . '"> x ' ;
print '<input name="sizewidth" size="4" value="' . GETPOST ( 'sizewidth' ) . '"> x ' ;
2016-12-10 13:25:33 +01:00
print '<input name="sizeheight" size="4" value="' . GETPOST ( 'sizeheight' ) . '">' ;
2016-02-22 13:11:46 +01:00
print $formproduct -> select_measuring_units ( " size_units " , " size " );
print '</td></tr>' ;
}
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE ))
{
// Surface
print '<tr><td>' . $langs -> trans ( " Surface " ) . '</td><td colspan="3">' ;
print '<input name="surface" size="4" value="' . GETPOST ( 'surface' ) . '">' ;
print $formproduct -> select_measuring_units ( " surface_units " , " surface " );
print '</td></tr>' ;
}
2018-08-31 10:57:01 +02:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME ))
2018-09-02 15:30:56 +02:00
{
2018-08-31 10:57:01 +02:00
// Volume
print '<tr><td>' . $langs -> trans ( " Volume " ) . '</td><td colspan="3">' ;
print '<input name="volume" size="4" value="' . GETPOST ( 'volume' ) . '">' ;
print $formproduct -> select_measuring_units ( " volume_units " , " volume " );
print '</td></tr>' ;
}
2011-10-01 12:48:31 +02:00
}
2010-05-26 17:03:11 +02:00
2015-07-12 18:05:56 +02:00
// Units
if ( $conf -> global -> PRODUCT_USE_UNITS )
{
print '<tr><td>' . $langs -> trans ( 'DefaultUnitToShow' ) . '</td>' ;
print '<td colspan="3">' ;
print $form -> selectUnits ( '' , 'units' );
print '</td></tr>' ;
}
2014-03-25 19:52:04 +01:00
// Custom code
2016-07-11 11:43:59 +02:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_CUSTOM_INFO ) && empty ( $type ))
2014-03-25 19:52:04 +01:00
{
2016-11-27 20:02:57 +01:00
print '<tr><td>' . $langs -> trans ( " CustomCode " ) . '</td><td><input name="customcode" class="maxwidth100onsmartphone" value="' . GETPOST ( 'customcode' ) . '"></td>' ;
2014-03-25 19:52:04 +01:00
// Origin country
print '<td>' . $langs -> trans ( " CountryOrigin " ) . '</td><td>' ;
print $form -> select_country ( GETPOST ( 'country_id' , 'int' ), 'country_id' );
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
print '</td></tr>' ;
}
2010-11-02 12:22:41 +01:00
2012-02-06 17:18:19 +01:00
// Other attributes
2018-06-23 15:13:39 +02:00
$parameters = array ( 'colspan' => 3 );
2012-02-06 17:18:19 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2013-04-03 18:37:54 +02:00
{
2014-02-12 00:23:15 +01:00
print $object -> showOptionals ( $extrafields , 'edit' , $parameters );
2012-02-06 17:18:19 +01:00
}
// Note (private, no output on invoices, propales...)
2016-07-28 13:53:17 +02:00
//if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode
//{
print '<tr><td class="tdtop">' . $langs -> trans ( " NoteNotVisibleOnBill " ) . '</td><td colspan="3">' ;
2017-06-07 16:44:04 +02:00
2016-07-28 13:53: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.
2017-09-25 00:16:52 +02:00
$doleditor = new DolEditor ( 'note_private' , GETPOST ( 'note_private' , 'none' ), '' , 140 , 'dolibarr_details' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_8 , '90%' );
2016-07-28 13:53:17 +02:00
$doleditor -> Create ();
2017-06-07 16:44:04 +02:00
2016-07-28 13:53: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
2015-06-27 23:01:05 +02:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
2015-06-19 14:30:23 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_PRODUCT , '' , 'parent' , 64 , 0 , 1 );
2018-02-04 14:34:31 +01:00
print $form -> multiselectarray ( 'categories' , $cate_arbo , GETPOST ( 'categories' , 'array' ), '' , 0 , '' , 0 , '100%' );
2015-06-19 14:30:23 +02:00
print " </td></tr> " ;
}
2015-02-26 14:15:33 +01:00
2011-10-01 12:48:31 +02:00
print '</table>' ;
2010-05-26 17:03:11 +02:00
2011-10-01 12:48:31 +02:00
print '<br>' ;
2010-05-26 17:03:11 +02:00
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ))
2011-10-01 12:48:31 +02:00
{
// We do no show price array on create when multiprices enabled.
// We must set them on prices tab.
2017-10-19 18:33:15 +02:00
print '<table class="border" width="100%">' ;
// 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>' ;
print '<br>' ;
2011-10-01 12:48:31 +02:00
}
else
2014-02-19 01:51:19 +01:00
{
2011-10-01 12:48:31 +02:00
print '<table class="border" width="100%">' ;
2010-05-26 17:03:11 +02:00
2015-07-16 05:31:05 +02:00
// Price
2016-11-27 20:02:57 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " SellingPrice " ) . '</td>' ;
print '<td><input name="price" class="maxwidth50" value="' . $object -> price . '">' ;
2015-06-06 14:21:18 +02:00
print $form -> selectPriceBaseType ( $object -> price_base_type , " price_base_type " );
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
2010-05-26 17:03:11 +02:00
2015-07-16 05:31:05 +02:00
// Min price
2011-10-01 12:48:31 +02:00
print '<tr><td>' . $langs -> trans ( " MinPrice " ) . '</td>' ;
2016-11-27 20:02:57 +01:00
print '<td><input name="price_min" class="maxwidth50" value="' . $object -> price_min . '">' ;
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
2010-05-26 17:03:11 +02:00
2011-10-01 12:48:31 +02:00
// VAT
2016-11-27 20:02:57 +01:00
print '<tr><td>' . $langs -> trans ( " VATRate " ) . '</td><td>' ;
2017-06-23 12:09:21 +02:00
$defaultva = get_default_tva ( $mysoc , $mysoc );
print $form -> load_tva ( " tva_tx " , $defaultva , $mysoc , $mysoc , 0 , 0 , '' , false , 1 );
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
2010-05-26 17:03:11 +02:00
2011-10-01 12:48:31 +02:00
print '</table>' ;
2010-05-26 17:03:11 +02:00
2011-10-01 12:48:31 +02:00
print '<br>' ;
}
2014-02-10 00:24:20 +01:00
2016-11-27 20:02:57 +01:00
// Accountancy codes
2015-07-16 05:31:05 +02:00
print '<table class="border" width="100%">' ;
2017-05-21 15:24:16 +02:00
2015-12-17 06:16:29 +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>' ;
print $formaccounting -> select_account ( GETPOST ( 'accountancy_code_sell' ), 'accountancy_code_sell' , 1 , null , 1 , 1 , '' );
print '</td></tr>' ;
2017-11-06 09:30:30 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL )
{
// Accountancy_code_sell_intra
if ( $mysoc -> isInEEC ())
{
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
print '<td>' ;
print $formaccounting -> select_account ( GETPOST ( 'accountancy_code_sell_intra' ), 'accountancy_code_sell_intra' , 1 , null , 1 , 1 , '' );
print '</td></tr>' ;
}
2014-02-02 18:26:17 +01:00
2017-11-06 09:30:30 +01:00
// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
print '<td>' ;
print $formaccounting -> select_account ( GETPOST ( 'accountancy_code_sell_export' ), 'accountancy_code_sell_export' , 1 , null , 1 , 1 , '' );
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td>' ;
2017-05-25 06:57:28 +02:00
print $formaccounting -> select_account ( GETPOST ( 'accountancy_code_buy' ), 'accountancy_code_buy' , 1 , null , 1 , 1 , '' );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2017-05-21 15:24:16 +02:00
}
2017-06-07 16:44:04 +02:00
else // For external software
2015-12-17 06:16:29 +01:00
{
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="' . $object -> accountancy_code_sell . '">' ;
print '</td></tr>' ;
2014-02-02 18:26:17 +01:00
2017-11-06 09:30:30 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL )
{
// Accountancy_code_sell_intra
if ( $mysoc -> isInEEC ())
{
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="' . $object -> accountancy_code_sell_intra . '">' ;
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
2017-11-06 09:30:30 +01:00
// Accountancy_code_sell_export
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_export" 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 class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="' . $object -> accountancy_code_buy . '">' ;
print '</td></tr>' ;
}
2015-12-17 06:16:29 +01:00
print '</table>' ;
2010-05-05 11:05:50 +02:00
2017-11-01 07:19:36 +01:00
dol_fiche_end ();
2015-04-12 17:08:14 +02:00
2016-08-12 22:53:30 +02:00
print '<div class="center">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Create " ) . '">' ;
2017-11-01 07:19:36 +01:00
print ' ' ;
2016-08-12 22:53:30 +02:00
print '<input type="button" class="button" value="' . $langs -> trans ( " Cancel " ) . '" onClick="javascript:history.go(-1)">' ;
print '</div>' ;
2006-12-15 16:13:38 +01:00
2017-11-01 07:19:36 +01:00
print '</form>' ;
}
2010-05-08 18:29:37 +02:00
2012-04-06 22:39:40 +02:00
/*
2011-08-27 19:25:09 +02:00
* Product card
*/
2010-05-26 16:52:32 +02:00
2013-01-15 11:23:24 +01:00
else if ( $object -> id > 0 )
2011-08-27 19:25:09 +02:00
{
2012-03-04 01:09:39 +01:00
// Fiche en mode edition
2018-04-03 20:23:47 +02:00
if ( $action == 'edit' && $usercancreate )
{
2012-07-27 21:27:03 +02:00
//WYSIWYG Editor
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2012-07-27 21:27:03 +02:00
2011-10-01 12:48:31 +02:00
$type = $langs -> trans ( 'Product' );
2015-11-07 14:37:47 +01:00
if ( $object -> isService ()) $type = $langs -> trans ( 'Service' );
2015-09-24 18:33:48 +02:00
//print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
2011-10-01 12:48:31 +02:00
// Main official, simple, and not duplicated code
2015-04-22 23:27:09 +02:00
print '<form action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '" method="POST">' . " \n " ;
2011-10-01 12:48:31 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ '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
$head = product_prepare_head ( $object );
$titre = $langs -> trans ( " CardProduct " . $object -> type );
$picto = ( $object -> type == Product :: TYPE_SERVICE ? 'service' : 'product' );
dol_fiche_head ( $head , 'card' , $titre , 0 , $picto );
2012-04-06 22:39:40 +02:00
print '<table class="border allwidth">' ;
2011-10-01 12:48:31 +02:00
// Ref
2016-11-27 20:02:57 +01:00
print '<tr><td class="titlefield 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
// Label
2016-11-27 20:02:57 +01:00
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
2014-02-19 01:51:19 +01:00
// Status To sell
2014-01-28 19:11:22 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Sell " ) . ')</td><td colspan="3">' ;
2011-10-01 12:48:31 +02:00
print '<select class="flat" name="statut">' ;
if ( $object -> status )
{
2015-05-07 12:20:20 +02:00
print '<option value="1" selected>' . $langs -> trans ( " OnSell " ) . '</option>' ;
2011-10-01 12:48:31 +02:00
print '<option value="0">' . $langs -> trans ( " NotOnSell " ) . '</option>' ;
}
else
{
print '<option value="1">' . $langs -> trans ( " OnSell " ) . '</option>' ;
2015-05-07 12:20:20 +02:00
print '<option value="0" selected>' . $langs -> trans ( " NotOnSell " ) . '</option>' ;
2011-10-01 12:48:31 +02:00
}
print '</select>' ;
print '</td></tr>' ;
2014-02-19 01:51:19 +01:00
// Status To Buy
2014-01-28 19:11:22 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Status " ) . ' (' . $langs -> trans ( " Buy " ) . ')</td><td colspan="3">' ;
2011-10-01 12:48:31 +02:00
print '<select class="flat" name="statut_buy">' ;
if ( $object -> status_buy )
{
2015-05-07 12:20:20 +02:00
print '<option value="1" selected>' . $langs -> trans ( " ProductStatusOnBuy " ) . '</option>' ;
2011-10-01 12:48:31 +02:00
print '<option value="0">' . $langs -> trans ( " ProductStatusNotOnBuy " ) . '</option>' ;
}
else
{
print '<option value="1">' . $langs -> trans ( " ProductStatusOnBuy " ) . '</option>' ;
2015-05-07 12:20:20 +02:00
print '<option value="0" selected>' . $langs -> trans ( " ProductStatusNotOnBuy " ) . '</option>' ;
2011-10-01 12:48:31 +02:00
}
print '</select>' ;
print '</td></tr>' ;
2014-03-04 18:55:55 +01:00
// Batch number managment
2018-04-12 23:16:23 +02:00
if ( $conf -> productbatch -> enabled )
2018-04-03 20:23:47 +02:00
{
if ( $object -> isProduct () || ! empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES ))
{
print '<tr><td>' . $langs -> trans ( " ManageLotSerial " ) . '</td><td colspan="3">' ;
$statutarray = array ( '0' => $langs -> trans ( " ProductStatusNotOnBatch " ), '1' => $langs -> trans ( " ProductStatusOnBatch " ));
print $form -> selectarray ( 'status_batch' , $statutarray , $object -> status_batch );
print '</td></tr>' ;
}
2014-03-04 18:55:55 +01:00
}
2014-02-19 01:51:19 +01:00
// Barcode
2014-03-16 17:37:54 +01:00
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) $showbarcode = 0 ;
2014-02-19 01:51:19 +01:00
if ( $showbarcode )
{
print '<tr><td>' . $langs -> trans ( 'BarcodeType' ) . '</td><td>' ;
if ( isset ( $_POST [ 'fk_barcode_type' ]))
{
$fk_barcode_type = GETPOST ( 'fk_barcode_type' );
}
else
{
2014-05-25 17:14:33 +02:00
$fk_barcode_type = $object -> barcode_type ;
2014-02-19 01:51:19 +01:00
if ( empty ( $fk_barcode_type ) && ! empty ( $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE )) $fk_barcode_type = $conf -> global -> PRODUIT_DEFAULT_BARCODE_TYPE ;
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
$formbarcode = new FormBarCode ( $db );
2018-09-10 23:50:48 +02:00
print $formbarcode -> selectBarcodeType ( $fk_barcode_type , 'fk_barcode_type' , 1 );
2014-02-19 01:51:19 +01:00
print '</td><td>' . $langs -> trans ( " BarcodeValue " ) . '</td><td>' ;
$tmpcode = isset ( $_POST [ 'barcode' ]) ? GETPOST ( 'barcode' ) : $object -> barcode ;
if ( empty ( $tmpcode ) && ! empty ( $modBarCodeProduct -> code_auto )) $tmpcode = $modBarCodeProduct -> getNextValue ( $object , $type );
2016-08-28 16:17:23 +02:00
print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="' . dol_escape_htmltag ( $tmpcode ) . '">' ;
2014-02-19 01:51:19 +01:00
print '</td></tr>' ;
}
2011-10-01 12:48:31 +02:00
// Description (used in invoice, propal...)
2015-06-30 01:34:17 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td colspan="3">' ;
2012-08-15 09:06:36 +02:00
2014-03-14 13:51:46 +01: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.
2016-11-25 17:47:47 +01:00
$doleditor = new DolEditor ( 'desc' , $object -> description , '' , 160 , 'dolibarr_details' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_4 , '90%' );
2011-10-01 12:48:31 +02:00
$doleditor -> Create ();
2012-07-27 21:27:03 +02:00
2011-10-01 12:48:31 +02:00
print " </td></tr> " ;
print " \n " ;
2014-03-14 13:51:46 +01:00
// Public Url
2015-06-30 01:34:17 +02:00
print '<tr><td>' . $langs -> trans ( " PublicUrl " ) . '</td><td colspan="3">' ;
2016-08-28 16:17:23 +02:00
print '<input type="text" name="url" class="quatrevingtpercent" value="' . $object -> url . '">' ;
2014-03-14 13:51:46 +01:00
print '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2014-01-28 19:11:22 +01:00
// Stock
2015-11-07 14:37:47 +01:00
if ( $object -> isProduct () && ! empty ( $conf -> stock -> enabled ))
2011-10-01 12:48:31 +02:00
{
2018-03-28 11:54:21 +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' )) . '">' . $langs -> trans ( " AddWarehouse " ) . '</a>' ;
print '</td>' ;
/*
2014-01-28 19:11:22 +01:00
print " <tr> " . '<td>' . $langs -> trans ( " StockLimit " ) . '</td><td>' ;
2011-10-01 12:48:31 +02:00
print '<input name="seuil_stock_alerte" size="4" value="' . $object -> seuil_stock_alerte . '">' ;
2014-01-28 19:11:22 +01:00
print '</td>' ;
2013-10-23 16:24:31 +02:00
2014-01-28 19:11:22 +01:00
print '<td>' . $langs -> trans ( " DesiredStock " ) . '</td><td>' ;
2013-05-30 16:32:48 +02:00
print '<input name="desiredstock" size="4" value="' . $object -> desiredstock . '">' ;
print '</td></tr>' ;
2018-03-28 11:54:21 +02:00
*/
2011-10-01 12:48:31 +02:00
}
2018-03-28 11:54:21 +02:00
/*
2011-10-01 12:48:31 +02:00
else
{
print '<input name="seuil_stock_alerte" type="hidden" value="' . $object -> seuil_stock_alerte . '">' ;
2013-05-30 16:32:48 +02:00
print '<input name="desiredstock" type="hidden" value="' . $object -> desiredstock . '">' ;
2015-03-11 14:55:45 +01:00
} */
2011-10-01 12:48:31 +02:00
2014-01-28 19:11:22 +01:00
// Nature
2015-03-30 03:14:07 +02:00
if ( $object -> type != Product :: TYPE_SERVICE )
2014-01-28 19:11:22 +01:00
{
print '<tr><td>' . $langs -> trans ( " Nature " ) . '</td><td colspan="3">' ;
$statutarray = array ( '-1' => ' ' , '1' => $langs -> trans ( " Finished " ), '0' => $langs -> trans ( " RowMaterial " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'finished' , $statutarray , $object -> finished );
2014-01-28 19:11:22 +01:00
print '</td></tr>' ;
}
2015-11-07 14:37:47 +01:00
if ( $object -> isService ())
2011-10-01 12:48:31 +02:00
{
// Duration
2014-01-28 19:11:22 +01:00
print '<tr><td>' . $langs -> trans ( " Duration " ) . '</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="' . $object -> duration_value . '">' ;
2011-10-01 12:48:31 +02:00
print ' ' ;
2018-06-20 12:10:25 +02:00
print '<input name="duration_unit" type="radio" value="i"' . ( $object -> duration_unit == 'i' ? ' checked' : '' ) . '>' . $langs -> trans ( " Minute " );
print ' ' ;
2011-10-01 12:48:31 +02:00
print '<input name="duration_unit" type="radio" value="h"' . ( $object -> duration_unit == 'h' ? ' checked' : '' ) . '>' . $langs -> trans ( " Hour " );
print ' ' ;
print '<input name="duration_unit" type="radio" value="d"' . ( $object -> duration_unit == 'd' ? ' checked' : '' ) . '>' . $langs -> trans ( " Day " );
print ' ' ;
print '<input name="duration_unit" type="radio" value="w"' . ( $object -> duration_unit == 'w' ? ' checked' : '' ) . '>' . $langs -> trans ( " Week " );
print ' ' ;
print '<input name="duration_unit" type="radio" value="m"' . ( $object -> duration_unit == 'm' ? ' checked' : '' ) . '>' . $langs -> trans ( " Month " );
print ' ' ;
print '<input name="duration_unit" type="radio" value="y"' . ( $object -> duration_unit == 'y' ? ' checked' : '' ) . '>' . $langs -> trans ( " Year " );
print '</td></tr>' ;
}
else
2015-07-12 18:05:56 +02:00
{
2011-10-01 12:48:31 +02:00
// Weight
2014-01-28 19:11:22 +01:00
print '<tr><td>' . $langs -> trans ( " Weight " ) . '</td><td colspan="3">' ;
2011-10-01 12:48:31 +02:00
print '<input name="weight" size="5" value="' . $object -> weight . '"> ' ;
print $formproduct -> select_measuring_units ( " weight_units " , " weight " , $object -> weight_units );
print '</td></tr>' ;
2016-12-10 13:25:33 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ))
2016-02-22 13:11:46 +01:00
{
2017-01-16 10:43:22 +01:00
// Length
print '<tr><td>' . $langs -> trans ( " Length " ) . ' x ' . $langs -> trans ( " Width " ) . ' x ' . $langs -> trans ( " Height " ) . '</td><td colspan="3">' ;
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 -> select_measuring_units ( " size_units " , " size " , $object -> length_units );
print '</td></tr>' ;
2016-02-22 13:11:46 +01:00
}
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE ))
{
// Surface
print '<tr><td>' . $langs -> trans ( " Surface " ) . '</td><td colspan="3">' ;
print '<input name="surface" size="5" value="' . $object -> surface . '"> ' ;
print $formproduct -> select_measuring_units ( " surface_units " , " surface " , $object -> surface_units );
print '</td></tr>' ;
}
2017-01-16 10:43:22 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME ))
{
// Volume
print '<tr><td>' . $langs -> trans ( " Volume " ) . '</td><td colspan="3">' ;
print '<input name="volume" size="5" value="' . $object -> volume . '"> ' ;
print $formproduct -> select_measuring_units ( " volume_units " , " volume " , $object -> volume_units );
print '</td></tr>' ;
}
2011-10-01 12:48:31 +02:00
}
2015-07-12 18:05:56 +02:00
// Units
if ( $conf -> global -> PRODUCT_USE_UNITS )
{
print '<tr><td>' . $langs -> trans ( 'DefaultUnitToShow' ) . '</td>' ;
print '<td colspan="3">' ;
print $form -> selectUnits ( $object -> fk_unit , 'units' );
print '</td></tr>' ;
}
2010-05-26 16:52:32 +02:00
2014-03-25 19:52:04 +01:00
// Custom code
2016-06-30 19:35:11 +02:00
if ( ! $object -> isService () && empty ( $conf -> global -> PRODUCT_DISABLE_CUSTOM_INFO ))
2014-03-25 19:52:04 +01:00
{
2016-11-27 20:02:57 +01:00
print '<tr><td>' . $langs -> trans ( " CustomCode " ) . '</td><td><input name="customcode" class="maxwidth100onsmartphone" value="' . $object -> customcode . '"></td>' ;
2014-03-25 19:52:04 +01:00
// Origin country
print '<td>' . $langs -> trans ( " CountryOrigin " ) . '</td><td>' ;
2016-08-28 16:17:23 +02:00
print $form -> select_country ( $object -> country_id , 'country_id' , '' , 0 , 'minwidth100 maxwidthonsmartphone' );
2014-03-25 19:52:04 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
print '</td></tr>' ;
}
2010-11-02 12:22:41 +01:00
2012-02-06 17:18:19 +01:00
// Other attributes
2017-06-07 16:44:04 +02:00
$parameters = array ( 'colspan' => ' colspan="3"' , 'cols' => 3 );
2012-02-06 17:18:19 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2012-02-06 17:18:19 +01:00
{
2013-04-01 18:59:41 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
2012-02-06 17:18:19 +01:00
}
2015-11-06 18:57:35 +01:00
// Tags-Categories
2017-06-07 16:44:04 +02:00
if ( $conf -> categorie -> enabled )
2015-11-06 18:57:35 +01:00
{
2015-06-30 01:34:17 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
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 );
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_PRODUCT );
2018-02-04 14:34:31 +01:00
$arrayselected = array ();
2015-06-19 14:30:23 +02:00
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'categories' , $cate_arbo , $arrayselected , '' , 0 , '' , 0 , '100%' );
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
2016-07-28 13:53:17 +02:00
// Note private
if ( ! empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB ))
{
print '<tr><td class="tdtop">' . $langs -> trans ( " NoteNotVisibleOnBill " ) . '</td><td colspan="3">' ;
2017-06-07 16:44:04 +02:00
2016-11-25 17:47:47 +01:00
$doleditor = new DolEditor ( 'note_private' , $object -> note_private , '' , 140 , 'dolibarr_notes' , '' , false , true , $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC , ROWS_4 , '90%' );
2016-07-28 13:53:17 +02:00
$doleditor -> Create ();
2017-06-07 16:44:04 +02:00
2016-07-28 13:53:17 +02:00
print " </td></tr> " ;
}
2017-06-07 16:44:04 +02:00
2011-10-01 12:48:31 +02:00
print '</table>' ;
print '<br>' ;
2014-02-10 00:24:20 +01:00
2015-12-17 06:16:29 +01:00
print '<table class="border" width="100%">' ;
if ( ! empty ( $conf -> accounting -> enabled ))
{
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
print '<td>' ;
2017-05-25 06:57:28 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_sell , 'accountancy_code_sell' , 1 , '' , 1 , 1 );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2014-02-10 00:24:20 +01:00
2017-11-06 09:30:30 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL )
{
// Accountancy_code_sell_intra
if ( $mysoc -> isInEEC ())
{
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
print '<td>' ;
print $formaccounting -> select_account ( $object -> accountancy_code_sell_intra , 'accountancy_code_sell_intra' , 1 , '' , 1 , 1 );
print '</td></tr>' ;
}
// Accountancy_code_sell_export
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
print '<td>' ;
print $formaccounting -> select_account ( $object -> accountancy_code_sell_export , 'accountancy_code_sell_export' , 1 , '' , 1 , 1 );
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
// Accountancy_code_buy
print '<tr><td>' . $langs -> trans ( " ProductAccountancyBuyCode " ) . '</td>' ;
print '<td>' ;
2017-05-25 06:57:28 +02:00
print $formaccounting -> select_account ( $object -> accountancy_code_buy , 'accountancy_code_buy' , 1 , '' , 1 , 1 );
2017-11-01 07:19:36 +01:00
print '</td></tr>' ;
2017-05-25 06:57:28 +02:00
}
2017-06-07 16:44:04 +02:00
else // For external software
2015-12-17 06:16:29 +01:00
{
2017-11-01 07:19:36 +01:00
// Accountancy_code_sell
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellCode " ) . '</td>' ;
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
2017-11-06 09:30:30 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL )
{
// Accountancy_code_sell_intra
if ( $mysoc -> isInEEC ())
{
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellIntraCode " ) . '</td>' ;
print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="' . $object -> accountancy_code_sell_intra . '">' ;
print '</td></tr>' ;
}
// Accountancy_code_sell_export
print '<tr><td class="titlefield">' . $langs -> trans ( " ProductAccountancySellExportCode " ) . '</td>' ;
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>' ;
}
2015-12-17 06:16:29 +01:00
print '</table>' ;
2014-02-10 00:24:20 +01:00
2017-11-01 07:19:36 +01:00
dol_fiche_end ();
2015-05-03 15:51:55 +02:00
2017-11-01 07:19:36 +01:00
print '<div class="center">' ;
2014-11-25 20:13:43 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Save " ) . '">' ;
print ' ' ;
2017-11-01 07:19:36 +01:00
print '<input type="submit" class="button" 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>' ;
}
2012-03-04 01:09:39 +01:00
// Fiche en mode visu
2011-10-01 12:48:31 +02:00
else
2014-02-19 01:51:19 +01:00
{
2014-03-16 17:37:54 +01:00
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) $showbarcode = 0 ;
2011-05-14 00:04:52 +02:00
2015-11-06 18:57:35 +01: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
2017-05-22 15:20:52 +02:00
dol_fiche_head ( $head , 'card' , $titre , - 1 , $picto );
2011-10-01 12:48:31 +02:00
2017-10-03 16:00:52 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/product/list.php?restore_lastsearch_values=1&type=' . $object -> type . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-12-10 22:54:13 +01:00
$object -> next_prev_filter = " fk_product_type = " . $object -> type ;
2017-06-12 16:26:25 +02:00
$shownav = 1 ;
if ( $user -> societe_id && ! in_array ( 'product' , explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL ))) $shownav = 0 ;
dol_banner_tab ( $object , 'ref' , $linkback , $shownav , 'ref' );
2017-06-07 16:44:04 +02:00
2015-11-06 18:57:35 +01:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2017-06-07 16:44:04 +02:00
2015-11-06 18:57:35 +01:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2017-06-07 16:44:04 +02:00
2018-02-11 12:09:12 +01:00
// Type
if ( ! empty ( $conf -> produit -> enabled ) && ! empty ( $conf -> service -> enabled ))
{
// TODO change for compatibility with edit in place
$typeformat = 'select;0:' . $langs -> trans ( " Product " ) . ',1:' . $langs -> trans ( " Service " );
2018-02-11 13:27:02 +01:00
print '<tr><td class="titlefield">' . $form -> editfieldkey ( " Type " , 'fk_product_type' , $object -> type , $object , $usercancreate , $typeformat ) . '</td><td colspan="2">' ;
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
2011-12-07 12:58:39 +01:00
if ( $showbarcode )
{
// Barcode type
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
2011-12-07 12:58:39 +01:00
print $langs -> trans ( " BarcodeType " );
2015-12-17 12:57:08 +01:00
print '</td>' ;
2018-02-11 13:27:02 +01:00
if (( $action != 'editbarcodetype' ) && $usercancreate && $createbarcode ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editbarcodetype&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'Edit' ), 1 ) . '</a></td>' ;
2011-12-07 12:58:39 +01:00
print '</tr></table>' ;
print '</td><td colspan="2">' ;
2016-11-29 12:06:58 +01:00
if ( $action == 'editbarcodetype' || $action == 'editbarcode' )
2011-12-07 12:58:39 +01:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php' ;
2011-12-07 15:06:29 +01:00
$formbarcode = new FormBarCode ( $db );
2018-04-03 20:23:47 +02:00
}
2016-11-29 12:06:58 +01:00
if ( $action == 'editbarcodetype' )
{
2018-09-10 23:58:57 +02:00
print $formbarcode -> formBarcodeType ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> barcode_type , 'fk_barcode_type' );
2011-12-07 12:58:39 +01:00
}
else
{
2011-12-07 15:06:29 +01:00
$object -> fetch_barcode ();
2012-02-29 22:54:34 +01:00
print $object -> barcode_type_label ? $object -> barcode_type_label : ( $object -> barcode ? '<div class="warning">' . $langs -> trans ( " SetDefaultBarcodeType " ) . '<div>' : '' );
2011-12-07 12:58:39 +01:00
}
print '</td></tr>' . " \n " ;
// Barcode value
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
2011-12-07 12:58:39 +01:00
print $langs -> trans ( " BarcodeValue " );
2015-12-17 12:57:08 +01:00
print '</td>' ;
2018-02-11 13:27:02 +01:00
if (( $action != 'editbarcode' ) && $usercancreate && $createbarcode ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editbarcode&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'Edit' ), 1 ) . '</a></td>' ;
2011-12-07 12:58:39 +01:00
print '</tr></table>' ;
print '</td><td colspan="2">' ;
2012-04-06 22:39:40 +02:00
if ( $action == 'editbarcode' )
2011-12-07 12:58:39 +01:00
{
2018-01-22 21:07:10 +01:00
$tmpcode = isset ( $_POST [ 'barcode' ]) ? GETPOST ( 'barcode' ) : $object -> barcode ;
if ( empty ( $tmpcode ) && ! empty ( $modBarCodeProduct -> code_auto )) $tmpcode = $modBarCodeProduct -> getNextValue ( $object , $type );
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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>' ;
2011-12-07 12:58:39 +01:00
}
else
{
2018-01-22 21:07:10 +01:00
print $object -> barcode ;
2011-12-07 12:58:39 +01:00
}
print '</td></tr>' . " \n " ;
}
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 " );
print '</td><td colspan="2">' ;
2017-05-21 15:24:16 +02:00
if ( ! empty ( $conf -> accounting -> enabled ))
{
2018-08-29 21:07:00 +02:00
if ( ! empty ( $object -> accountancy_code_sell ))
{
$accountingaccount = new AccountingAccount ( $db );
$accountingaccount -> fetch ( '' , $object -> accountancy_code_sell , 1 );
2017-05-21 15:24:16 +02:00
2018-08-29 21:07:00 +02:00
print $accountingaccount -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
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
2017-11-06 09:30:30 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL )
2017-05-21 15:24:16 +02:00
{
2017-11-06 09:30:30 +01:00
// Accountancy sell code intra-community
if ( $mysoc -> isInEEC ())
{
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancySellIntraCode " );
print '</td><td colspan="2">' ;
if ( ! empty ( $conf -> accounting -> enabled ))
{
2018-08-29 21:07:00 +02:00
if ( ! empty ( $object -> accountancy_code_sell_intra ))
{
$accountingaccount2 = new AccountingAccount ( $db );
$accountingaccount2 -> fetch ( '' , $object -> accountancy_code_sell_intra , 1 );
2017-11-06 09:30:30 +01:00
2018-08-29 21:07:00 +02:00
print $accountingaccount2 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
2017-11-06 09:30:30 +01:00
} else {
print $object -> accountancy_code_sell_intra ;
}
print '</td></tr>' ;
}
2017-11-01 07:19:36 +01:00
2017-11-06 09:30:30 +01:00
// Accountancy sell code export
print '<tr><td class="nowrap">' ;
print $langs -> trans ( " ProductAccountancySellExportCode " );
print '</td><td colspan="2">' ;
if ( ! empty ( $conf -> accounting -> enabled ))
{
2018-08-29 21:07:00 +02:00
if ( ! empty ( $object -> accountancy_code_sell_export ))
{
$accountingaccount3 = new AccountingAccount ( $db );
$accountingaccount3 -> fetch ( '' , $object -> accountancy_code_sell_export , 1 );
2017-11-01 07:19:36 +01:00
2018-08-29 21:07:00 +02:00
print $accountingaccount3 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
2017-11-06 09:30:30 +01:00
} 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 " );
print '</td><td colspan="2">' ;
if ( ! empty ( $conf -> accounting -> enabled ))
{
2018-08-29 21:07:00 +02:00
if ( ! empty ( $object -> accountancy_code_buy ))
{
$accountingaccount4 = new AccountingAccount ( $db );
$accountingaccount4 -> fetch ( '' , $object -> accountancy_code_buy , 1 );
2017-11-01 07:19:36 +01:00
2018-08-29 21:07:00 +02:00
print $accountingaccount4 -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
}
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
2014-10-23 11:02:16 +02:00
// Batch number management (to batch)
2018-04-12 23:16:23 +02:00
if ( ! empty ( $conf -> productbatch -> enabled ))
2018-04-03 20:23:47 +02:00
{
if ( $object -> isProduct () || ! empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES ))
{
print '<tr><td>' . $langs -> trans ( " ManageLotSerial " ) . '</td><td colspan="2">' ;
if ( ! empty ( $conf -> use_javascript_ajax ) && $usercancreate && ! empty ( $conf -> global -> MAIN_DIRECT_STATUS_UPDATE )) {
print ajax_object_onoff ( $object , 'status_batch' , 'tobatch' , 'ProductStatusOnBatch' , 'ProductStatusNotOnBatch' );
} else {
print $object -> getLibStatut ( 0 , 2 );
}
print '</td></tr>' ;
}
2014-10-23 11:02:16 +02:00
}
2014-03-04 18:55:55 +01:00
2011-10-01 12:48:31 +02:00
// Description
2015-06-30 01:34:17 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td colspan="2">' . ( dol_textishtml ( $object -> description ) ? $object -> description : dol_nl2br ( $object -> description , 1 , true )) . '</td></tr>' ;
2011-10-01 12:48:31 +02:00
2014-03-14 13:51:46 +01:00
// Public URL
2015-06-30 01:34:17 +02:00
print '<tr><td>' . $langs -> trans ( " PublicUrl " ) . '</td><td colspan="2">' ;
2014-03-14 13:51:46 +01:00
print dol_print_url ( $object -> url );
print '</td></tr>' ;
2018-03-28 11:54:21 +02:00
// Default warehouse
if ( $object -> isProduct () && ! empty ( $conf -> stock -> enabled ))
{
$warehouse = new Entrepot ( $db );
$warehouse -> fetch ( $object -> fk_default_warehouse );
print '<tr><td>' . $langs -> trans ( " DefaultWarehouse " ) . '</td><td>' ;
print ( ! empty ( $warehouse -> id ) ? $warehouse -> getNomUrl ( 1 ) : '' );
print '</td>' ;
}
2016-07-23 16:37:21 +02:00
//Parent product.
2018-04-24 11:01:17 +02:00
if ( ! empty ( $conf -> variants -> enabled ) && ( $object -> isProduct () || $object -> isService ())) {
2016-07-23 16:37:21 +02:00
$combination = new ProductCombination ( $db );
if ( $combination -> fetchByFkProductChild ( $object -> id ) > 0 ) {
$prodstatic = new Product ( $db );
$prodstatic -> fetch ( $combination -> fk_product_parent );
// Parent product
print '<tr><td>' . $langs -> trans ( " ParentProduct " ) . '</td><td colspan="2">' ;
print $prodstatic -> getNomUrl ( 1 );
print '</td></tr>' ;
}
}
2015-11-06 18:57:35 +01:00
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-07 16:44:04 +02:00
2015-11-06 18:57:35 +01:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2017-06-07 16:44:04 +02:00
2011-10-01 12:48:31 +02:00
// Nature
2015-03-30 03:14:07 +02:00
if ( $object -> type != Product :: TYPE_SERVICE )
2011-10-01 12:48:31 +02:00
{
2015-11-06 18:57:35 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Nature " ) . '</td><td colspan="2">' ;
2011-10-01 12:48:31 +02:00
print $object -> getLibFinished ();
print '</td></tr>' ;
}
2015-11-07 14:37:47 +01:00
if ( $object -> isService ())
2011-10-01 12:48:31 +02:00
{
// Duration
2015-11-06 18:57:35 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Duration " ) . '</td><td colspan="2">' . $object -> duration_value . ' ' ;
2011-10-01 12:48:31 +02:00
if ( $object -> duration_value > 1 )
{
2018-06-20 12:10:25 +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 " ));
2011-10-01 12:48:31 +02:00
}
else if ( $object -> duration_value > 0 )
{
2018-06-20 12:10:25 +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 " ));
2011-10-01 12:48:31 +02:00
}
2012-07-08 23:22:22 +02:00
print ( ! empty ( $object -> duration_unit ) && isset ( $dur [ $object -> duration_unit ]) ? $langs -> trans ( $dur [ $object -> duration_unit ]) : '' ) . " " ;
2011-10-01 12:48:31 +02:00
print '</td></tr>' ;
}
else
{
// Weight
2015-11-06 18:57:35 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Weight " ) . '</td><td colspan="2">' ;
2011-10-01 12:48:31 +02:00
if ( $object -> weight != '' )
{
print $object -> weight . " " . measuring_units_string ( $object -> weight_units , " weight " );
}
else
{
print ' ' ;
}
print " </td></tr> \n " ;
2016-12-10 13:25:33 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SIZE ))
2011-10-01 12:48:31 +02:00
{
2016-02-22 13:11:46 +01:00
// Length
2017-01-16 10:43:22 +01:00
print '<tr><td>' . $langs -> trans ( " Length " ) . ' x ' . $langs -> trans ( " Width " ) . ' x ' . $langs -> trans ( " Height " ) . '</td><td colspan="2">' ;
if ( $object -> length != '' || $object -> width != '' || $object -> height != '' )
2016-02-22 13:11:46 +01:00
{
2017-01-16 10:43:22 +01:00
print $object -> length ;
if ( $object -> width ) print " x " . $object -> width ;
if ( $object -> height ) print " x " . $object -> height ;
print ' ' . measuring_units_string ( $object -> length_units , " size " );
2016-02-22 13:11:46 +01:00
}
else
{
print ' ' ;
}
print " </td></tr> \n " ;
2011-10-01 12:48:31 +02:00
}
2016-02-22 13:11:46 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_SURFACE ))
2011-10-01 12:48:31 +02:00
{
2016-02-22 13:11:46 +01:00
// Surface
print '<tr><td>' . $langs -> trans ( " Surface " ) . '</td><td colspan="2">' ;
if ( $object -> surface != '' )
{
print $object -> surface . " " . measuring_units_string ( $object -> surface_units , " surface " );
}
else
{
print ' ' ;
}
print " </td></tr> \n " ;
2011-10-01 12:48:31 +02:00
}
2017-01-16 10:43:22 +01:00
if ( empty ( $conf -> global -> PRODUCT_DISABLE_VOLUME ))
2011-10-01 12:48:31 +02:00
{
2017-01-16 10:43:22 +01:00
// Volume
print '<tr><td>' . $langs -> trans ( " Volume " ) . '</td><td colspan="2">' ;
if ( $object -> volume != '' )
{
print $object -> volume . " " . measuring_units_string ( $object -> volume_units , " volume " );
}
else
{
print ' ' ;
}
print " </td></tr> \n " ;
2011-10-01 12:48:31 +02:00
}
}
2010-05-26 16:52:32 +02:00
2015-02-26 14:15:33 +01:00
// Unit
2015-06-10 18:58:42 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS ))
2015-02-26 14:15:33 +01:00
{
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>' ;
}
2014-03-25 19:52:04 +01:00
// Custom code
2017-10-22 04:23:17 +02:00
if ( ! $object -> isService () && empty ( $conf -> global -> PRODUCT_DISABLE_CUSTOM_INFO ))
2014-03-25 19:52:04 +01:00
{
print '<tr><td>' . $langs -> trans ( " CustomCode " ) . '</td><td colspan="2">' . $object -> customcode . '</td>' ;
2011-05-14 00:04:52 +02:00
2014-03-25 19:52:04 +01:00
// Origin country code
print '<tr><td>' . $langs -> trans ( " CountryOrigin " ) . '</td><td colspan="2">' . getCountry ( $object -> country_id , 0 , $db ) . '</td>' ;
}
2010-11-02 12:22:41 +01:00
2012-02-06 17:18:19 +01:00
// Other attributes
2012-03-03 19:02:44 +01:00
$parameters = array ( 'colspan' => ' colspan="' . ( 2 + (( $showphoto || $showbarcode ) ? 1 : 0 )) . '"' );
2017-06-07 16:44:04 +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
2015-06-19 14:30:23 +02:00
if ( $conf -> categorie -> enabled ) {
print '<tr><td valign="middle">' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
print $form -> showCategories ( $object -> id , 'product' , 1 );
print " </td></tr> " ;
}
2015-06-27 23:01:05 +02:00
2016-07-28 13:53:17 +02:00
// Note private
if ( ! empty ( $conf -> global -> MAIN_DISABLE_NOTES_TAB ))
{
print '<!-- show Note --> ' . " \n " ;
print '<tr><td class="tdtop">' . $langs -> trans ( " NotePrivate " ) . '</td><td colspan="' . ( 2 + (( $showphoto || $showbarcode ) ? 1 : 0 )) . '">' . ( dol_textishtml ( $object -> note_private ) ? $object -> note_private : dol_nl2br ( $object -> note_private , 1 , true )) . '</td></tr>' . " \n " ;
print '<!-- End show Note --> ' . " \n " ;
}
2017-06-07 16:44:04 +02:00
2015-11-06 18:57:35 +01:00
print " </table> \n " ;
print '</div>' ;
2017-06-07 16:44:04 +02:00
2015-11-06 18:57:35 +01:00
print '</div></div>' ;
print '<div style="clear:both"></div>' ;
2017-06-07 16:44:04 +02:00
2011-10-01 12:48:31 +02:00
dol_fiche_end ();
}
2011-08-27 19:25:09 +02:00
}
else if ( $action != 'create' )
{
2011-10-01 12:48:31 +02:00
exit ;
2011-08-27 19:25:09 +02:00
}
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
$module = ( ! empty ( $conf -> global -> PRODUCT_CODEPRODUCT_ADDON ) ? $conf -> global -> PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard' );
if ( substr ( $module , 0 , 16 ) == 'mod_codeproduct_' && substr ( $module , - 3 ) == 'php' )
{
$module = substr ( $module , 0 , dol_strlen ( $module ) - 4 );
}
$result = dol_include_once ( '/core/modules/product/' . $module . '.php' );
if ( $result > 0 )
{
$modCodeProduct = new $module ();
}
$tmpcode = '' ;
2015-08-13 09:28:25 +02:00
if ( ! empty ( $modCodeProduct -> code_auto )) $tmpcode = $modCodeProduct -> getNextValue ( $object , $object -> type );
2009-05-27 17:11:24 +02:00
2012-06-08 21:33:12 +02:00
// Define confirmation messages
$formquestionclone = array (
'text' => $langs -> trans ( " ConfirmClone " ),
2015-07-21 12:29:09 +02:00
array ( 'type' => 'text' , 'name' => 'clone_ref' , 'label' => $langs -> trans ( " NewRefForClone " ), 'value' => empty ( $tmpcode ) ? $langs -> trans ( " CopyOf " ) . ' ' . $object -> ref : $tmpcode , 'size' => 24 ),
2011-10-01 12:48:31 +02:00
array ( 'type' => 'checkbox' , 'name' => 'clone_content' , 'label' => $langs -> trans ( " CloneContentProduct " ), 'value' => 1 ),
2013-06-10 00:11:25 +02:00
array ( 'type' => 'checkbox' , 'name' => 'clone_prices' , 'label' => $langs -> trans ( " ClonePricesProduct " ) . ' (' . $langs -> trans ( " FeatureNotYetAvailable " ) . ')' , 'value' => 0 , 'disabled' => true ),
2012-06-08 21:33:12 +02:00
);
2016-11-14 01:47:34 +01:00
if ( ! empty ( $conf -> global -> PRODUIT_SOUSPRODUITS ))
{
$formquestionclone [] = array ( 'type' => 'checkbox' , 'name' => 'clone_composition' , 'label' => $langs -> trans ( 'CloneCompositionProduct' ), 'value' => 1 );
}
2012-06-08 21:33:12 +02:00
// Confirm delete product
2013-10-26 18:46:07 +02:00
if (( $action == 'delete' && ( empty ( $conf -> use_javascript_ajax ) || ! empty ( $conf -> dol_use_jmobile ))) // Output when action = clone if jmobile or no js
|| ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile ))) // Always output when not jmobile nor js
2012-06-08 21:33:12 +02:00
{
2016-03-25 15:53:44 +01:00
print $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
2013-10-26 18:46:07 +02:00
if (( $action == 'clone' && ( empty ( $conf -> use_javascript_ajax ) || ! empty ( $conf -> dol_use_jmobile ))) // Output when action = clone if jmobile or no js
|| ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile ))) // Always output when not jmobile nor js
2012-06-08 21:33:12 +02:00
{
2017-11-12 12:39:23 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'CloneProduct' ), $langs -> trans ( 'ConfirmCloneProduct' , $object -> ref ), 'confirm_clone' , $formquestionclone , 'yes' , 'action-clone' , 260 , 600 );
2012-06-08 21:33:12 +02:00
}
2009-05-27 17:11:24 +02:00
2002-12-14 17:32:49 +01:00
/* ************************************************************************** */
2006-07-14 15:37:43 +02:00
/* */
/* Barre d'action */
/* */
2002-12-14 17:32:49 +01:00
/* ************************************************************************** */
2017-04-30 03:18:49 +02:00
if ( $action != 'create' && $action != 'edit' )
2002-12-14 17:32:49 +01:00
{
2017-04-30 03:18:49 +02:00
print " \n " . '<div class="tabsAction">' . " \n " ;
2017-06-07 16:44:04 +02:00
2017-04-30 03:18:49 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook ))
2018-02-11 13:27:02 +01:00
{
if ( $usercancreate )
2017-04-12 19:30:01 +02:00
{
2017-04-30 03:18:49 +02:00
if ( ! isset ( $object -> no_button_edit ) || $object -> no_button_edit <> 1 ) print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=edit&id=' . $object -> id . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2017-06-07 16:44:04 +02:00
2017-04-30 03:18:49 +02:00
if ( ! isset ( $object -> no_button_copy ) || $object -> no_button_copy <> 1 )
2017-04-12 19:30:01 +02:00
{
2017-04-30 03:18:49 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile ))
{
print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">' . $langs -> trans ( 'ToClone' ) . '</span></div>' . " \n " ;
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?action=clone&id=' . $object -> id . '">' . $langs -> trans ( " ToClone " ) . '</a></div>' ;
}
2017-04-12 19:30:01 +02:00
}
}
2017-04-30 03:18:49 +02:00
$object_is_used = $object -> isObjectUsed ( $object -> id );
2017-06-07 16:44:04 +02:00
2018-02-11 13:27:02 +01:00
if ( $usercandelete )
2017-04-12 19:30:01 +02:00
{
2017-04-30 03:18:49 +02:00
if ( empty ( $object_is_used ) && ( ! isset ( $object -> no_button_delete ) || $object -> no_button_delete <> 1 ))
2017-04-12 19:30:01 +02:00
{
2017-04-30 03:18:49 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) && empty ( $conf -> dol_use_jmobile ))
{
print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">' . $langs -> trans ( 'Delete' ) . '</span></div>' . " \n " ;
}
else
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?action=delete&id=' . $object -> id . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
}
2017-04-12 19:30:01 +02:00
}
else
2017-04-30 03:18:49 +02:00
{
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " ProductIsUsed " ) . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
2017-04-12 19:30:01 +02:00
}
}
else
2017-04-30 03:18:49 +02:00
{
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotEnoughPermissions " ) . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
2017-04-12 19:30:01 +02:00
}
}
2017-06-07 16:44:04 +02:00
2017-04-30 03:18:49 +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
*/
2016-09-12 18:15:01 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_ADD_FORM_ADD_TO ) && $object -> id && ( $action == '' || $action == 'view' ) && $object -> status )
2003-06-28 15:55:12 +02:00
{
2013-06-02 00:37:33 +02:00
//Variable used to check if any text is going to be printed
$html = '' ;
//print '<div class="fichecenter"><div class="fichehalfleft">';
2011-10-01 12:48:31 +02:00
// Propals
2012-07-08 23:22:22 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> creer )
2011-10-01 12:48:31 +02:00
{
$propal = new Propal ( $db );
$langs -> load ( " propal " );
2013-04-27 15:08:35 +02:00
$otherprop = $propal -> liste_array ( 2 , 1 , 0 );
2015-05-03 20:07:16 +02:00
2013-04-27 15:08:35 +02:00
if ( is_array ( $otherprop ) && count ( $otherprop ))
2011-10-01 12:48:31 +02:00
{
2015-05-03 21:15:08 +02:00
$html .= '<tr><td style="width: 200px;">' ;
2016-08-05 00:36:58 +02:00
$html .= $langs -> trans ( " AddToDraftProposals " ) . '</td><td>' ;
2016-03-25 15:34:37 +01:00
$html .= $form -> selectarray ( " propalid " , $otherprop , 0 , 1 );
2013-06-02 00:37:33 +02:00
$html .= '</td></tr>' ;
2011-10-01 12:48:31 +02:00
}
else
2015-05-03 20:07:16 +02:00
{
2015-05-03 21:15:08 +02:00
$html .= '<tr><td style="width: 200px;">' ;
2016-08-05 00:36:58 +02:00
$html .= $langs -> trans ( " AddToDraftProposals " ) . '</td><td>' ;
2013-07-18 19:01:19 +02:00
$html .= $langs -> trans ( " NoDraftProposals " );
2013-06-02 00:37:33 +02:00
$html .= '</td></tr>' ;
2011-10-01 12:48:31 +02:00
}
}
// Commande
2012-07-08 23:22:22 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> creer )
2011-10-01 12:48:31 +02:00
{
$commande = new Commande ( $db );
$langs -> load ( " orders " );
2013-04-27 15:08:35 +02:00
$othercom = $commande -> liste_array ( 2 , 1 , null );
if ( is_array ( $othercom ) && count ( $othercom ))
2011-10-01 12:48:31 +02:00
{
2015-05-03 21:15:08 +02:00
$html .= '<tr><td style="width: 200px;">' ;
2016-08-05 00:36:58 +02:00
$html .= $langs -> trans ( " AddToDraftOrders " ) . '</td><td>' ;
2016-03-25 15:34:37 +01:00
$html .= $form -> selectarray ( " commandeid " , $othercom , 0 , 1 );
2013-06-02 00:37:33 +02:00
$html .= '</td></tr>' ;
2011-10-01 12:48:31 +02:00
}
else
2013-04-27 15:08:35 +02:00
{
2015-05-03 21:15:08 +02:00
$html .= '<tr><td style="width: 200px;">' ;
2016-08-05 00:36:58 +02:00
$html .= $langs -> trans ( " AddToDraftOrders " ) . '</td><td>' ;
2013-07-18 19:01:19 +02:00
$html .= $langs -> trans ( " NoDraftOrders " );
2013-06-02 00:37:33 +02:00
$html .= '</td></tr>' ;
2011-10-01 12:48:31 +02:00
}
}
// Factures
2012-07-08 23:22:22 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> creer )
2011-10-01 12:48:31 +02:00
{
2013-04-27 15:08:35 +02:00
$invoice = new Facture ( $db );
$langs -> load ( " bills " );
2013-06-02 00:37:33 +02:00
$otherinvoice = $invoice -> liste_array ( 2 , 1 , null );
if ( is_array ( $otherinvoice ) && count ( $otherinvoice ))
{
2015-05-03 21:15:08 +02:00
$html .= '<tr><td style="width: 200px;">' ;
2016-08-05 00:36:58 +02:00
$html .= $langs -> trans ( " AddToDraftInvoices " ) . '</td><td>' ;
2016-03-25 15:34:37 +01:00
$html .= $form -> selectarray ( " factureid " , $otherinvoice , 0 , 1 );
2013-06-02 00:37:33 +02:00
$html .= '</td></tr>' ;
}
else
{
2015-05-03 21:15:08 +02:00
$html .= '<tr><td style="width: 200px;">' ;
2016-08-05 00:36:58 +02:00
$html .= $langs -> trans ( " AddToDraftInvoices " ) . '</td><td>' ;
2013-07-18 19:01:19 +02:00
$html .= $langs -> trans ( " NoDraftInvoices " );
2013-06-02 00:37:33 +02:00
$html .= '</td></tr>' ;
}
2011-10-01 12:48:31 +02:00
}
2013-06-02 00:37:33 +02:00
//If any text is going to be printed, then we show the table
if ( ! empty ( $html ))
{
2015-05-03 20:07:16 +02:00
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="addin">' ;
2016-05-17 21:55:39 +02:00
print load_fiche_titre ( $langs -> trans ( " AddToDraft " ), '' , '' );
2017-06-07 16:44:04 +02:00
2015-08-23 07:37:38 +02:00
dol_fiche_head ( '' );
2015-05-03 20:07:16 +02:00
2015-05-03 21:15:08 +02:00
$html .= '<tr><td class="nowrap">' . $langs -> trans ( " Quantity " ) . ' ' ;
2016-08-05 00:36:58 +02:00
$html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td>' ;
$html .= '<td class="nowrap">' . $langs -> trans ( " ReductionShort " ) . '(%) ' ;
2015-05-03 20:07:16 +02:00
$html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">' ;
$html .= '</td></tr>' ;
print '<table width="100%" class="border">' ;
2013-06-02 00:37:33 +02:00
print $html ;
print '</table>' ;
2017-06-07 16:44:04 +02:00
2015-05-03 20:07:16 +02:00
print '<div class="center">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print '</div>' ;
2016-02-08 15:49:38 +01:00
dol_fiche_end ();
2015-05-03 20:07:16 +02:00
print '</form>' ;
2013-06-02 00:37:33 +02:00
}
2003-06-28 15:55:12 +02:00
}
2002-05-04 23:28:42 +02:00
2016-02-08 15:49:38 +01:00
/*
* Documents generes
*/
2017-04-07 11:01:12 +02:00
2017-04-30 03:18:49 +02:00
if ( $action != 'create' && $action != 'edit' && $action != 'delete' )
2016-02-08 15:49:38 +01:00
{
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
2017-04-12 19:30:01 +02:00
// Documents
$objectref = dol_sanitizeFileName ( $object -> ref );
$relativepath = $comref . '/' . $objectref . '.pdf' ;
$filedir = $conf -> produit -> dir_output . '/' . $objectref ;
2016-02-08 15:49:38 +01:00
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
2018-02-11 13:27:02 +01:00
$genallowed = $usercanread ;
2018-02-12 03:23:57 +01:00
$delallowed = $usercancreate ;
2016-02-08 15:49:38 +01:00
2016-09-12 18:37:40 +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
2016-02-08 15:49:38 +01:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2017-11-12 13:40:05 +01:00
$MAXEVENT = 10 ;
2017-11-26 20:21:01 +01:00
$morehtmlright = '<a href="' . DOL_URL_ROOT . '/product/agenda.php?id=' . $object -> id . '">' ;
$morehtmlright .= $langs -> trans ( " SeeAll " );
$morehtmlright .= '</a>' ;
2017-11-12 13:40:05 +01:00
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
2017-11-26 20:21:01 +01:00
$somethingshown = $formactions -> showactions ( $object , 'product' , 0 , 1 , '' , $MAXEVENT , '' , $morehtmlright ); // Show all action for product
2017-11-12 13:40:05 +01:00
2016-02-08 15:49:38 +01:00
print '</div></div></div>' ;
}
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 ();