2012-05-29 21:48:44 +02:00
< ? php
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-07-14 11:51:27 +02:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-05-29 21:48:44 +02:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
2017-07-12 11:00:18 +02:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ capnetworks . com >
2012-05-29 21:48:44 +02:00
* Copyright ( C ) 2008 Raphael Bertrand ( Resultic ) < raphael . bertrand @ resultic . fr >
2014-07-04 13:37:25 +02:00
* Copyright ( C ) 2010 - 2014 Juanjo Menent < jmenent @ 2 byte . es >
2015-07-15 20:30:33 +02:00
* Copyright ( C ) 2013 Alexandre Spangaro < aspangaro . dolibarr @ gmail . com >
2015-03-25 16:38:18 +01:00
* Copyright ( C ) 2015 Frederic France < frederic . france @ free . fr >
2015-02-27 15:08:08 +01:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2012-05-29 21:48:44 +02:00
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-05-29 21:48:44 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / comm / card . php
2012-05-29 21:48:44 +02:00
* \ingroup commercial compta
* \brief Page to show customer card of a third party
*/
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2015-03-15 23:32:43 +01:00
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2013-02-12 15:31:12 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2017-09-10 19:28:20 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> facture -> enabled )) require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2017-09-10 19:28:20 +02:00
if ( ! empty ( $conf -> facture -> enabled )) require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> propal -> enabled )) require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
if ( ! empty ( $conf -> commande -> enabled )) require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
2015-03-25 16:38:18 +01:00
if ( ! empty ( $conf -> expedition -> enabled )) require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> contrat -> enabled )) require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
if ( ! empty ( $conf -> adherent -> enabled )) require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
if ( ! empty ( $conf -> ficheinter -> enabled )) require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php' ;
2012-05-29 21:48:44 +02:00
2018-05-26 19:03:41 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'companies' , 'banks' ));
2016-06-03 15:43:05 +02:00
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> contrat -> enabled )) $langs -> load ( " contracts " );
if ( ! empty ( $conf -> commande -> enabled )) $langs -> load ( " orders " );
2015-03-25 16:38:18 +01:00
if ( ! empty ( $conf -> expedition -> enabled )) $langs -> load ( " sendings " );
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> facture -> enabled )) $langs -> load ( " bills " );
if ( ! empty ( $conf -> projet -> enabled )) $langs -> load ( " projects " );
if ( ! empty ( $conf -> ficheinter -> enabled )) $langs -> load ( " interventions " );
if ( ! empty ( $conf -> notification -> enabled )) $langs -> load ( " mails " );
2012-05-29 21:48:44 +02:00
// Security check
$id = ( GETPOST ( 'socid' , 'int' ) ? GETPOST ( 'socid' , 'int' ) : GETPOST ( 'id' , 'int' ));
if ( $user -> societe_id > 0 ) $id = $user -> societe_id ;
$result = restrictedArea ( $user , 'societe' , $id , '&societe' );
2017-05-16 13:27:32 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2012-05-29 21:48:44 +02:00
$mode = GETPOST ( " mode " );
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2012-05-29 21:48:44 +02:00
$offset = $conf -> liste_limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
if ( ! $sortorder ) $sortorder = " ASC " ;
if ( ! $sortfield ) $sortfield = " nom " ;
2017-09-15 10:50:50 +02:00
$cancelbutton = GETPOST ( 'cancel' , 'alpha' );
2012-05-29 21:48:44 +02:00
2015-03-14 13:05:28 +01:00
$object = new Client ( $db );
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-03-30 16:44:58 +02:00
$hookmanager -> initHooks ( array ( 'thirdpartycomm' , 'globalcard' ));
2014-05-07 17:23:38 +02:00
2012-05-29 21:48:44 +02:00
/*
* Actions
*/
2016-10-30 22:10:00 +01:00
$parameters = array ( 'id' => $id , 'socid' => $id );
2014-05-07 17:23:38 +02:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some
2014-09-28 03:41:32 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2014-05-07 17:23:38 +02:00
2015-01-18 17:13:42 +01:00
if ( empty ( $reshook ))
2012-05-29 21:48:44 +02:00
{
2015-01-18 18:44:22 +01:00
if ( $cancelbutton )
{
$action = " " ;
}
2015-05-06 23:13:07 +02:00
// set accountancy code
2015-01-17 19:28:27 +01:00
if ( $action == 'setcustomeraccountancycode' )
2012-05-29 21:48:44 +02:00
{
2014-12-23 11:00:18 +01:00
$result = $object -> fetch ( $id );
$object -> code_compta = $_POST [ " customeraccountancycode " ];
$result = $object -> update ( $object -> id , $user , 1 , 1 , 0 );
2015-11-07 21:56:21 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2012-05-29 21:48:44 +02:00
}
2015-01-17 19:28:27 +01:00
// conditions de reglement
if ( $action == 'setconditions' && $user -> rights -> societe -> creer )
{
$object -> fetch ( $id );
$result = $object -> setPaymentTerms ( GETPOST ( 'cond_reglement_id' , 'int' ));
2015-11-07 21:56:21 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
}
2015-01-17 14:34:16 +01:00
2015-01-17 19:28:27 +01:00
// mode de reglement
if ( $action == 'setmode' && $user -> rights -> societe -> creer )
{
$object -> fetch ( $id );
$result = $object -> setPaymentMethods ( GETPOST ( 'mode_reglement_id' , 'int' ));
2015-11-07 21:56:21 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
}
2015-01-17 14:34:16 +01:00
2016-06-03 15:43:05 +02:00
// Bank account
if ( $action == 'setbankaccount' && $user -> rights -> societe -> creer )
{
$object -> fetch ( $id );
$result = $object -> setBankAccount ( GETPOST ( 'fk_account' , 'int' ));
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2017-06-07 16:44:04 +02:00
2016-06-03 15:43:05 +02:00
// customer preferred shipping method
2016-04-04 18:28:55 +02:00
if ( $action == 'setshippingmethod' && $user -> rights -> societe -> creer )
{
$object -> fetch ( $id );
$result = $object -> setShippingMethod ( GETPOST ( 'shipping_method_id' , 'int' ));
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2015-01-17 19:28:27 +01:00
// assujetissement a la TVA
if ( $action == 'setassujtva' && $user -> rights -> societe -> creer )
{
$object -> fetch ( $id );
$object -> tva_assuj = $_POST [ 'assujtva_value' ];
2015-01-18 18:44:22 +01:00
$result = $object -> update ( $object -> id );
2015-11-07 21:56:21 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
}
2012-05-29 21:48:44 +02:00
2015-01-17 19:28:27 +01:00
// set prospect level
if ( $action == 'setprospectlevel' && $user -> rights -> societe -> creer )
{
$object -> fetch ( $id );
$object -> fk_prospectlevel = GETPOST ( 'prospect_level_id' , 'alpha' );
2016-04-16 22:13:28 +02:00
$result = $object -> update ( $object -> id , $user );
2015-11-10 19:22:27 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-01-17 19:28:27 +01:00
}
2013-02-12 19:16:48 +01:00
2015-06-05 10:49:02 +02:00
// set communication status
2015-05-06 23:13:07 +02:00
if ( $action == 'setstcomm' )
2014-12-26 04:44:15 +01:00
{
2014-12-23 11:00:18 +01:00
$object -> fetch ( $id );
2015-05-06 23:13:07 +02:00
$object -> stcomm_id = dol_getIdFromCode ( $db , GETPOST ( 'stcomm' , 'alpha' ), 'c_stcomm' );
2016-04-16 22:13:28 +02:00
$result = $object -> update ( $object -> id , $user );
2015-11-10 19:22:27 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-12-23 11:00:18 +01:00
}
2013-02-12 15:31:12 +01:00
2015-01-18 18:44:22 +01:00
// update outstandng limit
2015-02-24 13:44:00 +01:00
if ( $action == 'setoutstanding_limit' )
2014-12-26 04:44:15 +01:00
{
2014-12-23 11:00:18 +01:00
$object -> fetch ( $id );
2015-04-18 18:48:50 +02:00
$object -> outstanding_limit = GETPOST ( 'outstanding_limit' );
2016-04-16 22:13:28 +02:00
$result = $object -> update ( $object -> id , $user );
2015-11-07 21:56:21 +01:00
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-12-23 11:00:18 +01:00
}
2018-02-08 14:25:44 +01:00
2018-01-20 16:40:56 +01:00
// update order min amount
if ( $action == 'setorder_min_amount' )
{
$object -> fetch ( $id );
2018-09-06 17:37:02 +02:00
$object -> order_min_amount = price2num ( GETPOST ( 'order_min_amount' , 'alpha' ));
2018-01-20 16:40:56 +01:00
$result = $object -> update ( $object -> id , $user );
if ( $result < 0 ) setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2017-06-16 01:02:53 +02:00
2017-06-09 16:37:05 +02:00
if ( $action == 'update_extras' ) {
$object -> fetch ( $id );
2018-02-23 16:11:00 +01:00
$object -> oldcopy = dol_clone ( $object );
2017-06-09 16:37:05 +02:00
// Fill array 'array_options' with data from update form
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2018-02-23 16:11:00 +01:00
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object , GETPOST ( 'attribute' , 'none' ));
2017-06-09 16:37:05 +02:00
if ( $ret < 0 ) $error ++ ;
if ( ! $error )
{
2018-02-20 18:09:38 +01:00
$result = $object -> insertExtraFields ( 'COMPANY_MODIFY' );
2017-10-24 19:04:40 +02:00
if ( $result < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$error ++ ;
}
2017-06-09 16:37:05 +02:00
}
if ( $error ) $action = 'edit_extras' ;
}
2013-09-17 10:27:02 +02:00
}
2012-05-29 21:48:44 +02:00
/*
* View
*/
$contactstatic = new Contact ( $db );
$userstatic = new User ( $db );
$form = new Form ( $db );
2013-02-12 15:31:12 +01:00
$formcompany = new FormCompany ( $db );
2012-05-29 21:48:44 +02:00
2015-01-17 14:34:16 +01:00
if ( $id > 0 && empty ( $object -> id ))
{
// Load data of third party
$res = $object -> fetch ( $id );
2018-01-27 18:46:52 +01:00
if ( $object -> id < 0 ) dol_print_error ( $db , $object -> error , $object -> errors );
2015-01-17 14:34:16 +01:00
}
$title = $langs -> trans ( " CustomerCard " );
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/thirdpartynameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) $title = $object -> name ;
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas' ;
llxHeader ( '' , $title , $help_url );
2018-01-27 18:46:52 +01:00
if ( $object -> id > 0 )
2012-05-29 21:48:44 +02:00
{
$head = societe_prepare_head ( $object );
2017-05-23 01:32:19 +02:00
dol_fiche_head ( $head , 'customer' , $langs -> trans ( " ThirdParty " ), - 1 , 'company' );
2012-05-29 21:48:44 +02:00
2016-09-18 14:12:49 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-06-07 16:44:04 +02:00
2016-09-18 14:12:49 +02:00
dol_banner_tab ( $object , 'socid' , $linkback , ( $user -> societe_id ? 0 : 1 ), 'rowid' , 'nom' );
2017-06-07 16:44:04 +02:00
2013-04-11 20:00:12 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2012-05-29 21:48:44 +02:00
2015-10-13 13:06:32 +02:00
print '<div class="underbanner clearboth"></div>' ;
2012-05-29 21:48:44 +02:00
print '<table class="border" width="100%">' ;
2013-02-12 19:16:48 +01:00
// Prospect/Customer
2016-10-24 13:10:35 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( 'ProspectCustomer' ) . '</td><td>' ;
2013-02-12 19:16:48 +01:00
print $object -> getLibCustProspStatut ();
print '</td></tr>' ;
2012-05-29 21:48:44 +02:00
// Prefix
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) // Old not used prefix field
{
2016-10-24 13:10:35 +02:00
print '<tr><td>' . $langs -> trans ( " Prefix " ) . '</td><td>' ;
2016-04-04 18:28:55 +02:00
print ( $object -> prefix_comm ? $object -> prefix_comm : ' ' );
print '</td></tr>' ;
2012-05-29 21:48:44 +02:00
}
if ( $object -> client )
{
$langs -> load ( " compta " );
2013-05-01 16:05:52 +02:00
print '<tr><td>' ;
2016-10-24 13:10:35 +02:00
print $langs -> trans ( 'CustomerCode' ) . '</td><td>' ;
2012-05-29 21:48:44 +02:00
print $object -> code_client ;
if ( $object -> check_codeclient () <> 0 ) print ' <font class="error">(' . $langs -> trans ( " WrongCustomerCode " ) . ')</font>' ;
print '</td></tr>' ;
print '<tr>' ;
print '<td>' ;
2016-03-25 15:53:44 +01:00
print $form -> editfieldkey ( " CustomerAccountancyCode " , 'customeraccountancycode' , $object -> code_compta , $object , $user -> rights -> societe -> creer );
2016-10-24 13:10:35 +02:00
print '</td><td>' ;
2016-03-25 15:53:44 +01:00
print $form -> editfieldval ( " CustomerAccountancyCode " , 'customeraccountancycode' , $object -> code_compta , $object , $user -> rights -> societe -> creer );
2012-05-29 21:48:44 +02:00
print '</td>' ;
print '</tr>' ;
}
2018-03-15 14:25:09 +01:00
// This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
// We don't need them into customer profile.
// Except for spain and localtax where localtax depends on buyer and not seller
2017-06-16 01:02:53 +02:00
// VAT is used
2018-03-15 14:25:09 +01:00
/*
2012-05-29 21:48:44 +02:00
print '<tr>' ;
2018-03-15 14:25:09 +01:00
print '<td class="nowrap">' ;
print $form -> textwithpicto ( $langs -> trans ( 'VATIsUsed' ), $langs -> trans ( 'VATIsUsedWhenSelling' ));
print '</td>' ;
2017-06-16 01:02:53 +02:00
print '<td>' ;
2012-05-29 21:48:44 +02:00
print yn ( $object -> tva_assuj );
print '</td>' ;
print '</tr>' ;
2018-03-15 14:25:09 +01:00
*/
2012-05-29 21:48:44 +02:00
2018-03-15 14:25:09 +01:00
if ( $mysoc -> country_code == 'ES' )
2012-05-29 21:48:44 +02:00
{
2018-03-15 14:25:09 +01:00
// Local Taxes
if ( $mysoc -> localtax1_assuj == " 1 " )
{
print '<tr><td class="nowrap">' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax1_assuj );
print '</td></tr>' ;
}
if ( $mysoc -> localtax1_assuj == " 1 " )
{
print '<tr><td class="nowrap">' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
print yn ( $object -> localtax2_assuj );
print '</td></tr>' ;
}
2012-05-29 21:48:44 +02:00
}
// TVA Intra
2016-10-24 13:10:35 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( 'VATIntra' ) . '</td><td>' ;
2012-05-29 21:48:44 +02:00
print $object -> tva_intra ;
print '</td></tr>' ;
// Conditions de reglement par defaut
$langs -> load ( 'bills' );
2013-05-01 16:05:52 +02:00
print '<tr><td>' ;
print '<table width="100%" class="nobordernopadding"><tr><td>' ;
2012-05-29 21:48:44 +02:00
print $langs -> trans ( 'PaymentConditions' );
print '<td>' ;
if (( $action != 'editconditions' ) && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editconditions&socid=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
2016-10-24 13:10:35 +02:00
print '</td><td>' ;
2012-05-29 21:48:44 +02:00
if ( $action == 'editconditions' )
{
2014-09-19 14:57:31 +02:00
$form -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> cond_reglement_id , 'cond_reglement_id' , 1 );
2012-05-29 21:48:44 +02:00
}
else
{
2014-09-19 14:57:31 +02:00
$form -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> cond_reglement_id , 'none' );
2012-05-29 21:48:44 +02:00
}
print " </td> " ;
print '</tr>' ;
// Mode de reglement par defaut
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print $langs -> trans ( 'PaymentMode' );
print '<td>' ;
if (( $action != 'editmode' ) && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&socid=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
2016-10-24 13:10:35 +02:00
print '</td><td>' ;
2012-05-29 21:48:44 +02:00
if ( $action == 'editmode' )
{
2018-11-12 16:04:42 +01:00
$form -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> mode_reglement_id , 'mode_reglement_id' , 'CRDT' );
2012-05-29 21:48:44 +02:00
}
else
{
2013-06-16 21:31:21 +02:00
$form -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> mode_reglement_id , 'none' );
2012-05-29 21:48:44 +02:00
}
print " </td> " ;
print '</tr>' ;
2017-09-12 15:13:12 +02:00
if ( ! empty ( $conf -> banque -> enabled ))
2016-06-03 15:43:05 +02:00
{
2017-09-12 15:13:12 +02:00
// Compte bancaire par défaut
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
print $langs -> trans ( 'PaymentBankAccount' );
print '<td>' ;
if (( $action != 'editbankaccount' ) && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editbankaccount&socid=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetBankAccount' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td>' ;
if ( $action == 'editbankaccount' )
{
$form -> formSelectAccount ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> fk_account , 'fk_account' , 1 );
}
else
{
$form -> formSelectAccount ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> fk_account , 'none' );
}
print " </td> " ;
print '</tr>' ;
2016-06-03 15:43:05 +02:00
}
2012-05-29 21:48:44 +02:00
// Relative discounts (Discounts-Drawbacks-Rebates)
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print $langs -> trans ( " CustomerRelativeDiscountShort " );
print '<td><td align="right">' ;
if ( $user -> rights -> societe -> creer && ! $user -> societe_id > 0 )
{
print '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $object -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
}
print '</td></tr></table>' ;
2016-10-24 13:10:35 +02:00
print '</td><td>' . ( $object -> remise_percent ? '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $object -> id . '">' . $object -> remise_percent . '%</a>' : '' ) . '</td>' ;
2012-05-29 21:48:44 +02:00
print '</tr>' ;
// Absolute discounts (Discounts-Drawbacks-Rebates)
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print '<table width="100%" class="nobordernopadding">' ;
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print $langs -> trans ( " CustomerAbsoluteDiscountShort " );
print '<td><td align="right">' ;
if ( $user -> rights -> societe -> creer && ! $user -> societe_id > 0 )
{
print '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $object -> id . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id ) . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
}
print '</td></tr></table>' ;
print '</td>' ;
2016-10-24 13:10:35 +02:00
print '<td>' ;
2012-05-29 21:48:44 +02:00
$amount_discount = $object -> getAvailableDiscounts ();
if ( $amount_discount < 0 ) dol_print_error ( $db , $object -> error );
2014-04-06 21:17:35 +02:00
if ( $amount_discount > 0 ) print '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $object -> id . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id ) . '">' . price ( $amount_discount , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency ) . '</a>' ;
2016-07-29 11:06:03 +02:00
//else print $langs->trans("DiscountNone");
2012-05-29 21:48:44 +02:00
print '</td>' ;
print '</tr>' ;
2017-01-20 12:08:33 +01:00
// Max outstanding bill
if ( $object -> client )
{
print '<tr class="nowrap">' ;
print '<td>' ;
print $form -> editfieldkey ( " OutstandingBill " , 'outstanding_limit' , $object -> outstanding_limit , $object , $user -> rights -> societe -> creer );
print '</td><td>' ;
$limit_field_type = ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_JEDITABLE )) ? 'numeric' : 'amount' ;
print $form -> editfieldval ( " OutstandingBill " , 'outstanding_limit' , $object -> outstanding_limit , $object , $user -> rights -> societe -> creer , $limit_field_type ,( $object -> outstanding_limit != '' ? price ( $object -> outstanding_limit ) : '' ));
//if (empty($object->outstanding_limit)) print $langs->trans("NoLimit");
2017-06-07 16:44:04 +02:00
2018-01-20 16:40:56 +01:00
print '</td>' ;
print '</tr>' ;
2018-09-06 17:37:02 +02:00
}
2018-02-08 14:25:44 +01:00
2018-09-06 17:37:02 +02:00
if ( $object -> client )
{
if ( ! empty ( $conf -> commande -> enabled ) && ! empty ( $conf -> global -> ORDER_MANAGE_MIN_AMOUNT ))
{
print '<!-- Minimim amount for orders -->' . " \n " ;
print '<tr class="nowrap">' ;
print '<td>' ;
print $form -> editfieldkey ( " OrderMinAmount " , 'order_min_amount' , $object -> order_min_amount , $object , $user -> rights -> societe -> creer );
print '</td><td>' ;
print $form -> editfieldval ( " OrderMinAmount " , 'order_min_amount' , $object -> order_min_amount , $object , $user -> rights -> societe -> creer , $limit_field_type ,( $object -> order_min_amount != '' ? price ( $object -> order_min_amount ) : '' ));
print '</td>' ;
print '</tr>' ;
}
2017-01-20 12:08:33 +01:00
}
2018-02-08 14:25:44 +01:00
2017-06-07 16:44:04 +02:00
2012-05-29 21:48:44 +02:00
// Multiprice level
2018-05-23 17:05:08 +02:00
if ( ! empty ( $conf -> global -> PRODUIT_MULTIPRICES ) || ! empty ( $conf -> global -> PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES ))
2012-05-29 21:48:44 +02:00
{
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print $langs -> trans ( " PriceLevel " );
print '<td><td align="right">' ;
if ( $user -> rights -> societe -> creer )
{
print '<a href="' . DOL_URL_ROOT . '/comm/multiprix.php?id=' . $object -> id . '">' . img_edit ( $langs -> trans ( " Modify " )) . '</a>' ;
}
print '</td></tr></table>' ;
2016-10-24 13:10:35 +02:00
print '</td><td>' ;
2014-05-01 12:19:24 +02:00
print $object -> price_level ;
2014-05-04 21:19:24 +02:00
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL' . $object -> price_level ;
2014-05-01 12:19:24 +02:00
if ( ! empty ( $conf -> global -> $keyforlabel )) print ' - ' . $langs -> trans ( $conf -> global -> $keyforlabel );
print " </td> " ;
2012-05-29 21:48:44 +02:00
print '</tr>' ;
}
2013-04-03 15:20:56 +02:00
2016-04-04 18:28:55 +02:00
// Preferred shipping Method
if ( ! empty ( $conf -> global -> SOCIETE_ASK_FOR_SHIPPING_METHOD )) {
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
print $langs -> trans ( 'SendingMethod' );
print '<td>' ;
if (( $action != 'editshipping' ) && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editshipping&socid=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
2016-10-24 13:10:35 +02:00
print '</td><td>' ;
2016-04-04 18:28:55 +02:00
if ( $action == 'editshipping' )
{
$form -> formSelectShippingMethod ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> shipping_method_id , 'shipping_method_id' );
}
else
{
$form -> formSelectShippingMethod ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> shipping_method_id , 'none' );
}
print " </td> " ;
print '</tr>' ;
}
2015-05-29 18:49:10 +02:00
// Categories
2016-05-17 10:33:27 +02:00
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
2016-05-30 01:30:28 +02:00
$langs -> load ( " categories " );
2016-05-17 10:33:27 +02:00
print '<tr><td>' . $langs -> trans ( " CustomersCategoriesShort " ) . '</td>' ;
2016-10-24 13:10:35 +02:00
print '<td>' ;
2015-06-12 15:55:39 +02:00
print $form -> showCategories ( $object -> id , 'customer' , 1 );
print " </td></tr> " ;
}
2015-05-29 18:49:10 +02:00
2015-03-14 13:05:28 +01:00
// Other attributes
2017-06-07 16:44:04 +02:00
$parameters = array ( 'socid' => $object -> id );
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2015-03-14 13:05:28 +01:00
// Sales representative
2012-08-23 02:04:35 +02:00
include DOL_DOCUMENT_ROOT . '/societe/tpl/linesalesrepresentative.tpl.php' ;
2012-06-23 20:39:20 +02:00
2012-05-29 21:48:44 +02:00
// Module Adherent
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> adherent -> enabled ))
2012-05-29 21:48:44 +02:00
{
$langs -> load ( " members " );
$langs -> load ( " users " );
2016-10-31 21:31:57 +01:00
2016-10-30 22:10:00 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
2016-10-24 13:10:35 +02:00
print '<td>' ;
2012-05-29 21:48:44 +02:00
$adh = new Adherent ( $db );
$result = $adh -> fetch ( '' , '' , $object -> id );
if ( $result > 0 )
{
$adh -> ref = $adh -> getFullName ( $langs );
print $adh -> getNomUrl ( 1 );
}
else
{
2017-04-09 13:12:25 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " ThirdpartyNotLinkedToMember " ) . '</span>' ;
2012-05-29 21:48:44 +02:00
}
print '</td>' ;
print " </tr> \n " ;
}
print " </table> " ;
2016-10-24 13:10:35 +02:00
if ( $object -> client == 2 || $object -> client == 3 )
{
2016-10-30 20:29:21 +01:00
print '<br>' ;
2017-06-07 16:44:04 +02:00
2016-10-30 20:29:21 +01:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border" width="100%">' ;
2017-06-07 16:44:04 +02:00
2016-10-24 13:10:35 +02:00
// Level of prospect
print '<tr><td class="titlefield nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
print $langs -> trans ( 'ProspectLevel' );
print '<td>' ;
if ( $action != 'editlevel' && $user -> rights -> societe -> creer ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editlevel&socid=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'Modify' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td>' ;
if ( $action == 'editlevel' )
2017-01-23 10:23:24 +01:00
{
2016-10-24 13:10:35 +02:00
$formcompany -> form_prospect_level ( $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id , $object -> fk_prospectlevel , 'prospect_level_id' , 1 );
2017-01-23 10:23:24 +01:00
}
else
{
print $object -> getLibProspLevel ();
}
print " </td> " ;
print '</tr>' ;
// Status
$object -> loadCacheOfProspStatus ();
print '<tr><td>' . $langs -> trans ( " StatusProsp " ) . '</td><td>' . $object -> getLibProspCommStatut ( 4 , $object -> cacheprospectstatus [ $object -> stcomm_id ][ 'label' ]);
print ' ' ;
print '<div class="floatright">' ;
foreach ( $object -> cacheprospectstatus as $key => $val )
{
$titlealt = 'default' ;
if ( ! empty ( $val [ 'code' ]) && ! in_array ( $val [ 'code' ], array ( 'ST_NO' , 'ST_NEVER' , 'ST_TODO' , 'ST_PEND' , 'ST_DONE' ))) $titlealt = $val [ 'label' ];
if ( $object -> stcomm_id != $val [ 'id' ]) print '<a class="pictosubstatus" href="' . $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id . '&stcomm=' . $val [ 'code' ] . '&action=setstcomm">' . img_action ( $titlealt , $val [ 'code' ]) . '</a>' ;
}
print '</div></td></tr>' ;
2016-10-30 20:29:21 +01:00
print " </table> " ;
2016-10-24 13:10:35 +02:00
}
2017-06-07 16:44:04 +02:00
2013-04-11 20:00:12 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2018-03-01 02:37:18 +01:00
print '<div class="underbanner clearboth"></div>' ;
2013-04-27 15:08:35 +02:00
2017-01-20 14:02:51 +01:00
$boxstat = '' ;
2017-06-07 16:44:04 +02:00
2012-05-29 21:48:44 +02:00
// Nbre max d'elements des petites listes
2016-10-24 13:10:35 +02:00
$MAXLIST = $conf -> global -> MAIN_SIZE_SHORTLIST_LIMIT ;
2012-05-29 21:48:44 +02:00
// Lien recap
2017-01-20 14:02:51 +01:00
$boxstat .= '<div class="box">' ;
2018-03-01 23:51:06 +01:00
$boxstat .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " DolibarrStateBoard " )) . '" class="border boxtable boxtablenobottom boxtablenotop" width="100%">' ;
2017-01-20 14:02:51 +01:00
$boxstat .= '<tr class="impair"><td colspan="2" class="tdboxstats nohover">' ;
2017-06-07 16:44:04 +02:00
2017-07-12 11:00:18 +02:00
if ( ! empty ( $conf -> propal -> enabled ))
2015-10-19 20:36:25 +02:00
{
2017-07-12 11:00:18 +02:00
// Box proposals
$tmp = $object -> getOutstandingProposals ();
$outstandingOpened = $tmp [ 'opened' ];
$outstandingTotal = $tmp [ 'total_ht' ];
$outstandingTotalIncTax = $tmp [ 'total_ttc' ];
$text = $langs -> trans ( " OverAllProposals " );
2018-02-09 09:14:34 +01:00
$link = DOL_URL_ROOT . '/comm/propal/list.php?socid=' . $object -> id ;
2017-07-12 11:00:18 +02:00
$icon = 'bill' ;
if ( $link ) $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">' ;
$boxstat .= '<div class="boxstats">' ;
$boxstat .= '<span class="boxstatstext">' . img_object ( " " , $icon ) . ' ' . $text . '</span><br>' ;
$boxstat .= '<span class="boxstatsindicator">' . price ( $outstandingTotal , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency ) . '</span>' ;
$boxstat .= '</div>' ;
if ( $link ) $boxstat .= '</a>' ;
2015-10-19 20:36:25 +02:00
}
2016-10-24 13:10:35 +02:00
2017-07-12 11:00:18 +02:00
if ( ! empty ( $conf -> commande -> enabled ))
2017-01-20 14:02:51 +01:00
{
2018-02-09 09:14:34 +01:00
// Box commandes
2017-07-12 11:00:18 +02:00
$tmp = $object -> getOutstandingOrders ();
$outstandingOpened = $tmp [ 'opened' ];
$outstandingTotal = $tmp [ 'total_ht' ];
$outstandingTotalIncTax = $tmp [ 'total_ttc' ];
$text = $langs -> trans ( " OverAllOrders " );
2018-02-09 09:14:34 +01:00
$link = DOL_URL_ROOT . '/commande/list.php?socid=' . $object -> id ;
2017-07-12 11:00:18 +02:00
$icon = 'bill' ;
if ( $link ) $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">' ;
$boxstat .= '<div class="boxstats">' ;
$boxstat .= '<span class="boxstatstext">' . img_object ( " " , $icon ) . ' ' . $text . '</span><br>' ;
$boxstat .= '<span class="boxstatsindicator">' . price ( $outstandingTotal , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency ) . '</span>' ;
$boxstat .= '</div>' ;
if ( $link ) $boxstat .= '</a>' ;
2017-01-20 14:02:51 +01:00
}
2017-06-07 16:44:04 +02:00
2017-07-12 11:00:18 +02:00
if ( ! empty ( $conf -> facture -> enabled ))
2017-01-20 14:02:51 +01:00
{
2018-02-09 09:14:34 +01:00
// Box factures
2017-07-12 11:00:18 +02:00
$tmp = $object -> getOutstandingBills ();
$outstandingOpened = $tmp [ 'opened' ];
$outstandingTotal = $tmp [ 'total_ht' ];
$outstandingTotalIncTax = $tmp [ 'total_ttc' ];
$text = $langs -> trans ( " OverAllInvoices " );
2018-02-09 09:14:34 +01:00
$link = DOL_URL_ROOT . '/compta/facture/list.php?socid=' . $object -> id ;
2017-07-12 11:00:18 +02:00
$icon = 'bill' ;
if ( $link ) $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">' ;
$boxstat .= '<div class="boxstats">' ;
$boxstat .= '<span class="boxstatstext">' . img_object ( " " , $icon ) . ' ' . $text . '</span><br>' ;
$boxstat .= '<span class="boxstatsindicator">' . price ( $outstandingTotal , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency ) . '</span>' ;
$boxstat .= '</div>' ;
if ( $link ) $boxstat .= '</a>' ;
// Box outstanding bill
$warn = '' ;
if ( $object -> outstanding_limit != '' && $object -> outstanding_limit < $outstandingOpened )
{
$warn = ' ' . img_warning ( $langs -> trans ( " OutstandingBillReached " ));
}
$text = $langs -> trans ( " CurrentOutstandingBill " );
$link = DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $object -> id ;
$icon = 'bill' ;
if ( $link ) $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">' ;
$boxstat .= '<div class="boxstats">' ;
$boxstat .= '<span class="boxstatstext">' . img_object ( " " , $icon ) . ' ' . $text . '</span><br>' ;
$boxstat .= '<span class="boxstatsindicator' . ( $outstandingOpened > 0 ? ' amountremaintopay' : '' ) . '">' . price ( $outstandingOpened , 1 , $langs , 1 , - 1 , - 1 , $conf -> currency ) . $warn . '</span>' ;
$boxstat .= '</div>' ;
if ( $link ) $boxstat .= '</a>' ;
2017-01-20 14:02:51 +01:00
}
2017-06-07 16:44:04 +02:00
2017-07-04 21:56:47 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreBoxStatsCustomer' , $parameters , $object , $action );
if ( empty ( $reshook )){
$boxstat .= $hookmanager -> resPrint ;
}
2017-09-03 04:16:43 +02:00
2017-01-20 14:02:51 +01:00
$boxstat .= '</td></tr>' ;
$boxstat .= '</table>' ;
$boxstat .= '</div>' ;
2017-06-07 16:44:04 +02:00
2017-07-04 21:56:47 +02:00
print $boxstat ;
2017-06-07 16:44:04 +02:00
2012-05-29 21:48:44 +02:00
$now = dol_now ();
/*
* Last proposals
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> lire )
2012-05-29 21:48:44 +02:00
{
2018-09-20 19:45:13 +02:00
$langs -> load ( " propal " );
2015-01-25 01:20:58 +01:00
$sql = " SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht " ;
$sql .= " , p.tva as total_tva " ;
$sql .= " , p.total as total_ttc " ;
$sql .= " , p.ref, p.ref_client, p.remise " ;
$sql .= " , p.datep as dp, p.fin_validite as datelimite " ;
2012-05-29 21:48:44 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c " ;
$sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id " ;
$sql .= " AND s.rowid = " . $object -> id ;
2018-09-20 19:45:13 +02:00
$sql .= " AND p.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
2012-05-29 21:48:44 +02:00
$sql .= " ORDER BY p.datep DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
2018-03-24 13:15:00 +01:00
$propal_static = new Propal ( $db );
2012-05-29 21:48:44 +02:00
2018-03-24 13:15:00 +01:00
$num = $db -> num_rows ( $resql );
2012-05-29 21:48:44 +02:00
if ( $num > 0 )
{
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder" width="100%">' ;
2012-05-29 21:48:44 +02:00
print '<tr class="liste_titre">' ;
2016-09-18 13:58:17 +02:00
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LastPropals " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/comm/propal/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllPropals " ) . ' <span class="badge">' . $num . '</span></a></td>' ;
2012-05-29 21:48:44 +02:00
print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/comm/propal/stats/index.php?socid=' . $object -> id . '">' . img_picto ( $langs -> trans ( " Statistics " ), 'stats' ) . '</a></td>' ;
print '</tr></table></td>' ;
print '</tr>' ;
}
$i = 0 ;
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
2017-06-07 16:44:04 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-01-19 18:55:55 +01:00
print '<td class="nowrap">' ;
2015-01-25 01:20:58 +01:00
$propal_static -> id = $objp -> propalid ;
$propal_static -> ref = $objp -> ref ;
$propal_static -> ref_client = $objp -> ref_client ;
$propal_static -> total_ht = $objp -> total_ht ;
$propal_static -> total_tva = $objp -> total_tva ;
$propal_static -> total_ttc = $objp -> total_ttc ;
2015-01-19 18:55:55 +01:00
print $propal_static -> getNomUrl ( 1 );
2016-11-28 15:53:31 +01:00
if ( ( $db -> jdate ( $objp -> datelimite ) < ( $now - $conf -> propal -> cloture -> warning_delay )) && $objp -> fk_statut == 1 ) {
2015-01-19 18:55:55 +01:00
print " " . img_warning ();
}
2016-02-29 10:50:52 +01:00
print '</td><td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> dp ), 'day' ) . " </td> \n " ;
2013-04-11 20:00:12 +02:00
print '<td align="right" style="min-width: 60px">' . price ( $objp -> total_ht ) . '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td align="right" style="min-width: 60px" class="nowrap">' . $propal_static -> LibStatut ( $objp -> fk_statut , 5 ) . '</td></tr>' ;
2012-05-29 21:48:44 +02:00
$i ++ ;
}
$db -> free ( $resql );
2018-06-24 11:30:44 +02:00
if ( $num > 0 )
{
print " </table> " ;
print '</div>' ;
}
2012-05-29 21:48:44 +02:00
}
else
{
dol_print_error ( $db );
}
}
/*
* Last orders
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire )
2012-05-29 21:48:44 +02:00
{
2015-01-25 01:20:58 +01:00
$sql = " SELECT s.nom, s.rowid " ;
$sql .= " , c.rowid as cid, c.total_ht " ;
$sql .= " , c.tva as total_tva " ;
$sql .= " , c.total_ttc " ;
$sql .= " , c.ref, c.ref_client, c.fk_statut, c.facture " ;
$sql .= " , c.date_commande as dc " ;
2012-05-29 21:48:44 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND s.rowid = " . $object -> id ;
$sql .= " AND c.entity = " . $conf -> entity ;
$sql .= " ORDER BY c.date_commande DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
2018-03-24 13:15:00 +01:00
$commande_static = new Commande ( $db );
2012-05-29 21:48:44 +02:00
2018-03-24 13:15:00 +01:00
$num = $db -> num_rows ( $resql );
2012-05-29 21:48:44 +02:00
if ( $num > 0 )
{
2012-10-02 10:52:08 +02:00
// Check if there are orders billable
$sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,' ;
2018-03-16 10:51:12 +01:00
$sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed' ;
2012-10-02 10:52:08 +02:00
$sql2 .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s' ;
$sql2 .= ', ' . MAIN_DB_PREFIX . 'commande as c' ;
$sql2 .= ' WHERE c.fk_soc = s.rowid' ;
$sql2 .= ' AND s.rowid = ' . $object -> id ;
// Show orders with status validated, shipping started and delivered (well any order we can bill)
$sql2 .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0)) " ;
2012-10-13 17:00:38 +02:00
2012-10-02 10:52:08 +02:00
$resql2 = $db -> query ( $sql2 );
2012-10-04 18:23:21 +02:00
$orders2invoice = $db -> num_rows ( $resql2 );
2012-10-02 10:52:08 +02:00
$db -> free ( $resql2 );
2012-10-13 17:00:38 +02:00
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
2012-10-02 10:52:08 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2016-09-18 13:58:17 +02:00
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LastCustomerOrders " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/commande/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllOrders " ) . ' <span class="badge">' . $num . '</span></a></td>' ;
2012-10-02 10:52:08 +02:00
print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/commande/stats/index.php?socid=' . $object -> id . '">' . img_picto ( $langs -> trans ( " Statistics " ), 'stats' ) . '</a></td>' ;
2012-10-04 18:23:21 +02:00
//if($num2 > 0) print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$object->id.'">'.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').'</a></td>';
//else print '<td width="20px" align="right"><a href="#">'.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'</a></td>';
2012-10-02 10:52:08 +02:00
print '</tr></table></td>' ;
print '</tr>' ;
2012-05-29 21:48:44 +02:00
}
$i = 0 ;
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
2017-06-07 16:44:04 +02:00
2018-03-16 10:51:12 +01:00
$commande_static -> id = $objp -> cid ;
$commande_static -> ref = $objp -> ref ;
$commande_static -> ref_client = $objp -> ref_client ;
$commande_static -> total_ht = $objp -> total_ht ;
$commande_static -> total_tva = $objp -> total_tva ;
$commande_static -> total_ttc = $objp -> total_ttc ;
$commande_static -> billed = $objp -> billed ;
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-01-19 18:55:55 +01:00
print '<td class="nowrap">' ;
print $commande_static -> getNomUrl ( 1 );
2016-02-29 10:50:52 +01:00
print '</td><td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> dc ), 'day' ) . " </td> \n " ;
2013-04-11 20:00:12 +02:00
print '<td align="right" style="min-width: 60px">' . price ( $objp -> total_ht ) . '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td align="right" style="min-width: 60px" class="nowrap">' . $commande_static -> LibStatut ( $objp -> fk_statut , $objp -> facture , 5 ) . '</td></tr>' ;
2012-05-29 21:48:44 +02:00
$i ++ ;
}
$db -> free ( $resql );
2018-06-24 11:30:44 +02:00
if ( $num > 0 )
{
print " </table> " ;
print '</div>' ;
}
2012-05-29 21:48:44 +02:00
}
else
{
dol_print_error ( $db );
}
}
2015-03-25 16:38:18 +01:00
/*
2018-02-01 01:25:45 +01:00
* Last shipments
2015-03-25 16:38:18 +01:00
*/
2018-03-24 13:15:00 +01:00
if ( ! empty ( $conf -> expedition -> enabled ) && $user -> rights -> expedition -> lire )
{
2015-03-25 16:38:18 +01:00
$sql = 'SELECT e.rowid as id' ;
$sql .= ', e.ref' ;
$sql .= ', e.date_creation' ;
$sql .= ', e.fk_statut as statut' ;
$sql .= ', s.nom' ;
$sql .= ', s.rowid as socid' ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " expedition as e " ;
$sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = " . $object -> id ;
2017-05-30 18:50:54 +02:00
$sql .= " AND e.entity IN ( " . getEntity ( 'expedition' ) . " ) " ;
2015-03-25 16:38:18 +01:00
$sql .= ' GROUP BY e.rowid' ;
$sql .= ', e.ref' ;
$sql .= ', e.date_creation' ;
$sql .= ', e.fk_statut' ;
$sql .= ', s.nom' ;
$sql .= ', s.rowid' ;
$sql .= " ORDER BY e.date_creation DESC " ;
$resql = $db -> query ( $sql );
2018-03-24 13:15:00 +01:00
if ( $resql )
{
$sendingstatic = new Expedition ( $db );
$num = $db -> num_rows ( $resql );
2015-03-25 16:38:18 +01:00
if ( $num > 0 ) {
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder" width="100%">' ;
2015-03-25 16:38:18 +01:00
print '<tr class="liste_titre">' ;
2016-09-18 13:58:17 +02:00
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LastSendings " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/expedition/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllSendings " ) . ' <span class="badge">' . $num . '</span></a></td>' ;
2015-03-25 16:38:18 +01:00
print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/expedition/stats/index.php?socid=' . $object -> id . '">' . img_picto ( $langs -> trans ( " Statistics " ), 'stats' ) . '</a></td>' ;
print '</tr></table></td>' ;
print '</tr>' ;
}
2018-03-24 13:15:00 +01:00
$i = 0 ;
while ( $i < $num && $i < $MAXLIST )
{
2015-03-25 16:38:18 +01:00
$objp = $db -> fetch_object ( $resql );
2018-03-24 13:15:00 +01:00
2015-03-25 16:38:18 +01:00
$sendingstatic -> id = $objp -> id ;
$sendingstatic -> ref = $objp -> ref ;
2018-03-24 13:15:00 +01:00
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
2015-03-25 16:38:18 +01:00
print $sendingstatic -> getNomUrl ( 1 );
print '</td>' ;
if ( $objp -> date_creation > 0 ) {
2016-02-29 10:50:52 +01:00
print '<td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> date_creation ), 'day' ) . '</td>' ;
2015-03-25 16:38:18 +01:00
} else {
print '<td align="right"><b>!!!</b></td>' ;
}
print '<td align="right" class="nowrap" width="100" >' . $sendingstatic -> LibStatut ( $objp -> statut , 5 ) . '</td>' ;
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $resql );
if ( $num > 0 )
2018-06-24 11:30:44 +02:00
{
2015-03-25 16:38:18 +01:00
print " </table> " ;
2018-06-24 11:30:44 +02:00
print '</div>' ;
}
2015-03-25 16:38:18 +01:00
} else {
dol_print_error ( $db );
}
}
2012-05-29 21:48:44 +02:00
/*
* Last linked contracts
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire )
2012-05-29 21:48:44 +02:00
{
2018-03-24 13:15:00 +01:00
$sql = " SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup " ;
2012-05-29 21:48:44 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " contrat as c " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND s.rowid = " . $object -> id ;
$sql .= " AND c.entity = " . $conf -> entity ;
$sql .= " ORDER BY c.datec DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
2018-03-24 13:15:00 +01:00
$contrat = new Contrat ( $db );
2012-05-29 21:48:44 +02:00
$num = $db -> num_rows ( $resql );
2018-03-24 13:15:00 +01:00
if ( $num > 0 )
2012-05-29 21:48:44 +02:00
{
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder" width="100%">' ;
2012-05-29 21:48:44 +02:00
print '<tr class="liste_titre">' ;
2015-12-03 11:03:40 +01:00
print '<td colspan="6"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LastContracts " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td>' ;
2017-01-20 14:10:57 +01:00
print '<td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/contrat/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllContracts " ) . ' <span class="badge">' . $num . '</span></a></td>' ;
//print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/contract/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>' ;
2012-05-29 21:48:44 +02:00
print '</tr>' ;
}
2018-03-24 13:15:00 +01:00
2012-05-29 21:48:44 +02:00
$i = 0 ;
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
2017-06-07 16:44:04 +02:00
2012-05-29 21:48:44 +02:00
$contrat -> id = $objp -> id ;
$contrat -> ref = $objp -> ref ? $objp -> ref : $objp -> id ;
2018-03-24 13:15:00 +01:00
$contrat -> ref_customer = $objp -> refcus ;
$contrat -> ref_supplier = $objp -> refsup ;
2018-06-24 11:30:44 +02:00
$contrat -> fetch_lines ();
2018-03-24 13:15:00 +01:00
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print $contrat -> getNomUrl ( 1 , 12 );
print " </td> \n " ;
2015-12-03 11:03:40 +01:00
print '<td class="nowrap">' . dol_trunc ( $objp -> refsup , 12 ) . " </td> \n " ;
2016-02-29 10:50:52 +01:00
print '<td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> dc ), 'day' ) . " </td> \n " ;
print '<td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> dcon ), 'day' ) . " </td> \n " ;
2012-05-29 21:48:44 +02:00
print '<td width="20"> </td>' ;
2018-06-24 11:30:44 +02:00
print '<td align="right" class="nowraponall">' ;
2012-05-29 21:48:44 +02:00
print $contrat -> getLibStatut ( 4 );
print " </td> \n " ;
print '</tr>' ;
$i ++ ;
}
$db -> free ( $resql );
2018-06-24 11:30:44 +02:00
if ( $num > 0 )
{
print " </table> " ;
print '</div>' ;
}
2012-05-29 21:48:44 +02:00
}
else
{
dol_print_error ( $db );
}
}
/*
* Last interventions
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> ficheinter -> enabled ) && $user -> rights -> ficheinter -> lire )
2012-05-29 21:48:44 +02:00
{
$sql = " SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " fichinter as f " ;
$sql .= " WHERE f.fk_soc = s.rowid " ;
$sql .= " AND s.rowid = " . $object -> id ;
$sql .= " AND f.entity = " . $conf -> entity ;
$sql .= " ORDER BY f.tms DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
2018-03-24 13:15:00 +01:00
$fichinter_static = new Fichinter ( $db );
2012-05-29 21:48:44 +02:00
$num = $db -> num_rows ( $resql );
if ( $num > 0 )
{
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder" width="100%">' ;
2012-05-29 21:48:44 +02:00
print '<tr class="liste_titre">' ;
2017-01-20 14:10:57 +01:00
print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LastInterventions " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/fichinter/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllInterventions " ) . ' <span class="badge">' . $num . '</span></td>' ;
print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/fichinter/stats/index.php?socid=' . $object -> id . '">' . img_picto ( $langs -> trans ( " Statistics " ), 'stats' ) . '</a></td>' ;
print '</tr></table></td>' ;
2012-05-29 21:48:44 +02:00
print '</tr>' ;
}
2018-03-24 13:15:00 +01:00
2012-05-29 21:48:44 +02:00
$i = 0 ;
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
$fichinter_static -> id = $objp -> id ;
$fichinter_static -> statut = $objp -> fk_statut ;
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2014-09-18 21:18:25 +02:00
print '<td class="nowrap"><a href="' . DOL_URL_ROOT . '/fichinter/card.php?id=' . $objp -> id . '">' . img_object ( $langs -> trans ( " ShowPropal " ), " propal " ) . ' ' . $objp -> ref . '</a></td>' . " \n " ;
2016-02-29 10:50:52 +01:00
//print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
print '<td align="right" style="min-width: 60px">' . convertSecondToTime ( $objp -> duration ) . '</td>' . " \n " ;
print '<td align="right" class="nowrap" style="min-width: 60px">' . $fichinter_static -> getLibStatut ( 5 ) . '</td>' . " \n " ;
2012-05-29 21:48:44 +02:00
print '</tr>' ;
2017-06-07 16:44:04 +02:00
2012-05-29 21:48:44 +02:00
$i ++ ;
}
$db -> free ( $resql );
2018-06-24 11:30:44 +02:00
if ( $num > 0 )
{
print " </table> " ;
print '</div>' ;
}
2012-05-29 21:48:44 +02:00
}
else
{
dol_print_error ( $db );
}
}
2017-09-10 19:28:20 +02:00
/*
* Last invoices templates
*/
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
{
$sql = 'SELECT f.rowid as id, f.titre as ref, f.amount' ;
$sql .= ', f.total as total_ht' ;
$sql .= ', f.tva as total_tva' ;
$sql .= ', f.total_ttc' ;
$sql .= ', f.datec as dc' ;
2018-06-18 16:27:25 +02:00
$sql .= ', f.date_last_gen, f.date_when' ;
2017-09-10 20:47:45 +02:00
$sql .= ', f.frequency' ;
$sql .= ', f.unit_frequency' ;
$sql .= ', f.suspended as suspended' ;
2017-09-10 19:28:20 +02:00
$sql .= ', s.nom, s.rowid as socid' ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " facture_rec as f " ;
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = " . $object -> id ;
$sql .= " AND f.entity = " . $conf -> entity ;
$sql .= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,' ;
2017-09-10 20:47:45 +02:00
$sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,' ;
$sql .= ' f.suspended,' ;
2017-09-10 19:28:20 +02:00
$sql .= ' s.nom, s.rowid' ;
2017-09-10 20:47:45 +02:00
$sql .= " ORDER BY f.date_last_gen, f.datec DESC " ;
2017-09-10 19:28:20 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
2018-03-24 13:15:00 +01:00
$invoicetemplate = new FactureRec ( $db );
2017-09-10 19:28:20 +02:00
$num = $db -> num_rows ( $resql );
if ( $num > 0 )
{
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
2017-09-10 19:28:20 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LatestCustomerTemplateInvoices " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/compta/facture/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllCustomerTemplateInvoices " ) . ' <span class="badge">' . $num . '</span></a></td>' ;
print '</tr></table></td>' ;
print '</tr>' ;
}
2018-03-24 13:15:00 +01:00
$i = 0 ;
2017-09-10 19:28:20 +02:00
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
$invoicetemplate -> id = $objp -> id ;
$invoicetemplate -> ref = $objp -> ref ;
2017-09-10 20:47:45 +02:00
$invoicetemplate -> suspended = $objp -> suspended ;
$invoicetemplate -> frequency = $objp -> frequency ;
$invoicetemplate -> unit_frequency = $objp -> unit_frequency ;
2017-09-10 19:28:20 +02:00
$invoicetemplate -> total_ht = $objp -> total_ht ;
$invoicetemplate -> total_tva = $objp -> total_tva ;
$invoicetemplate -> total_ttc = $objp -> total_ttc ;
2018-06-18 16:27:25 +02:00
$invoicetemplate -> date_last_gen = $objp -> date_last_gen ;
$invoicetemplate -> date_when = $objp -> date_when ;
2018-03-24 13:15:00 +01:00
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
2017-09-10 19:28:20 +02:00
print $invoicetemplate -> getNomUrl ( 1 );
print '</td>' ;
2017-09-10 20:47:45 +02:00
if ( $objp -> frequency && $objp -> date_last_gen > 0 )
2017-09-10 19:28:20 +02:00
{
2017-09-10 20:47:45 +02:00
print '<td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> date_last_gen ), 'day' ) . '</td>' ;
2017-09-10 19:28:20 +02:00
}
else
{
2017-09-10 20:47:45 +02:00
if ( $objp -> dc > 0 )
{
print '<td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> dc ), 'day' ) . '</td>' ;
}
else
{
print '<td align="right"><b>!!!</b></td>' ;
}
2017-09-10 19:28:20 +02:00
}
print '<td align="right" style="min-width: 60px">' ;
print price ( $objp -> total_ht );
print '</td>' ;
if ( ! empty ( $conf -> global -> MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES ))
{
print '<td align="right" style="min-width: 60px">' ;
print price ( $objp -> total_ttc );
print '</td>' ;
}
print '<td align="right" class="nowrap" style="min-width: 60px">' ;
2017-09-10 20:47:45 +02:00
print $langs -> trans ( 'FrequencyPer_' . $invoicetemplate -> unit_frequency , $invoicetemplate -> frequency ) . ' - ' ;
print ( $invoicetemplate -> LibStatut ( $invoicetemplate -> frequency , $invoicetemplate -> suspended , 5 , 0 ));
2017-09-10 19:28:20 +02:00
print '</td>' ;
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $resql );
2018-06-24 11:30:44 +02:00
if ( $num > 0 )
{
print " </table> " ;
print '</div>' ;
}
2017-09-10 19:28:20 +02:00
}
else
{
dol_print_error ( $db );
}
}
2012-05-29 21:48:44 +02:00
/*
* Last invoices
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2012-05-29 21:48:44 +02:00
{
2015-01-25 01:20:58 +01:00
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount' ;
2015-04-13 19:11:23 +02:00
$sql .= ', f.total as total_ht' ;
2015-01-25 01:20:58 +01:00
$sql .= ', f.tva as total_tva' ;
$sql .= ', f.total_ttc' ;
$sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as statut' ;
$sql .= ', s.nom, s.rowid as socid' ;
$sql .= ', SUM(pf.amount) as am' ;
2012-05-29 21:48:44 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " facture as f " ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiement_facture as pf ON f.rowid=pf.fk_facture' ;
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = " . $object -> id ;
$sql .= " AND f.entity = " . $conf -> entity ;
2015-01-25 01:20:58 +01:00
$sql .= ' GROUP BY f.rowid, f.facnumber, f.type, f.amount, f.total, f.tva, f.total_ttc,' ;
2012-05-29 21:48:44 +02:00
$sql .= ' f.datef, f.datec, f.paye, f.fk_statut,' ;
$sql .= ' s.nom, s.rowid' ;
$sql .= " ORDER BY f.datef DESC, f.datec DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
2018-03-24 13:15:00 +01:00
$facturestatic = new Facture ( $db );
2012-05-29 21:48:44 +02:00
$num = $db -> num_rows ( $resql );
if ( $num > 0 )
{
2018-06-24 11:30:44 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder" width="100%">' ;
2012-05-29 21:48:44 +02:00
print '<tr class="liste_titre">' ;
2016-09-18 13:58:17 +02:00
print '<td colspan="5"><table width="100%" class="nobordernopadding"><tr><td>' . $langs -> trans ( " LastCustomersBills " ,( $num <= $MAXLIST ? " " : $MAXLIST )) . '</td><td align="right"><a class="notasortlink" href="' . DOL_URL_ROOT . '/compta/facture/list.php?socid=' . $object -> id . '">' . $langs -> trans ( " AllBills " ) . ' <span class="badge">' . $num . '</span></a></td>' ;
2012-05-29 21:48:44 +02:00
print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/compta/facture/stats/index.php?socid=' . $object -> id . '">' . img_picto ( $langs -> trans ( " Statistics " ), 'stats' ) . '</a></td>' ;
print '</tr></table></td>' ;
print '</tr>' ;
}
2018-03-24 13:15:00 +01:00
$i = 0 ;
2012-05-29 21:48:44 +02:00
while ( $i < $num && $i < $MAXLIST )
{
$objp = $db -> fetch_object ( $resql );
2017-06-07 16:44:04 +02:00
2015-01-25 01:20:58 +01:00
$facturestatic -> id = $objp -> facid ;
$facturestatic -> ref = $objp -> facnumber ;
$facturestatic -> type = $objp -> type ;
2018-03-24 13:15:00 +01:00
$facturestatic -> total_ht = $objp -> total_ht ;
$facturestatic -> total_tva = $objp -> total_tva ;
$facturestatic -> total_ttc = $objp -> total_ttc ;
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
2012-05-29 21:48:44 +02:00
print $facturestatic -> getNomUrl ( 1 );
print '</td>' ;
if ( $objp -> df > 0 )
{
2016-02-29 10:50:52 +01:00
print '<td align="right" width="80px">' . dol_print_date ( $db -> jdate ( $objp -> df ), 'day' ) . '</td>' ;
2012-05-29 21:48:44 +02:00
}
else
{
print '<td align="right"><b>!!!</b></td>' ;
}
2016-02-29 10:50:52 +01:00
print '<td align="right" style="min-width: 60px">' ;
print price ( $objp -> total_ht );
print '</td>' ;
2012-05-29 21:48:44 +02:00
2016-02-29 10:50:52 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES ))
{
print '<td align="right" style="min-width: 60px">' ;
print price ( $objp -> total_ttc );
print '</td>' ;
}
2017-06-07 16:44:04 +02:00
2016-02-29 10:50:52 +01:00
print '<td align="right" class="nowrap" style="min-width: 60px">' . ( $facturestatic -> LibStatut ( $objp -> paye , $objp -> statut , 5 , $objp -> am )) . '</td>' ;
2012-05-29 21:48:44 +02:00
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $resql );
2018-06-24 11:30:44 +02:00
if ( $num > 0 )
{
print " </table> " ;
print '</div>' ;
}
2012-05-29 21:48:44 +02:00
}
else
{
dol_print_error ( $db );
}
}
2013-04-11 20:00:12 +02:00
print '</div></div></div>' ;
print '<div style="clear:both"></div>' ;
2012-05-29 21:48:44 +02:00
2013-04-11 20:00:12 +02:00
dol_fiche_end ();
2012-05-29 21:48:44 +02:00
/*
* Barre d ' actions
*/
2014-09-27 17:13:15 +02:00
2013-04-03 18:37:54 +02:00
print '<div class="tabsAction">' ;
2012-05-29 21:48:44 +02:00
2016-05-05 21:38:29 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been
2012-05-29 21:48:44 +02:00
2016-05-05 21:38:29 +02:00
if ( empty ( $reshook ))
{
2017-02-24 15:16:53 +01:00
if ( $object -> status != 1 )
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="' . dol_escape_js ( $langs -> trans ( " ThirdPartyIsClosed " )) . '" href="#">' . $langs -> trans ( " ThirdPartyIsClosed " ) . '</a></div>' ;
}
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> creer && $object -> status == 1 )
{
$langs -> load ( " propal " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/comm/propal/card.php?socid=' . $object -> id . '&action=create">' . $langs -> trans ( " AddProp " ) . '</a></div>' ;
}
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> creer && $object -> status == 1 )
{
$langs -> load ( " orders " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/commande/card.php?socid=' . $object -> id . '&action=create">' . $langs -> trans ( " AddOrder " ) . '</a></div>' ;
}
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
if ( $user -> rights -> contrat -> creer && $object -> status == 1 )
{
$langs -> load ( " contracts " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?socid=' . $object -> id . '&action=create">' . $langs -> trans ( " AddContract " ) . '</a></div>' ;
}
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
if ( ! empty ( $conf -> ficheinter -> enabled ) && $user -> rights -> ficheinter -> creer && $object -> status == 1 )
{
$langs -> load ( " fichinter " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fichinter/card.php?socid=' . $object -> id . '&action=create">' . $langs -> trans ( " AddIntervention " ) . '</a></div>' ;
}
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
// Add invoice
if ( $user -> societe_id == 0 )
{
if ( ! empty ( $conf -> deplacement -> enabled ) && $object -> status == 1 )
{
$langs -> load ( " trips " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/deplacement/card.php?socid=' . $object -> id . '&action=create">' . $langs -> trans ( " AddTrip " ) . '</a></div>' ;
}
2017-06-07 16:44:04 +02:00
2017-02-24 15:16:53 +01:00
if ( ! empty ( $conf -> facture -> enabled ) && $object -> status == 1 )
2016-05-05 21:38:29 +02:00
{
2017-01-20 12:17:10 +01:00
if ( empty ( $user -> rights -> facture -> creer ))
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="' . dol_escape_js ( $langs -> trans ( " NotAllowed " )) . '" href="#">' . $langs -> trans ( " AddBill " ) . '</a></div>' ;
}
else
2016-05-05 21:38:29 +02:00
{
$langs -> load ( " bills " );
$langs -> load ( " orders " );
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
if ( ! empty ( $conf -> commande -> enabled ))
{
2017-04-23 16:05:54 +02:00
if ( $object -> client != 0 && $object -> client != 2 )
{
if ( ! empty ( $orders2invoice ) && $orders2invoice > 0 ) print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/commande/orderstoinvoice.php?socid=' . $object -> id . '">' . $langs -> trans ( " CreateInvoiceForThisCustomer " ) . '</a></div>' ;
else print '<div class="inline-block divButAction"><a class="butActionRefused" title="' . dol_escape_js ( $langs -> trans ( " NoOrdersToInvoice " )) . '" href="#">' . $langs -> trans ( " CreateInvoiceForThisCustomer " ) . '</a></div>' ;
}
else print '<div class="inline-block divButAction"><a class="butActionRefused" title="' . dol_escape_js ( $langs -> trans ( " ThirdPartyMustBeEditAsCustomer " )) . '" href="#">' . $langs -> trans ( " AddBill " ) . '</a></div>' ;
2016-05-05 21:38:29 +02:00
}
2017-04-27 17:20:40 +02:00
2017-04-28 13:37:36 +02:00
if ( $object -> client != 0 && $object -> client != 2 ) print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&socid=' . $object -> id . '">' . $langs -> trans ( " AddBill " ) . '</a></div>' ;
2016-05-05 21:38:29 +02:00
else print '<div class="inline-block divButAction"><a class="butActionRefused" title="' . dol_escape_js ( $langs -> trans ( " ThirdPartyMustBeEditAsCustomer " )) . '" href="#">' . $langs -> trans ( " AddBill " ) . '</a></div>' ;
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
}
}
}
2017-06-07 16:44:04 +02:00
2016-05-05 21:38:29 +02:00
// Add action
2017-02-24 15:16:53 +01:00
if ( ! empty ( $conf -> agenda -> enabled ) && ! empty ( $conf -> global -> MAIN_REPEATTASKONEACHTAB ) && $object -> status == 1 )
2016-05-05 21:38:29 +02:00
{
if ( $user -> rights -> agenda -> myactions -> create )
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&socid=' . $object -> id . '">' . $langs -> trans ( " AddAction " ) . '</a></div>' ;
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" title="' . dol_escape_js ( $langs -> trans ( " NotAllowed " )) . '" href="#">' . $langs -> trans ( " AddAction " ) . '</a></div>' ;
}
}
}
2017-06-07 16:44:04 +02:00
2012-05-29 21:48:44 +02:00
print '</div>' ;
2018-01-31 14:01:58 +01:00
if ( ! empty ( $conf -> global -> MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD ))
2012-05-29 21:48:44 +02:00
{
// List of contacts
show_contacts ( $conf , $langs , $db , $object , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id );
}
2012-06-09 19:16:31 +02:00
2012-05-29 21:48:44 +02:00
// Addresses list
if ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) && ! empty ( $conf -> global -> MAIN_REPEATADDRESSONEACHTAB ))
{
2015-02-10 11:38:13 +01:00
show_addresses ( $conf , $langs , $db , $object , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id );
2012-05-29 21:48:44 +02:00
}
if ( ! empty ( $conf -> global -> MAIN_REPEATTASKONEACHTAB ))
{
print load_fiche_titre ( $langs -> trans ( " ActionsOnCompany " ), '' , '' );
// List of todo actions
show_actions_todo ( $conf , $langs , $db , $object );
// List of done actions
show_actions_done ( $conf , $langs , $db , $object );
}
2015-10-24 19:29:41 +02:00
2012-05-29 21:48:44 +02:00
}
else
{
2018-01-27 18:46:52 +01:00
$langs -> load ( " errors " );
print $langs -> trans ( 'ErrorRecordNotFound' );
2012-05-29 21:48:44 +02:00
}
// End of page
llxFooter ();
2014-07-08 01:02:30 +02:00
2012-05-29 21:48:44 +02:00
$db -> close ();