2004-10-20 22:06:49 +02:00
< ? php
2014-10-02 09:30:31 +02:00
/* Copyright ( C ) 2003 - 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 Simon Tosser < simon @ kornog - computing . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2014 Regis Houssin < regis . houssin @ inodbox . com >
2016-04-27 16:51:51 +02:00
* Copyright ( C ) 2016 Francis Appels < francis . appels @ yahoo . com >
2021-04-14 10:13:31 +02:00
* Copyright ( C ) 2021 Noé Cendrier < noe . cendrier @ altairis . fr >
2021-05-19 23:29:35 +02:00
* Copyright ( C ) 2021 Frédéric France < frederic . france @ netlogic . fr >
2022-05-23 21:58:29 +02:00
* Copyright ( C ) 2022 Charlene Benke < charlene @ patas - monkey . com >
2003-11-17 17:59:01 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-11-17 17:59:01 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2003-11-17 17:59:01 +01:00
*/
2005-03-19 00:27:37 +01:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / product / stock / card . php
2008-10-25 20:33:32 +02:00
* \ingroup stock
* \brief Page fiche entrepot
2008-10-25 14:49:16 +02:00
*/
2005-01-09 01:52:31 +01:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2018-05-09 16:02:46 +02: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 . '/product/stock/class/entrepot.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/stock.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2016-09-16 11:17:19 +02:00
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
2019-11-13 19:35:39 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2019-09-19 16:03:40 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2021-04-14 10:13:31 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
}
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'products' , 'stocks' , 'companies' , 'categories' ));
2005-01-09 01:52:31 +01:00
2019-11-13 19:35:39 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
$confirm = GETPOST ( 'confirm' );
2021-04-15 10:31:18 +02:00
$projectid = GETPOST ( 'projectid' , 'int' );
2003-11-17 17:59:01 +01:00
2019-01-27 11:55:16 +01:00
$id = GETPOST ( 'id' , 'int' );
2021-09-02 18:48:46 +02:00
$socid = GETPOST ( 'socid' , 'int' );
2019-01-27 11:55:16 +01:00
$ref = GETPOST ( 'ref' , 'alpha' );
2017-12-24 15:02:15 +01:00
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2021-02-26 14:25:17 +01:00
if ( ! $sortfield ) {
$sortfield = " p.ref " ;
}
if ( ! $sortorder ) {
$sortorder = " DESC " ;
}
2006-04-27 01:59:54 +02:00
2019-11-13 19:35:39 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2014-11-28 20:41:52 +01:00
2013-01-10 08:27:12 +01:00
// Security check
2019-02-14 15:23:34 +01:00
//$result=restrictedArea($user,'stock', $id, 'entrepot&stock');
2019-11-13 19:35:39 +01:00
$result = restrictedArea ( $user , 'stock' );
2013-01-02 18:43:59 +01:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2019-08-16 17:32:58 +02:00
$hookmanager -> initHooks ( array ( 'warehousecard' , 'globalcard' ));
2013-01-02 18:43:59 +01:00
2016-04-27 16:51:51 +02:00
$object = new Entrepot ( $db );
2019-06-03 15:44:17 +02:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-06-03 15:44:17 +02:00
// Load object
2019-11-13 19:35:39 +01:00
if ( $id > 0 || ! empty ( $ref )) {
2020-09-07 10:18:17 +02:00
$ret = $object -> fetch ( $id , $ref );
if ( $ret <= 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$action = '' ;
}
2019-06-03 15:44:17 +02:00
}
2004-08-18 17:04:30 +02:00
2021-10-25 15:32:10 +02:00
$usercanread = (( $user -> rights -> stock -> lire ));
$usercancreate = (( $user -> rights -> stock -> creer ));
$usercandelete = (( $user -> rights -> stock -> supprimer ));
2018-05-24 12:32:04 +02:00
2006-04-27 01:59:54 +02:00
/*
* Actions
*/
2019-06-03 15:44:17 +02:00
$error = 0 ;
2019-11-13 19:35:39 +01:00
$parameters = array ( 'id' => $id , 'ref' => $ref );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 14:25:17 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
if ( empty ( $reshook )) {
2021-09-14 08:46:07 +02:00
$backurlforlist = DOL_URL_ROOT . '/product/stock/list.php' ;
if ( empty ( $backtopage ) || ( $cancel && empty ( $id ))) {
if ( empty ( $backtopage ) || ( $cancel && strpos ( $backtopage , '__ID__' ))) {
if ( empty ( $id ) && (( $action != 'add' && $action != 'create' ) || $cancel )) {
$backtopage = $backurlforlist ;
} else {
$backtopage = DOL_URL_ROOT . '/product/stock/card.php?id=' . (( ! empty ( $id ) && $id > 0 ) ? $id : '__ID__' );
}
}
}
if ( $cancel ) {
if ( ! empty ( $backtopageforcancel )) {
header ( " Location: " . $backtopageforcancel );
exit ;
} elseif ( ! empty ( $backtopage )) {
header ( " Location: " . $backtopage );
exit ;
}
$action = '' ;
}
2019-09-30 19:00:19 +02:00
// Ajout entrepot
2021-02-26 14:25:17 +01:00
if ( $action == 'add' && $user -> rights -> stock -> creer ) {
2020-11-19 21:19:54 +01:00
$object -> ref = ( string ) GETPOST ( " ref " , " alpha " );
$object -> fk_parent = ( int ) GETPOST ( " fk_parent " , " int " );
2021-04-14 13:45:25 +02:00
$object -> fk_project = GETPOST ( 'projectid' , 'int' );
2020-11-19 21:19:54 +01:00
$object -> label = ( string ) GETPOST ( " libelle " , " alpha " );
$object -> description = ( string ) GETPOST ( " desc " , " alpha " );
2021-04-19 20:55:09 +02:00
$object -> statut = GETPOST ( " statut " , " int " );
2020-11-19 21:19:54 +01:00
$object -> lieu = ( string ) GETPOST ( " lieu " , " alpha " );
$object -> address = ( string ) GETPOST ( " address " , " alpha " );
$object -> zip = ( string ) GETPOST ( " zipcode " , " alpha " );
$object -> town = ( string ) GETPOST ( " town " , " alpha " );
2020-12-01 02:41:19 +01:00
$object -> country_id = GETPOST ( " country_id " );
2020-11-19 21:19:54 +01:00
$object -> phone = ( string ) GETPOST ( " phone " , " alpha " );
$object -> fax = ( string ) GETPOST ( " fax " , " alpha " );
2011-11-14 11:28:16 +01:00
2020-04-22 23:55:50 +02:00
if ( ! empty ( $object -> label )) {
2020-09-07 10:18:17 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
if ( $ret < 0 ) {
$error ++ ;
$action = 'create' ;
}
if ( ! $error ) {
$id = $object -> create ( $user );
if ( $id > 0 ) {
setEventMessages ( $langs -> trans ( " RecordSaved " ), null , 'mesgs' );
2019-09-30 19:00:19 +02:00
$categories = GETPOST ( 'categories' , 'array' );
$object -> setCategories ( $categories );
2020-09-07 10:18:17 +02:00
if ( ! empty ( $backtopage )) {
2022-02-21 16:50:12 +01:00
$backtopage = str_replace ( " __ID__ " , $id , $backtopage );
2020-09-07 10:18:17 +02:00
header ( " Location: " . $backtopage );
exit ;
} else {
2021-04-25 15:55:36 +02:00
header ( " Location: card.php?id= " . urlencode ( $id ));
2020-09-07 10:18:17 +02:00
exit ;
}
} else {
$action = 'create' ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2020-05-21 15:05:19 +02:00
} else {
2019-09-30 19:00:19 +02:00
setEventMessages ( $langs -> trans ( " ErrorWarehouseRefRequired " ), null , 'errors' );
2019-11-13 19:35:39 +01:00
$action = " create " ; // Force retour sur page creation
2019-09-30 19:00:19 +02:00
}
}
2019-06-03 15:44:17 +02:00
2019-09-30 19:00:19 +02:00
// Delete warehouse
2021-02-26 14:25:17 +01:00
if ( $action == 'confirm_delete' && $confirm == 'yes' && $user -> rights -> stock -> supprimer ) {
2019-09-30 19:00:19 +02:00
$object -> fetch ( GETPOST ( 'id' , 'int' ));
2019-11-13 19:35:39 +01:00
$result = $object -> delete ( $user );
2021-02-26 14:25:17 +01:00
if ( $result > 0 ) {
2020-09-07 10:18:17 +02:00
setEventMessages ( $langs -> trans ( " RecordDeleted " ), null , 'mesgs' );
2019-09-30 19:00:19 +02:00
header ( " Location: " . DOL_URL_ROOT . '/product/stock/list.php?restore_lastsearch_values=1' );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2019-09-30 19:00:19 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-11-13 19:35:39 +01:00
$action = '' ;
2019-09-30 19:00:19 +02:00
}
}
2019-06-03 15:44:17 +02:00
2019-09-30 19:00:19 +02:00
// Modification entrepot
2021-04-19 20:59:10 +02:00
if ( $action == 'update' && ! $cancel ) {
2021-02-26 14:25:17 +01:00
if ( $object -> fetch ( $id )) {
2021-06-14 15:37:02 +02:00
$object -> label = GETPOST ( " libelle " );
2019-09-30 19:00:19 +02:00
$object -> fk_parent = GETPOST ( " fk_parent " );
2021-04-14 13:45:25 +02:00
$object -> fk_project = GETPOST ( 'projectid' );
2023-06-14 16:51:23 +02:00
$object -> description = GETPOST ( " desc " , 'restricthtml' );
2019-09-30 19:00:19 +02:00
$object -> statut = GETPOST ( " statut " );
$object -> lieu = GETPOST ( " lieu " );
$object -> address = GETPOST ( " address " );
$object -> zip = GETPOST ( " zipcode " );
$object -> town = GETPOST ( " town " );
$object -> country_id = GETPOST ( " country_id " );
2021-06-14 15:37:02 +02:00
$object -> phone = GETPOST ( " phone " );
$object -> fax = GETPOST ( " fax " );
2019-09-30 19:00:19 +02:00
2020-09-07 10:18:17 +02:00
// Fill array 'array_options' with data from add form
2021-12-08 18:27:03 +01:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , '@GETPOSTISSET' );
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2019-09-30 19:00:19 +02:00
2020-09-07 10:18:17 +02:00
if ( ! $error ) {
$ret = $object -> update ( $id , $user );
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
}
2019-09-30 19:00:19 +02:00
if ( $error ) {
$action = 'edit' ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
} else {
$categories = GETPOST ( 'categories' , 'array' );
$object -> setCategories ( $categories );
2020-09-07 10:18:17 +02:00
$action = '' ;
}
2020-05-21 15:05:19 +02:00
} else {
2011-11-06 13:54:06 +01:00
$action = 'edit' ;
2015-12-12 10:59:02 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-09-30 19:00:19 +02:00
}
2020-05-21 15:05:19 +02:00
} elseif ( $action == 'update_extras' ) {
2020-09-07 10:18:17 +02:00
$object -> oldcopy = dol_clone ( $object );
// Fill array 'array_options' with data from update form
2020-09-18 01:29:17 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , GETPOST ( 'attribute' , 'restricthtml' ));
2021-02-26 14:25:17 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2020-09-07 10:18:17 +02:00
if ( ! $error ) {
$result = $object -> insertExtraFields ();
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
}
2021-02-26 14:25:17 +01:00
if ( $error ) {
$action = 'edit_extras' ;
}
2021-04-14 13:45:25 +02:00
} elseif ( $action == 'classin' && $usercancreate ) {
// Link to a project
$object -> setProject ( GETPOST ( 'projectid' , 'int' ));
2008-10-25 14:49:16 +02:00
}
2003-11-17 17:59:01 +01:00
2021-02-26 14:25:17 +01:00
if ( $cancel == $langs -> trans ( " Cancel " )) {
2019-09-30 19:00:19 +02:00
$action = '' ;
}
2005-01-09 01:52:31 +01:00
2018-05-24 12:16:04 +02:00
2019-09-30 19:00:19 +02:00
// Actions to build doc
$upload_dir = $conf -> stock -> dir_output ;
2019-11-05 19:41:30 +01:00
$permissiontoadd = $user -> rights -> stock -> creer ;
2019-09-30 19:00:19 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
}
2018-05-24 12:16:04 +02:00
2003-11-17 17:59:01 +01:00
/*
2008-10-25 14:49:16 +02:00
* View
*/
2004-07-27 10:35:14 +02:00
2019-11-13 19:35:39 +01:00
$productstatic = new Product ( $db );
$form = new Form ( $db );
$formproduct = new FormProduct ( $db );
$formcompany = new FormCompany ( $db );
2018-05-09 16:02:46 +02:00
$formfile = new FormFile ( $db );
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2021-04-14 10:13:31 +02:00
$formproject = new FormProjets ( $db );
}
2008-10-25 20:33:32 +02:00
2019-11-13 19:35:39 +01:00
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks' ;
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $langs -> trans ( " WarehouseCard " ), $help_url );
2006-08-19 04:30:41 +02:00
2022-07-11 00:05:50 +02:00
if ( $action == 'create' ) {
2020-04-12 19:56:50 +02:00
print load_fiche_titre ( $langs -> trans ( " NewWarehouse " ), '' , 'stock' );
2009-07-09 21:29:56 +02:00
2017-06-21 11:37:34 +02:00
dol_set_focus ( 'input[name="libelle"]' );
2016-09-19 13:57:50 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' . " \n " ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2008-10-25 14:49:16 +02:00
print '<input type="hidden" name="action" value="add">' ;
2014-11-30 15:24:39 +01:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2014-12-09 14:27:02 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ();
2014-12-09 14:27:02 +01:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2006-08-13 16:37:56 +02:00
// Ref
2016-10-24 20:52:21 +02:00
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs -> trans ( " Ref " ) . '</td><td><input name="libelle" size="20" value=""></td></tr>' ;
2008-11-26 13:01:51 +01:00
2019-11-13 19:35:39 +01:00
print '<tr><td>' . $langs -> trans ( " LocationSummary " ) . '</td><td><input name="lieu" size="40" value="' . ( ! empty ( $object -> lieu ) ? $object -> lieu : '' ) . '"></td></tr>' ;
2017-06-12 16:26:25 +02:00
2016-09-16 11:17:19 +02:00
// Parent entrepot
print '<tr><td>' . $langs -> trans ( " AddIn " ) . '</td><td>' ;
2020-11-05 22:25:14 +01:00
print img_picto ( '' , 'stock' ) . $formproduct -> selectWarehouses (( GETPOSTISSET ( 'fk_parent' ) ? GETPOST ( 'fk_parent' , 'int' ) : 'ifone' ), 'fk_parent' , '' , 1 );
2016-09-16 11:17:19 +02:00
print '</td></tr>' ;
2005-04-12 01:47:54 +02:00
2021-04-14 10:13:31 +02:00
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2021-04-14 10:13:31 +02:00
$langs -> load ( 'projects' );
print '<tr><td>' . $langs -> trans ( 'Project' ) . '</td><td colspan="2">' ;
print img_picto ( '' , 'project' ) . $formproject -> select_projects (( $socid > 0 ? $socid : - 1 ), $projectid , 'projectid' , 0 , 0 , 1 , 1 , 0 , 0 , 0 , '' , 1 , 0 , 'maxwidth500' );
2022-06-20 15:41:19 +02:00
print ' <a href="' . DOL_URL_ROOT . '/projet/card.php?socid=' . $socid . '&action=create&status=1&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?action=create&socid=' . $socid ) . '"><span class="fa fa-plus-circle valignmiddle" title="' . $langs -> trans ( " AddProject " ) . '"></span></a>' ;
2021-04-14 10:13:31 +02:00
print '</td></tr>' ;
}
2021-04-14 16:08:28 +02:00
2006-08-13 16:37:56 +02:00
// Description
2016-10-24 20:52:21 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
2010-09-02 21:10:34 +02:00
// Editeur wysiwyg
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2021-09-02 18:48:46 +02:00
$doleditor = new DolEditor ( 'desc' , ( ! empty ( $object -> description ) ? $object -> description : '' ), '' , 180 , 'dolibarr_notes' , 'In' , false , true , empty ( $conf -> fckeditor -> enabled ) ? '' : $conf -> fckeditor -> enabled , ROWS_5 , '90%' );
2010-09-02 21:10:34 +02:00
$doleditor -> Create ();
2008-10-25 14:49:16 +02:00
print '</td></tr>' ;
2016-10-24 20:52:21 +02:00
print '<tr><td>' . $langs -> trans ( 'Address' ) . '</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
2019-11-13 19:35:39 +01:00
print ( ! empty ( $object -> address ) ? $object -> address : '' );
2008-10-25 14:49:16 +02:00
print '</textarea></td></tr>' ;
2011-11-14 11:28:16 +01:00
// Zip / Town
print '<tr><td>' . $langs -> trans ( 'Zip' ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print $formcompany -> select_ziptown (( ! empty ( $object -> zip ) ? $object -> zip : '' ), 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
2016-10-24 20:52:21 +02:00
print '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( 'Town' ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print $formcompany -> select_ziptown (( ! empty ( $object -> town ) ? $object -> town : '' ), 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
2011-11-14 11:28:16 +01:00
print '</td></tr>' ;
2008-10-25 14:49:16 +02:00
2011-11-14 11:28:16 +01:00
// Country
2016-10-24 20:52:21 +02:00
print '<tr><td>' . $langs -> trans ( 'Country' ) . '</td><td>' ;
2020-04-22 17:59:54 +02:00
print img_picto ( '' , 'globe-americas' , 'class="paddingright"' );
2019-11-13 19:35:39 +01:00
print $form -> select_country (( ! empty ( $object -> country_id ) ? $object -> country_id : $mysoc -> country_code ), 'country_id' );
2021-02-26 14:25:17 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2008-10-25 14:49:16 +02:00
print '</td></tr>' ;
2020-03-18 01:17:54 +01:00
// Phone / Fax
2020-08-17 19:44:06 +02:00
print '<tr><td class="titlefieldcreate">' . $form -> editfieldkey ( 'Phone' , 'phone' , '' , $object , 0 ) . '</td><td>' ;
2020-04-22 17:59:54 +02:00
print img_picto ( '' , 'object_phoning' , 'class="paddingright"' );
print '<input name="phone" size="20" value="' . $object -> phone . '"></td></tr>' ;
2020-08-17 19:44:06 +02:00
print '<tr><td class="titlefieldcreate">' . $form -> editfieldkey ( 'Fax' , 'fax' , '' , $object , 0 ) . '</td>' ;
2020-04-22 17:59:54 +02:00
print '<td>' ;
print img_picto ( '' , 'object_phoning_fax' , 'class="paddingright"' );
print '<input name="fax" size="20" value="' . $object -> fax . '"></td></tr>' ;
2020-03-18 01:17:54 +01:00
2016-04-27 16:51:51 +02:00
// Status
2016-10-24 20:52:21 +02:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
2021-06-24 11:51:10 +02:00
print '<select id="warehousestatus" name="statut" class="flat">' ;
2021-02-26 14:25:17 +01:00
foreach ( $object -> statuts as $key => $value ) {
if ( $key == 1 ) {
2016-04-27 16:51:51 +02:00
print '<option value="' . $key . '" selected>' . $langs -> trans ( $value ) . '</option>' ;
2020-05-21 15:05:19 +02:00
} else {
2016-04-27 16:51:51 +02:00
print '<option value="' . $key . '">' . $langs -> trans ( $value ) . '</option>' ;
}
}
2008-10-25 14:49:16 +02:00
print '</select>' ;
2021-06-24 11:51:10 +02:00
print ajax_combobox ( 'warehousestatus' );
2008-10-25 14:49:16 +02:00
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php' ;
2019-06-03 15:44:17 +02:00
2021-09-02 18:48:46 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2019-09-19 16:03:40 +02:00
// Categories
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
2019-09-27 13:28:28 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_WAREHOUSE , '' , 'parent' , 64 , 0 , 1 );
2020-12-03 14:34:15 +01:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , GETPOST ( 'categories' , 'array' ), '' , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2019-09-19 16:03:40 +02:00
print " </td></tr> " ;
}
2008-10-25 14:49:16 +02:00
print '</table>' ;
2011-11-06 13:54:06 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2014-12-09 14:27:02 +01:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ( " Create " );
2011-09-15 01:01:07 +02:00
2008-10-25 14:49:16 +02:00
print '</form>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-09-07 10:18:17 +02:00
$id = GETPOST ( " id " , 'int' );
2021-02-26 14:25:17 +01:00
if ( $id > 0 || $ref ) {
2011-11-14 11:28:16 +01:00
$object = new Entrepot ( $db );
2017-12-24 15:02:15 +01:00
$result = $object -> fetch ( $id , $ref );
2021-02-26 14:25:17 +01:00
if ( $result <= 0 ) {
2017-12-24 15:02:15 +01:00
print 'No record found' ;
exit ;
2008-10-25 14:49:16 +02:00
}
/*
* Affichage fiche
*/
2021-02-26 14:25:17 +01:00
if ( $action <> 'edit' && $action <> 're-edit' ) {
2011-11-14 11:28:16 +01:00
$head = stock_prepare_head ( $object );
2009-07-29 21:02:04 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Warehouse " ), - 1 , 'stock' );
2008-10-25 14:49:16 +02:00
2016-09-19 13:57:50 +02:00
$formconfirm = '' ;
2017-06-12 16:26:25 +02:00
2019-11-26 20:14:46 +01:00
// Confirm delete warehouse
2021-02-26 14:25:17 +01:00
if ( $action == 'delete' ) {
2019-11-26 20:14:46 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " DeleteAWarehouse " ), $langs -> trans ( " ConfirmDeleteWarehouse " , $object -> label ), " confirm_delete " , '' , 0 , 2 );
2009-12-09 17:49:27 +01:00
}
2010-03-13 00:40:39 +01:00
2018-08-30 11:27:48 +02:00
// Call Hook formConfirm
2020-01-28 12:00:27 +01:00
$parameters = array ( 'formConfirm' => $formconfirm );
2018-08-30 11:27:48 +02:00
$reshook = $hookmanager -> executeHooks ( 'formConfirm' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
$formconfirm .= $hookmanager -> resPrint ;
} elseif ( $reshook > 0 ) {
$formconfirm = $hookmanager -> resPrint ;
}
2016-12-10 22:13:06 +01:00
2016-09-19 13:57:50 +02:00
// Print form confirm
print $formconfirm ;
2016-12-10 22:13:06 +01:00
2016-09-19 13:57:50 +02:00
// Warehouse card
2019-12-05 15:22:06 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/product/stock/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-12-10 22:13:06 +01:00
2019-12-18 15:20:36 +01:00
$morehtmlref = '<div class="refidno">' ;
$morehtmlref .= $langs -> trans ( " LocationSummary " ) . ' : ' . $object -> lieu ;
2021-04-14 13:45:25 +02:00
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2021-04-14 13:45:25 +02:00
$langs -> load ( " projects " );
$morehtmlref .= '<br>' . img_picto ( '' , 'project' ) . ' ' . $langs -> trans ( 'Project' ) . ' ' ;
if ( $usercancreate ) {
if ( $action != 'classify' ) {
2021-09-18 22:09:55 +02:00
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classify&token=' . newToken () . '&id=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'SetProject' )) . '</a> : ' ;
2021-04-14 13:45:25 +02:00
}
if ( $action == 'classify' ) {
$projectid = $object -> fk_project ;
$morehtmlref .= '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '">' ;
$morehtmlref .= '<input type="hidden" name="action" value="classin">' ;
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$morehtmlref .= $formproject -> select_projects (( $socid > 0 ? $socid : - 1 ), $projectid , 'projectid' , 0 , 0 , 1 , 1 , 0 , 0 , 0 , '' , 1 , 0 , 'maxwidth500' );
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs -> trans ( " Modify " ) . '">' ;
$morehtmlref .= '</form>' ;
} else {
2022-06-20 15:25:47 +02:00
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , ( $socid > 0 ? $socid : - 1 ), $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
2021-04-14 13:45:25 +02:00
}
} else {
if ( ! empty ( $object -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
2021-10-29 09:40:38 +02:00
$morehtmlref .= ' : ' . $proj -> getNomUrl ( 1 );
if ( $proj -> title ) {
$morehtmlref .= ' - ' . $proj -> title ;
}
2021-04-14 13:45:25 +02:00
} else {
$morehtmlref .= '' ;
}
}
2021-04-14 10:13:31 +02:00
}
2020-09-07 10:18:17 +02:00
$morehtmlref .= '</div>' ;
2016-12-10 22:13:06 +01:00
2020-09-07 10:18:17 +02:00
$shownav = 1 ;
2021-02-26 14:25:17 +01:00
if ( $user -> socid && ! in_array ( 'stock' , explode ( ',' , $conf -> global -> MAIN_MODULES_FOR_EXTERNAL ))) {
$shownav = 0 ;
}
2017-06-12 16:26:25 +02:00
2020-09-07 10:18:17 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , $shownav , 'ref' , 'ref' , $morehtmlref );
2016-12-10 22:13:06 +01:00
2020-09-07 10:18:17 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2016-12-10 22:13:06 +01:00
2020-09-07 10:18:17 +02:00
print '<table class="border centpercent tableforfield">' ;
2016-09-19 13:57:50 +02:00
2016-09-16 11:17:19 +02:00
// Parent entrepot
2019-11-26 20:14:46 +01:00
$parentwarehouse = new Entrepot ( $db );
2019-12-18 15:20:36 +01:00
if ( ! empty ( $object -> fk_parent ) && $parentwarehouse -> fetch ( $object -> fk_parent ) > 0 ) {
2016-09-16 11:17:19 +02:00
print '<tr><td>' . $langs -> trans ( " ParentWarehouse " ) . '</td><td>' ;
2019-11-26 20:14:46 +01:00
print $parentwarehouse -> getNomUrl ( 3 );
2016-09-16 11:17:19 +02:00
print '</td></tr>' ;
}
2021-04-27 22:36:25 +02:00
print '<tr>' ;
2006-08-13 16:37:56 +02:00
// Description
2021-04-27 22:36:25 +02:00
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' . dol_htmlentitiesbr ( $object -> description ) . '</td></tr>' ;
2008-10-25 14:49:16 +02:00
2019-11-13 19:35:39 +01:00
$calcproductsunique = $object -> nb_different_products ();
$calcproducts = $object -> nb_products ();
2016-12-10 22:13:06 +01:00
2016-09-19 13:57:50 +02:00
// Total nb of different products
print '<tr><td>' . $langs -> trans ( " NumberOfDifferentProducts " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print empty ( $calcproductsunique [ 'nb' ]) ? '0' : $calcproductsunique [ 'nb' ];
2016-09-19 13:57:50 +02:00
print " </td></tr> " ;
2016-12-10 22:13:06 +01:00
2009-01-10 03:18:17 +01:00
// Nb of products
2016-09-19 13:57:50 +02:00
print '<tr><td>' . $langs -> trans ( " NumberOfProducts " ) . '</td><td>' ;
2020-09-07 10:18:17 +02:00
$valtoshow = price2num ( $calcproducts [ 'nb' ], 'MS' );
print empty ( $valtoshow ) ? '0' : $valtoshow ;
2009-07-11 12:12:10 +02:00
print " </td></tr> " ;
2016-12-10 22:13:06 +01:00
2016-09-19 13:57:50 +02:00
print '</table>' ;
2016-12-10 22:13:06 +01:00
2016-09-19 13:57:50 +02:00
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="underbanner clearboth"></div>' ;
2016-12-10 22:13:06 +01:00
2020-04-22 17:59:54 +02:00
print '<table class="border centpercent tableforfield">' ;
2016-12-10 22:13:06 +01:00
2009-07-11 12:12:10 +02:00
// Value
2016-10-24 20:52:21 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " EstimatedStockValueShort " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print price (( empty ( $calcproducts [ 'value' ]) ? '0' : price2num ( $calcproducts [ 'value' ], 'MT' )), 0 , $langs , 0 , - 1 , - 1 , $conf -> currency );
2008-10-25 14:49:16 +02:00
print " </td></tr> " ;
2016-12-10 22:13:06 +01:00
2009-01-10 03:18:17 +01:00
// Last movement
2019-10-17 17:06:38 +02:00
if ( ! empty ( $user -> rights -> stock -> mouvement -> lire )) {
$sql = " SELECT max(m.datem) as datem " ;
2019-12-18 15:20:36 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " stock_mouvement as m " ;
2020-09-20 02:57:15 +02:00
$sql .= " WHERE m.fk_entrepot = " . (( int ) $object -> id );
2019-10-17 17:06:38 +02:00
$resqlbis = $db -> query ( $sql );
if ( $resqlbis ) {
$obj = $db -> fetch_object ( $resqlbis );
$lastmovementdate = $db -> jdate ( $obj -> datem );
} else {
dol_print_error ( $db );
}
2019-12-18 15:20:36 +01:00
print '<tr><td>' . $langs -> trans ( " LastMovement " ) . '</td><td>' ;
2019-10-17 17:06:38 +02:00
if ( $lastmovementdate ) {
2021-03-24 01:53:08 +01:00
print dol_print_date ( $lastmovementdate , 'dayhour' );
print ' ' ;
print img_picto ( $langs -> trans ( 'LastMovement' ), 'movement' , 'class="pictofixedwidth"' );
print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_list.php?id=' . $object -> id . '">' . $langs -> trans ( " FullList " ) . '</a>' ;
2019-10-17 17:06:38 +02:00
} else {
print $langs -> trans ( " None " );
}
print " </td></tr> " ;
2011-11-06 13:54:06 +01:00
}
2016-12-10 22:13:06 +01:00
2020-09-07 10:18:17 +02:00
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2020-08-17 19:48:05 +02:00
2019-09-19 16:03:40 +02:00
// Categories
2022-06-09 22:41:59 +02:00
if ( isModEnabled ( 'categorie' )) {
2019-09-19 16:03:40 +02:00
print '<tr><td valign="middle">' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
2019-11-14 08:15:39 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_WAREHOUSE , 1 );
2019-09-19 16:03:40 +02:00
print " </td></tr> " ;
}
2020-08-17 19:48:05 +02:00
2008-10-25 14:49:16 +02:00
print " </table> " ;
2016-09-19 13:57:50 +02:00
print '</div>' ;
print '</div>' ;
2016-12-10 22:13:06 +01:00
2016-09-19 13:57:50 +02:00
print '<div class="clearboth"></div>' ;
2016-12-10 22:13:06 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2008-10-25 14:49:16 +02:00
2021-03-16 04:22:43 +01:00
/*
* Action bar
*/
2008-10-25 14:49:16 +02:00
print " <div class= \" tabsAction \" > \n " ;
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
2021-04-14 13:45:25 +02:00
if ( empty ( $action ) || $action == 'classin' ) {
2020-10-01 10:50:54 +02:00
if ( $user -> rights -> stock -> creer ) {
print '<a class="butAction" href="card.php?action=edit&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " Modify " ) . '</a>' ;
2021-02-26 14:25:17 +01:00
} else {
2020-10-01 10:50:54 +02:00
print '<a class="butActionRefused classfortooltip" href="#">' . $langs -> trans ( " Modify " ) . '</a>' ;
}
2014-09-20 00:57:29 +02:00
2020-10-01 10:50:54 +02:00
if ( $user -> rights -> stock -> supprimer ) {
print '<a class="butActionDelete" href="card.php?action=delete&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
2021-02-26 14:25:17 +01:00
} else {
2020-10-01 10:50:54 +02:00
print '<a class="butActionRefused classfortooltip" href="#">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
2014-01-24 11:15:25 +01:00
}
2008-10-25 14:49:16 +02:00
}
2014-09-20 00:57:29 +02:00
2008-10-25 14:49:16 +02:00
print " </div> " ;
/* ************************************************************************** */
/* */
/* Affichage de la liste des produits de l'entrepot */
/* */
/* ************************************************************************** */
print '<br>' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2008-10-25 14:49:16 +02:00
print " <tr class= \" liste_titre \" > " ;
2021-04-23 18:03:16 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2019-01-27 11:55:16 +01:00
print_liste_field_titre ( " Product " , " " , " p.ref " , " &id= " . $id , " " , " " , $sortfield , $sortorder );
print_liste_field_titre ( " Label " , " " , " p.label " , " &id= " . $id , " " , " " , $sortfield , $sortorder );
2021-03-24 01:53:08 +01:00
print_liste_field_titre ( " NumberOfUnit " , " " , " ps.reel " , " &id= " . $id , " " , '' , $sortfield , $sortorder , 'right ' );
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
print_liste_field_titre ( " Unit " , " " , " p.fk_unit " , " &id= " . $id , " " , 'align="left"' , $sortfield , $sortorder );
}
2021-03-24 01:53:08 +01:00
print_liste_field_titre ( $form -> textwithpicto ( $langs -> trans ( " AverageUnitPricePMPShort " ), $langs -> trans ( " AverageUnitPricePMPDesc " )), " " , " p.pmp " , " &id= " . $id , " " , '' , $sortfield , $sortorder , 'right ' );
2019-02-24 11:18:55 +01:00
print_liste_field_titre ( " EstimatedStockValueShort " , " " , " " , " &id= " . $id , " " , '' , $sortfield , $sortorder , 'right ' );
2020-09-07 10:18:17 +02:00
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
print_liste_field_titre ( " SellPriceMin " , " " , " p.price " , " &id= " . $id , " " , '' , $sortfield , $sortorder , 'right ' );
}
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
print_liste_field_titre ( " EstimatedStockValueSellShort " , " " , " " , " &id= " . $id , " " , '' , $sortfield , $sortorder , 'right ' );
}
2019-02-24 11:18:55 +01:00
if ( $user -> rights -> stock -> mouvement -> creer ) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( '' );
}
2019-02-24 11:18:55 +01:00
if ( $user -> rights -> stock -> creer ) {
2020-09-07 10:18:17 +02:00
print_liste_field_titre ( '' );
}
2021-04-23 18:03:16 +02:00
// Hook fields
$parameters = array ( 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2015-06-26 06:23:29 +02:00
print " </tr> \n " ;
2008-10-25 14:49:16 +02:00
2019-11-13 19:35:39 +01:00
$totalunit = 0 ;
$totalvalue = $totalvaluesell = 0 ;
2009-07-11 12:12:10 +02:00
2021-04-26 19:29:56 +02:00
//For MultiCompany PMP per entity
$separatedPMP = false ;
if ( ! empty ( $conf -> global -> MULTICOMPANY_PRODUCT_SHARING_ENABLED ) && ! empty ( $conf -> global -> MULTICOMPANY_PMP_PER_ENTITY_ENABLED )) {
$separatedPMP = true ;
}
$sql = " SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.price, p.price_ttc, p.entity, " ;
2021-05-19 23:29:35 +02:00
$sql .= " p.tosell, p.tobuy, " ;
$sql .= " p.accountancy_code_sell, " ;
$sql .= " p.accountancy_code_sell_intra, " ;
$sql .= " p.accountancy_code_sell_export, " ;
$sql .= " p.accountancy_code_buy, " ;
$sql .= " p.accountancy_code_buy_intra, " ;
$sql .= " p.accountancy_code_buy_export, " ;
$sql .= 'p.barcode,' ;
2021-04-26 19:29:56 +02:00
if ( $separatedPMP ) {
2021-04-27 09:55:35 +02:00
$sql .= " pa.pmp as ppmp, " ;
2021-04-26 20:13:55 +02:00
} else {
2021-04-26 19:29:56 +02:00
$sql .= " p.pmp as ppmp, " ;
}
2019-11-13 19:35:39 +01:00
$sql .= " ps.reel as value " ;
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
$sql .= " ,fk_unit " ;
}
2021-04-23 18:03:16 +02:00
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
2021-04-23 18:05:24 +02:00
if ( $reshook > 0 ) { //Note that $sql is replaced if reshook > 0
2021-04-23 18:03:16 +02:00
$sql = " " ;
}
$sql .= $hookmanager -> resPrint ;
2019-11-13 19:35:39 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " product_stock as ps, " . MAIN_DB_PREFIX . " product as p " ;
2021-04-26 19:29:56 +02:00
if ( $separatedPMP ) {
2021-04-27 09:55:35 +02:00
$sql .= " , " . MAIN_DB_PREFIX . " product_perentity as pa " ;
2021-04-26 19:29:56 +02:00
}
2019-11-13 19:35:39 +01:00
$sql .= " WHERE ps.fk_product = p.rowid " ;
$sql .= " AND ps.reel <> 0 " ; // We do not show if stock is 0 (no product in this warehouse)
2021-06-09 15:36:47 +02:00
$sql .= " AND ps.fk_entrepot = " . (( int ) $object -> id );
2021-04-26 19:29:56 +02:00
if ( $separatedPMP ) {
2021-06-14 15:37:02 +02:00
$sql .= " AND pa.fk_product = p.rowid AND pa.entity = " . ( int ) $conf -> entity ;
2021-04-26 19:29:56 +02:00
}
2019-11-13 19:35:39 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2008-10-25 14:49:16 +02:00
2014-06-13 01:34:39 +02:00
dol_syslog ( 'List products' , LOG_DEBUG );
2011-09-20 15:32:16 +02:00
$resql = $db -> query ( $sql );
2021-02-26 14:25:17 +01:00
if ( $resql ) {
2008-10-25 14:49:16 +02:00
$num = $db -> num_rows ( $resql );
$i = 0 ;
2022-05-23 21:58:29 +02:00
$sameunits = true ;
2021-02-26 14:25:17 +01:00
while ( $i < $num ) {
2008-10-25 14:49:16 +02:00
$objp = $db -> fetch_object ( $resql );
// Multilangs
2021-02-26 14:25:17 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) { // si l'option est active
2009-04-27 22:37:50 +02:00
$sql = " SELECT label " ;
2019-11-13 19:35:39 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " product_lang " ;
2021-08-27 18:18:50 +02:00
$sql .= " WHERE fk_product = " . (( int ) $objp -> rowid );
$sql .= " AND lang = ' " . $db -> escape ( $langs -> getDefaultLang ()) . " ' " ;
2019-11-13 19:35:39 +01:00
$sql .= " LIMIT 1 " ;
2008-10-25 14:49:16 +02:00
$result = $db -> query ( $sql );
2021-02-26 14:25:17 +01:00
if ( $result ) {
2008-10-25 14:49:16 +02:00
$objtp = $db -> fetch_object ( $result );
2021-02-26 14:25:17 +01:00
if ( $objtp -> label != '' ) {
$objp -> produit = $objtp -> label ;
}
2008-10-25 14:49:16 +02:00
}
}
2009-02-20 23:53:15 +01:00
//print '<td>'.dol_print_date($objp->datem).'</td>';
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2021-06-24 11:51:10 +02:00
2021-04-23 18:03:16 +02:00
$parameters = array ( 'obj' => $objp );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-06-24 11:51:10 +02:00
2019-11-13 19:35:39 +01:00
$productstatic -> id = $objp -> rowid ;
2018-03-16 14:09:38 +01:00
$productstatic -> ref = $objp -> ref ;
$productstatic -> label = $objp -> produit ;
2019-11-13 19:35:39 +01:00
$productstatic -> type = $objp -> type ;
$productstatic -> entity = $objp -> entity ;
$productstatic -> status_batch = $objp -> tobatch ;
2022-07-20 16:35:51 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
$productstatic -> fk_unit = $objp -> fk_unit ;
}
2021-05-19 23:29:35 +02:00
$productstatic -> status = $objp -> tosell ;
$productstatic -> status_buy = $objp -> tobuy ;
$productstatic -> barcode = $objp -> barcode ;
$productstatic -> accountancy_code_sell = $objp -> accountancy_code_sell ;
$productstatic -> accountancy_code_sell_intra = $objp -> accountancy_code_sell_intra ;
$productstatic -> accountancy_code_sell_export = $objp -> accountancy_code_sell_export ;
$productstatic -> accountancy_code_buy = $objp -> accountancy_code_buy ;
$productstatic -> accountancy_code_buy_intra = $objp -> accountancy_code_buy_intra ;
$productstatic -> accountancy_code_buy_export = $objp -> accountancy_code_buy_export ;
2021-06-24 11:51:10 +02:00
print " <td> " ;
2019-01-27 11:55:16 +01:00
print $productstatic -> getNomUrl ( 1 , 'stock' , 16 );
2009-07-10 02:15:41 +02:00
print '</td>' ;
2016-12-10 22:13:06 +01:00
2016-11-18 16:34:03 +01:00
// Label
2021-06-24 11:51:10 +02:00
print '<td class="tdoverflowmax200" title="' . dol_escape_htmltag ( $objp -> produit ) . '">' . dol_escape_htmltag ( $objp -> produit ) . '</td>' ;
2009-01-10 03:18:17 +01:00
2019-02-24 11:18:55 +01:00
print '<td class="right">' ;
2019-11-13 19:35:39 +01:00
$valtoshow = price ( price2num ( $objp -> value , 'MS' ), 0 , '' , 0 , 0 ); // TODO replace with a qty() function
print empty ( $valtoshow ) ? '0' : $valtoshow ;
2016-11-18 16:34:03 +01:00
print '</td>' ;
2019-11-13 19:35:39 +01:00
$totalunit += $objp -> value ;
2009-01-10 03:18:17 +01:00
2020-09-07 10:18:17 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
// Units
print '<td align="left">' ;
2021-02-26 14:25:17 +01:00
if ( is_null ( $productstatic -> fk_unit )) {
$productstatic -> fk_unit = 1 ;
}
2020-09-07 10:18:17 +02:00
print $langs -> trans ( $productstatic -> getLabelOfUnit ());
print '</td>' ;
}
// Price buy PMP
2021-06-24 11:51:10 +02:00
print '<td class="right nowraponall">' . price ( price2num ( $objp -> ppmp , 'MU' )) . '</td>' ;
2016-12-10 22:13:06 +01:00
2020-09-07 10:18:17 +02:00
// Total PMP
2021-06-24 11:51:10 +02:00
print '<td class="right amount nowraponall">' . price ( price2num ( $objp -> ppmp * $objp -> value , 'MT' )) . '</td>' ;
2019-11-13 19:35:39 +01:00
$totalvalue += price2num ( $objp -> ppmp * $objp -> value , 'MT' );
2009-07-09 21:29:56 +02:00
2020-09-07 10:18:17 +02:00
// Price sell min
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
2020-09-07 10:18:17 +02:00
$pricemin = $objp -> price ;
print '<td class="right">' ;
print price ( price2num ( $pricemin , 'MU' ), 1 );
print '</td>' ;
// Total sell min
print '<td class="right">' ;
print price ( price2num ( $pricemin * $objp -> value , 'MT' ), 1 );
print '</td>' ;
}
$totalvaluesell += price2num ( $pricemin * $objp -> value , 'MT' );
2021-02-26 14:25:17 +01:00
if ( $user -> rights -> stock -> mouvement -> creer ) {
2019-02-24 11:18:55 +01:00
print '<td class="center"><a href="' . DOL_URL_ROOT . '/product/stock/product.php?dwid=' . $object -> id . '&id=' . $objp -> rowid . '&action=transfert&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $id ) . '">' ;
2021-03-24 01:53:08 +01:00
print img_picto ( $langs -> trans ( " TransferStock " ), 'add' , 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"' );
print $langs -> trans ( " TransferStock " );
2008-10-25 14:49:16 +02:00
print " </a></td> " ;
}
2009-07-09 21:29:56 +02:00
2021-02-26 14:25:17 +01:00
if ( $user -> rights -> stock -> creer ) {
2019-02-24 11:18:55 +01:00
print '<td class="center"><a href="' . DOL_URL_ROOT . '/product/stock/product.php?dwid=' . $object -> id . '&id=' . $objp -> rowid . '&action=correction&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $id ) . '">' ;
2021-03-24 01:53:08 +01:00
print img_picto ( $langs -> trans ( " CorrectStock " ), 'add' , 'class="hideonsmartphone pictofixedwidth" style="color: #a69944"' );
print $langs -> trans ( " CorrectStock " );
2008-10-25 14:49:16 +02:00
print " </a></td> " ;
2020-09-07 10:18:17 +02:00
}
2022-11-05 15:37:59 +01:00
2020-09-07 10:18:17 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_USE_UNITS )) {
2021-02-26 14:25:17 +01:00
if ( $i == 0 ) {
$units = $productstatic -> fk_unit ;
} elseif ( $productstatic -> fk_unit != $units ) {
$sameunits = false ;
}
2020-09-07 10:18:17 +02:00
}
2022-11-05 15:37:59 +01:00
2020-09-07 10:18:17 +02:00
print " </tr> " ;
$i ++ ;
}
$db -> free ( $resql );
2009-07-11 12:12:10 +02:00
2022-11-05 15:37:59 +01:00
// Total
2009-07-11 12:12:10 +02:00
print '<tr class="liste_total"><td class="liste_total" colspan="2">' . $langs -> trans ( " Total " ) . '</td>' ;
2019-02-24 11:18:55 +01:00
print '<td class="liste_total right">' ;
2019-11-13 19:35:39 +01:00
$valtoshow = price2num ( $totalunit , 'MS' );
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_USE_UNITS ) || $sameunits ) {
print empty ( $valtoshow ) ? '0' : $valtoshow ;
}
2016-11-18 16:34:03 +01:00
print '</td>' ;
2020-03-20 19:08:24 +01:00
print '<td class="liste_total">' ;
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUCT_USE_UNITS ) && $sameunits ) {
print $langs -> trans ( $productstatic -> getLabelOfUnit ());
}
2020-09-07 10:18:17 +02:00
print '</td>' ;
print '<td class="liste_total right">' . price ( price2num ( $totalvalue , 'MT' )) . '</td>' ;
2021-02-26 14:25:17 +01:00
if ( empty ( $conf -> global -> PRODUIT_MULTIPRICES )) {
2020-09-07 10:18:17 +02:00
print '<td class="liste_total"> </td>' ;
print '<td class="liste_total right">' . price ( price2num ( $totalvaluesell , 'MT' )) . '</td>' ;
}
2022-11-05 15:37:59 +01:00
if ( $user -> rights -> stock -> mouvement -> creer ) {
print '<td class="liste_total"> </td>' ;
}
if ( $user -> rights -> stock -> creer ) {
print '<td class="liste_total"> </td>' ;
}
2009-07-11 12:12:10 +02:00
print '</tr>' ;
2020-05-21 15:05:19 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2008-10-25 14:49:16 +02:00
}
print " </table> \n " ;
}
/*
* Edition fiche
*/
2021-02-26 14:25:17 +01:00
if ( $action == 'edit' || $action == 're-edit' ) {
2014-07-20 00:10:40 +02:00
$langs -> trans ( " WarehouseEdit " );
2008-10-25 14:49:16 +02:00
2014-09-18 21:18:25 +02:00
print '<form action="card.php" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2008-10-25 14:49:16 +02:00
print '<input type="hidden" name="action" value="update">' ;
2011-11-14 11:28:16 +01:00
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2008-10-25 14:49:16 +02:00
2015-06-30 13:14:19 +02:00
$head = stock_prepare_head ( $object );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Warehouse " ), 0 , 'stock' );
2015-06-30 13:14:19 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2003-11-17 17:59:01 +01:00
2006-08-13 16:37:56 +02:00
// Ref
2019-11-26 20:14:46 +01:00
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs -> trans ( " Ref " ) . '</td><td><input name="libelle" size="20" value="' . $object -> label . '"></td></tr>' ;
2016-12-10 22:13:06 +01:00
2020-11-05 22:25:14 +01:00
print '<tr><td>' . $langs -> trans ( " LocationSummary " ) . '</td><td><input name="lieu" class="minwidth300" value="' . $object -> lieu . '"></td></tr>' ;
2004-03-14 17:40:46 +01:00
2016-09-16 11:17:19 +02:00
// Parent entrepot
print '<tr><td>' . $langs -> trans ( " AddIn " ) . '</td><td>' ;
2016-10-20 14:29:51 +02:00
print $formproduct -> selectWarehouses ( $object -> fk_parent , 'fk_parent' , '' , 1 );
2016-09-16 11:17:19 +02:00
print '</td></tr>' ;
2008-10-25 14:49:16 +02:00
2021-04-14 10:13:31 +02:00
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2021-04-14 13:45:25 +02:00
$projectid = $object -> fk_project ;
2021-04-14 10:13:31 +02:00
$langs -> load ( 'projects' );
print '<tr><td>' . $langs -> trans ( 'Project' ) . '</td><td colspan="2">' ;
print img_picto ( '' , 'project' ) . $formproject -> select_projects (( $socid > 0 ? $socid : - 1 ), $projectid , 'projectid' , 0 , 0 , 1 , 1 , 0 , 0 , 0 , '' , 1 , 0 , 'maxwidth500' );
2022-06-20 15:39:11 +02:00
print ' <a href="' . DOL_URL_ROOT . '/projet/card.php?socid=' . ( $socid > 0 ? $socid : " " ) . '&action=create&status=1&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?action=create' . ( $socid > 0 ? '&socid=' . $socid : " " )) . '"><span class="fa fa-plus-circle valignmiddle" title="' . $langs -> trans ( " AddProject " ) . '"></span></a>' ;
2021-04-14 10:13:31 +02:00
print '</td></tr>' ;
}
2021-04-14 16:08:28 +02:00
2008-10-25 14:49:16 +02:00
// Description
2016-12-10 22:13:06 +01:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
2010-09-02 21:10:34 +02:00
// Editeur wysiwyg
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2019-11-13 19:35:39 +01:00
$doleditor = new DolEditor ( 'desc' , $object -> description , '' , 180 , 'dolibarr_notes' , 'In' , false , true , $conf -> fckeditor -> enabled , ROWS_5 , '90%' );
2010-09-02 21:10:34 +02:00
$doleditor -> Create ();
2008-10-25 14:49:16 +02:00
print '</td></tr>' ;
2016-12-10 22:13:06 +01:00
print '<tr><td>' . $langs -> trans ( 'Address' ) . '</td><td><textarea name="address" class="quatrevingtpercent" rows="3" wrap="soft">' ;
2011-11-14 11:28:16 +01:00
print $object -> address ;
2008-10-25 14:49:16 +02:00
print '</textarea></td></tr>' ;
2011-11-14 11:28:16 +01:00
// Zip / Town
print '<tr><td>' . $langs -> trans ( 'Zip' ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
2016-12-10 22:13:06 +01:00
print '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( 'Town' ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print $formcompany -> select_ziptown ( $object -> town , 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
2011-11-14 11:28:16 +01:00
print '</td></tr>' ;
2008-10-25 14:49:16 +02:00
2011-11-14 11:28:16 +01:00
// Country
2016-12-10 22:13:06 +01:00
print '<tr><td>' . $langs -> trans ( 'Country' ) . '</td><td>' ;
2020-04-22 17:59:54 +02:00
print img_picto ( '' , 'globe-americas' , 'class="paddingright"' );
2019-11-13 19:35:39 +01:00
print $form -> select_country ( $object -> country_id ? $object -> country_id : $mysoc -> country_code , 'country_id' );
2021-02-26 14:25:17 +01:00
if ( $user -> admin ) {
print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2008-10-25 14:49:16 +02:00
print '</td></tr>' ;
2020-03-18 01:17:54 +01:00
// Phone / Fax
2020-08-17 19:44:06 +02:00
print '<tr><td class="titlefieldcreate">' . $form -> editfieldkey ( 'Phone' , 'phone' , '' , $object , 0 ) . '</td><td>' ;
2020-04-22 17:59:54 +02:00
print img_picto ( '' , 'object_phoning' , 'class="paddingright"' );
print '<input name="phone" size="20" value="' . $object -> phone . '"></td></tr>' ;
2020-08-17 19:44:06 +02:00
print '<tr><td class="titlefieldcreate">' . $form -> editfieldkey ( 'Fax' , 'fax' , '' , $object , 0 ) . '</td><td>' ;
2020-04-22 17:59:54 +02:00
print img_picto ( '' , 'object_phoning_fax' , 'class="paddingright"' );
print '<input name="fax" size="20" value="' . $object -> fax . '"></td></tr>' ;
2020-03-18 01:17:54 +01:00
2019-06-03 15:44:17 +02:00
// Status
2016-12-10 22:13:06 +01:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
2021-06-24 11:51:10 +02:00
print '<select id="warehousestatus" name="statut" class="flat">' ;
2021-02-26 14:25:17 +01:00
foreach ( $object -> statuts as $key => $value ) {
if ( $key == $object -> statut ) {
2016-04-27 16:51:51 +02:00
print '<option value="' . $key . '" selected>' . $langs -> trans ( $value ) . '</option>' ;
2020-05-21 15:05:19 +02:00
} else {
2016-04-27 16:51:51 +02:00
print '<option value="' . $key . '">' . $langs -> trans ( $value ) . '</option>' ;
}
}
2008-10-25 14:49:16 +02:00
print '</select>' ;
2021-06-24 11:51:10 +02:00
print ajax_combobox ( 'warehousestatus' );
2008-10-25 14:49:16 +02:00
print '</td></tr>' ;
2020-09-07 10:18:17 +02:00
// Other attributes
$parameters = array ( 'colspan' => ' colspan="3"' , 'cols' => '3' );
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-02-26 14:25:17 +01:00
if ( empty ( $reshook )) {
2020-09-07 10:18:17 +02:00
print $object -> showOptionals ( $extrafields , 'edit' , $parameters );
}
2020-08-17 19:48:05 +02:00
2019-09-19 16:03:40 +02:00
// Tags-Categories
2022-06-09 22:41:59 +02:00
if ( isModEnabled ( 'categorie' )) {
2019-09-19 16:03:40 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
2019-09-27 13:28:28 +02:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_WAREHOUSE , '' , 'parent' , 64 , 0 , 1 );
2019-09-19 16:03:40 +02:00
$c = new Categorie ( $db );
2019-09-27 13:28:28 +02:00
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_WAREHOUSE );
2019-11-13 19:35:39 +01:00
$arrayselected = array ();
foreach ( $cats as $cat ) {
2019-09-19 16:03:40 +02:00
$arrayselected [] = $cat -> id ;
}
2020-12-03 14:34:15 +01:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , $arrayselected , '' , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2019-09-19 16:03:40 +02:00
print " </td></tr> " ;
}
2020-08-17 19:48:05 +02:00
2008-10-25 14:49:16 +02:00
print '</table>' ;
2011-11-14 11:28:16 +01:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-06-30 13:14:19 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2012-10-13 14:47:46 +02:00
2008-10-25 14:49:16 +02:00
print '</form>' ;
}
}
2004-07-21 18:08:31 +02:00
}
2004-03-14 17:40:46 +01:00
2018-05-09 16:02:46 +02:00
/*
2020-08-18 14:02:36 +02:00
* Documents generated
2018-05-09 16:02:46 +02:00
*/
2020-08-18 14:02:36 +02:00
$modulepart = 'stock' ;
2018-05-24 12:32:04 +02:00
2021-02-26 14:25:17 +01:00
if ( $action != 'create' && $action != 'edit' && $action != 'delete' ) {
2020-08-18 14:48:38 +02:00
print '<br>' ;
2020-09-07 10:18:17 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
print '<a name="builddoc"></a>' ; // ancre
2018-05-09 16:02:46 +02:00
2020-09-07 10:18:17 +02:00
// Documents
$objectref = dol_sanitizeFileName ( $object -> ref );
$relativepath = $object -> ref . '/' . $objectref . '.pdf' ;
$filedir = $conf -> stock -> dir_output . '/' . $objectref ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
$genallowed = $usercanread ;
$delallowed = $usercancreate ;
$modulepart = 'stock' ;
2018-05-09 16:02:46 +02:00
2022-05-23 21:58:29 +02:00
print $formfile -> showdocuments ( $modulepart , $objectref , $filedir , $urlsource , $genallowed , $delallowed , $object -> model_pdf , 0 , 0 , 0 , 28 , 0 , '' , 0 , '' , '' , '' , $object );
2020-09-07 10:18:17 +02:00
$somethingshown = $formfile -> numoffiles ;
2018-05-09 16:02:46 +02:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichehalfright">' ;
2018-05-09 16:02:46 +02:00
2020-09-07 10:18:17 +02:00
$MAXEVENT = 10 ;
2018-05-09 16:02:46 +02:00
2021-11-12 14:57:36 +01:00
$morehtmlcenter = '' ;
2022-05-18 23:11:59 +02:00
//$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/product/stock/agenda.php?id='.$object->id);
2018-05-09 16:02:46 +02:00
2020-09-07 10:18:17 +02:00
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
$formactions = new FormActions ( $db );
2021-11-12 14:57:36 +01:00
$somethingshown = $formactions -> showactions ( $object , 'stock' , 0 , 1 , '' , $MAXEVENT , '' , $morehtmlcenter ); // Show all action for product
2018-05-09 16:02:46 +02:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2018-05-09 16:02:46 +02:00
}
2018-08-15 12:48:13 +02:00
// End of page
2011-12-29 18:07:41 +01:00
llxFooter ();
2003-11-17 17:59:01 +01:00
$db -> close ();