2020-02-11 17:12:22 +01:00
< ? php
/* Copyright ( C ) 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2022-01-03 13:14:40 +01:00
* Copyright ( C ) 2022 Ferran Marcet < fmarcet @ 2 byte . es >
2020-02-11 17:12:22 +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
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2021-04-19 17:46:20 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2020-02-11 17:12:22 +01:00
*/
/**
* \file mo_movements . php
* \ingroup mrp
* \brief Page to show tock movements of a MO
*/
// Load Dolibarr environment
require '../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
2020-02-11 18:18:04 +01:00
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php' ;
2020-02-11 17:12:22 +01:00
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php' ;
2020-02-11 18:18:04 +01:00
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/productlot.class.php' ;
2020-02-11 17:12:22 +01:00
dol_include_once ( '/mrp/class/mo.class.php' );
dol_include_once ( '/mrp/lib/mrp_mo.lib.php' );
// Load translation files required by the page
$langs -> loadLangs ( array ( " mrp " , " stocks " , " other " ));
// Get parameters
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$action = GETPOST ( 'action' , 'aZ09' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$cancel = GETPOST ( 'cancel' , 'aZ09' );
2020-02-11 18:18:04 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'mostockmovement' ; // To manage different context of search
2020-02-11 17:12:22 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
//$lineid = GETPOST('lineid', 'int');
2020-02-11 18:18:04 +01:00
$msid = GETPOST ( 'msid' , 'int' );
$year = GETPOST ( " year " , 'int' );
$month = GETPOST ( " month " , 'int' );
$search_ref = GETPOST ( 'search_ref' , 'alpha' );
$search_movement = GETPOST ( " search_movement " , 'alpha' );
$search_product_ref = trim ( GETPOST ( " search_product_ref " , 'alpha' ));
$search_product = trim ( GETPOST ( " search_product " , 'alpha' ));
$search_warehouse = trim ( GETPOST ( " search_warehouse " , 'alpha' ));
$search_inventorycode = trim ( GETPOST ( " search_inventorycode " , 'alpha' ));
$search_user = trim ( GETPOST ( " search_user " , 'alpha' ));
$search_batch = trim ( GETPOST ( " search_batch " , 'alpha' ));
$search_qty = trim ( GETPOST ( " search_qty " , 'alpha' ));
$search_type_mouvement = GETPOST ( 'search_type_mouvement' , 'int' );
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2021-02-26 18:26:44 +01:00
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
} // If $page is not defined, or '' or -1
2020-02-11 18:18:04 +01:00
$offset = $limit * $page ;
2021-02-26 18:26:44 +01:00
if ( ! $sortfield ) {
$sortfield = " m.datem " ;
}
if ( ! $sortorder ) {
$sortorder = " DESC " ;
}
2020-02-11 17:12:22 +01:00
// Initialize technical objects
$object = new Mo ( $db );
$extrafields = new ExtraFields ( $db );
$diroutputmassaction = $conf -> mrp -> dir_output . '/temp/massgeneration/' . $user -> id ;
$hookmanager -> initHooks ( array ( 'mocard' , 'globalcard' )); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
// Initialize array of search criterias
$search_all = trim ( GETPOST ( " search_all " , 'alpha' ));
$search = array ();
2021-02-26 18:26:44 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( GETPOST ( 'search_' . $key , 'alpha' )) {
$search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
}
2020-02-11 17:12:22 +01:00
}
2021-02-26 18:26:44 +01:00
if ( empty ( $action ) && empty ( $id ) && empty ( $ref )) {
$action = 'view' ;
}
2020-02-11 17:12:22 +01:00
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php' ; // Must be include, not include_once.
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid;
2020-06-18 01:09:30 +02:00
$isdraft = (( $object -> status == $object :: STATUS_DRAFT ) ? 1 : 0 );
$result = restrictedArea ( $user , 'mrp' , $object -> id , 'mrp_mo' , '' , 'fk_soc' , 'rowid' , $isdraft );
2020-02-11 17:12:22 +01:00
2020-02-11 18:18:04 +01:00
$objectlist = new MouvementStock ( $db );
// Definition of fields for list
$arrayfields = array (
2021-02-27 02:00:00 +01:00
'm.rowid' => array ( 'label' => " Ref " , 'checked' => 1 , 'position' => 1 ),
'm.datem' => array ( 'label' => " Date " , 'checked' => 1 , 'position' => 2 ),
'p.ref' => array ( 'label' => " ProductRef " , 'checked' => 1 , 'css' => 'maxwidth100' , 'position' => 3 ),
'p.label' => array ( 'label' => " ProductLabel " , 'checked' => 0 , 'position' => 5 ),
'm.batch' => array ( 'label' => " BatchNumberShort " , 'checked' => 1 , 'position' => 8 , 'enabled' => ( ! empty ( $conf -> productbatch -> enabled ))),
'pl.eatby' => array ( 'label' => " EatByDate " , 'checked' => 0 , 'position' => 9 , 'enabled' => ( ! empty ( $conf -> productbatch -> enabled ))),
'pl.sellby' => array ( 'label' => " SellByDate " , 'checked' => 0 , 'position' => 10 , 'enabled' => ( ! empty ( $conf -> productbatch -> enabled ))),
2022-08-12 15:54:50 +02:00
'e.ref' => array ( 'label' => " Warehouse " , 'checked' => 1 , 'position' => 100 , 'enabled' => ( ! ( $id > 0 ))), // If we are on specific warehouse, we hide it
2021-02-27 02:00:00 +01:00
'm.fk_user_author' => array ( 'label' => " Author " , 'checked' => 0 , 'position' => 120 ),
'm.inventorycode' => array ( 'label' => " InventoryCodeShort " , 'checked' => 1 , 'position' => 130 ),
'm.label' => array ( 'label' => " MovementLabel " , 'checked' => 1 , 'position' => 140 ),
'm.type_mouvement' => array ( 'label' => " TypeMovement " , 'checked' => 0 , 'position' => 150 ),
'origin' => array ( 'label' => " Origin " , 'checked' => 1 , 'position' => 155 ),
'm.fk_projet' => array ( 'label' => 'Project' , 'checked' => 0 , 'position' => 180 ),
'm.value' => array ( 'label' => " Qty " , 'checked' => 1 , 'position' => 200 ),
'm.price' => array ( 'label' => " UnitPurchaseValue " , 'checked' => 0 , 'position' => 210 )
//'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
//'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500)
2020-02-11 18:18:04 +01:00
);
2020-08-20 15:27:34 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_DISABLE_SELLBY )) {
unset ( $arrayfields [ 'pl.sellby' ]);
}
2021-08-17 17:55:00 +02:00
if ( ! empty ( $conf -> global -> PRODUCT_DISABLE_EATBY )) {
unset ( $arrayfields [ 'pl.eatby' ]);
}
2020-02-11 18:18:04 +01:00
$objectlist -> fields = dol_sort_array ( $objectlist -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2020-02-11 17:12:22 +01:00
$permissionnote = $user -> rights -> mrp -> write ; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user -> rights -> mrp -> write ; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user -> rights -> mrp -> write ; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user -> rights -> mrp -> delete || ( $permissiontoadd && isset ( $object -> status ) && $object -> status == $object :: STATUS_DRAFT );
$upload_dir = $conf -> mrp -> multidir_output [ isset ( $object -> entity ) ? $object -> entity : 1 ];
$permissiontoproduce = $permissiontoadd ;
2021-01-30 17:27:16 +01:00
$permissiontoupdatecost = $user -> rights -> bom -> write ; // User who can define cost must have knowledge of pricing
2020-02-11 17:12:22 +01:00
2021-01-30 17:27:16 +01:00
if ( $permissiontoupdatecost ) {
$arrayfields [ 'm.price' ][ 'enabled' ] = 1 ;
}
2020-02-11 17:12:22 +01:00
2022-01-06 11:07:05 +01:00
$arrayofselected = array ();
2020-02-11 17:12:22 +01:00
/*
* Actions
*/
2021-02-26 18:26:44 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
$massaction = '' ;
}
2020-02-11 18:18:04 +01:00
2020-02-11 17:12:22 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 18:26:44 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2020-02-11 17:12:22 +01:00
2020-02-11 18:18:04 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Do we click on purge search criteria ?
2021-02-26 18:26:44 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // Both test are required to be compatible with all browsers
2020-02-11 18:18:04 +01:00
$year = '' ;
$month = '' ;
$search_ref = '' ;
$search_movement = " " ;
$search_type_mouvement = " " ;
$search_inventorycode = " " ;
$search_product_ref = " " ;
$search_product = " " ;
$search_warehouse = " " ;
$search_user = " " ;
$search_batch = " " ;
$search_qty = '' ;
$sall = " " ;
2022-05-08 18:25:22 +02:00
$toselect = array ();
2020-02-11 18:18:04 +01:00
$search_array_options = array ();
}
2021-02-26 18:26:44 +01:00
if ( empty ( $reshook )) {
2020-10-31 14:32:18 +01:00
$error = 0 ;
$backurlforlist = dol_buildpath ( '/mrp/mo_list.php' , 1 );
if ( empty ( $backtopage ) || ( $cancel && empty ( $id ))) {
//var_dump($backurlforlist);exit;
2021-02-26 18:26:44 +01:00
if ( empty ( $id ) && (( $action != 'add' && $action != 'create' ) || $cancel )) {
$backtopage = $backurlforlist ;
} else {
$backtopage = DOL_URL_ROOT . '/mrp/mo_production.php?id=' . ( $id > 0 ? $id : '__ID__' );
}
2020-10-31 14:32:18 +01:00
}
$triggermodname = 'MRP_MO_MODIFY' ; // Name of trigger action code to execute when we modify record
// Actions cancel, add, update, delete or clone
include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php' ;
// Actions when linking object each other
include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php' ;
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php' ;
// Actions to send emails
$triggersendname = 'MO_SENTBYMAIL' ;
$autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO' ;
$trackid = 'mo' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
// Action to move up and down lines of object
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
2021-02-26 18:26:44 +01:00
if ( $action == 'set_thirdparty' && $permissiontoadd ) {
2020-10-31 14:32:18 +01:00
$object -> setValueFrom ( 'fk_soc' , GETPOST ( 'fk_soc' , 'int' ), '' , '' , 'date' , '' , $user , 'MO_MODIFY' );
}
2021-02-26 18:26:44 +01:00
if ( $action == 'classin' && $permissiontoadd ) {
2020-10-31 14:32:18 +01:00
$object -> setProject ( GETPOST ( 'projectid' , 'int' ));
}
if ( $action == 'confirm_reopen' ) {
$result = $object -> setStatut ( $object :: STATUS_INPROGRESS , 0 , '' , 'MRP_REOPEN' );
}
2020-02-11 17:12:22 +01:00
}
/*
* View
*/
$form = new Form ( $db );
$formproject = new FormProjets ( $db );
$formproduct = new FormProduct ( $db );
2020-02-11 18:18:04 +01:00
$productstatic = new Product ( $db );
$productlot = new ProductLot ( $db );
$warehousestatic = new Entrepot ( $db );
$userstatic = new User ( $db );
2020-02-11 17:12:22 +01:00
2021-04-19 17:46:20 +02:00
$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication' ;
2021-04-19 20:20:23 +02:00
llxHeader ( '' , $langs -> trans ( 'Mo' ), $help_url );
2020-02-11 17:12:22 +01:00
// Part to show record
2021-02-26 18:26:44 +01:00
if ( $object -> id > 0 && ( empty ( $action ) || ( $action != 'edit' && $action != 'create' ))) {
2020-02-11 17:12:22 +01:00
$res = $object -> fetch_thirdparty ();
$res = $object -> fetch_optionals ();
$head = moPrepareHead ( $object );
2020-10-27 02:55:22 +01:00
print dol_get_fiche_head ( $head , 'stockmovement' , $langs -> trans ( " ManufacturingOrder " ), - 1 , $object -> picto );
2020-02-11 17:12:22 +01:00
$formconfirm = '' ;
// Confirmation to delete
2021-02-26 18:26:44 +01:00
if ( $action == 'delete' ) {
2020-10-31 14:32:18 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'DeleteMo' ), $langs -> trans ( 'ConfirmDeleteMo' ), 'confirm_delete' , '' , 0 , 1 );
2020-02-11 17:12:22 +01:00
}
// Confirmation to delete line
2021-02-26 18:26:44 +01:00
if ( $action == 'deleteline' ) {
2020-02-11 17:12:22 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&lineid=' . $lineid , $langs -> trans ( 'DeleteLine' ), $langs -> trans ( 'ConfirmDeleteLine' ), 'confirm_deleteline' , '' , 0 , 1 );
}
// Clone confirmation
if ( $action == 'clone' ) {
// Create an array for form
$formquestion = array ();
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ToClone' ), $langs -> trans ( 'ConfirmCloneMo' , $object -> ref ), 'confirm_clone' , $formquestion , 'yes' , 1 );
}
// Confirmation of action xxxx
2021-02-26 18:26:44 +01:00
if ( $action == 'xxx' ) {
2020-02-11 17:12:22 +01:00
$formquestion = array ();
2020-10-31 14:32:18 +01:00
/*
2020-02-11 17:12:22 +01:00
$forcecombo = 0 ;
if ( $conf -> browser -> name == 'ie' ) $forcecombo = 1 ; // There is a bug in IE10 that make combo inside popup crazy
2021-02-26 18:26:44 +01:00
$formquestion = array (
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
);
*/
2020-10-31 14:32:18 +01:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'XXX' ), $text , 'confirm_xxx' , $formquestion , 0 , 1 , 220 );
2020-02-11 17:12:22 +01:00
}
// Call Hook formConfirm
$parameters = array ( 'formConfirm' => $formconfirm , 'lineid' => $lineid );
$reshook = $hookmanager -> executeHooks ( 'formConfirm' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-26 18:26:44 +01:00
if ( empty ( $reshook )) {
$formconfirm .= $hookmanager -> resPrint ;
} elseif ( $reshook > 0 ) {
$formconfirm = $hookmanager -> resPrint ;
}
2020-02-11 17:12:22 +01:00
// Print form confirm
print $formconfirm ;
// Object card
// ------------------------------------------------------------
$linkback = '<a href="' . dol_buildpath ( '/mrp/mo_list.php' , 1 ) . '?restore_lastsearch_values=1' . ( ! empty ( $socid ) ? '&socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
$morehtmlref = '<div class="refidno">' ;
/*
// Ref bis
$morehtmlref .= $form -> editfieldkey ( " RefBis " , 'ref_client' , $object -> ref_client , $object , $user -> rights -> mrp -> creer , 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " RefBis " , 'ref_client' , $object -> ref_client , $object , $user -> rights -> mrp -> creer , 'string' , '' , null , null , '' , 1 ); */
// Thirdparty
$morehtmlref .= $langs -> trans ( 'ThirdParty' ) . ' : ' . ( is_object ( $object -> thirdparty ) ? $object -> thirdparty -> getNomUrl ( 1 ) : '' );
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2020-10-31 14:32:18 +01:00
$langs -> load ( " projects " );
$morehtmlref .= '<br>' . $langs -> trans ( 'Project' ) . ' ' ;
2021-02-26 18:26:44 +01:00
if ( $permissiontoadd ) {
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-02-26 18:26:44 +01:00
}
2020-10-31 14:32:18 +01:00
if ( $action == 'classify' ) {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1);
$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 ( $object -> fk_soc , $object -> fk_project , 'projectid' , 0 , 0 , 1 , 0 , 1 , 0 , 0 , '' , 1 );
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs -> trans ( " Modify " ) . '">' ;
$morehtmlref .= '</form>' ;
} else {
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_soc , $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
}
} else {
if ( ! empty ( $object -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
$morehtmlref .= $proj -> getNomUrl ();
} else {
$morehtmlref .= '' ;
}
}
2020-02-11 17:12:22 +01:00
}
$morehtmlref .= '</div>' ;
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border centpercent tableforfield">' . " \n " ;
// Common attributes
$keyforbreak = 'fk_warehouse' ;
unset ( $object -> fields [ 'fk_project' ]);
unset ( $object -> fields [ 'fk_soc' ]);
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php' ;
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
print '</table>' ;
print '</div>' ;
print '</div>' ;
print '<div class="clearboth"></div>' ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2020-02-11 17:12:22 +01:00
/*
print '<div class="tabsAction">' ;
$parameters = array ();
// Note that $action and $object may be modified by hook
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action );
if ( empty ( $reshook )) {
// Cancel - Reopen
if ( $permissiontoadd )
{
if ( $object -> status == $object :: STATUS_VALIDATED || $object -> status == $object :: STATUS_INPROGRESS )
{
print '<a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=confirm_close&confirm=yes">' . $langs -> trans ( " Cancel " ) . '</a>' . " \n " ;
}
if ( $object -> status == $object :: STATUS_CANCELED )
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=confirm_reopen&confirm=yes">' . $langs -> trans ( " Re-Open " ) . '</a>' . " \n " ;
}
if ( $object -> status == $object :: STATUS_PRODUCED ) {
if ( $permissiontoproduce ) {
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=confirm_reopen">' . $langs -> trans ( 'ReOpen' ) . '</a>' ;
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotEnoughPermissions " ) . '">' . $langs -> trans ( 'ReOpen' ) . '</a>' ;
}
}
}
}
print '</div>' ;
*/
2020-02-11 18:18:04 +01:00
$sql = " SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity, " ;
$sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, " ;
$sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype, " ;
$sql .= " m.batch, m.price, " ;
$sql .= " m.type_mouvement, " ;
$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby, " ;
$sql .= " u.login, u.photo, u.lastname, u.firstname " ;
// Add fields from extrafields
if ( ! empty ( $extrafields -> attributes [ $objectlist -> table_element ][ 'label' ])) {
2021-02-26 18:26:44 +01:00
foreach ( $extrafields -> attributes [ $objectlist -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $objectlist -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : '' );
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
}
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $objectlist may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= " FROM " . MAIN_DB_PREFIX . " entrepot as e, " ;
$sql .= " " . MAIN_DB_PREFIX . " product as p, " ;
$sql .= " " . MAIN_DB_PREFIX . " stock_mouvement as m " ;
2021-02-26 18:26:44 +01:00
if ( is_array ( $extrafields -> attributes [ $objectlist -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $objectlist -> table_element ][ 'label' ])) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $objectlist -> table_element . " _extrafields as ef on (m.rowid = ef.fk_object) " ;
}
2020-02-11 18:18:04 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user as u ON m.fk_user_author = u.rowid " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product " ;
$sql .= " WHERE m.fk_product = p.rowid " ;
$sql .= " AND m.origintype = 'mo' AND m.fk_origin = " . ( int ) $object -> id ;
2021-02-26 18:26:44 +01:00
if ( $msid > 0 ) {
2021-04-24 20:18:11 +02:00
$sql .= " AND m.rowid = " . (( int ) $msid );
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
$sql .= " AND m.fk_entrepot = e.rowid " ;
$sql .= " AND e.entity IN ( " . getEntity ( 'stock' ) . " ) " ;
2021-02-26 18:26:44 +01:00
if ( empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES )) {
$sql .= " AND p.fk_product_type = 0 " ;
}
2020-02-11 18:18:04 +01:00
$sql .= dolSqlDateFilter ( 'm.datem' , 0 , $month , $year );
2021-02-26 18:26:44 +01:00
if ( ! empty ( $search_ref )) {
$sql .= natural_search ( 'm.rowid' , $search_ref , 1 );
}
if ( ! empty ( $search_movement )) {
$sql .= natural_search ( 'm.label' , $search_movement );
}
if ( ! empty ( $search_inventorycode )) {
$sql .= natural_search ( 'm.inventorycode' , $search_inventorycode );
}
if ( ! empty ( $search_product_ref )) {
$sql .= natural_search ( 'p.ref' , $search_product_ref );
}
if ( ! empty ( $search_product )) {
$sql .= natural_search ( 'p.label' , $search_product );
}
if ( $search_warehouse != '' && $search_warehouse != '-1' ) {
$sql .= natural_search ( 'e.rowid' , $search_warehouse , 2 );
}
if ( ! empty ( $search_user )) {
2021-12-15 10:52:57 +01:00
$sql .= natural_search ( array ( 'u.lastname' , 'u.firstname' , 'u.login' ), $search_user );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $search_batch )) {
$sql .= natural_search ( 'm.batch' , $search_batch );
}
if ( $search_qty != '' ) {
$sql .= natural_search ( 'm.value' , $search_qty , 1 );
}
if ( $search_type_mouvement != '' && $search_type_mouvement != '-1' ) {
$sql .= natural_search ( 'm.type_mouvement' , $search_type_mouvement , 2 );
}
2020-02-11 18:18:04 +01:00
// Add where from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $objectlist may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= $db -> order ( $sortfield , $sortorder );
$nbtotalofrecords = '' ;
2021-02-26 18:26:44 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2020-02-11 18:18:04 +01:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2021-02-26 18:26:44 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2020-02-11 18:18:04 +01:00
$page = 0 ;
$offset = 0 ;
}
}
$sql .= $db -> plimit ( $limit + 1 , $offset );
$param = '' ;
2021-02-26 18:26:44 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
if ( $id > 0 ) {
$param .= '&id=' . urlencode ( $id );
}
if ( $search_movement ) {
$param .= '&search_movement=' . urlencode ( $search_movement );
}
if ( $search_inventorycode ) {
$param .= '&search_inventorycode=' . urlencode ( $search_inventorycode );
}
if ( $search_type_mouvement ) {
$param .= '&search_type_mouvement=' . urlencode ( $search_type_mouvement );
}
if ( $search_product_ref ) {
$param .= '&search_product_ref=' . urlencode ( $search_product_ref );
}
if ( $search_product ) {
$param .= '&search_product=' . urlencode ( $search_product );
}
if ( $search_batch ) {
$param .= '&search_batch=' . urlencode ( $search_batch );
}
if ( $search_warehouse > 0 ) {
$param .= '&search_warehouse=' . urlencode ( $search_warehouse );
}
if ( $search_user ) {
$param .= '&search_user=' . urlencode ( $search_user );
}
2020-02-11 18:18:04 +01:00
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
// List of mass actions available
$arrayofmassactions = array (
// 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
2021-02-26 18:26:44 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) {
$arrayofmassactions = array ();
}
2020-02-11 18:18:04 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-26 18:26:44 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2020-02-11 18:18:04 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2021-02-26 18:26:44 +01:00
if ( $id > 0 ) {
print '<input type="hidden" name="id" value="' . $id . '">' ;
}
2020-02-11 18:18:04 +01:00
2021-02-26 18:26:44 +01:00
if ( $id > 0 ) {
print_barre_liste ( $texte , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , '' , '' , $limit );
} else {
print_barre_liste ( $texte , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'generic' , 0 , '' , '' , $limit );
}
2020-02-11 18:18:04 +01:00
$moreforfilter = '' ;
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2021-02-26 18:26:44 +01:00
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
2020-02-11 18:18:04 +01:00
2021-02-26 18:26:44 +01:00
if ( ! empty ( $moreforfilter )) {
2020-02-11 18:18:04 +01:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
// Fields title search
print '<tr class="liste_titre_filter">' ;
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.rowid' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Ref
print '<td class="liste_titre left">' ;
print '<input class="flat maxwidth25" type="text" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.datem' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre nowraponall">' ;
print '<input class="flat" type="text" size="2" maxlength="2" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " Month " )) . '" name="month" value="' . $month . '">' ;
2021-02-26 18:26:44 +01:00
if ( empty ( $conf -> productbatch -> enabled )) {
print ' ' ;
}
2020-02-11 18:18:04 +01:00
//else print '<br>';
$syear = $year ? $year : - 1 ;
print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " Year " )) . '" name="year" value="' . ( $syear > 0 ? $syear : '' ) . '">' ;
//print $formother->selectyear($syear,'year',1, 20, 5);
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Product Ref
print '<td class="liste_titre left">' ;
print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="' . dol_escape_htmltag ( $idproduct ? $product -> ref : $search_product_ref ) . '">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'p.label' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Product label
print '<td class="liste_titre left">' ;
print '<input class="flat maxwidth100" type="text" name="search_product" value="' . dol_escape_htmltag ( $idproduct ? $product -> label : $search_product ) . '">' ;
print '</td>' ;
}
// Batch
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.batch' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="' . dol_escape_htmltag ( $search_batch ) . '"></td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'pl.eatby' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre left">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'pl.sellby' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre left">' ;
print '</td>' ;
}
// Warehouse
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre maxwidthonsmartphone left">' ;
//print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
print $formproduct -> selectWarehouses ( $search_warehouse , 'search_warehouse' , 'warehouseopen,warehouseinternal' , 1 , 0 , 0 , '' , 0 , 0 , null , 'maxwidth200' );
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.fk_user_author' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Author
print '<td class="liste_titre left">' ;
print '<input class="flat" type="text" size="6" name="search_user" value="' . dol_escape_htmltag ( $search_user ) . '">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.inventorycode' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Inventory code
print '<td class="liste_titre left">' ;
print '<input class="flat" type="text" size="4" name="search_inventorycode" value="' . dol_escape_htmltag ( $search_inventorycode ) . '">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.label' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Label of movement
print '<td class="liste_titre left">' ;
print '<input class="flat" type="text" size="8" name="search_movement" value="' . dol_escape_htmltag ( $search_movement ) . '">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.type_mouvement' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Type of movement
print '<td class="liste_titre center">' ;
//print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">';
print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">' ;
2020-10-16 13:30:20 +02:00
print '<option value="" ' . (( $search_type_mouvement == " " ) ? 'selected="selected"' : '' ) . '> </option>' ;
2020-02-11 18:18:04 +01:00
print '<option value="0" ' . (( $search_type_mouvement == " 0 " ) ? 'selected="selected"' : '' ) . '>' . $langs -> trans ( 'StockIncreaseAfterCorrectTransfer' ) . '</option>' ;
print '<option value="1" ' . (( $search_type_mouvement == " 1 " ) ? 'selected="selected"' : '' ) . '>' . $langs -> trans ( 'StockDecreaseAfterCorrectTransfer' ) . '</option>' ;
print '<option value="2" ' . (( $search_type_mouvement == " 2 " ) ? 'selected="selected"' : '' ) . '>' . $langs -> trans ( 'StockDecrease' ) . '</option>' ;
print '<option value="3" ' . (( $search_type_mouvement == " 3 " ) ? 'selected="selected"' : '' ) . '>' . $langs -> trans ( 'StockIncrease' ) . '</option>' ;
print '</select>' ;
print ajax_combobox ( 'search_type_mouvement' );
// TODO: add new function $formentrepot->selectTypeOfMovement(...) like
// print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'origin' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Origin of movement
print '<td class="liste_titre left">' ;
print ' ' ;
print '</td>' ;
}
2021-02-27 02:00:00 +01:00
if ( ! empty ( $arrayfields [ 'm.fk_projet' ][ 'checked' ])) {
// fk_project
print '<td class="liste_titre" align="left">' ;
print ' ' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.value' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Qty
print '<td class="liste_titre right">' ;
print '<input class="flat" type="text" size="4" name="search_qty" value="' . dol_escape_htmltag ( $search_qty ) . '">' ;
print '</td>' ;
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.price' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Price
print '<td class="liste_titre left">' ;
print ' ' ;
print '</td>' ;
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.datec' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Date modification
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.tms' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Actions
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpicto ;
print '</td>' ;
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.rowid' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.rowid' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'm.rowid' , '' , $param , '' , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'm.datem' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.datem' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'm.datem' , '' , $param , '' , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'p.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.ref' , '' , $param , '' , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'p.label' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'p.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.label' , '' , $param , '' , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'm.batch' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.batch' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'm.batch' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'pl.eatby' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'pl.eatby' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'pl.eatby' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'pl.sellby' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'pl.sellby' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'pl.sellby' , '' , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-26 18:26:44 +01:00
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// We are on a specific warehouse card, no filter on other should be possible
print_liste_field_titre ( $arrayfields [ 'e.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.ref " , " " , $param , " " , $sortfield , $sortorder );
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.fk_user_author' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.fk_user_author' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.fk_user_author " , " " , $param , " " , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'm.inventorycode' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.inventorycode' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.inventorycode " , " " , $param , " " , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'm.label' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.label " , " " , $param , " " , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'm.type_mouvement' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.type_mouvement' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.type_mouvement " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'origin' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'origin' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , " " , $sortfield , $sortorder );
2021-02-26 18:26:44 +01:00
}
2021-02-27 02:00:00 +01:00
if ( ! empty ( $arrayfields [ 'm.fk_projet' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'm.fk_projet' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.fk_projet " , " " , $param , '' , $sortfield , $sortorder );
}
2021-02-26 18:26:44 +01:00
if ( ! empty ( $arrayfields [ 'm.value' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.value' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.value " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2021-02-26 18:26:44 +01:00
}
if ( ! empty ( $arrayfields [ 'm.price' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'm.price' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " m.price " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
// Extra fields
2020-02-21 17:53:37 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2020-02-11 18:18:04 +01:00
// Hook fields
2020-02-21 17:53:37 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2020-02-11 18:18:04 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.datec' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'p.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.tms' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print_liste_field_titre ( $arrayfields [ 'p.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
print " </tr> \n " ;
$resql = $db -> query ( $sql );
2020-02-21 17:53:37 +01:00
if ( ! $resql ) {
2020-02-11 18:18:04 +01:00
dol_print_error ( $db );
}
$num = $db -> num_rows ( $resql );
2022-01-06 11:07:05 +01:00
$totalarray = array ();
2020-02-11 18:18:04 +01:00
$i = 0 ;
while ( $i < ( $limit ? min ( $num , $limit ) : $num )) {
$objp = $db -> fetch_object ( $resql );
2022-01-03 13:14:40 +01:00
// Multilangs
2022-01-06 11:01:27 +01:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS )) { // If multilang is enabled
// TODO Use a cache here
2022-01-03 13:14:40 +01:00
$sql = " SELECT label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " product_lang " ;
2022-01-06 18:12:02 +01:00
$sql .= " WHERE fk_product = " . (( int ) $objp -> rowid );
$sql .= " AND lang = ' " . $db -> escape ( $langs -> getDefaultLang ()) . " ' " ;
2022-01-03 13:14:40 +01:00
$sql .= " LIMIT 1 " ;
$result = $db -> query ( $sql );
2022-01-06 11:07:05 +01:00
if ( $result ) {
2022-01-03 13:14:40 +01:00
$objtp = $db -> fetch_object ( $result );
2022-01-06 11:07:05 +01:00
if ( ! empty ( $objtp -> label )) {
$objp -> produit = $objtp -> label ;
}
2022-01-03 13:14:40 +01:00
}
}
2020-02-11 18:18:04 +01:00
$userstatic -> id = $objp -> fk_user_author ;
$userstatic -> login = $objp -> login ;
$userstatic -> lastname = $objp -> lastname ;
$userstatic -> firstname = $objp -> firstname ;
$userstatic -> photo = $objp -> photo ;
$productstatic -> id = $objp -> rowid ;
$productstatic -> ref = $objp -> product_ref ;
$productstatic -> label = $objp -> produit ;
$productstatic -> type = $objp -> type ;
$productstatic -> entity = $objp -> entity ;
$productstatic -> status_batch = $objp -> tobatch ;
$productlot -> id = $objp -> lotid ;
$productlot -> batch = $objp -> batch ;
$productlot -> eatby = $objp -> eatby ;
$productlot -> sellby = $objp -> sellby ;
$warehousestatic -> id = $objp -> entrepot_id ;
$warehousestatic -> libelle = $objp -> warehouse_ref ; // deprecated
$warehousestatic -> label = $objp -> warehouse_ref ;
$warehousestatic -> lieu = $objp -> lieu ;
2020-02-21 17:53:37 +01:00
if ( ! empty ( $objp -> fk_origin )) {
2020-02-11 18:18:04 +01:00
$origin = $objectlist -> get_origin ( $objp -> fk_origin , $objp -> origintype );
} else {
$origin = '' ;
}
print '<tr class="oddeven">' ;
// Id movement
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.rowid' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// This is primary not movement id
2022-01-06 11:01:27 +01:00
print '<td>' . dol_escape_htmltag ( $objp -> mid ) . '</td>' ;
2020-02-11 18:18:04 +01:00
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.datem' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Date
2020-02-21 17:53:37 +01:00
print '<td>' . dol_print_date ( $db -> jdate ( $objp -> datem ), 'dayhour' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Product ref
print '<td class="nowraponall">' ;
print $productstatic -> getNomUrl ( 1 , 'stock' , 16 );
print " </td> \n " ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'p.label' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Product label
2021-02-27 02:00:00 +01:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $productstatic -> label ) . '">' ;
2020-02-11 18:18:04 +01:00
print $productstatic -> label ;
print " </td> \n " ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.batch' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="center nowraponall">' ;
2021-02-26 18:26:44 +01:00
if ( $productlot -> id > 0 ) {
2020-02-11 18:18:04 +01:00
print $productlot -> getNomUrl ( 1 );
2021-02-26 18:26:44 +01:00
} else {
2022-01-06 11:01:27 +01:00
print dol_escape_htmltag ( $productlot -> batch ); // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement.
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
print '</td>' ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'pl.eatby' ][ 'checked' ])) {
print '<td class="center">' . dol_print_date ( $objp -> eatby , 'day' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'pl.sellby' ][ 'checked' ])) {
print '<td class="center">' . dol_print_date ( $objp -> sellby , 'day' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
}
// Warehouse
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td>' ;
print $warehousestatic -> getNomUrl ( 1 );
print " </td> \n " ;
}
// Author
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.fk_user_author' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
print '<td class="tdoverflowmax100">' ;
2020-02-21 17:53:37 +01:00
print $userstatic -> getNomUrl ( - 1 );
2020-02-11 18:18:04 +01:00
print " </td> \n " ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.inventorycode' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Inventory code
print '<td>' ;
//print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_card.php' . '?id=' . $objp->entrepot_id . '&search_inventorycode=' . $objp->inventorycode . '&search_type_mouvement=' . $objp->type_mouvement . '">';
2022-01-06 11:07:05 +01:00
print dol_escape_htmltag ( $objp -> inventorycode );
2020-02-11 18:18:04 +01:00
//print '</a>';
print '</td>' ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.label' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Label of movement
2022-01-06 11:07:05 +01:00
print '<td class="tdoverflowmax300" title="' . dol_escape_htmltag ( $objp -> label ) . '">' . dol_escape_htmltag ( $objp -> label ) . '</td>' ;
2020-02-11 18:18:04 +01:00
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.type_mouvement' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Type of movement
switch ( $objp -> type_mouvement ) {
case " 0 " :
2020-02-21 17:53:37 +01:00
print '<td class="center">' . $langs -> trans ( 'StockIncreaseAfterCorrectTransfer' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
break ;
case " 1 " :
2020-02-21 17:53:37 +01:00
print '<td class="center">' . $langs -> trans ( 'StockDecreaseAfterCorrectTransfer' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
break ;
case " 2 " :
2020-02-21 17:53:37 +01:00
print '<td class="center">' . $langs -> trans ( 'StockDecrease' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
break ;
case " 3 " :
2020-02-21 17:53:37 +01:00
print '<td class="center">' . $langs -> trans ( 'StockIncrease' ) . '</td>' ;
2020-02-11 18:18:04 +01:00
break ;
}
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'origin' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Origin of movement
2022-05-23 12:31:37 +02:00
print '<td class="nowraponall">' . $origin . '</td>' ;
2020-02-11 18:18:04 +01:00
}
2021-02-27 02:00:00 +01:00
if ( ! empty ( $arrayfields [ 'm.fk_projet' ][ 'checked' ])) {
// fk_project
print '<td>' ;
if ( $objp -> fk_project != 0 ) {
print $movement -> get_origin ( $objp -> fk_project , 'project' );
}
print '</td>' ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.value' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Qty
print '<td class="right">' ;
2021-02-26 18:26:44 +01:00
if ( $objp -> qt > 0 ) {
2020-02-11 18:18:04 +01:00
print '+' ;
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
print $objp -> qty ;
print '</td>' ;
}
2020-02-21 17:53:37 +01:00
if ( ! empty ( $arrayfields [ 'm.price' ][ 'checked' ])) {
2020-02-11 18:18:04 +01:00
// Price
print '<td class="right">' ;
2021-02-26 18:26:44 +01:00
if ( $objp -> price != 0 ) {
2020-02-11 18:18:04 +01:00
print price ( $objp -> price );
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
print '</td>' ;
}
// Action column
print '<td class="nowrap center">' ;
2021-02-26 18:26:44 +01:00
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2020-02-11 18:18:04 +01:00
$selected = 0 ;
2021-02-26 18:26:44 +01:00
if ( in_array ( $obj -> rowid , $arrayofselected )) {
2020-02-11 18:18:04 +01:00
$selected = 1 ;
2021-02-26 18:26:44 +01:00
}
2020-02-21 17:53:37 +01:00
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2020-02-11 18:18:04 +01:00
}
print '</td>' ;
2021-02-26 18:26:44 +01:00
if ( ! $i ) {
2020-02-21 17:53:37 +01:00
$totalarray [ 'nbfield' ] ++ ;
2021-02-26 18:26:44 +01:00
}
2020-02-11 18:18:04 +01:00
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $resql );
2020-02-11 17:12:22 +01:00
2020-02-11 18:18:04 +01:00
print " </table> " ;
print '</div>' ;
print " </form> " ;
2020-02-11 17:12:22 +01:00
}
// End of page
llxFooter ();
$db -> close ();