2004-10-19 22:19:58 +02:00
< ? php
2020-09-16 10:51:19 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
* Copyright ( C ) 2019 Nicolas ZABOURI < info @ inovea - conseil . com >
* Copyright ( C ) 2020 Pierre Ardoin < mapiolca @ me . com >
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2002-04-29 20:01:16 +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
2002-04-29 20:01:16 +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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2002-04-29 20:01:16 +02:00
*/
2004-10-30 14:15:59 +02:00
2005-01-29 01:44:52 +01:00
/**
2020-09-16 10:51:19 +02:00
* \file htdocs / comm / index . php
* \ingroup commercial
* \brief Home page of commercial area
2009-01-23 01:47:23 +01:00
*/
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2005-08-25 17:07:01 +02:00
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> lire ) accessforbidden ();
2009-01-23 17:44:12 +01:00
2020-09-16 10:51:19 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php' ;
2019-06-18 14:07:52 +02:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
2020-09-16 10:51:19 +02:00
$hookmanager = new HookManager ( $db );
2019-06-18 14:07:52 +02:00
$hookmanager -> initHooks ( array ( 'commercialindex' ));
2018-05-26 19:03:41 +02:00
// Load translation files required by the page
2020-09-16 10:51:19 +02:00
$langs -> loadLangs ( array ( " boxes " , " commercial " , " contracts " , " orders " , " propal " , " supplier_proposal " ));
2002-04-30 12:44:42 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-13 19:35:02 +01:00
$bid = GETPOST ( 'bid' , 'int' );
2012-10-13 11:41:17 +02:00
2009-04-27 22:37:50 +02:00
// Securite acces client
2019-11-13 19:35:02 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2020-09-10 11:04:41 +02:00
if ( isset ( $user -> socid ) && $user -> socid > 0 ) {
2009-01-23 01:47:23 +01:00
$action = '' ;
2019-10-31 20:46:31 +01:00
$socid = $user -> socid ;
2003-10-14 13:02:31 +02:00
}
2020-09-21 13:54:26 +02:00
$max = $conf -> global -> MAIN_SIZE_SHORTLIST_LIMIT ;
2019-11-13 19:35:02 +01:00
$now = dol_now ();
2005-06-21 21:49:42 +02:00
2002-05-10 14:28:10 +02:00
/*
2005-01-29 15:58:53 +01:00
* Actions
2002-05-10 14:28:10 +02:00
*/
2002-05-09 16:57:48 +02:00
2005-01-29 15:58:53 +01:00
/*
2008-08-09 00:12:27 +02:00
* View
2005-01-29 15:58:53 +01:00
*/
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2008-01-20 14:53:02 +01:00
$formfile = new FormFile ( $db );
2019-11-13 19:35:02 +01:00
$companystatic = new Societe ( $db );
if ( ! empty ( $conf -> propal -> enabled )) $propalstatic = new Propal ( $db );
if ( ! empty ( $conf -> supplier_proposal -> enabled )) $supplierproposalstatic = new SupplierProposal ( $db );
if ( ! empty ( $conf -> commande -> enabled )) $orderstatic = new Commande ( $db );
2020-03-22 05:33:30 +01:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD ) || ! empty ( $conf -> supplier_order -> enabled )) $supplierorderstatic = new CommandeFournisseur ( $db );
2007-07-13 19:10:38 +02:00
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $langs -> trans ( " CommercialArea " ));
2006-04-08 00:27:25 +02:00
2019-09-28 06:02:25 +02:00
print load_fiche_titre ( $langs -> trans ( " CommercialArea " ), '' , 'commercial' );
2002-05-09 16:57:48 +02:00
2013-03-30 14:27:13 +01:00
print '<div class="fichecenter"><div class="fichethirdleft">' ;
2004-05-08 20:44:22 +02:00
2020-09-16 14:03:41 +02:00
// This is useless due to the global search combo
if ( ! empty ( $conf -> global -> MAIN_SEARCH_FORM_ON_HOME_AREAS )) {
2020-09-10 11:04:41 +02:00
// Search proposal
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> lire ) {
$listofsearchfields [ 'search_proposal' ] = array ( 'text' => 'Proposal' );
}
// Search customer order
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire ) {
$listofsearchfields [ 'search_customer_order' ] = array ( 'text' => 'CustomerOrder' );
}
// Search supplier proposal
if ( ! empty ( $conf -> supplier_proposal -> enabled ) && $user -> rights -> supplier_proposal -> lire ) {
$listofsearchfields [ 'search_supplier_proposal' ] = array ( 'text' => 'SupplierProposalShort' );
}
// Search supplier order
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD ) || ! empty ( $conf -> supplier_order -> enabled )) && $user -> rights -> fournisseur -> commande -> lire ) {
$listofsearchfields [ 'search_supplier_order' ] = array ( 'text' => 'SupplierOrder' );
}
// Search intervention
if ( ! empty ( $conf -> ficheinter -> enabled ) && $user -> rights -> ficheinter -> lire ) {
$listofsearchfields [ 'search_intervention' ] = array ( 'text' => 'Intervention' );
}
// Search contract
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire ) {
$listofsearchfields [ 'search_contract' ] = array ( 'text' => 'Contract' );
}
if ( count ( $listofsearchfields )) {
print '<form method="post" action="' . DOL_URL_ROOT . '/core/search.php">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<div class="div-table-responsive-no-min">' ;
print '<table class="noborder nohover centpercent">' ;
$i = 0 ;
foreach ( $listofsearchfields as $key => $value ) {
if ( $i == 0 ) print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " Search " ) . '</td></tr>' ;
print '<tr ' . $bc [ false ] . '>' ;
print '<td class="nowrap"><label for="' . $key . '">' . $langs -> trans ( $value [ " text " ]) . '</label></td><td><input type="text" class="flat inputsearch" name="' . $key . '" id="' . $key . '" size="18"></td>' ;
if ( $i == 0 ) print '<td class="noborderbottom" rowspan="' . count ( $listofsearchfields ) . '"><input type="submit" value="' . $langs -> trans ( " Search " ) . '" class="button "></td>' ;
print '</tr>' ;
$i ++ ;
}
print '</table>' ;
print '</div>' ;
print '</form>' ;
print '<br>' ;
}
2015-10-16 10:52:49 +02:00
}
2005-01-29 01:44:52 +01:00
/*
2020-09-01 13:20:56 +02:00
* Draft customer proposals
2005-01-29 01:44:52 +01:00
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> lire ) {
2020-12-08 15:36:37 +01:00
$sql = " SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status " ;
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-11-02 11:41:07 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as p, " ;
$sql .= " " . MAIN_DB_PREFIX . " societe as s " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE p.entity IN ( " . getEntity ( $propalstatic -> element ) . " ) " ;
2019-11-13 19:35:02 +01:00
$sql .= " AND p.fk_soc = s.rowid " ;
2020-09-16 10:51:19 +02:00
$sql .= " AND p.fk_statut = " . Propal :: STATUS_DRAFT ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$resql = $db -> query ( $sql );
2020-09-10 11:04:41 +02:00
if ( $resql ) {
2015-10-13 14:09:14 +02:00
$total = 0 ;
$num = $db -> num_rows ( $resql );
2020-09-10 11:04:41 +02:00
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2020-09-16 14:03:41 +02:00
startSimpleTable ( " ProposalsDraft " , " comm/propal/list.php " , " search_status= " . Propal :: STATUS_DRAFT , 2 , $num );
2020-09-10 11:07:10 +02:00
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
2009-01-23 01:47:23 +01:00
$i = 0 ;
2020-09-10 11:04:41 +02:00
while ( $i < $nbofloop ) {
2009-01-23 01:47:23 +01:00
$obj = $db -> fetch_object ( $resql );
2017-11-12 12:39:23 +01:00
2019-11-13 19:35:02 +01:00
$propalstatic -> id = $obj -> rowid ;
$propalstatic -> ref = $obj -> ref ;
2020-09-10 11:04:41 +02:00
$propalstatic -> ref_client = $obj -> ref_client ;
$propalstatic -> total_ht = $obj -> total_ht ;
$propalstatic -> total_tva = $obj -> total_tva ;
$propalstatic -> total_ttc = $obj -> total_ttc ;
2020-11-02 11:41:07 +01:00
$propalstatic -> statut = $obj -> status ;
2020-09-10 11:07:10 +02:00
2019-11-13 19:35:02 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $obj -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $obj -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $obj -> email ;
2020-12-08 15:36:37 +01:00
$companystatic -> entity = $obj -> entity ;
$companystatic -> canvas = $obj -> canvas ;
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2020-10-06 15:11:45 +02:00
print '<td class="nowrap tdoverflowmax100">' . $propalstatic -> getNomUrl ( 1 ) . '</td>' ;
print '<td class="nowrap tdoverflowmax100">' . $companystatic -> getNomUrl ( 1 , 'customer' ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="nowrap right tdamount">' . price (( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc )) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '</tr>' ;
2009-01-23 01:47:23 +01:00
$i ++ ;
2020-09-16 14:03:41 +02:00
$total += ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc );
2009-01-23 01:47:23 +01:00
}
2015-10-20 18:19:32 +02:00
}
2012-07-05 15:38:08 +02:00
2020-09-10 11:04:41 +02:00
addSummaryTableLine ( 3 , $num , $nbofloop , $total , " NoProposal " );
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2009-01-23 01:47:23 +01:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2009-04-05 04:23:57 +02:00
dol_print_error ( $db );
}
2002-04-29 20:01:16 +02:00
}
2005-06-21 21:49:42 +02:00
2016-02-09 11:56:12 +01:00
/*
* Draft supplier proposals
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> supplier_proposal -> enabled ) && $user -> rights -> supplier_proposal -> lire ) {
2020-12-08 15:36:37 +01:00
$sql = " SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.fk_statut as status " ;
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-11-02 11:41:07 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " supplier_proposal as p, " ;
$sql .= " " . MAIN_DB_PREFIX . " societe as s " ;
2020-09-10 11:04:41 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE p.entity IN ( " . getEntity ( $supplierproposalstatic -> element ) . " ) " ;
$sql .= " AND p.fk_statut = " . SupplierProposal :: STATUS_DRAFT ;
2020-09-10 11:04:41 +02:00
$sql .= " AND p.fk_soc = s.rowid " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2020-09-16 14:03:41 +02:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
2020-09-10 11:04:41 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$total = 0 ;
$num = $db -> num_rows ( $resql );
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2020-09-16 14:03:41 +02:00
startSimpleTable ( " SupplierProposalsDraft " , " supplier_proposal/list.php " , " search_status= " . SupplierProposal :: STATUS_DRAFT , 2 , $num );
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
$i = 0 ;
while ( $i < $nbofloop ) {
$obj = $db -> fetch_object ( $resql );
$supplierproposalstatic -> id = $obj -> rowid ;
$supplierproposalstatic -> ref = $obj -> ref ;
$supplierproposalstatic -> total_ht = $obj -> total_ht ;
$supplierproposalstatic -> total_tva = $obj -> total_tva ;
$supplierproposalstatic -> total_ttc = $obj -> total_ttc ;
2020-12-01 02:41:19 +01:00
$supplierproposalstatic -> statut = $obj -> status ;
2020-09-10 11:04:41 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $obj -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $obj -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $obj -> email ;
2020-12-08 15:36:37 +01:00
$companystatic -> entity = $obj -> entity ;
$companystatic -> canvas = $obj -> canvas ;
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2020-10-06 15:11:45 +02:00
print '<td class="nowrap tdoverflowmax100">' . $supplierproposalstatic -> getNomUrl ( 1 ) . '</td>' ;
print '<td class="nowrap tdoverflowmax100">' . $companystatic -> getNomUrl ( 1 , 'supplier' ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="nowrap right tdamount">' . price ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc ) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '</tr>' ;
$i ++ ;
2020-09-16 14:03:41 +02:00
$total += ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc );
2020-09-10 11:04:41 +02:00
}
}
addSummaryTableLine ( 3 , $num , $nbofloop , $total , " NoProposal " );
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
} else {
dol_print_error ( $db );
}
2016-02-09 11:56:12 +01:00
}
2003-11-09 16:37:14 +01:00
/*
2020-09-01 13:20:56 +02:00
* Draft customer orders
2003-11-09 16:37:14 +01:00
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire ) {
2020-12-08 15:36:37 +01:00
$sql = " SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, c.fk_statut as status " ;
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-11-02 11:41:07 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commande as c, " ;
$sql .= " " . MAIN_DB_PREFIX . " societe as s " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE c.entity IN ( " . getEntity ( $orderstatic -> element ) . " ) " ;
$sql .= " AND c.fk_statut = " . Commande :: STATUS_DRAFT ;
$sql .= " AND c.fk_soc = s.rowid " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2020-09-16 14:03:41 +02:00
if ( $socid ) $sql .= " AND c.fk_soc = " . $socid ;
2002-04-29 20:01:16 +02:00
2009-01-23 01:47:23 +01:00
$resql = $db -> query ( $sql );
2020-09-10 11:04:41 +02:00
if ( $resql ) {
2015-10-13 14:09:14 +02:00
$total = 0 ;
$num = $db -> num_rows ( $resql );
2020-09-10 11:04:41 +02:00
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2020-09-16 14:03:41 +02:00
startSimpleTable ( " DraftOrders " , " commande/list.php " , " search_status= " . Commande :: STATUS_DRAFT , 2 , $num );
2017-11-12 12:39:23 +01:00
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
2009-01-23 01:47:23 +01:00
$i = 0 ;
2020-09-10 11:04:41 +02:00
while ( $i < $nbofloop ) {
2009-01-23 01:47:23 +01:00
$obj = $db -> fetch_object ( $resql );
2020-09-10 11:04:41 +02:00
$orderstatic -> id = $obj -> rowid ;
$orderstatic -> ref = $obj -> ref ;
$orderstatic -> ref_client = $obj -> ref_client ;
$orderstatic -> total_ht = $obj -> total_ht ;
$orderstatic -> total_tva = $obj -> total_tva ;
$orderstatic -> total_ttc = $obj -> total_ttc ;
2020-11-02 11:41:07 +01:00
$orderstatic -> statut = $obj -> status ;
2020-09-10 11:07:10 +02:00
2019-11-13 19:35:02 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $obj -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $obj -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $obj -> email ;
$companystatic -> entity = $obj -> entity ;
2020-12-08 15:36:37 +01:00
$companystatic -> canvas = $obj -> canvas ;
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2020-10-06 15:11:45 +02:00
print '<td class="nowrap tdoverflowmax100">' . $orderstatic -> getNomUrl ( 1 ) . '</td>' ;
print '<td class="nowrap tdoverflowmax100">' . $companystatic -> getNomUrl ( 1 , 'customer' ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="nowrap right tdamount">' . price ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc ) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '</tr>' ;
2009-01-23 01:47:23 +01:00
$i ++ ;
2020-09-16 14:03:41 +02:00
$total += ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc );
2009-01-23 01:47:23 +01:00
}
2015-10-20 18:19:32 +02:00
}
2012-07-05 15:38:08 +02:00
2020-09-10 11:04:41 +02:00
addSummaryTableLine ( 3 , $num , $nbofloop , $total , " NoProposal " );
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2011-12-29 18:07:41 +01:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2015-10-20 17:00:34 +02:00
dol_print_error ( $db );
}
}
/*
2020-11-02 11:41:07 +01:00
* Draft purchase orders
2015-10-20 17:00:34 +02:00
*/
2020-09-10 11:04:41 +02:00
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD ) || ! empty ( $conf -> supplier_order -> enabled )) && $user -> rights -> fournisseur -> commande -> lire ) {
2020-12-08 15:36:37 +01:00
$sql = " SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, cf.fk_statut as status " ;
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-11-02 11:41:07 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commande_fournisseur as cf, " ;
$sql .= " " . MAIN_DB_PREFIX . " societe as s " ;
2020-09-10 11:04:41 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE cf.entity IN ( " . getEntity ( $supplierorderstatic -> element ) . " ) " ;
$sql .= " AND cf.fk_statut = " . CommandeFournisseur :: STATUS_DRAFT ;
$sql .= " AND cf.fk_soc = s.rowid " ;
2020-09-10 11:04:41 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2020-09-16 14:03:41 +02:00
if ( $socid ) $sql .= " AND cf.fk_soc = " . $socid ;
2020-09-10 11:04:41 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$total = 0 ;
$num = $db -> num_rows ( $resql );
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2020-09-16 14:03:41 +02:00
startSimpleTable ( " DraftSuppliersOrders " , " fourn/commande/list.php " , " search_status= " . CommandeFournisseur :: STATUS_DRAFT , 2 , $num );
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
$i = 0 ;
while ( $i < $nbofloop ) {
$obj = $db -> fetch_object ( $resql );
$supplierorderstatic -> id = $obj -> rowid ;
$supplierorderstatic -> ref = $obj -> ref ;
$supplierorderstatic -> ref_supplier = $obj -> ref_suppliert ;
$supplierorderstatic -> total_ht = $obj -> total_ht ;
$supplierorderstatic -> total_tva = $obj -> total_tva ;
$supplierorderstatic -> total_ttc = $obj -> total_ttc ;
2020-11-02 11:41:07 +01:00
$supplierorderstatic -> statut = $obj -> status ;
2020-09-10 11:04:41 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $obj -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $obj -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $obj -> email ;
2020-12-08 15:36:37 +01:00
$companystatic -> entity = $obj -> entity ;
$companystatic -> canvas = $obj -> canvas ;
2004-05-08 20:44:22 +02:00
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2020-10-06 15:11:45 +02:00
print '<td class="nowrap tdoverflowmax100">' . $supplierorderstatic -> getNomUrl ( 1 ) . '</td>' ;
print '<td class="nowrap tdoverflowmax100">' . $companystatic -> getNomUrl ( 1 , 'supplier' ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="nowrap right tdamount">' . price ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc ) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '</tr>' ;
2013-03-16 14:53:15 +01:00
2020-09-10 11:04:41 +02:00
$i ++ ;
2020-09-16 14:03:41 +02:00
$total += ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc );
2020-09-10 11:04:41 +02:00
}
}
2004-10-30 14:15:59 +02:00
2020-09-10 11:04:41 +02:00
addSummaryTableLine ( 3 , $num , $nbofloop , $total , " NoProposal " );
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
} else {
dol_print_error ( $db );
}
}
2009-04-06 19:49:18 +02:00
2020-09-16 14:03:41 +02:00
print '</div><div class="fichetwothirdright">' ;
print '<div class="ficheaddleft">' ;
2005-10-25 21:40:01 +02:00
2005-06-21 21:49:42 +02:00
/*
2009-08-26 00:35:10 +02:00
* Last modified customers or prospects
2005-06-21 21:49:42 +02:00
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> societe -> enabled ) && $user -> rights -> societe -> lire ) {
2020-12-08 15:36:37 +01:00
$sql = " SELECT s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
$sql .= " , s.datec, s.tms " ;
2019-11-13 19:35:02 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE s.entity IN ( " . getEntity ( $companystatic -> element ) . " ) " ;
$sql .= " AND s.client IN ( " . Societe :: CUSTOMER . " , " . Societe :: PROSPECT . " , " . Societe :: CUSTOMER_AND_PROSPECT . " ) " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2020-09-16 14:03:41 +02:00
if ( $socid ) $sql .= " AND s.rowid = $socid " ;
2009-04-06 19:49:18 +02:00
$sql .= " ORDER BY s.tms DESC " ;
2009-01-23 01:47:23 +01:00
$sql .= $db -> plimit ( $max , 0 );
$resql = $db -> query ( $sql );
2020-09-10 11:04:41 +02:00
if ( $resql ) {
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) {
$header = " BoxTitleLastCustomersOrProspects " ;
2020-09-08 11:15:33 +02:00
}
2020-09-10 11:04:41 +02:00
elseif ( ! empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) {
$header = " BoxTitleLastModifiedProspects " ;
2020-09-08 11:15:33 +02:00
}
2020-09-08 11:22:02 +02:00
else {
2020-09-10 11:04:41 +02:00
$header = " BoxTitleLastModifiedCustomers " ;
2020-09-08 11:15:33 +02:00
}
2020-09-10 11:04:41 +02:00
$num = $db -> num_rows ( $resql );
startSimpleTable ( $langs -> trans ( $header , min ( $max , $num )), " societe/list.php " , " type=p,c " , 1 );
if ( $num ) {
$i = 0 ;
while ( $i < $num && $i < $max ) {
2009-01-23 01:47:23 +01:00
$objp = $db -> fetch_object ( $resql );
2020-09-10 11:04:41 +02:00
2020-12-08 15:36:37 +01:00
$companystatic -> id = $objp -> socid ;
2019-11-13 19:35:02 +01:00
$companystatic -> name = $objp -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $objp -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $objp -> code_client ;
2020-02-18 08:28:39 +01:00
$companystatic -> code_compta = $objp -> code_compta ;
2020-12-08 15:36:37 +01:00
$companystatic -> client = $objp -> client ;
$companystatic -> code_fournisseur = $objp -> code_fournisseur ;
$companystatic -> code_compta_fournisseur = $objp -> code_compta_fournisseur ;
$companystatic -> fournisseur = $objp -> fournisseur ;
$companystatic -> logo = $objp -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $objp -> email ;
2020-12-08 15:36:37 +01:00
$companystatic -> entity = $objp -> entity ;
$companystatic -> canvas = $objp -> canvas ;
2020-09-10 11:04:41 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2020-10-06 15:11:45 +02:00
print '<td class="nowrap tdoverflowmax100">' . $companystatic -> getNomUrl ( 1 , 'customer' ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="nowrap">' ;
//print $companystatic->getLibCustProspStatut();
$obj = $companystatic ;
$s = '' ;
if (( $obj -> client == 2 || $obj -> client == 3 ) && empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ))
{
$s .= '<a class="customer-back opacitymedium" title="' . $langs -> trans ( " Prospect " ) . '" href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $companystatic -> id . '">' . dol_substr ( $langs -> trans ( " Prospect " ), 0 , 1 ) . '</a>' ;
}
if (( $obj -> client == 1 || $obj -> client == 3 ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS ))
{
$s .= '<a class="customer-back" title="' . $langs -> trans ( " Customer " ) . '" href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $companystatic -> id . '">' . dol_substr ( $langs -> trans ( " Customer " ), 0 , 1 ) . '</a>' ;
}
/*
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD ) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) && $obj -> fournisseur )
{
$s .= '<a class="vendor-back" title="' . $langs -> trans ( " Supplier " ) . '" href="' . DOL_URL_ROOT . '/fourn/card.php?socid=' . $companystatic -> id . '">' . dol_substr ( $langs -> trans ( " Supplier " ), 0 , 1 ) . '</a>' ;
} */
print $s ;
print '</td>' ;
print '<td class="right nowrap tddate">' . dol_print_date ( $db -> jdate ( $objp -> tms ), 'day' ) . '</td>' ;
2009-01-23 01:47:23 +01:00
print '</tr>' ;
2020-09-10 11:04:41 +02:00
2009-01-23 01:47:23 +01:00
$i ++ ;
}
2009-05-10 06:20:37 +02:00
}
2020-09-10 11:04:41 +02:00
addSummaryTableLine ( 3 , $num );
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
} else {
dol_print_error ( $db );
2009-05-10 06:20:37 +02:00
}
}
2020-09-10 11:04:41 +02:00
/*
* Last suppliers
*/
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD ) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) && $user -> rights -> societe -> lire ) {
2020-12-08 15:36:37 +01:00
$sql = " SELECT s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
$sql .= " , s.datec as dc, s.tms as dm " ;
2019-11-13 19:35:02 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $user -> socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE s.entity IN ( " . getEntity ( $companystatic -> element ) . " ) " ;
$sql .= " AND s.fournisseur = " . Societe :: SUPPLIER ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $user -> socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2020-09-16 14:03:41 +02:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
2019-11-13 19:35:02 +01:00
$sql .= " ORDER BY s.datec DESC " ;
$sql .= $db -> plimit ( $max , 0 );
2009-05-10 06:20:37 +02:00
2020-09-10 11:04:41 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
$num = $db -> num_rows ( $resql );
2020-10-16 15:40:52 +02:00
startSimpleTable ( $langs -> trans ( " BoxTitleLastModifiedSuppliers " , min ( $max , $num )), " societe/list.php " , " type=f " , 1 );
2009-05-10 06:20:37 +02:00
2020-09-10 11:04:41 +02:00
if ( $num ) {
$i = 0 ;
while ( $i < $num && $i < $max ) {
$objp = $db -> fetch_object ( $resql );
2020-09-08 11:15:33 +02:00
2020-12-08 15:36:37 +01:00
$companystatic -> id = $objp -> socid ;
2020-09-10 11:04:41 +02:00
$companystatic -> name = $objp -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $objp -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $objp -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $objp -> code_compta ;
$companystatic -> client = $objp -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $objp -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $objp -> code_compta_fournisseur ;
2020-10-16 15:40:52 +02:00
$companystatic -> fournisseur = $objp -> fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> logo = $objp -> logo ;
$companystatic -> email = $objp -> email ;
$companystatic -> entity = $objp -> entity ;
$companystatic -> canvas = $objp -> canvas ;
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2020-10-06 15:11:45 +02:00
print '<td class="nowrap tdoverflowmax100">' . $companystatic -> getNomUrl ( 1 , 'supplier' ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td>' ;
$obj = $companystatic ;
$s = '' ;
/* if (( $obj -> client == 2 || $obj -> client == 3 ) && empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ))
{
$s .= '<a class="customer-back opacitymedium" title="' . $langs -> trans ( " Prospect " ) . '" href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $companystatic -> id . '">' . dol_substr ( $langs -> trans ( " Prospect " ), 0 , 1 ) . '</a>' ;
}
if (( $obj -> client == 1 || $obj -> client == 3 ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS ))
{
$s .= '<a class="customer-back" title="' . $langs -> trans ( " Customer " ) . '" href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $companystatic -> id . '">' . dol_substr ( $langs -> trans ( " Customer " ), 0 , 1 ) . '</a>' ;
} */
if (( ! empty ( $conf -> fournisseur -> enabled ) && empty ( $conf -> global -> MAIN_USE_NEW_SUPPLIERMOD ) || ! empty ( $conf -> supplier_order -> enabled ) || ! empty ( $conf -> supplier_invoice -> enabled )) && $obj -> fournisseur )
{
$s .= '<a class="vendor-back" title="' . $langs -> trans ( " Supplier " ) . '" href="' . DOL_URL_ROOT . '/fourn/card.php?socid=' . $companystatic -> id . '">' . dol_substr ( $langs -> trans ( " Supplier " ), 0 , 1 ) . '</a>' ;
}
print $s ;
print '</td>' ;
print '<td class="right tddate">' . dol_print_date ( $db -> jdate ( $objp -> dm ), 'day' ) . '</td>' ;
2009-05-10 06:20:37 +02:00
print '</tr>' ;
2017-11-12 12:39:23 +01:00
2009-05-10 06:20:37 +02:00
$i ++ ;
}
}
2020-09-10 11:04:41 +02:00
2020-10-16 15:40:52 +02:00
addSummaryTableLine ( 3 , $num );
2020-09-10 11:04:41 +02:00
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
} else {
dol_print_error ( $db );
2009-01-23 01:47:23 +01:00
}
2005-06-21 21:49:42 +02:00
}
2005-10-25 21:40:01 +02:00
2009-04-06 19:49:18 +02:00
/*
* Last actions
*/
2020-09-10 11:04:41 +02:00
if ( $user -> rights -> agenda -> myactions -> read ) {
2009-04-06 19:49:18 +02:00
show_array_last_actions_done ( $max );
}
/*
* Actions to do
*/
2020-09-10 11:04:41 +02:00
if ( $user -> rights -> agenda -> myactions -> read ) {
2020-09-21 13:54:26 +02:00
show_array_actions_to_do ( $max );
2009-04-06 19:49:18 +02:00
}
2004-05-08 20:44:22 +02:00
/*
2020-02-20 00:21:25 +01:00
* Latest contracts
2004-05-08 20:44:22 +02:00
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire && 0 ) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
2020-09-16 10:51:19 +02:00
$staticcontrat = new Contrat ( $db );
2009-01-23 01:47:23 +01:00
2020-12-08 15:36:37 +01:00
$sql = " SELECT s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-09-10 11:04:41 +02:00
$sql .= " , c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo " ;
2019-11-13 19:35:02 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " , " . MAIN_DB_PREFIX . " contrat as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " product as p " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE c.entity IN ( " . getEntity ( $staticcontrat -> element ) . " ) " ;
$sql .= " AND c.fk_soc = s.rowid " ;
2019-11-13 19:35:02 +01:00
$sql .= " AND c.fk_product = p.rowid " ;
2020-09-16 10:51:19 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2019-11-13 19:35:02 +01:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$sql .= " ORDER BY c.tms DESC " ;
2020-09-21 13:54:26 +02:00
$sql .= $db -> plimit ( $max + 1 , 0 );
2019-11-13 19:35:02 +01:00
$resql = $db -> query ( $sql );
2020-09-10 11:04:41 +02:00
if ( $resql ) {
2010-08-09 17:42:57 +02:00
$num = $db -> num_rows ( $resql );
2020-09-21 13:54:26 +02:00
startSimpleTable ( $langs -> trans ( " LastContracts " , $max ), " " , " " , 2 );
2020-09-08 11:22:02 +02:00
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
2009-04-06 19:49:18 +02:00
$i = 0 ;
2020-09-10 11:04:41 +02:00
while ( $i < $num ) {
2010-08-09 17:42:57 +02:00
$obj = $db -> fetch_object ( $resql );
2020-09-10 11:04:41 +02:00
2020-12-08 15:36:37 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$companystatic -> name_alias = $obj -> name_alias ;
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
$companystatic -> email = $obj -> email ;
$companystatic -> entity = $obj -> entity ;
$companystatic -> canvas = $obj -> canvas ;
2020-09-10 11:04:41 +02:00
2020-10-16 15:40:52 +02:00
$staticcontrat -> id = $obj -> contratid ;
$staticcontrat -> ref = $obj -> ref ;
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2020-10-16 15:40:52 +02:00
print '<td>' . $staticcontrat -> getNomUrl ( 1 ) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '<td>' . $companystatic -> getNomUrl ( 1 , 'customer' , 44 ) . '</td>' ;
print '<td class="right">' . $staticcontrat -> LibStatut ( $obj -> statut , 3 ) . '</td>' ;
print '</tr>' ;
2017-11-12 12:39:23 +01:00
2009-04-06 19:49:18 +02:00
$i ++ ;
}
2009-01-23 01:47:23 +01:00
}
2020-09-10 11:04:41 +02:00
addSummaryTableLine ( 2 , $num );
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2004-07-13 09:20:09 +02:00
}
2003-11-09 16:37:14 +01:00
}
2020-09-10 11:04:41 +02:00
2004-05-08 20:44:22 +02:00
/*
2020-09-16 10:51:19 +02:00
* Opened ( validated ) proposals
2004-05-08 20:44:22 +02:00
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> lire ) {
2020-09-16 14:03:41 +02:00
$sql = " SELECT p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.tva as total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv " ;
2020-12-08 15:36:37 +01:00
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-09-16 10:51:19 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as p " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE p.entity IN ( " . getEntity ( $propalstatic -> element ) . " ) " ;
$sql .= " AND p.fk_soc = s.rowid " ;
$sql .= " AND p.fk_statut = " . Propal :: STATUS_VALIDATED ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$sql .= " ORDER BY p.rowid DESC " ;
2020-09-10 11:04:41 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
2020-09-21 13:54:26 +02:00
$total = $total_ttc = 0 ;
2020-09-10 11:04:41 +02:00
$num = $db -> num_rows ( $resql );
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
startSimpleTable ( " ProposalsOpened " , " comm/propal/list.php " , " search_status=1 " , 4 , $num );
2017-11-12 12:39:23 +01:00
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
$i = 0 ;
2020-09-21 13:54:26 +02:00
$othernb = 0 ;
2009-01-23 17:44:12 +01:00
2020-09-10 11:04:41 +02:00
while ( $i < $nbofloop ) {
$obj = $db -> fetch_object ( $resql );
2009-01-23 01:47:23 +01:00
2020-09-21 13:54:26 +02:00
if ( $i >= $max ) {
$othernb += 1 ;
$i ++ ;
$total += $obj -> total_ht ;
$total_ttc += $obj -> total_ttc ;
continue ;
}
2019-11-13 19:35:02 +01:00
$propalstatic -> id = $obj -> propalid ;
$propalstatic -> ref = $obj -> ref ;
2020-09-10 11:04:41 +02:00
$propalstatic -> ref_client = $obj -> ref_client ;
$propalstatic -> total_ht = $obj -> total_ht ;
$propalstatic -> total_tva = $obj -> total_tva ;
$propalstatic -> total_ttc = $obj -> total_ttc ;
2020-09-10 11:07:10 +02:00
2020-12-08 15:36:37 +01:00
$companystatic -> id = $obj -> socid ;
2020-09-10 11:04:41 +02:00
$companystatic -> name = $obj -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $obj -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $obj -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $obj -> email ;
2020-12-08 15:36:37 +01:00
$companystatic -> entity = $obj -> entity ;
$companystatic -> canvas = $obj -> canvas ;
2020-09-10 11:04:41 +02:00
2020-09-16 14:03:41 +02:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> propal -> multidir_output [ $obj -> entity ] . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> propalid ;
$warning = ( $db -> jdate ( $obj -> dfv ) < ( $now - $conf -> propal -> cloture -> warning_delay )) ? img_warning ( $langs -> trans ( " Late " )) : '' ;
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2009-01-23 01:47:23 +01:00
2020-09-10 11:04:41 +02:00
print '<td class="nowrap" width="140">' ;
2009-01-23 01:47:23 +01:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2020-09-16 14:03:41 +02:00
print '<td class="nobordernopadding nowrap">' . $propalstatic -> getNomUrl ( 1 ) . '</td>' ;
print '<td width="18" class="nobordernopadding nowrap">' . $warning . '</td>' ;
print '<td width="16" align="center" class="nobordernopadding">' . $formfile -> getDocumentsLink ( $propalstatic -> element , $filename , $filedir ) . '</td>' ;
print '</tr>' ;
print '</table>' ;
2009-01-23 01:47:23 +01:00
print '</td>' ;
2009-01-23 17:44:12 +01:00
2020-09-10 11:04:41 +02:00
print '<td class="nowrap">' . $companystatic -> getNomUrl ( 1 , 'customer' , 44 ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="right tddate">' . dol_print_date ( $db -> jdate ( $obj -> dp ), 'day' ) . '</td>' ;
print '<td class="right tdamount">' . price ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc ) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '<td align="center" width="14">' . $propalstatic -> LibStatut ( $obj -> fk_statut , 3 ) . '</td>' ;
print '</tr>' ;
2009-01-23 01:47:23 +01:00
$i ++ ;
2020-09-21 13:54:26 +02:00
$total += $obj -> total_ht ;
$total_ttc += $obj -> total_ttc ;
}
if ( $othernb ) {
print '<tr class="oddeven">' ;
print '<td class="nowrap" colspan="5">' ;
print '<span class="opacitymedium">' . $langs -> trans ( " More " ) . '... (' . $othernb . ')</span>' ;
print '</td>' ;
print " </tr> \n " ;
2009-01-23 01:47:23 +01:00
}
}
2020-09-10 11:04:41 +02:00
2020-09-21 13:54:26 +02:00
addSummaryTableLine ( 5 , $num , $nbofloop , empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $total_ttc : $total , " NoProposal " , true );
2020-09-10 11:04:41 +02:00
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2009-01-23 01:47:23 +01:00
}
2003-11-09 16:37:14 +01:00
}
2020-09-10 11:04:41 +02:00
2015-04-18 17:49:48 +02:00
/*
2020-09-16 10:51:19 +02:00
* Opened ( validated ) order
2015-04-18 17:49:48 +02:00
*/
2020-09-10 11:04:41 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire ) {
2020-09-16 10:51:19 +02:00
$sql = " SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.tva as total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed " ;
2020-12-08 15:36:37 +01:00
$sql .= " , s.rowid as socid, s.nom as name, s.name_alias " ;
$sql .= " , s.code_client, s.code_compta, s.client " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur " ;
$sql .= " , s.logo, s.email, s.entity " ;
$sql .= " , s.canvas " ;
2020-09-16 10:51:19 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2020-09-16 10:51:19 +02:00
$sql .= " WHERE c.entity IN ( " . getEntity ( $orderstatic -> element ) . " ) " ;
$sql .= " AND c.fk_soc = s.rowid " ;
$sql .= " AND c.fk_statut IN ( " . Commande :: STATUS_VALIDATED . " , " . Commande :: STATUS_SHIPMENTONPROCESS . " ) " ;
2019-11-13 19:35:02 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$sql .= " ORDER BY c.rowid DESC " ;
2020-09-10 11:04:41 +02:00
$resql = $db -> query ( $sql );
if ( $resql ) {
2020-09-21 13:54:26 +02:00
$total = $total_ttc = 0 ;
2020-09-10 11:04:41 +02:00
$num = $db -> num_rows ( $resql );
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2020-09-16 14:03:41 +02:00
startSimpleTable ( " OrdersOpened " , " commande/list.php " , " search_status= " . Commande :: STATUS_VALIDATED , 4 , $num );
2017-11-12 12:39:23 +01:00
2020-09-10 11:04:41 +02:00
if ( $num > 0 ) {
$i = 0 ;
2020-09-21 13:54:26 +02:00
$othernb = 0 ;
2015-04-18 17:49:48 +02:00
2020-09-10 11:04:41 +02:00
while ( $i < $nbofloop ) {
$obj = $db -> fetch_object ( $resql );
2015-04-18 17:49:48 +02:00
2020-09-21 13:54:26 +02:00
if ( $i >= $max ) {
$othernb += 1 ;
$i ++ ;
$total += $obj -> total_ht ;
$total_ttc += $obj -> total_ttc ;
continue ;
}
2019-11-13 19:35:02 +01:00
$orderstatic -> id = $obj -> commandeid ;
$orderstatic -> ref = $obj -> ref ;
2020-09-10 11:04:41 +02:00
$orderstatic -> ref_client = $obj -> ref_client ;
$orderstatic -> total_ht = $obj -> total_ht ;
$orderstatic -> total_tva = $obj -> total_tva ;
$orderstatic -> total_ttc = $obj -> total_ttc ;
2020-12-08 15:36:37 +01:00
$companystatic -> id = $obj -> socid ;
2020-09-10 11:04:41 +02:00
$companystatic -> name = $obj -> name ;
2020-12-08 15:36:37 +01:00
$companystatic -> name_alias = $obj -> name_alias ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_client = $obj -> code_client ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> client = $obj -> client ;
2020-09-10 11:04:41 +02:00
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2020-12-08 15:36:37 +01:00
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> logo = $obj -> logo ;
2020-09-10 11:04:41 +02:00
$companystatic -> email = $obj -> email ;
2020-12-08 15:36:37 +01:00
$companystatic -> entity = $obj -> entity ;
$companystatic -> canvas = $obj -> canvas ;
2020-09-10 11:04:41 +02:00
2020-09-16 10:51:19 +02:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> commande -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> propalid ;
2020-09-16 14:03:41 +02:00
//$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
2020-09-16 10:51:19 +02:00
2020-09-10 11:04:41 +02:00
print '<tr class="oddeven">' ;
2015-04-18 17:49:48 +02:00
2020-09-10 11:04:41 +02:00
print '<td class="nowrap" width="140">' ;
2015-04-18 17:49:48 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2020-09-16 14:03:41 +02:00
print '<td class="nobordernopadding nowrap">' . $orderstatic -> getNomUrl ( 1 ) . '</td>' ;
print '<td width="18" class="nobordernopadding nowrap"></td>' ;
print '<td width="16" align="center" class="nobordernopadding">' . $formfile -> getDocumentsLink ( $orderstatic -> element , $filename , $filedir ) . '</td>' ;
print '</tr>' ;
print '</table>' ;
2015-04-18 17:49:48 +02:00
print '</td>' ;
2020-09-10 11:04:41 +02:00
print '<td class="nowrap">' . $companystatic -> getNomUrl ( 1 , 'customer' , 44 ) . '</td>' ;
2020-10-16 15:40:52 +02:00
print '<td class="right tddate">' . dol_print_date ( $db -> jdate ( $obj -> dp ), 'day' ) . '</td>' ;
print '<td class="right tdamount">' . price ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $obj -> total_ht : $obj -> total_ttc ) . '</td>' ;
2020-09-10 11:04:41 +02:00
print '<td align="center" width="14">' . $orderstatic -> LibStatut ( $obj -> fk_statut , $obj -> billed , 3 ) . '</td>' ;
2020-09-16 10:51:19 +02:00
print '</tr>' ;
2020-09-10 11:04:41 +02:00
2015-04-18 17:49:48 +02:00
$i ++ ;
2020-09-21 13:54:26 +02:00
$total += $obj -> total_ht ;
$total_ttc += $obj -> total_ttc ;
}
if ( $othernb ) {
print '<tr class="oddeven">' ;
print '<td class="nowrap" colspan="5">' ;
print '<span class="opacitymedium">' . $langs -> trans ( " More " ) . '... (' . $othernb . ')</span>' ;
print '</td>' ;
print " </tr> \n " ;
2015-04-18 17:49:48 +02:00
}
}
2020-09-10 11:04:41 +02:00
2020-09-21 13:54:26 +02:00
addSummaryTableLine ( 5 , $num , $nbofloop , empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT ) ? $total_ttc : $total , " None " , true );
2020-09-10 11:04:41 +02:00
finishSimpleTable ( true );
2020-09-20 16:11:02 +02:00
2020-09-10 11:04:41 +02:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2015-04-18 17:49:48 +02:00
dol_print_error ( $db );
}
}
2020-09-16 14:03:41 +02:00
print '</div>' ;
print '</div>' ;
print '</div>' ;
2002-04-29 20:01:16 +02:00
2019-06-18 14:07:52 +02:00
$parameters = array ( 'user' => $user );
$reshook = $hookmanager -> executeHooks ( 'dashboardCommercials' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2018-07-29 17:17:29 +02:00
// End of page
2012-02-02 07:49:50 +01:00
llxFooter ();
$db -> close ();