2018-10-03 12:22:41 +02:00
< ? php
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 - 2010 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2016 Ferran Marcet < fmarcet @ 2 byte . es >
*
* 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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
2018-10-10 12:19:57 +02:00
* \file htdocs / reception / list . php
* \ingroup reception
* \brief Page to list all receptions
2018-10-03 12:22:41 +02:00
*/
require '../main.inc.php' ;
2018-10-10 12:19:57 +02:00
require_once DOL_DOCUMENT_ROOT . '/reception/class/reception.class.php' ;
2018-10-16 12:05:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
2018-10-22 15:47:42 +02:00
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php' ;
2018-10-03 12:22:41 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2018-10-16 17:22:27 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2018-10-03 12:22:41 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2018-10-10 12:19:57 +02:00
$langs -> load ( " receptions " );
2018-10-03 12:22:41 +02:00
$langs -> load ( " deliveries " );
$langs -> load ( 'companies' );
2018-10-16 12:05:28 +02:00
$langs -> load ( 'bills' );
2018-10-03 12:22:41 +02:00
$socid = GETPOST ( 'socid' , 'int' );
2018-10-16 12:05:28 +02:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
2018-10-03 12:22:41 +02:00
// Security check
2018-10-10 12:19:57 +02:00
$receptionid = GETPOST ( 'id' , 'int' );
2018-10-03 12:22:41 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2018-10-10 12:19:57 +02:00
$result = restrictedArea ( $user , 'reception' , $receptionid , '' );
2018-10-03 12:22:41 +02:00
2018-10-10 12:19:57 +02:00
$diroutputmassaction = $conf -> reception -> dir_output . '/temp/massgeneration/' . $user -> id ;
2018-10-03 12:22:41 +02:00
2018-10-18 15:11:43 +02:00
$search_ref_rcp = GETPOST ( " search_ref_rcp " );
2018-10-03 12:22:41 +02:00
$search_ref_liv = GETPOST ( 'search_ref_liv' );
2018-10-10 12:19:57 +02:00
$search_ref_supplier = GETPOST ( 'search_ref_supplier' );
2018-10-03 12:22:41 +02:00
$search_company = GETPOST ( " search_company " );
$search_town = GETPOST ( 'search_town' , 'alpha' );
$search_zip = GETPOST ( 'search_zip' , 'alpha' );
$search_state = trim ( GETPOST ( " search_state " ));
$search_country = GETPOST ( " search_country " , 'int' );
$search_type_thirdparty = GETPOST ( " search_type_thirdparty " , 'int' );
$search_billed = GETPOST ( " search_billed " , 'int' );
$sall = GETPOST ( 'sall' , 'alphanohtml' );
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
if ( ! $sortfield ) $sortfield = " e.ref " ;
if ( ! $sortorder ) $sortorder = " DESC " ;
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-10-10 12:19:57 +02:00
$contextpage = 'receptionlist' ;
2018-10-03 12:22:41 +02:00
$viewstatut = GETPOST ( 'viewstatut' );
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-10-10 12:19:57 +02:00
$hookmanager -> initHooks ( array ( 'receptionlist' ));
2018-10-03 12:22:41 +02:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2018-10-10 12:19:57 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'reception' );
2018-10-03 12:22:41 +02:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'e.ref' => " Ref " ,
's.nom' => " ThirdParty " ,
'e.note_public' => 'NotePublic' ,
);
if ( empty ( $user -> socid )) $fieldstosearchall [ " e.note_private " ] = " NotePrivate " ;
$checkedtypetiers = 0 ;
$arrayfields = array (
'e.ref' => array ( 'label' => $langs -> trans ( " Ref " ), 'checked' => 1 ),
2018-10-10 12:19:57 +02:00
'e.ref_supplier' => array ( 'label' => $langs -> trans ( " RefSupplier " ), 'checked' => 1 ),
2018-10-03 12:22:41 +02:00
's.nom' => array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 1 ),
's.town' => array ( 'label' => $langs -> trans ( " Town " ), 'checked' => 1 ),
's.zip' => array ( 'label' => $langs -> trans ( " Zip " ), 'checked' => 1 ),
'state.nom' => array ( 'label' => $langs -> trans ( " StateShort " ), 'checked' => 0 ),
'country.code_iso' => array ( 'label' => $langs -> trans ( " Country " ), 'checked' => 0 ),
'typent.code' => array ( 'label' => $langs -> trans ( " ThirdPartyType " ), 'checked' => $checkedtypetiers ),
'e.date_delivery' => array ( 'label' => $langs -> trans ( " DateDeliveryPlanned " ), 'checked' => 1 ),
'e.datec' => array ( 'label' => $langs -> trans ( " DateCreation " ), 'checked' => 0 , 'position' => 500 ),
'e.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
'e.fk_statut' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 , 'position' => 1000 ),
2018-10-10 12:19:57 +02:00
'e.billed' => array ( 'label' => $langs -> trans ( " Billed " ), 'checked' => 1 , 'position' => 1000 , 'enabled' => ( ! empty ( $conf -> global -> WORKFLOW_BILL_ON_RECEPTION )))
2018-10-03 12:22:41 +02:00
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
$arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => $extrafields -> attribute_list [ $key ], 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => $extrafields -> attribute_perms [ $key ]);
}
}
/*
* Actions
*/
if ( GETPOST ( 'cancel' )) { $action = 'list' ; $massaction = '' ; }
2018-10-16 12:05:28 +02:00
if ( ! GETPOST ( 'confirmmassaction' ) && $massaction != 'confirm_createbills' ) { $massaction = '' ; }
2018-10-03 12:22:41 +02:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) // All tests are required to be compatible with all browsers
{
2018-10-10 12:19:57 +02:00
$search_ref_supplier = '' ;
2018-10-18 15:11:43 +02:00
$search_ref_rcp = '' ;
2018-10-03 12:22:41 +02:00
$search_ref_liv = '' ;
$search_company = '' ;
$search_town = '' ;
$search_zip = " " ;
$search_state = " " ;
$search_type = '' ;
$search_country = '' ;
$search_type_thirdparty = '' ;
$search_billed = '' ;
$viewstatut = '' ;
$search_array_options = array ();
}
if ( empty ( $reshook ))
{
2018-10-16 12:05:28 +02:00
if ( $massaction == 'confirm_createbills' ) {
$receptions = GETPOST ( 'toselect' , 'array' );
$createbills_onebythird = GETPOST ( 'createbills_onebythird' , 'int' );
$validate_invoices = GETPOST ( 'valdate_invoices' , 'int' );
$TFact = array ();
$TFactThird = array ();
$nb_bills_created = 0 ;
$db -> begin ();
2018-10-17 11:56:32 +02:00
$errors = array ();
2018-10-16 12:05:28 +02:00
foreach ( $receptions as $id_reception )
2018-12-15 13:58:39 +01:00
{
2018-10-16 12:05:28 +02:00
$rcp = new Reception ( $db );
2018-10-17 11:56:32 +02:00
// On ne facture que les réceptions validées
if ( $rcp -> fetch ( $id_reception ) <= 0 || $rcp -> statut != 1 ){
$errors [] = $langs -> trans ( 'StatusMustBeValidate' , $rcp -> ref );
$error ++ ;
continue ;
}
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
$object = new FactureFournisseur ( $db );
2018-10-18 10:26:32 +02:00
if ( ! empty ( $createbills_onebythird ) && ! empty ( $TFactThird [ $rcp -> socid ])){
$object = $TFactThird [ $rcp -> socid ]; // If option "one bill per third" is set, we use already created reception.
2018-10-22 16:49:36 +02:00
if ( empty ( $object -> rowid ) && $object -> id != null ) $object -> rowid = $object -> id ;
if ( ! empty ( $object -> rowid )) $object -> fetchObjectLinked ();
2018-10-18 10:26:32 +02:00
$rcp -> fetchObjectLinked ();
2018-12-15 13:58:39 +01:00
2018-10-18 10:26:32 +02:00
if ( count ( $rcp -> linkedObjectsIds [ 'order_supplier' ]) > 0 )
{
foreach ( $rcp -> linkedObjectsIds [ 'order_supplier' ] as $key => $value )
{
if ( empty ( $object -> linkedObjectsIds [ 'order_supplier' ]) || ! in_array ( $value , $object -> linkedObjectsIds [ 'order_supplier' ])) //Dont try to link if already linked
$object -> add_object_linked ( 'order_supplier' , $value ); // add supplier order linked object
}
}
}
2018-10-16 12:05:28 +02:00
else {
$object -> socid = $rcp -> socid ;
$object -> type = FactureFournisseur :: TYPE_STANDARD ;
2018-10-17 11:56:32 +02:00
$object -> cond_reglement_id = $rcp -> thirdparty -> cond_reglement_supplier_id ;
$object -> mode_reglement_id = $rcp -> thirdparty -> mode_reglement_supplier_id ;
2018-10-18 10:26:32 +02:00
$object -> fk_account = ! empty ( $rcp -> thirdparty -> fk_account ) ? $rcp -> thirdparty -> fk_account : 0 ;
$object -> remise_percent = ! empty ( $rcp -> thirdparty -> remise_percent ) ? $rcp -> thirdparty -> remise_percent : 0 ;
$object -> remise_absolue = ! empty ( $rcp -> thirdparty -> remise_absolue ) ? $rcp -> thirdparty -> remise_absolue : 0 ;
2018-10-16 12:05:28 +02:00
$object -> fk_project = $rcp -> fk_project ;
2018-10-18 10:26:32 +02:00
$object -> ref_supplier = $rcp -> ref_supplier ;
2018-10-16 12:05:28 +02:00
2018-10-16 17:22:27 +02:00
$datefacture = dol_mktime ( 12 , 0 , 0 , GETPOST ( 'remonth' ), GETPOST ( 'reday' ), GETPOST ( 'reyear' ));
2018-10-16 12:05:28 +02:00
if ( empty ( $datefacture ))
{
$datefacture = dol_mktime ( date ( " h " ), date ( " M " ), 0 , date ( " m " ), date ( " d " ), date ( " Y " ));
}
$object -> date = $datefacture ;
$object -> origin = 'reception' ;
$object -> origin_id = $id_reception ;
2018-12-15 13:58:39 +01:00
2018-10-18 10:26:32 +02:00
$rcp -> fetchObjectLinked ();
if ( count ( $rcp -> linkedObjectsIds [ 'order_supplier' ]) > 0 )
{
foreach ( $rcp -> linkedObjectsIds [ 'order_supplier' ] as $key => $value )
{
$object -> linked_objects [ 'order_supplier' ] = $value ;
}
}
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
$res = $object -> create ( $user );
2018-10-16 14:58:56 +02:00
//var_dump($object->error);exit;
2018-10-16 12:05:28 +02:00
if ( $res > 0 ){
$nb_bills_created ++ ;
$object -> id = $res ;
2018-10-16 12:19:48 +02:00
} else {
2018-10-22 16:49:36 +02:00
$errors [] = $rcp -> ref . ' : ' . $langs -> trans ( $object -> error );
2018-10-16 12:19:48 +02:00
$error ++ ;
2018-10-16 12:05:28 +02:00
}
}
if ( $object -> id > 0 )
{
if ( ! empty ( $createbills_onebythird ) && ! empty ( $TFactThird [ $rcp -> socid ])){ //cause function create already add object linked for facturefournisseur
$res = $object -> add_object_linked ( $object -> origin , $id_reception );
if ( $res == 0 )
{
2018-10-17 11:56:32 +02:00
$errors [] = $object -> error ;
2018-10-16 12:05:28 +02:00
$error ++ ;
}
}
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
if ( ! $error )
{
$lines = $rcp -> lines ;
if ( empty ( $lines ) && method_exists ( $rcp , 'fetch_lines' ))
{
$rcp -> fetch_lines ();
$lines = $rcp -> lines ;
}
$fk_parent_line = 0 ;
$num = count ( $lines );
for ( $i = 0 ; $i < $num ; $i ++ )
{
$desc = ( $lines [ $i ] -> desc ? $lines [ $i ] -> desc : $lines [ $i ] -> libelle );
if ( $lines [ $i ] -> subprice < 0 )
{
// Negative line, we create a discount line
$discount = new DiscountAbsolute ( $db );
$discount -> fk_soc = $object -> socid ;
$discount -> amount_ht = abs ( $lines [ $i ] -> total_ht );
$discount -> amount_tva = abs ( $lines [ $i ] -> total_tva );
$discount -> amount_ttc = abs ( $lines [ $i ] -> total_ttc );
$discount -> tva_tx = $lines [ $i ] -> tva_tx ;
$discount -> fk_user = $user -> id ;
$discount -> description = $desc ;
$discountid = $discount -> create ( $user );
if ( $discountid > 0 )
{
$result = $object -> insert_discount ( $discountid );
//$result=$discount->link_to_invoice($lineid,$id);
}
else
{
setEventMessages ( $discount -> error , $discount -> errors , 'errors' );
$error ++ ;
break ;
}
}
else
{
// Positive line
$product_type = ( $lines [ $i ] -> product_type ? $lines [ $i ] -> product_type : 0 );
// Date start
$date_start = false ;
if ( $lines [ $i ] -> date_debut_prevue ) $date_start = $lines [ $i ] -> date_debut_prevue ;
if ( $lines [ $i ] -> date_debut_reel ) $date_start = $lines [ $i ] -> date_debut_reel ;
if ( $lines [ $i ] -> date_start ) $date_start = $lines [ $i ] -> date_start ;
//Date end
$date_end = false ;
if ( $lines [ $i ] -> date_fin_prevue ) $date_end = $lines [ $i ] -> date_fin_prevue ;
if ( $lines [ $i ] -> date_fin_reel ) $date_end = $lines [ $i ] -> date_fin_reel ;
if ( $lines [ $i ] -> date_end ) $date_end = $lines [ $i ] -> date_end ;
// Reset fk_parent_line for no child products and special product
if (( $lines [ $i ] -> product_type != 9 && empty ( $lines [ $i ] -> fk_parent_line )) || $lines [ $i ] -> product_type == 9 )
{
$fk_parent_line = 0 ;
}
$result = $object -> addline (
$desc ,
$lines [ $i ] -> subprice ,
$lines [ $i ] -> tva_tx ,
$lines [ $i ] -> localtax1_tx ,
$lines [ $i ] -> localtax2_tx ,
$lines [ $i ] -> qty ,
$lines [ $i ] -> fk_product ,
$lines [ $i ] -> remise_percent ,
$date_start ,
$date_end ,
0 ,
$lines [ $i ] -> info_bits ,
'HT' ,
$product_type ,
$i ,
false ,
0 ,
null ,
2018-10-22 14:32:50 +02:00
$lines [ $i ] -> rowid ,
0 ,
$lines [ $i ] -> ref_supplier
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
);
2018-12-15 13:58:39 +01:00
2018-10-17 11:56:32 +02:00
$rcp -> add_object_linked ( 'facture_fourn_det' , $result );
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
if ( $result > 0 )
{
$lineid = $result ;
}
else
{
$lineid = 0 ;
$error ++ ;
break ;
}
// Defined the new fk_parent_line
if ( $result > 0 && $lines [ $i ] -> product_type == 9 )
{
$fk_parent_line = $result ;
}
}
}
}
}
//$rcp->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
if ( ! empty ( $createbills_onebythird ) && empty ( $TFactThird [ $rcp -> socid ])) $TFactThird [ $rcp -> socid ] = $object ;
else $TFact [ $object -> id ] = $object ;
}
// Build doc with all invoices
$TAllFact = empty ( $createbills_onebythird ) ? $TFact : $TFactThird ;
$toselect = array ();
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
if ( ! $error && $validate_invoices )
{
$massaction = $action = 'builddoc' ;
foreach ( $TAllFact as & $object )
{
$result = $object -> validate ( $user );
if ( $result <= 0 )
{
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
break ;
}
$id = $object -> id ; // For builddoc action
// Fac builddoc
$donotredirect = 1 ;
$upload_dir = $conf -> fournisseur -> facture -> dir_output ;
$permissioncreate = $user -> rights -> fournisseur -> facture -> creer ;
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
}
$massaction = $action = 'confirm_createbills' ;
}
if ( ! $error )
{
$db -> commit ();
setEventMessage ( $langs -> trans ( 'BillCreated' , $nb_bills_created ));
}
else
{
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
$db -> rollback ();
$action = 'create' ;
$_GET [ " origin " ] = $_POST [ " origin " ];
$_GET [ " originid " ] = $_POST [ " originid " ];
2018-10-17 11:56:32 +02:00
setEventMessages ( $object -> error , $errors , 'errors' );
2018-10-16 12:05:28 +02:00
$error ++ ;
}
2018-10-03 12:22:41 +02:00
}
}
/*
* View
*/
$form = new Form ( $db );
$companystatic = new Societe ( $db );
2018-10-10 12:19:57 +02:00
$reception = new Reception ( $db );
2018-10-03 12:22:41 +02:00
$formcompany = new FormCompany ( $db );
2018-10-16 17:22:27 +02:00
$formfile = new FormFile ( $db );
2018-10-03 12:22:41 +02:00
2018-10-10 12:19:57 +02:00
$helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:Módulo_Receptiones' ;
llxHeader ( '' , $langs -> trans ( 'ListOfReceptions' ), $helpurl );
2018-10-03 12:22:41 +02:00
2018-10-10 12:19:57 +02:00
$sql = " SELECT e.rowid, e.ref, e.ref_supplier, e.date_reception as date_reception, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed, " ;
2018-10-03 12:22:41 +02:00
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ' ;
$sql .= " typent.code as typent_code, " ;
$sql .= " state.code_departement as state_code, state.nom as state_name, " ;
$sql .= ' e.date_creation as date_creation, e.tms as date_update' ;
// Add fields from extrafields
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2018-10-10 12:19:57 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " reception as e " ;
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " reception_extrafields as ef on (e.rowid = ef.fk_object) " ;
2018-10-03 12:22:41 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON s.rowid = e.fk_soc " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as country on (country.rowid = s.fk_pays) " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_typent as typent on (typent.id = s.fk_typent) " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_departements as state on (state.rowid = s.fk_departement) " ;
2018-10-10 12:19:57 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'reception' AND ee.targettype = 'delivery' " ;
2018-10-03 12:22:41 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " livraison as l ON l.rowid = ee.fk_target " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) // Internal user with no permission to see all
{
$sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
}
2018-10-10 12:19:57 +02:00
$sql .= " WHERE e.entity IN ( " . getEntity ( 'reception' ) . " ) " ;
2018-10-03 12:22:41 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) // Internal user with no permission to see all
{
$sql .= " AND e.fk_soc = sc.fk_soc " ;
$sql .= " AND sc.fk_user = " . $user -> id ;
}
if ( $socid )
{
$sql .= " AND e.fk_soc = " . $socid ;
}
if ( $viewstatut <> '' && $viewstatut >= 0 ) {
$sql .= " AND e.fk_statut = " . $viewstatut ;
}
if ( $search_billed != '' && $search_billed >= 0 ) $sql .= ' AND e.billed = ' . $search_billed ;
if ( $search_town ) $sql .= natural_search ( 's.town' , $search_town );
if ( $search_zip ) $sql .= natural_search ( " s.zip " , $search_zip );
if ( $search_state ) $sql .= natural_search ( " state.nom " , $search_state );
if ( $search_country ) $sql .= " AND s.fk_pays IN ( " . $search_country . ')' ;
if ( $search_type_thirdparty ) $sql .= " AND s.fk_typent IN ( " . $search_type_thirdparty . ')' ;
2018-10-18 15:11:43 +02:00
if ( $search_ref_rcp ) $sql .= natural_search ( 'e.ref' , $search_ref_rcp );
2018-10-03 12:22:41 +02:00
if ( $search_ref_liv ) $sql .= natural_search ( 'l.ref' , $search_ref_liv );
if ( $search_company ) $sql .= natural_search ( 's.nom' , $search_company );
2018-10-10 12:19:57 +02:00
if ( $search_ref_supplier ) $sql .= natural_search ( 'e.ref_supplier' , $search_ref_supplier );
2018-10-03 12:22:41 +02:00
if ( $sall ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
// Add where from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$typ = $extrafields -> attribute_type [ $tmpkey ];
$mode = 0 ;
if ( in_array ( $typ , array ( 'int' , 'double' , 'real' ))) $mode = 1 ; // Search on a numeric
if ( in_array ( $typ , array ( 'sellist' )) && $crit != '0' && $crit != '-1' ) $mode = 2 ; // Search on a foreign key int
if ( $crit != '' && ( ! in_array ( $typ , array ( 'select' , 'sellist' )) || $crit != '0' ))
{
$sql .= natural_search ( 'ef.' . $tmpkey , $crit , $mode );
}
}
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$nbtotalofrecords = '' ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
}
$sql .= $db -> order ( $sortfield , $sortorder );
$sql .= $db -> plimit ( $limit + 1 , $offset );
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2018-10-10 12:19:57 +02:00
$reception = new Reception ( $db );
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2018-10-03 12:22:41 +02:00
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $sall ) $param .= " &sall= " . $sall ;
2018-10-18 15:11:43 +02:00
if ( $search_ref_rcp ) $param .= " &search_ref_rcp= " . $search_ref_rcp ;
2018-10-03 12:22:41 +02:00
if ( $search_ref_liv ) $param .= " &search_ref_liv= " . $search_ref_liv ;
if ( $search_company ) $param .= " &search_company= " . $search_company ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
2018-12-15 13:58:39 +01:00
if ( $search_billed != '' && $search_billed >= 0 ) $param .= " &search_billed= " . $search_billed ;
2018-10-22 16:08:43 +02:00
if ( $search_town ) $param .= " &search_town= " . $search_town ;
if ( $search_zip ) $param .= " &search_zip= " . $search_zip ;
if ( $search_state ) $param .= " &search_state= " . $search_state ;
if ( $viewstatut ) $param .= " &viewstatut= " . $viewstatut ;
2018-12-15 13:58:39 +01:00
if ( $search_country ) $param .= " &search_country= " . $search_country ;
2018-10-22 16:08:43 +02:00
if ( $search_type_thirdparty ) $param .= " &search_type_thirdparty= " . $search_type_thirdparty ;
if ( $search_ref_supplier ) $param .= " &search_ref_supplier= " . $search_ref_supplier ;
2018-10-03 12:22:41 +02:00
// Add $param from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
if ( $val != '' ) $param .= '&search_options_' . $tmpkey . '=' . urlencode ( $val );
}
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
$arrayofmassactions = array (
// 'presend'=>$langs->trans("SendByMail"),
);
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
if ( $user -> rights -> fournisseur -> facture -> creer ) $arrayofmassactions [ 'createbills' ] = $langs -> trans ( " CreateInvoiceForThisSupplier " );
if ( $massaction == 'createbills' ) $arrayofmassactions = array ();
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2018-10-03 12:22:41 +02:00
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
$i = 0 ;
print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2018-10-16 12:05:28 +02:00
print_barre_liste ( $langs -> trans ( 'ListOfReceptions' ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , '' , 0 , '' , '' , $limit );
2018-12-15 13:58:39 +01:00
2018-10-16 12:05:28 +02:00
if ( $massaction == 'createbills' )
{
//var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createbills">' ;
2018-10-03 12:22:41 +02:00
2018-10-16 12:05:28 +02:00
print '<table class="noborder" width="100%" >' ;
print '<tr>' ;
print '<td class="titlefieldmiddle">' ;
print $langs -> trans ( 'DateInvoice' );
print '</td>' ;
print '<td>' ;
print $form -> select_date ( '' , '' , '' , '' , '' , '' , 1 , 1 );
print '</td>' ;
print '</tr>' ;
print '<tr>' ;
print '<td>' ;
print $langs -> trans ( 'CreateOneBillByThird' );
print '</td>' ;
print '<td>' ;
print $form -> selectyesno ( 'createbills_onebythird' , '' , 1 );
print '</td>' ;
print '</tr>' ;
print '<tr>' ;
print '<td>' ;
print $langs -> trans ( 'ValidateInvoices' );
print '</td>' ;
print '<td>' ;
if ( ! empty ( $conf -> stock -> enabled ) && ! empty ( $conf -> global -> STOCK_CALCULATE_ON_BILL ))
{
print $form -> selectyesno ( 'valdate_invoices' , 0 , 1 , 1 );
print ' (' . $langs -> trans ( " AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation " ) . ')' ;
}
else
{
print $form -> selectyesno ( 'valdate_invoices' , 0 , 1 );
}
print '</td>' ;
print '</tr>' ;
print '</table>' ;
print '<br>' ;
print '<div class="center">' ;
print '<input type="submit" class="button" id="createbills" name="createbills" value="' . $langs -> trans ( 'CreateInvoiceForThisSupplier' ) . '"> ' ;
print '<input type="submit" class="button" id="cancel" name="cancel" value="' . $langs -> trans ( 'Cancel' ) . '">' ;
print '</div>' ;
print '<br>' ;
}
2018-12-15 13:58:39 +01:00
2018-10-03 12:22:41 +02:00
if ( $sall )
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall );
}
$moreforfilter = '' ;
if ( ! empty ( $moreforfilter ))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
$parameters = array ( 'type' => $type );
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
print '</div>' ;
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2018-10-16 12:05:28 +02:00
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
2018-10-03 12:22:41 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
// Lignes des champs de filtre
print '<tr class="liste_titre_filter">' ;
// Ref
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
2018-10-18 15:11:43 +02:00
print '<input class="flat" size="6" type="text" name="search_ref_rcp" value="' . $search_ref_rcp . '">' ;
2018-10-03 12:22:41 +02:00
print '</td>' ;
}
// Ref customer
2018-10-10 12:19:57 +02:00
if ( ! empty ( $arrayfields [ 'e.ref_supplier' ][ 'checked' ]))
2018-10-03 12:22:41 +02:00
{
print '<td class="liste_titre">' ;
2018-10-10 12:19:57 +02:00
print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="' . $search_ref_supplier . '">' ;
2018-10-03 12:22:41 +02:00
print '</td>' ;
}
// Thirdparty
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
print '<td class="liste_titre" align="left">' ;
print '<input class="flat" type="text" size="8" name="search_company" value="' . dol_escape_htmltag ( $search_company ) . '">' ;
print '</td>' ;
}
// Town
if ( ! empty ( $arrayfields [ 's.town' ][ 'checked' ])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="' . $search_town . '"></td>' ;
// Zip
if ( ! empty ( $arrayfields [ 's.zip' ][ 'checked' ])) print '<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="' . $search_zip . '"></td>' ;
// State
if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat" size="4" type="text" name="search_state" value="' . dol_escape_htmltag ( $search_state ) . '">' ;
print '</td>' ;
}
// Country
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ]))
{
print '<td class="liste_titre" align="center">' ;
print $form -> select_country ( $search_country , 'search_country' , '' , 0 , 'maxwidth100' );
print '</td>' ;
}
// Company type
if ( ! empty ( $arrayfields [ 'typent.code' ][ 'checked' ]))
{
print '<td class="liste_titre maxwidthonsmartphone" align="center">' ;
print $form -> selectarray ( " search_type_thirdparty " , $formcompany -> typent_array ( 0 ), $search_type_thirdparty , 0 , 0 , 0 , '' , 0 , 0 , 0 , ( empty ( $conf -> global -> SOCIETE_SORT_ON_TYPEENT ) ? 'ASC' : $conf -> global -> SOCIETE_SORT_ON_TYPEENT ));
print '</td>' ;
}
// Date delivery planned
if ( ! empty ( $arrayfields [ 'e.date_delivery' ][ 'checked' ]))
{
print '<td class="liste_titre"> </td>' ;
}
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ]))
{
// Delivery ref
print '<td class="liste_titre">' ;
print '<input class="flat" size="10" type="text" name="search_ref_liv" value="' . $search_ref_liv . '"' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ]))
{
// Date received
print '<td class="liste_titre"> </td>' ;
}
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
$typeofextrafield = $extrafields -> attribute_type [ $key ];
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'int' , 'double' , 'select' )))
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$searchclass = '' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'select' ))) $searchclass = 'searchstring' ;
if ( in_array ( $typeofextrafield , array ( 'int' , 'double' ))) $searchclass = 'searchnum' ;
print '<input class="flat' . ( $searchclass ? ' ' . $searchclass : '' ) . '" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . dol_escape_htmltag ( $search_array_options [ 'search_options_' . $tmpkey ]) . '">' ;
}
print '</td>' ;
}
}
}
// 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
if ( ! empty ( $arrayfields [ 'e.datec' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'e.tms' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Status
if ( ! empty ( $arrayfields [ 'e.fk_statut' ][ 'checked' ]))
{
print '<td class="liste_titre maxwidthonsmartphone" align="right">' ;
2018-10-10 12:19:57 +02:00
print $form -> selectarray ( 'viewstatut' , array ( '0' => $langs -> trans ( 'StatusReceptionDraftShort' ), '1' => $langs -> trans ( 'StatusReceptionValidatedShort' ), '2' => $langs -> trans ( 'StatusReceptionProcessedShort' )), $viewstatut , 1 );
2018-10-03 12:22:41 +02:00
print '</td>' ;
}
// Status billed
if ( ! empty ( $arrayfields [ 'e.billed' ][ 'checked' ]))
{
print '<td class="liste_titre maxwidthonsmartphone" align="center">' ;
print $form -> selectyesno ( 'search_billed' , $search_billed , 1 , 0 , 1 );
print '</td>' ;
}
// Action column
print '<td class="liste_titre" align="middle">' ;
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpicto ;
print '</td>' ;
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.ref " , " " , $param , '' , $sortfield , $sortorder );
2018-10-10 12:19:57 +02:00
if ( ! empty ( $arrayfields [ 'e.ref_supplier' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.ref_supplier' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.ref_supplier " , " " , $param , '' , $sortfield , $sortorder );
2018-10-03 12:22:41 +02:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , 'align="left"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.town' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.town' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 's.town' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.zip' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.zip' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 's.zip' , '' , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'state.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " state.nom " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'country.code_iso' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " country.code_iso " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'typent.code' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'typent.code' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " typent.code " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.date_delivery' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.date_delivery' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.date_delivery " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'l.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " l.ref " , " " , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'l.date_delivery' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " l.date_delivery " , " " , $param , 'align="center"' , $sortfield , $sortorder );
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
$sortonfield = " ef. " . $key ;
if ( ! empty ( $extrafields -> attribute_computed [ $key ])) $sortonfield = '' ;
print_liste_field_titre ( $extralabels [ $key ], $_SERVER [ " PHP_SELF " ], $sortonfield , " " , $param ,( $align ? 'align="' . $align . '"' : '' ), $sortfield , $sortorder );
}
}
}
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'e.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.date_creation " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.fk_statut' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.fk_statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'e.billed' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'e.billed' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " e.billed " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
$i = 0 ;
$var = true ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $resql );
2018-10-10 12:19:57 +02:00
$reception -> id = $obj -> rowid ;
$reception -> ref = $obj -> ref ;
2018-12-15 13:58:39 +01:00
2018-10-03 12:22:41 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> ref = $obj -> name ;
$companystatic -> name = $obj -> name ;
print '<tr class="oddeven">' ;
// Ref
if ( ! empty ( $arrayfields [ 'e.ref' ][ 'checked' ]))
{
print " <td> " ;
2018-10-10 12:19:57 +02:00
print $reception -> getNomUrl ( 1 );
2018-10-16 17:22:27 +02:00
$filename = dol_sanitizeFileName ( $reception -> ref );
$filedir = $conf -> reception -> dir_output . '/' . dol_sanitizeFileName ( $reception -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $reception -> rowid ;
print $formfile -> getDocumentsLink ( $reception -> element , $filename , $filedir );
2018-10-03 12:22:41 +02:00
print " </td> \n " ;
2018-12-15 13:58:39 +01:00
2018-10-03 12:22:41 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Ref customer
2018-10-10 12:19:57 +02:00
if ( ! empty ( $arrayfields [ 'e.ref_supplier' ][ 'checked' ]))
2018-10-03 12:22:41 +02:00
{
print " <td> " ;
2018-10-10 12:19:57 +02:00
print $obj -> ref_supplier ;
2018-10-03 12:22:41 +02:00
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Third party
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
print '<td>' ;
print $companystatic -> getNomUrl ( 1 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Town
if ( ! empty ( $arrayfields [ 's.town' ][ 'checked' ]))
{
print '<td class="nocellnopadd">' ;
print $obj -> town ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Zip
if ( ! empty ( $arrayfields [ 's.zip' ][ 'checked' ]))
{
print '<td class="nocellnopadd">' ;
print $obj -> zip ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// State
if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ]))
{
print " <td> " . $obj -> state_name . " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Country
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ]))
{
print '<td align="center">' ;
$tmparray = getCountry ( $obj -> fk_pays , 'all' );
print $tmparray [ 'label' ];
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Type ent
if ( ! empty ( $arrayfields [ 'typent.code' ][ 'checked' ]))
{
print '<td align="center">' ;
if ( count ( $typenArray ) == 0 ) $typenArray = $formcompany -> typent_array ( 1 );
print $typenArray [ $obj -> typent_code ];
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date delivery planed
if ( ! empty ( $arrayfields [ 'e.date_delivery' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_livraison ), " day " );
/* $now = time ();
2018-10-10 12:19:57 +02:00
if ( ( $now - $db -> jdate ( $obj -> date_reception )) > $conf -> warnings -> lim && $obj -> statutid == 1 )
2018-10-03 12:22:41 +02:00
{
} */
print " </td> \n " ;
}
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ]) || ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ]))
{
2018-10-10 12:19:57 +02:00
$reception -> fetchObjectLinked ( $reception -> id , $reception -> element );
2018-10-03 12:22:41 +02:00
$receiving = '' ;
2018-10-10 12:19:57 +02:00
if ( count ( $reception -> linkedObjects [ 'delivery' ]) > 0 ) $receiving = reset ( $reception -> linkedObjects [ 'delivery' ]);
2018-10-03 12:22:41 +02:00
if ( ! empty ( $arrayfields [ 'l.ref' ][ 'checked' ]))
{
// Ref
print '<td>' ;
print ! empty ( $receiving ) ? $receiving -> getNomUrl ( $db ) : '' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'l.date_delivery' ][ 'checked' ]))
{
// Date received
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_reception ), " day " );
print '</td>' . " \n " ;
}
}
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
print '<td class="tdofextrafield"' ;
$align = $extrafields -> getAlignFlag ( $key );
if ( $align ) print ' align="' . $align . '"' ;
print '>' ;
$tmpkey = 'options_' . $key ;
print $extrafields -> showOutputField ( $key , $obj -> $tmpkey , '' , 1 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
}
}
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 'e.datec' ][ 'checked' ]))
{
print '<td align="center" class="nowrap">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'e.tms' ][ 'checked' ]))
{
print '<td align="center" class="nowrap">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Status
if ( ! empty ( $arrayfields [ 'e.fk_statut' ][ 'checked' ]))
{
2018-10-10 12:19:57 +02:00
print '<td align="right" class="nowrap">' . $reception -> LibStatut ( $obj -> fk_statut , 5 ) . '</td>' ;
2018-10-03 12:22:41 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Billed
if ( ! empty ( $arrayfields [ 'e.billed' ][ 'checked' ]))
{
print '<td align="center">' . yn ( $obj -> billed ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Action column
2018-10-16 12:05:28 +02:00
print '<td align="center">' ;
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0 ;
if ( in_array ( $obj -> rowid , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
2018-10-03 12:22:41 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
print " </tr> \n " ;
$i ++ ;
}
print " </table> " ;
print " </div> " ;
print '</form>' ;
$db -> free ( $resql );
}
else
{
dol_print_error ( $db );
}
llxFooter ();
$db -> close ();