2006-12-11 21:52:01 +01:00
< ? php
/* Copyright ( C ) 2004 - 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-12-09 11:16:04 +01:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2010-05-28 22:41:41 +02:00
* Copyright ( C ) 2005 Eric Seigne < eric . seigne @ ryxeo . com >
2012-12-30 15:11:07 +01:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ capnetworks . com >
2010-09-28 18:24:25 +02:00
* Copyright ( C ) 2010 Juanjo Menent < jmenent @ 2 byte . es >
2015-02-11 22:54:06 +01:00
* Copyright ( C ) 2014 Cedric Gross < c . gross @ kreiz - it . fr >
2016-08-05 10:02:36 +02:00
* Copyright ( C ) 2016 Florian Henry < florian . henry @ atm - consulting . fr >
2017-01-25 16:08:46 +01:00
* Copyright ( C ) 2017 Ferran Marcet < fmarcet @ 2 byte . es >
2006-12-11 21:52: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
* the Free Software Foundation ; either version 2 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
2011-12-17 21:58:44 +01:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
* or see http :// www . gnu . org /
2006-12-11 21:52:01 +01:00
*/
/**
2016-08-05 10:02:36 +02:00
* \file htdocs / fourn / commande / dispatch . php
* \ingroup commande
* \brief Page to dispatch receiving
2008-11-16 02:54:33 +01:00
*/
2017-08-23 16:07:11 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2016-08-05 10:02:36 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_order/modules_commandefournisseur.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/fourn.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.dispatch.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php' ;
if ( ! empty ( $conf -> projet -> enabled ))
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2006-12-11 21:52:01 +01:00
$langs -> load ( 'orders' );
$langs -> load ( 'sendings' );
$langs -> load ( 'companies' );
$langs -> load ( 'bills' );
$langs -> load ( 'deliveries' );
$langs -> load ( 'products' );
$langs -> load ( 'stocks' );
2016-08-05 10:02:36 +02:00
if ( ! empty ( $conf -> productbatch -> enabled ))
$langs -> load ( 'productbatch' );
2006-12-11 21:52:01 +01:00
2016-08-05 10:02:36 +02:00
// Security check
$id = GETPOST ( " id " , 'int' );
$ref = GETPOST ( 'ref' );
2015-03-08 02:08:26 +01:00
$lineid = GETPOST ( 'lineid' , 'int' );
$action = GETPOST ( 'action' );
2016-08-05 10:02:36 +02:00
if ( $user -> societe_id )
$socid = $user -> societe_id ;
2013-03-24 21:06:45 +01:00
$result = restrictedArea ( $user , 'fournisseur' , $id , '' , 'commande' );
2006-12-11 21:52:01 +01:00
2016-08-05 10:02:36 +02:00
if ( empty ( $conf -> stock -> enabled )) {
2010-08-26 16:49:40 +02:00
accessforbidden ();
}
2016-08-05 10:02:36 +02:00
// Recuperation de l'id de projet
$projectid = 0 ;
if ( $_GET [ " projectid " ])
$projectid = GETPOST ( " projectid " , 'int' );
2006-12-11 21:52:01 +01:00
2016-12-09 11:16:04 +01:00
$object = new CommandeFournisseur ( $db );
2010-08-26 16:49:40 +02:00
2016-08-05 10:02:36 +02:00
if ( $id > 0 || ! empty ( $ref )) {
2016-12-09 11:16:04 +01:00
$result = $object -> fetch ( $id , $ref );
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
}
2016-12-09 11:16:04 +01:00
$result = $object -> fetch_thirdparty ();
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
}
}
2016-09-12 01:05:45 +02:00
2006-12-11 21:52:01 +01:00
/*
* Actions
*/
2015-02-11 22:54:06 +01:00
2017-08-23 16:07:11 +02:00
if ( $action == 'checkdispatchline' && ! (( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande -> receptionner )) || ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande_advance -> check ))))
{
$error = 0 ;
2015-03-08 02:08:26 +01:00
$supplierorderdispatch = new CommandeFournisseurDispatch ( $db );
2017-08-23 16:07:11 +02:00
$db -> begin ();
2016-08-05 10:02:36 +02:00
$result = $supplierorderdispatch -> fetch ( $lineid );
if ( ! $result )
2017-08-23 16:07:11 +02:00
{
$error ++ ;
2015-03-08 02:08:26 +01:00
setEventMessages ( $supplierorderdispatch -> error , $supplierorderdispatch -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$action = '' ;
2017-08-23 16:07:11 +02:00
}
if ( ! $error )
{
$result = $supplierorderdispatch -> setStatut ( 1 );
if ( $result < 0 ) {
setEventMessages ( $supplierorderdispatch -> error , $supplierorderdispatch -> errors , 'errors' );
$error ++ ;
$action = '' ;
}
}
if ( ! $error )
{
2016-12-09 11:16:04 +01:00
$result = $object -> calcAndSetStatusDispatch ( $user );
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
$action = '' ;
}
2015-03-08 02:08:26 +01:00
}
2017-08-23 16:07:11 +02:00
if ( ! $error )
{
$db -> commit ();
}
else
{
$db -> rollback ();
}
2015-03-08 02:08:26 +01:00
}
2017-08-23 16:07:11 +02:00
if ( $action == 'uncheckdispatchline' && ! (( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande -> receptionner )) || ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande_advance -> check ))))
{
$error = 0 ;
2015-03-08 02:08:26 +01:00
$supplierorderdispatch = new CommandeFournisseurDispatch ( $db );
2017-08-23 16:07:11 +02:00
$db -> begin ();
2016-08-05 10:02:36 +02:00
$result = $supplierorderdispatch -> fetch ( $lineid );
if ( ! $result )
2017-08-23 16:07:11 +02:00
{
$error ++ ;
2015-03-08 02:08:26 +01:00
setEventMessages ( $supplierorderdispatch -> error , $supplierorderdispatch -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$action = '' ;
2017-08-23 16:07:11 +02:00
}
if ( ! $error )
{
$result = $supplierorderdispatch -> setStatut ( 0 );
if ( $result < 0 ) {
setEventMessages ( $supplierorderdispatch -> error , $supplierorderdispatch -> errors , 'errors' );
$error ++ ;
$action = '' ;
}
}
if ( ! $error )
{
2016-12-09 11:16:04 +01:00
$result = $object -> calcAndSetStatusDispatch ( $user );
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
$action = '' ;
}
2015-03-08 02:08:26 +01:00
}
2017-08-23 16:07:11 +02:00
if ( ! $error )
{
$db -> commit ();
}
else
{
$db -> rollback ();
}
2015-03-08 02:08:26 +01:00
}
2017-08-23 16:07:11 +02:00
if ( $action == 'denydispatchline' && ! (( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande -> receptionner )) || ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande_advance -> check ))))
{
$error = 0 ;
2015-04-09 15:14:50 +02:00
$supplierorderdispatch = new CommandeFournisseurDispatch ( $db );
2017-08-23 16:07:11 +02:00
$db -> begin ();
2016-08-05 10:02:36 +02:00
$result = $supplierorderdispatch -> fetch ( $lineid );
if ( ! $result )
2017-08-23 16:07:11 +02:00
{
$error ++ ;
2015-04-09 15:14:50 +02:00
setEventMessages ( $supplierorderdispatch -> error , $supplierorderdispatch -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$action = '' ;
2017-08-23 16:07:11 +02:00
}
if ( ! $error )
{
$result = $supplierorderdispatch -> setStatut ( 2 );
if ( $result < 0 ) {
setEventMessages ( $supplierorderdispatch -> error , $supplierorderdispatch -> errors , 'errors' );
$error ++ ;
$action = '' ;
}
}
if ( ! $error )
{
2016-12-09 11:16:04 +01:00
$result = $object -> calcAndSetStatusDispatch ( $user );
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
$action = '' ;
}
2015-04-09 15:14:50 +02:00
}
2017-08-23 16:07:11 +02:00
if ( ! $error )
{
$db -> commit ();
}
else
{
$db -> rollback ();
}
2015-04-09 15:14:50 +02:00
}
2016-08-05 10:02:36 +02:00
if ( $action == 'dispatch' && $user -> rights -> fournisseur -> commande -> receptionner ) {
$error = 0 ;
2015-02-10 21:08:02 +01:00
2014-03-01 14:49:30 +01:00
$db -> begin ();
2006-12-11 21:52:01 +01:00
2016-08-05 10:02:36 +02:00
$pos = 0 ;
2017-08-23 16:07:11 +02:00
foreach ( $_POST as $key => $value )
2016-09-12 01:05:45 +02:00
{
2016-08-05 10:02:36 +02:00
// without batch module enabled
2017-08-23 16:07:11 +02:00
if ( preg_match ( '/^product_([0-9]+)_([0-9]+)$/i' , $key , $reg ))
2016-09-12 01:05:45 +02:00
{
2016-08-05 10:02:36 +02:00
$pos ++ ;
// $numline=$reg[2] + 1; // line of product
$numline = $pos ;
$prod = " product_ " . $reg [ 1 ] . '_' . $reg [ 2 ];
$qty = " qty_ " . $reg [ 1 ] . '_' . $reg [ 2 ];
$ent = " entrepot_ " . $reg [ 1 ] . '_' . $reg [ 2 ];
$pu = " pu_ " . $reg [ 1 ] . '_' . $reg [ 2 ]; // This is unit price including discount
$fk_commandefourndet = " fk_commandefourndet_ " . $reg [ 1 ] . '_' . $reg [ 2 ];
// We ask to move a qty
if ( GETPOST ( $qty ) > 0 ) {
if ( ! ( GETPOST ( $ent , 'int' ) > 0 )) {
dol_syslog ( 'No dispatch for line ' . $key . ' as no warehouse choosed' );
$text = $langs -> transnoentities ( 'Warehouse' ) . ', ' . $langs -> transnoentities ( 'Line' ) . ' ' . ( $numline );
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $text ), null , 'errors' );
$error ++ ;
2015-02-10 21:08:02 +01:00
}
2015-04-02 13:57:20 +02:00
2016-08-05 10:02:36 +02:00
if ( ! $error ) {
2016-12-09 11:16:04 +01:00
$result = $object -> dispatchProduct ( $user , GETPOST ( $prod , 'int' ), GETPOST ( $qty ), GETPOST ( $ent , 'int' ), GETPOST ( $pu ), GETPOST ( 'comment' ), '' , '' , '' , GETPOST ( $fk_commandefourndet , 'int' ), $notrigger );
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
2015-03-08 02:08:26 +01:00
}
}
2010-08-26 16:49:40 +02:00
}
2015-02-11 14:46:16 +01:00
}
2016-08-05 10:02:36 +02:00
// with batch module enabled
2017-08-23 16:07:11 +02:00
if ( preg_match ( '/^product_batch_([0-9]+)_([0-9]+)$/i' , $key , $reg ))
2016-09-12 01:05:45 +02:00
{
2016-08-05 10:02:36 +02:00
$pos ++ ;
// eat-by date dispatch
// $numline=$reg[2] + 1; // line of product
$numline = $pos ;
$prod = 'product_batch_' . $reg [ 1 ] . '_' . $reg [ 2 ];
$qty = 'qty_' . $reg [ 1 ] . '_' . $reg [ 2 ];
$ent = 'entrepot_' . $reg [ 1 ] . '_' . $reg [ 2 ];
$pu = 'pu_' . $reg [ 1 ] . '_' . $reg [ 2 ];
$fk_commandefourndet = 'fk_commandefourndet_' . $reg [ 1 ] . '_' . $reg [ 2 ];
$lot = 'lot_number_' . $reg [ 1 ] . '_' . $reg [ 2 ];
$dDLUO = dol_mktime ( 12 , 0 , 0 , $_POST [ 'dluo_' . $reg [ 1 ] . '_' . $reg [ 2 ] . 'month' ], $_POST [ 'dluo_' . $reg [ 1 ] . '_' . $reg [ 2 ] . 'day' ], $_POST [ 'dluo_' . $reg [ 1 ] . '_' . $reg [ 2 ] . 'year' ]);
$dDLC = dol_mktime ( 12 , 0 , 0 , $_POST [ 'dlc_' . $reg [ 1 ] . '_' . $reg [ 2 ] . 'month' ], $_POST [ 'dlc_' . $reg [ 1 ] . '_' . $reg [ 2 ] . 'day' ], $_POST [ 'dlc_' . $reg [ 1 ] . '_' . $reg [ 2 ] . 'year' ]);
$fk_commandefourndet = 'fk_commandefourndet_' . $reg [ 1 ] . '_' . $reg [ 2 ];
// We ask to move a qty
if ( GETPOST ( $qty ) > 0 ) {
if ( ! ( GETPOST ( $ent , 'int' ) > 0 )) {
dol_syslog ( 'No dispatch for line ' . $key . ' as no warehouse choosed' );
$text = $langs -> transnoentities ( 'Warehouse' ) . ', ' . $langs -> transnoentities ( 'Line' ) . ' ' . ( $numline ) . '-' . ( $reg [ 1 ] + 1 );
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $text ), null , 'errors' );
$error ++ ;
2015-03-08 02:08:26 +01:00
}
2015-02-11 22:54:06 +01:00
2016-08-05 10:02:36 +02:00
if ( ! ( GETPOST ( $lot , 'alpha' ) || $dDLUO || $dDLC )) {
dol_syslog ( 'No dispatch for line ' . $key . ' as serial/eat-by/sellby date are not set' );
$text = $langs -> transnoentities ( 'atleast1batchfield' ) . ', ' . $langs -> transnoentities ( 'Line' ) . ' ' . ( $numline ) . '-' . ( $reg [ 1 ] + 1 );
setEventMessages ( $langs -> trans ( 'ErrorFieldRequired' , $text ), null , 'errors' );
$error ++ ;
2015-02-10 21:08:02 +01:00
}
2015-04-02 13:57:20 +02:00
2016-08-05 10:02:36 +02:00
if ( ! $error ) {
2016-12-09 11:16:04 +01:00
$result = $object -> dispatchProduct ( $user , GETPOST ( $prod , 'int' ), GETPOST ( $qty ), GETPOST ( $ent , 'int' ), GETPOST ( $pu ), GETPOST ( 'comment' ), $dDLC , $dDLUO , GETPOST ( $lot , 'alpha' ), GETPOST ( $fk_commandefourndet , 'int' ), $notrigger );
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
2015-02-11 22:54:06 +01:00
}
}
2015-02-10 21:08:02 +01:00
}
2008-11-16 02:54:33 +01:00
}
2006-12-11 21:52:01 +01:00
}
2013-03-24 21:06:45 +01:00
2016-08-05 09:46:17 +02:00
if ( ! $error ) {
2017-03-25 03:53:11 +01:00
$result = $object -> calcAndSetStatusDispatch ( $user , GETPOST ( 'closeopenorder' ) ? 1 : 0 , GETPOST ( 'comment' ));
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
2016-08-05 09:46:17 +02:00
}
}
2016-08-05 10:02:36 +02:00
if ( ! $notrigger && ! $error ) {
2013-02-25 16:56:37 +01:00
global $conf , $langs , $user ;
2016-08-05 10:02:36 +02:00
// Call trigger
2016-08-05 09:46:17 +02:00
2016-12-09 11:16:04 +01:00
$result = $object -> call_trigger ( 'ORDER_SUPPLIER_DISPATCH' , $user );
2016-08-05 10:02:36 +02:00
// End call triggers
2015-02-10 21:08:02 +01:00
2016-08-05 10:02:36 +02:00
if ( $result < 0 ) {
2016-12-09 11:16:04 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-08-05 10:02:36 +02:00
$error ++ ;
2015-02-10 21:08:02 +01:00
}
2013-02-25 16:56:37 +01:00
}
2006-12-11 21:52:01 +01:00
2016-08-05 10:02:36 +02:00
if ( $result >= 0 && ! $error ) {
2014-03-01 14:49:30 +01:00
$db -> commit ();
2016-08-05 10:02:36 +02:00
header ( " Location: dispatch.php?id= " . $id );
exit ();
} else {
2014-03-01 14:49:30 +01:00
$db -> rollback ();
2010-05-28 22:41:41 +02:00
}
2006-12-11 21:52:01 +01:00
}
2008-06-14 12:01:31 +02:00
/*
* View
*/
2016-08-09 13:26:08 +02:00
$now = dol_now ();
2016-08-05 10:02:36 +02:00
$form = new Form ( $db );
2015-12-18 18:00:31 +01:00
$formproduct = new FormProduct ( $db );
2015-02-24 11:19:47 +01:00
$warehouse_static = new Entrepot ( $db );
$supplierorderdispatch = new CommandeFournisseurDispatch ( $db );
2016-08-03 08:25:35 +02:00
$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores' ;
2016-08-09 13:26:08 +02:00
llxHeader ( '' , $langs -> trans ( " Order " ), $help_url , '' , 0 , 0 , array ( '/fourn/js/lib_dispatch.js' ));
2016-08-05 10:02:36 +02:00
if ( $id > 0 || ! empty ( $ref )) {
$soc = new Societe ( $db );
2016-12-09 11:16:04 +01:00
$soc -> fetch ( $object -> socid );
2016-08-05 10:02:36 +02:00
$author = new User ( $db );
2016-12-09 11:16:04 +01:00
$author -> fetch ( $object -> user_author_id );
2016-08-05 10:02:36 +02:00
2016-12-09 11:16:04 +01:00
$head = ordersupplier_prepare_head ( $object );
2016-08-05 10:02:36 +02:00
$title = $langs -> trans ( " SupplierOrder " );
dol_fiche_head ( $head , 'dispatch' , $title , 0 , 'order' );
2017-08-23 16:07:11 +02:00
2016-12-09 11:16:04 +01:00
// Supplier order card
$linkback = '<a href="' . DOL_URL_ROOT . '/fourn/commande/list.php' . ( ! empty ( $socid ) ? '?socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-08-23 16:07:11 +02:00
2016-12-09 11:16:04 +01:00
$morehtmlref = '<div class="refidno">' ;
// Ref supplier
$morehtmlref .= $form -> editfieldkey ( " RefSupplier " , 'ref_supplier' , $object -> ref_supplier , $object , 0 , 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " RefSupplier " , 'ref_supplier' , $object -> ref_supplier , $object , 0 , 'string' , '' , null , null , '' , 1 );
// Thirdparty
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $object -> thirdparty -> getNomUrl ( 1 );
// Project
if ( ! empty ( $conf -> projet -> enabled ))
{
$langs -> load ( " projects " );
$morehtmlref .= '<br>' . $langs -> trans ( 'Project' ) . ' ' ;
if ( $user -> rights -> fournisseur -> commande -> creer )
{
if ( $action != 'classify' )
//$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ' ;
if ( $action == 'classify' ) {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $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="' . $_SESSION [ 'newtoken' ] . '">' ;
$morehtmlref .= $formproject -> select_projects ( $object -> socid , $object -> fk_project , 'projectid' , $maxlength , 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 -> socid , $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
}
} else {
if ( ! empty ( $object -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object -> fk_project . '" title="' . $langs -> trans ( 'ShowProject' ) . '">' ;
$morehtmlref .= $proj -> ref ;
$morehtmlref .= '</a>' ;
} else {
$morehtmlref .= '' ;
}
}
}
$morehtmlref .= '</div>' ;
2017-08-23 16:07:11 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2016-12-09 11:16:04 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-08-23 16:07:11 +02:00
2016-08-05 10:02:36 +02:00
print '<table class="border" width="100%">' ;
// Date
2016-12-09 11:16:04 +01:00
if ( $object -> methode_commande_id > 0 ) {
print '<tr><td class="titlefield">' . $langs -> trans ( " Date " ) . '</td><td>' ;
if ( $object -> date_commande ) {
print dol_print_date ( $object -> date_commande , " dayhourtext " ) . " \n " ;
2016-08-05 10:02:36 +02:00
}
print " </td></tr> " ;
2015-02-24 11:19:47 +01:00
2016-12-09 11:16:04 +01:00
if ( $object -> methode_commande ) {
2017-01-25 12:58:21 +01:00
print '<tr><td>' . $langs -> trans ( " Method " ) . '</td><td>' . $object -> getInputMethod () . '</td></tr>' ;
2016-08-05 10:02:36 +02:00
}
}
2006-12-11 21:52:01 +01:00
2016-08-05 10:02:36 +02:00
// Auteur
print '<tr><td>' . $langs -> trans ( " AuthorRequest " ) . '</td>' ;
2016-12-09 11:16:04 +01:00
print '<td>' . $author -> getNomUrl ( 1 , '' , 0 , 0 , 0 ) . '</td>' ;
2016-08-05 10:02:36 +02:00
print '</tr>' ;
2006-12-11 21:52:01 +01:00
2016-08-05 10:02:36 +02:00
print " </table> " ;
2008-11-16 02:54:33 +01:00
2016-12-09 11:16:04 +01:00
print '</div>' ;
2017-08-23 16:07:11 +02:00
2016-08-05 10:02:36 +02:00
// if ($mesg) print $mesg;
print '<br>' ;
2009-01-31 01:06:19 +01:00
2016-08-05 10:02:36 +02:00
$disabled = 1 ;
if ( ! empty ( $conf -> global -> STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER ))
$disabled = 0 ;
2008-11-16 02:54:33 +01:00
2016-12-09 11:16:04 +01:00
// Line of orders
if ( $object -> statut <= 2 || $object -> statut >= 6 ) {
2016-08-05 10:02:36 +02:00
print $langs -> trans ( " OrderStatusNotReadyToDispatch " );
}
2008-11-16 02:54:33 +01:00
2016-12-09 11:16:04 +01:00
if ( $object -> statut == 3 || $object -> statut == 4 || $object -> statut == 5 ) {
2016-08-05 10:02:36 +02:00
$entrepot = new Entrepot ( $db );
$listwarehouses = $entrepot -> list_array ( 1 );
2009-01-31 01:06:19 +01:00
2016-12-09 11:16:04 +01:00
print '<form method="POST" action="dispatch.php?id=' . $object -> id . '">' ;
2016-08-05 10:02:36 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="dispatch">' ;
2017-08-23 16:07:11 +02:00
2016-12-09 11:16:04 +01:00
print '<div class="div-table-responsive">' ;
2016-08-05 10:02:36 +02:00
print '<table class="noborder" width="100%">' ;
2009-01-31 01:06:19 +01:00
2016-08-05 10:02:36 +02:00
// Set $products_dispatched with qty dispatched for each product id
$products_dispatched = array ();
$sql = " SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commande_fournisseur_dispatch as cfd " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " commande_fournisseurdet as l on l.rowid = cfd.fk_commandefourndet " ;
2016-12-09 11:16:04 +01:00
$sql .= " WHERE cfd.fk_commande = " . $object -> id ;
2016-08-05 10:02:36 +02:00
$sql .= " GROUP BY l.rowid, cfd.fk_product " ;
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$num = $db -> num_rows ( $resql );
$i = 0 ;
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
if ( $num ) {
while ( $i < $num ) {
$objd = $db -> fetch_object ( $resql );
$products_dispatched [ $objd -> rowid ] = price2num ( $objd -> qty , 5 );
2016-12-09 11:16:04 +01:00
$i ++ ;
2016-08-05 10:02:36 +02:00
}
2008-11-16 02:54:33 +01:00
}
2016-08-05 10:02:36 +02:00
$db -> free ( $resql );
2006-12-11 21:52:01 +01:00
}
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
$sql = " SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, SUM(l.qty) as qty, " ;
$sql .= " p.ref, p.label, p.tobatch " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commande_fournisseurdet as l " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " product as p ON l.fk_product=p.rowid " ;
2016-12-09 11:16:04 +01:00
$sql .= " WHERE l.fk_commande = " . $object -> id ;
2016-08-05 10:02:36 +02:00
if ( empty ( $conf -> global -> STOCK_SUPPORTS_SERVICES ))
$sql .= " AND l.product_type = 0 " ;
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent " ; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
$sql .= " ORDER BY p.ref, p.label " ;
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$num = $db -> num_rows ( $resql );
$i = 0 ;
2010-08-26 16:49:40 +02:00
2016-08-05 10:02:36 +02:00
if ( $num ) {
print '<tr class="liste_titre">' ;
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
print '<td>' . $langs -> trans ( " Description " ) . '</td>' ;
print '<td></td>' ;
print '<td></td>' ;
print '<td></td>' ;
print '<td align="right">' . $langs -> trans ( " QtyOrdered " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " QtyDispatchedShort " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " QtyToDispatchShort " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " Warehouse " ) . '</td>' ;
print " </tr> \n " ;
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
if ( ! empty ( $conf -> productbatch -> enabled )) {
2008-11-16 02:54:33 +01:00
print '<tr class="liste_titre">' ;
2015-02-11 22:54:06 +01:00
print '<td></td>' ;
2016-08-05 10:02:36 +02:00
print '<td>' . $langs -> trans ( " batch_number " ) . '</td>' ;
2016-08-08 20:31:03 +02:00
print '<td>' . $langs -> trans ( " EatByDate " ) . '</td>' ;
print '<td>' . $langs -> trans ( " SellByDate " ) . '</td>' ;
2016-08-05 10:02:36 +02:00
print '<td colspan="4"> </td>' ;
2008-11-16 02:54:33 +01:00
print " </tr> \n " ;
}
2016-08-05 10:02:36 +02:00
}
2008-11-16 02:54:33 +01:00
2016-12-09 11:16:04 +01:00
$nbfreeproduct = 0 ; // Nb of lins of free products/services
$nbproduct = 0 ; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default)
// or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on.
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
$var = false ;
while ( $i < $num ) {
$objp = $db -> fetch_object ( $resql );
2010-05-28 23:52:51 +02:00
2016-08-05 10:02:36 +02:00
// On n'affiche pas les produits personnalises
if ( ! $objp -> fk_product > 0 ) {
2016-12-09 11:16:04 +01:00
$nbfreeproduct ++ ;
2016-08-05 10:02:36 +02:00
} else {
$remaintodispatch = price2num ( $objp -> qty - (( float ) $products_dispatched [ $objp -> rowid ]), 5 ); // Calculation of dispatched
if ( $remaintodispatch < 0 )
$remaintodispatch = 0 ;
2015-02-11 22:54:06 +01:00
2016-08-05 10:02:36 +02:00
if ( $remaintodispatch || empty ( $conf -> global -> SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED )) {
2016-12-09 11:16:04 +01:00
$nbproduct ++ ;
2014-03-01 14:49:30 +01:00
2016-08-05 10:02:36 +02:00
$var = ! $var ;
2015-02-11 22:54:06 +01:00
2016-08-05 10:02:36 +02:00
// To show detail cref and description value, we must make calculation by cref
// print ($objp->cref?' ('.$objp->cref.')':'');
// if ($objp->description) print '<br>'.nl2br($objp->description);
$suffix = '_0_' . $i ;
2013-11-14 17:08:59 +01:00
2016-08-05 10:02:36 +02:00
print " \n " ;
print '<!-- Line ' . $suffix . ' -->' . " \n " ;
print " <tr " . $bc [ $var ] . " > " ;
2015-02-11 22:54:06 +01:00
2016-08-05 10:02:36 +02:00
$linktoprod = '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), 'product' ) . ' ' . $objp -> ref . '</a>' ;
$linktoprod .= ' - ' . $objp -> label . " \n " ;
2015-02-19 00:01:26 +01:00
2016-08-05 10:02:36 +02:00
if ( ! empty ( $conf -> productbatch -> enabled )) {
if ( $objp -> tobatch ) {
print '<td colspan="4">' ;
print $linktoprod ;
print " </td> " ;
} else {
2015-02-11 22:54:06 +01:00
print '<td>' ;
2016-08-05 10:02:36 +02:00
print $linktoprod ;
print " </td> " ;
print '<td colspan="3">' ;
print $langs -> trans ( " ProductDoesNotUseBatchSerial " );
2015-12-18 18:00:31 +01:00
print '</td>' ;
2015-02-11 22:54:06 +01:00
}
2016-08-05 10:02:36 +02:00
} else {
print '<td colspan="4">' ;
print $linktoprod ;
print " </td> " ;
}
$var = ! $var ;
$up_ht_disc = $objp -> subprice ;
if ( ! empty ( $objp -> remise_percent ) && empty ( $conf -> global -> STOCK_EXCLUDE_DISCOUNT_FOR_PMP ))
$up_ht_disc = price2num ( $up_ht_disc * ( 100 - $objp -> remise_percent ) / 100 , 'MU' );
2016-12-09 11:16:04 +01:00
// Qty ordered
2016-08-05 10:02:36 +02:00
print '<td align="right">' . $objp -> qty . '</td>' ;
// Already dispatched
print '<td align="right">' . $products_dispatched [ $objp -> rowid ] . '</td>' ;
if ( ! empty ( $conf -> productbatch -> enabled ) && $objp -> tobatch == 1 ) {
$type = 'batch' ;
print '<td align="right">' . img_picto ( $langs -> trans ( 'AddDispatchBatchLine' ), 'split.png' , 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"' ) . '</td>' ; // Dispatch column
print '<td></td>' ; // Warehouse column
print '</tr>' ;
print '<tr ' . $bc [ $var ] . ' name="' . $type . $suffix . '">' ;
print '<td>' ;
print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp -> rowid . '">' ;
print '<input name="product_batch' . $suffix . '" type="hidden" value="' . $objp -> fk_product . '">' ;
print '<input name="pu' . $suffix . '" type="hidden" value="' . $up_ht_disc . '"><!-- This is a up including discount -->' ;
// hidden fields for js function
print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp -> qty . '">' ;
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched [ $objp -> rowid ] . '">' ;
2015-02-11 22:54:06 +01:00
print '</td>' ;
2013-11-14 17:08:59 +01:00
2016-08-05 10:02:36 +02:00
print '<td>' ;
print '<input type="text" id="lot_number' . $suffix . '" name="lot_number' . $suffix . '" size="40" value="' . GETPOST ( 'lot_number' . $suffix ) . '">' ;
print '</td>' ;
print '<td>' ;
$dlcdatesuffix = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dlc' . $suffix . 'month' ), GETPOST ( 'dlc' . $suffix . 'day' ), GETPOST ( 'dlc' . $suffix . 'year' ));
$form -> select_date ( $dlcdatesuffix , 'dlc' . $suffix , '' , '' , 1 , " " );
print '</td>' ;
print '<td>' ;
$dluodatesuffix = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dluo' . $suffix . 'month' ), GETPOST ( 'dluo' . $suffix . 'day' ), GETPOST ( 'dluo' . $suffix . 'year' ));
$form -> select_date ( $dluodatesuffix , 'dluo' . $suffix , '' , '' , 1 , " " );
print '</td>' ;
print '<td colspan="2"> </td>' ; // Qty ordered + qty already dispatached
} else {
$type = 'dispatch' ;
print '<td align="right">' . img_picto ( $langs -> trans ( 'AddStockLocationLine' ), 'split.png' , 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"' ) . '</td>' ; // Dispatch column
print '<td></td>' ;
print '</tr>' ;
print '<tr ' . $bc [ $var ] . ' name="' . $type . $suffix . '">' ;
print '<td colspan="6">' ;
print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp -> rowid . '">' ;
print '<input name="product' . $suffix . '" type="hidden" value="' . $objp -> fk_product . '">' ;
print '<input name="pu' . $suffix . '" type="hidden" value="' . $up_ht_disc . '"><!-- This is a up including discount -->' ;
// hidden fields for js function
print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp -> qty . '">' ;
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched [ $objp -> rowid ] . '">' ;
print '</td>' ;
}
// Dispatch
print '<td align="right">' ;
print '<input id="qty' . $suffix . '" name="qty' . $suffix . '" type="text" size="8" value="' . ( GETPOST ( 'qty' . $suffix ) != '' ? GETPOST ( 'qty' . $suffix ) : $remaintodispatch ) . '">' ;
print '</td>' ;
2015-02-11 22:54:06 +01:00
2016-08-05 10:02:36 +02:00
// Warehouse
print '<td align="right">' ;
if ( count ( $listwarehouses ) > 1 ) {
print $formproduct -> selectWarehouses ( GETPOST ( " entrepot " . $suffix ), " entrepot " . $suffix , '' , 1 , 0 , $objp -> fk_product );
} elseif ( count ( $listwarehouses ) == 1 ) {
print $formproduct -> selectWarehouses ( GETPOST ( " entrepot " . $suffix ), " entrepot " . $suffix , '' , 0 , 0 , $objp -> fk_product );
} else {
2017-03-25 03:53:11 +01:00
$langs -> load ( " errors " );
print $langs -> trans ( " ErrorNoWarehouseDefined " );
2010-08-26 16:49:40 +02:00
}
2016-08-05 10:02:36 +02:00
print " </td> \n " ;
print " </tr> \n " ;
2008-11-16 02:54:33 +01:00
}
}
2016-12-09 11:16:04 +01:00
$i ++ ;
2010-05-28 23:52:51 +02:00
}
2016-08-05 10:02:36 +02:00
$db -> free ( $resql );
} else {
dol_print_error ( $db );
2006-12-11 21:52:01 +01:00
}
2014-03-01 14:49:30 +01:00
2016-08-05 10:02:36 +02:00
print " </table> \n " ;
2016-12-09 11:16:04 +01:00
print '</div>' ;
print " <br> \n " ;
2016-08-05 10:02:36 +02:00
2017-08-23 16:07:11 +02:00
if ( $nbproduct )
2016-09-12 01:05:45 +02:00
{
2016-12-09 11:16:04 +01:00
$checkboxlabel = $langs -> trans ( " CloseReceivedSupplierOrdersAutomatically " , $langs -> transnoentitiesnoconv ( $object -> statuts [ 5 ]));
2017-08-23 16:07:11 +02:00
2016-09-12 01:05:45 +02:00
print '<br><div class="center">' ;
print $langs -> trans ( " Comment " ) . ' : ' ;
2017-03-25 03:53:11 +01:00
print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="' ;
2016-12-09 11:16:04 +01:00
print $_POST [ " comment " ] ? GETPOST ( " comment " ) : $langs -> trans ( " DispatchSupplierOrder " , $object -> ref );
// print ' / '.$object->ref_supplier; // Not yet available
2016-09-12 01:05:45 +02:00
print '" class="flat"><br>' ;
2016-08-05 10:02:36 +02:00
2016-09-12 01:05:45 +02:00
print '<input type="checkbox" checked="checked" name="closeopenorder"> ' . $checkboxlabel ;
2017-08-23 16:07:11 +02:00
2016-09-12 01:05:45 +02:00
print '<br><input type="submit" class="button" value="' . $langs -> trans ( " DispatchVerb " ) . '"' ;
2016-08-05 10:02:36 +02:00
if ( count ( $listwarehouses ) <= 0 )
print ' disabled' ;
print '>' ;
2016-12-09 11:16:04 +01:00
print '</div>' ;
2016-08-05 10:02:36 +02:00
}
2016-12-09 11:16:04 +01:00
// Message if nothing to dispatch
if ( ! $nbproduct ) {
if ( empty ( $conf -> global -> SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED ))
2016-12-26 18:21:18 +01:00
print '<div class="opacitymedium">' . $langs -> trans ( " NoPredefinedProductToDispatch " ) . '</div>' ; // No predefined line at all
2017-08-23 16:07:11 +02:00
else
2016-12-26 18:21:18 +01:00
print '<div class="opacitymedium">' . $langs -> trans ( " NoMorePredefinedProductToDispatch " ) . '</div>' ; // No predefined line that remain to be dispatched.
2016-08-05 10:02:36 +02:00
}
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
print '</form>' ;
}
2008-11-16 02:54:33 +01:00
2016-08-05 10:02:36 +02:00
dol_fiche_end ();
2017-08-23 16:07:11 +02:00
2016-08-05 10:02:36 +02:00
// List of lines already dispatched
$sql = " SELECT p.ref, p.label, " ;
$sql .= " e.rowid as warehouse_id, e.label as entrepot, " ;
$sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " product as p, " ;
$sql .= " " . MAIN_DB_PREFIX . " commande_fournisseur_dispatch as cfd " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " entrepot as e ON cfd.fk_entrepot = e.rowid " ;
2016-12-09 11:16:04 +01:00
$sql .= " WHERE cfd.fk_commande = " . $object -> id ;
2016-08-05 10:02:36 +02:00
$sql .= " AND cfd.fk_product = p.rowid " ;
$sql .= " ORDER BY cfd.rowid ASC " ;
$resql = $db -> query ( $sql );
if ( $resql ) {
$num = $db -> num_rows ( $resql );
$i = 0 ;
if ( $num > 0 ) {
2016-12-09 11:16:04 +01:00
print " <br> \n " ;
2014-03-01 14:49:30 +01:00
2016-08-05 10:02:36 +02:00
print load_fiche_titre ( $langs -> trans ( " ReceivingForSameOrder " ));
2014-03-01 14:49:30 +01:00
2016-12-09 11:16:04 +01:00
print '<div class="div-table-responsive">' ;
2016-08-05 10:02:36 +02:00
print '<table class="noborder" width="100%">' ;
2010-05-28 23:52:51 +02:00
2016-08-05 10:02:36 +02:00
print '<tr class="liste_titre">' ;
2017-03-25 03:53:11 +01:00
print '<td>' . $langs -> trans ( " Product " ) . '</td>' ;
2016-08-05 10:02:36 +02:00
if ( ! empty ( $conf -> productbatch -> enabled )) {
print '<td>' . $langs -> trans ( " batch_number " ) . '</td>' ;
2016-08-08 20:31:03 +02:00
print '<td>' . $langs -> trans ( " EatByDate " ) . '</td>' ;
print '<td>' . $langs -> trans ( " SellByDate " ) . '</td>' ;
2016-08-05 10:02:36 +02:00
}
print '<td align="right">' . $langs -> trans ( " QtyDispatched " ) . '</td>' ;
print '<td></td>' ;
print '<td>' . $langs -> trans ( " Warehouse " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Comment " ) . '</td>' ;
if ( ! empty ( $conf -> global -> SUPPLIER_ORDER_USE_DISPATCH_STATUS ))
print '<td align="center" colspan="2">' . $langs -> trans ( " Status " ) . '</td>' ;
print " </tr> \n " ;
$var = false ;
while ( $i < $num ) {
$objp = $db -> fetch_object ( $resql );
print " <tr " . $bc [ $var ] . " > " ;
print '<td>' ;
print '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp -> fk_product . '">' . img_object ( $langs -> trans ( " ShowProduct " ), 'product' ) . ' ' . $objp -> ref . '</a>' ;
print ' - ' . $objp -> label ;
print " </td> \n " ;
if ( ! empty ( $conf -> productbatch -> enabled )) {
print '<td>' . $objp -> batch . '</td>' ;
print '<td>' . dol_print_date ( $db -> jdate ( $objp -> eatby ), 'day' ) . '</td>' ;
print '<td>' . dol_print_date ( $db -> jdate ( $objp -> sellby ), 'day' ) . '</td>' ;
2015-02-11 22:54:06 +01:00
}
2010-05-28 23:52:51 +02:00
2016-08-05 10:02:36 +02:00
// Qty
print '<td align="right">' . $objp -> qty . '</td>' ;
print '<td> </td>' ;
// Warehouse
print '<td>' ;
$warehouse_static -> id = $objp -> warehouse_id ;
$warehouse_static -> libelle = $objp -> entrepot ;
print $warehouse_static -> getNomUrl ( 1 );
print '</td>' ;
// Comment
2017-03-25 03:53:11 +01:00
print '<td class="tdoverflowmax300">' . $objp -> comment . '</td>' ;
2016-08-05 10:02:36 +02:00
// Status
if ( ! empty ( $conf -> global -> SUPPLIER_ORDER_USE_DISPATCH_STATUS )) {
print '<td align="right">' ;
$supplierorderdispatch -> status = ( empty ( $objp -> status ) ? 0 : $objp -> status );
// print $supplierorderdispatch->status;
print $supplierorderdispatch -> getLibStatut ( 5 );
2010-07-11 21:29:18 +02:00
print '</td>' ;
2015-02-11 15:03:33 +01:00
2016-08-05 10:02:36 +02:00
// Add button to check/uncheck disaptching
print '<td align="center">' ;
2017-08-23 16:07:11 +02:00
if (( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande -> receptionner )) || ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> fournisseur -> commande_advance -> check )))
{
2016-08-05 10:02:36 +02:00
if ( empty ( $objp -> status )) {
print '<a class="button buttonRefused" href="#">' . $langs -> trans ( " Approve " ) . '</a>' ;
print '<a class="button buttonRefused" href="#">' . $langs -> trans ( " Deny " ) . '</a>' ;
} else {
print '<a class="button buttonRefused" href="#">' . $langs -> trans ( " Disapprove " ) . '</a>' ;
print '<a class="button buttonRefused" href="#">' . $langs -> trans ( " Deny " ) . '</a>' ;
2015-03-08 02:08:26 +01:00
}
2016-08-05 10:02:36 +02:00
} else {
$disabled = '' ;
2016-12-09 11:16:04 +01:00
if ( $object -> statut == 5 )
2016-08-05 10:02:36 +02:00
$disabled = 1 ;
if ( empty ( $objp -> status )) {
print '<a class="button' . ( $disabled ? ' buttonRefused' : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . " &action=checkdispatchline&lineid= " . $objp -> dispatchlineid . '">' . $langs -> trans ( " Approve " ) . '</a>' ;
print '<a class="button' . ( $disabled ? ' buttonRefused' : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . " &action=denydispatchline&lineid= " . $objp -> dispatchlineid . '">' . $langs -> trans ( " Deny " ) . '</a>' ;
}
if ( $objp -> status == 1 ) {
print '<a class="button' . ( $disabled ? ' buttonRefused' : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . " &action=uncheckdispatchline&lineid= " . $objp -> dispatchlineid . '">' . $langs -> trans ( " Reinit " ) . '</a>' ;
print '<a class="button' . ( $disabled ? ' buttonRefused' : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . " &action=denydispatchline&lineid= " . $objp -> dispatchlineid . '">' . $langs -> trans ( " Deny " ) . '</a>' ;
}
if ( $objp -> status == 2 ) {
print '<a class="button' . ( $disabled ? ' buttonRefused' : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . " &action=uncheckdispatchline&lineid= " . $objp -> dispatchlineid . '">' . $langs -> trans ( " Reinit " ) . '</a>' ;
print '<a class="button' . ( $disabled ? ' buttonRefused' : '' ) . '" href="' . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . " &action=checkdispatchline&lineid= " . $objp -> dispatchlineid . '">' . $langs -> trans ( " Approve " ) . '</a>' ;
2015-03-08 02:08:26 +01:00
}
}
2016-08-05 10:02:36 +02:00
print '</td>' ;
2010-05-28 23:52:51 +02:00
}
2016-08-05 10:02:36 +02:00
print " </tr> \n " ;
$i ++ ;
$var = ! $var ;
2008-11-16 02:54:33 +01:00
}
2016-08-05 10:02:36 +02:00
$db -> free ( $resql );
print " </table> \n " ;
2016-12-09 11:16:04 +01:00
print '</div>' ;
2006-12-11 21:52:01 +01:00
}
2016-08-05 10:02:36 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2006-12-11 21:52:01 +01:00
}
}
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-02-11 15:03:33 +01:00
$db -> close ();