2004-10-19 22:19:58 +02:00
< ? php
2005-08-25 17:07:01 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-04-13 01:32:53 +02:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2017-05-06 10:54:28 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
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
2011-08-03 02:45:22 +02:00
* along with this program . If not , see < http :// 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
/**
2009-04-06 19:49:18 +02:00
* \file htdocs / comm / index . php
* \ingroup commercial
2011-02-21 09:58:45 +01:00
* \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' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.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 -> propal -> enabled )) require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
2016-02-09 11:56:12 +01:00
if ( ! empty ( $conf -> supplier_proposal -> enabled )) require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php' ;
2015-01-08 10:01:02 +01:00
if ( ! empty ( $conf -> commande -> enabled )) require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
2015-10-20 17:00:34 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled )) require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
2005-08-25 17:07:01 +02:00
2012-07-09 12:31:21 +02:00
if ( ! $user -> rights -> societe -> lire ) accessforbidden ();
2009-01-23 17:44:12 +01:00
2018-05-26 19:03:41 +02:00
// Load translation files required by the page
2018-05-24 10:48:03 +02:00
$langs -> loadLangs ( array ( " commercial " , " propal " ));
2002-04-30 12:44:42 +02:00
2012-10-13 11:41:17 +02:00
$action = GETPOST ( 'action' , 'alpha' );
$bid = GETPOST ( 'bid' , 'int' );
2009-04-27 22:37:50 +02:00
// Securite acces client
2012-07-09 12:31:21 +02:00
$socid = GETPOST ( 'socid' , 'int' );
if ( isset ( $user -> societe_id ) && $user -> societe_id > 0 )
2003-10-14 13:02:31 +02:00
{
2009-01-23 01:47:23 +01:00
$action = '' ;
$socid = $user -> societe_id ;
2003-10-14 13:02:31 +02:00
}
2005-07-03 04:37:16 +02:00
$max = 5 ;
2012-04-30 15:01:25 +02: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 );
2009-04-05 04:23:57 +02:00
$companystatic = new Societe ( $db );
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> propal -> enabled )) $propalstatic = new Propal ( $db );
2016-02-09 11:56:12 +01:00
if ( ! empty ( $conf -> supplier_proposal -> enabled )) $supplierproposalstatic = new SupplierProposal ( $db );
2015-01-08 10:01:02 +01:00
if ( ! empty ( $conf -> commande -> enabled )) $orderstatic = new Commande ( $db );
2015-10-20 17:00:34 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled )) $supplierorderstatic = new CommandeFournisseur ( $db );
2007-07-13 19:10:38 +02:00
2016-08-31 10:19:40 +02:00
llxHeader ( " " , $langs -> trans ( " CommercialArea " ));
2006-04-08 00:27:25 +02:00
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " CommercialArea " ), '' , 'title_commercial.png' );
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
2017-02-21 14:17:44 +01:00
if ( ! empty ( $conf -> global -> MAIN_SEARCH_FORM_ON_HOME_AREAS )) // This is useless due to the global search combo
2015-03-10 13:25:25 +01:00
{
2017-02-21 14:17:44 +01: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 ) && $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' );
}
2017-11-12 12:39:23 +01:00
2017-02-21 14:17:44 +01:00
if ( count ( $listofsearchfields ))
{
print '<form method="post" action="' . DOL_URL_ROOT . '/core/search.php">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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 ++ ;
}
2017-11-12 12:39:23 +01:00
print '</table>' ;
2017-02-21 14:17:44 +01:00
print '</form>' ;
print '<br>' ;
}
2015-10-16 10:52:49 +02:00
}
2005-01-29 01:44:52 +01:00
/*
2009-10-17 01:25:15 +02:00
* Draft proposals
2005-01-29 01:44:52 +01:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> lire )
2005-05-14 17:12:15 +02:00
{
2015-10-20 18:24:14 +02:00
$langs -> load ( " propal " );
2015-01-25 01:20:58 +01:00
$sql = " SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas " ;
2015-10-03 21:32:43 +02:00
$sql .= " , s.code_client " ;
2009-04-27 22:37:50 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as p " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-04-27 22:37:50 +02:00
$sql .= " WHERE p.fk_statut = 0 " ;
$sql .= " AND p.fk_soc = s.rowid " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND p.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-04-27 22:37:50 +02:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
2009-04-29 20:02:50 +02:00
2009-01-23 01:47:23 +01:00
$resql = $db -> query ( $sql );
if ( $resql )
{
2015-10-13 14:09:14 +02:00
$total = 0 ;
$num = $db -> num_rows ( $resql );
2017-11-12 12:39:23 +01:00
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2011-12-29 18:07:41 +01:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="3">' . $langs -> trans ( " ProposalsDraft " ) . ( $num ? ' <span class="badge">' . $num . '</span>' : '' ) . '</th></tr>' ;
2011-12-29 18:07:41 +01:00
2009-01-23 01:47:23 +01:00
if ( $num > 0 )
{
$i = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2017-11-12 12:39:23 +01:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td class="nowrap">' ;
2009-04-05 04:23:57 +02:00
$propalstatic -> id = $obj -> rowid ;
$propalstatic -> ref = $obj -> ref ;
2015-01-21 01:06:04 +01:00
$propalstatic -> ref_client = $obj -> ref_client ;
2015-01-25 01:20:58 +01:00
$propalstatic -> total_ht = $obj -> total_ht ;
$propalstatic -> total_tva = $obj -> total_tva ;
$propalstatic -> total_ttc = $obj -> total_ttc ;
2009-04-05 04:23:57 +02:00
print $propalstatic -> getNomUrl ( 1 );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2009-04-05 04:23:57 +02:00
$companystatic -> id = $obj -> socid ;
2011-02-21 09:58:45 +01:00
$companystatic -> name = $obj -> name ;
2009-04-05 04:23:57 +02:00
$companystatic -> client = $obj -> client ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2011-02-21 09:58:45 +01:00
$companystatic -> canvas = $obj -> canvas ;
2009-04-05 04:23:57 +02:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 16 );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td align="right" class="nowrap">' . price ( $obj -> total_ht ) . '</td></tr>' ;
2009-01-23 01:47:23 +01:00
$i ++ ;
2012-07-09 12:31:21 +02:00
$total += $obj -> total_ht ;
2009-01-23 01:47:23 +01:00
}
if ( $total > 0 )
{
2017-11-12 12:39:23 +01:00
2009-01-23 01:47:23 +01:00
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td colspan="2" align="right">' . price ( $total ) . " </td></tr> " ;
}
}
2015-10-20 18:19:32 +02:00
else
{
2017-11-12 12:39:23 +01:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoProposal " ) . '</td></tr>' ;
2015-10-20 18:19:32 +02:00
}
2018-02-15 12:57:04 +01:00
print " </table></div><br> " ;
2012-07-05 15:38:08 +02:00
2009-01-23 01:47:23 +01:00
$db -> free ( $resql );
}
2009-04-05 04:23:57 +02:00
else
{
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
*/
if ( ! empty ( $conf -> supplier_proposal -> enabled ) && $user -> rights -> supplier_proposal -> lire )
{
$langs -> load ( " supplier_proposal " );
$sql = " SELECT p.rowid, p.ref, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas " ;
$sql .= " , s.code_client " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " supplier_proposal as p " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE p.fk_statut = 0 " ;
$sql .= " AND p.fk_soc = s.rowid " ;
2018-04-21 14:41:31 +02:00
$sql .= " AND p.entity IN ( " . getEntity ( 'supplier_proposal' ) . " ) " ;
2016-02-09 11:56:12 +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 );
if ( $resql )
{
$total = 0 ;
$num = $db -> num_rows ( $resql );
2017-11-12 12:39:23 +01:00
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2016-02-09 11:56:12 +01:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="3">' . $langs -> trans ( " SupplierProposalsDraft " ) . ( $num ? ' <span class="badge">' . $num . '</span>' : '' ) . '</th></tr>' ;
2016-02-09 11:56:12 +01:00
if ( $num > 0 )
{
$i = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2017-11-12 12:39:23 +01:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td class="nowrap">' ;
2016-02-09 11:56:12 +01:00
$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 ;
print $supplierproposalstatic -> getNomUrl ( 1 );
print '</td>' ;
print '<td class="nowrap">' ;
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$companystatic -> client = $obj -> client ;
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
$companystatic -> canvas = $obj -> canvas ;
2018-03-09 22:36:00 +01:00
print $companystatic -> getNomUrl ( 1 , 'supplier' , 16 );
2016-02-09 11:56:12 +01:00
print '</td>' ;
print '<td align="right" class="nowrap">' . price ( $obj -> total_ht ) . '</td></tr>' ;
$i ++ ;
$total += $obj -> total_ht ;
}
if ( $total > 0 )
{
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td colspan="2" align="right">' . price ( $total ) . " </td></tr> " ;
}
}
else
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoProposal " ) . '</td></tr>' ;
2016-02-09 11:56:12 +01:00
}
2018-02-15 12:57:04 +01:00
print " </table></div><br> " ;
2016-02-09 11:56:12 +01:00
$db -> free ( $resql );
}
else
{
dol_print_error ( $db );
}
}
2003-11-09 16:37:14 +01:00
/*
2009-10-17 01:25:15 +02:00
* Draft orders
2003-11-09 16:37:14 +01:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire )
2004-05-18 09:59:20 +02:00
{
2009-01-23 01:47:23 +01:00
$langs -> load ( " orders " );
2009-04-29 20:02:50 +02:00
2015-01-25 01:20:58 +01:00
$sql = " SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas " ;
2015-10-03 21:32:43 +02:00
$sql .= " , s.code_client " ;
2009-04-27 22:37:50 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-04-27 22:37:50 +02:00
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND c.fk_statut = 0 " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND c.entity IN ( " . getEntity ( 'commande' ) . " ) " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-04-27 22:37:50 +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 );
if ( $resql )
{
2015-10-13 14:09:14 +02:00
$total = 0 ;
$num = $db -> num_rows ( $resql );
2017-11-12 12:39:23 +01:00
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2011-12-29 18:07:41 +01:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="3">' . $langs -> trans ( " DraftOrders " ) . ( $num ? ' <span class="badge">' . $num . '</span>' : '' ) . '</th></tr>' ;
2011-12-29 18:07:41 +01:00
2017-03-25 01:03:02 +01:00
if ( $num > 0 )
2009-01-23 01:47:23 +01:00
{
$i = 0 ;
while ( $i < $num )
{
2017-11-12 12:39:23 +01:00
2009-01-23 01:47:23 +01:00
$obj = $db -> fetch_object ( $resql );
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td class="nowrap">' ;
2015-01-08 10:01:02 +01:00
$orderstatic -> id = $obj -> rowid ;
$orderstatic -> ref = $obj -> ref ;
2015-01-21 01:06:04 +01:00
$orderstatic -> ref_client = $obj -> ref_client ;
2015-01-25 01:20:58 +01:00
$orderstatic -> total_ht = $obj -> total_ht ;
$orderstatic -> total_tva = $obj -> total_tva ;
$orderstatic -> total_ttc = $obj -> total_ttc ;
2015-01-08 10:01:02 +01:00
print $orderstatic -> getNomUrl ( 1 );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2009-04-05 04:23:57 +02:00
$companystatic -> id = $obj -> socid ;
2011-02-21 09:58:45 +01:00
$companystatic -> name = $obj -> name ;
2009-04-05 04:23:57 +02:00
$companystatic -> client = $obj -> client ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2011-02-21 09:58:45 +01:00
$companystatic -> canvas = $obj -> canvas ;
2009-04-05 04:23:57 +02:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 16 );
print '</td>' ;
2018-05-02 14:36:55 +02:00
if ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT )) {
print '<td align="right" class="nowrap">' . price ( $obj -> total_ht ) . '</td></tr>' ;
}
else {
print '<td align="right" class="nowrap">' . price ( $obj -> total_ttc ) . '</td></tr>' ;
}
2009-01-23 01:47:23 +01:00
$i ++ ;
$total += $obj -> total_ttc ;
}
if ( $total > 0 )
{
2017-11-12 12:39:23 +01:00
2009-01-23 01:47:23 +01:00
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td colspan="2" align="right">' . price ( $total ) . " </td></tr> " ;
}
}
2015-10-20 18:19:32 +02:00
else
{
2017-11-12 12:39:23 +01:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoOrder " ) . '</td></tr>' ;
2015-10-20 18:19:32 +02:00
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2012-07-05 15:38:08 +02:00
2011-12-29 18:07:41 +01:00
$db -> free ( $resql );
2009-01-23 01:47:23 +01:00
}
2015-10-20 17:00:34 +02:00
else
{
dol_print_error ( $db );
}
}
/*
* Draft suppliers orders
*/
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> commande -> lire )
{
$langs -> load ( " orders " );
$sql = " SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas " ;
$sql .= " , s.code_client " ;
$sql .= " , s.code_fournisseur " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " commande_fournisseur as cf " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE cf.fk_soc = s.rowid " ;
$sql .= " AND cf.fk_statut = 0 " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND cf.entity IN ( " . getEntity ( 'supplier_order' ) . " ) " ;
2015-10-20 17:00:34 +02: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 cf.fk_soc = " . $socid ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$total = 0 ;
$num = $db -> num_rows ( $resql );
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2015-10-20 17:00:34 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="3">' . $langs -> trans ( " DraftSuppliersOrders " ) . ( $num ? ' <span class="badge">' . $num . '</span>' : '' ) . '</th></tr>' ;
2015-10-20 17:00:34 +02:00
2017-03-25 01:03:02 +01:00
if ( $num > 0 )
2015-10-20 17:00:34 +02:00
{
$i = 0 ;
while ( $i < $num )
{
2017-11-12 12:39:23 +01:00
2015-10-20 17:00:34 +02:00
$obj = $db -> fetch_object ( $resql );
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td class="nowrap">' ;
2015-10-20 17:00:34 +02:00
$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 ;
print $supplierorderstatic -> getNomUrl ( 1 );
print '</td>' ;
print '<td class="nowrap">' ;
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$companystatic -> client = $obj -> client ;
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
$companystatic -> canvas = $obj -> canvas ;
2016-06-29 16:16:56 +02:00
print $companystatic -> getNomUrl ( 1 , 'supplier' , 16 );
2015-10-20 17:00:34 +02:00
print '</td>' ;
2018-05-02 14:36:55 +02:00
if ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT )) {
print '<td align="right" class="nowrap">' . price ( $obj -> total_ht ) . '</td></tr>' ;
}
else {
print '<td align="right" class="nowrap">' . price ( $obj -> total_ttc ) . '</td></tr>' ;
}
2015-10-20 17:00:34 +02:00
$i ++ ;
$total += $obj -> total_ttc ;
}
if ( $total > 0 )
{
2017-11-12 12:39:23 +01:00
2015-10-20 17:00:34 +02:00
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td colspan="2" align="right">' . price ( $total ) . " </td></tr> " ;
}
}
2015-10-20 18:19:32 +02:00
else
{
2017-11-12 12:39:23 +01:00
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoSupplierOrder " ) . '</td></tr>' ;
2015-10-20 18:19:32 +02:00
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2015-10-20 17:00:34 +02:00
$db -> free ( $resql );
} else {
dol_print_error ( $db );
}
2002-04-29 20:01:16 +02:00
}
2004-05-08 20:44:22 +02:00
2013-03-16 14:53:15 +01:00
2013-06-05 16:24:32 +02:00
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">' ;
2004-10-30 14:15:59 +02:00
2009-04-06 19:49:18 +02:00
$NBMAX = 3 ;
$max = 3 ;
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
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> societe -> enabled ) && $user -> rights -> societe -> lire )
2005-06-21 21:49:42 +02:00
{
2009-05-10 06:20:37 +02:00
$langs -> load ( " boxes " );
2012-07-09 12:31:21 +02:00
$sql = " SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas " ;
2015-10-03 21:32:43 +02:00
$sql .= " , s.code_client " ;
2009-01-23 01:47:23 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2010-01-05 21:03:37 +01:00
$sql .= " WHERE s.client IN (1, 2, 3) " ;
2018-01-30 15:48:09 +01:00
$sql .= " AND s.entity IN ( " . getEntity ( $companystatic -> element ) . " ) " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-04-27 22:37:50 +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 );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2009-05-10 06:20:37 +02:00
$i = 0 ;
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2009-05-10 06:20:37 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="2">' ;
2015-10-13 14:21:00 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print $langs -> trans ( " BoxTitleLastCustomersOrProspects " , $max );
else if ( ! empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print $langs -> trans ( " BoxTitleLastModifiedProspects " , $max );
else print $langs -> trans ( " BoxTitleLastModifiedCustomers " , $max );
2017-03-07 22:45:22 +01:00
print '</th>' ;
2017-11-12 12:39:23 +01:00
print '<th align="right"><a class="commonlink" href="' . DOL_URL_ROOT . '/societe/list.php?type=p,c">' . $langs -> trans ( " FullList " ) . '</a></th>' ;
2010-01-05 21:03:37 +01:00
print '</tr>' ;
2009-01-23 01:47:23 +01:00
if ( $num )
{
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
2011-02-21 09:58:45 +01:00
$companystatic -> id = $objp -> rowid ;
$companystatic -> name = $objp -> name ;
$companystatic -> client = $objp -> client ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $objp -> code_client ;
$companystatic -> code_fournisseur = $objp -> code_fournisseur ;
2011-02-21 09:58:45 +01:00
$companystatic -> canvas = $objp -> canvas ;
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' . $companystatic -> getNomUrl ( 1 , 'customer' , 48 ) . '</td>' ;
2009-01-23 01:47:23 +01:00
print '<td align="right" nowrap>' ;
2013-02-12 19:16:48 +01:00
print $companystatic -> getLibCustProspStatut ();
2008-03-02 22:30:39 +01:00
print " </td> " ;
2009-04-06 19:49:18 +02:00
print '<td align="right" nowrap>' . dol_print_date ( $db -> jdate ( $objp -> tms ), 'day' ) . " </td> " ;
2009-01-23 01:47:23 +01:00
print '</tr>' ;
$i ++ ;
2017-11-12 12:39:23 +01:00
2009-01-23 01:47:23 +01:00
}
$db -> free ( $resql );
}
2009-05-10 06:20:37 +02:00
else
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2009-05-10 06:20:37 +02:00
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2009-05-10 06:20:37 +02:00
}
}
// Last suppliers
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> societe -> lire )
2009-05-10 06:20:37 +02:00
{
$langs -> load ( " boxes " );
2011-02-21 09:58:45 +01:00
$sql = " SELECT s.nom as name, s.rowid, s.datec as dc, s.canvas, s.tms as dm " ;
2015-10-03 21:32:43 +02:00
$sql .= " , s.code_fournisseur " ;
2009-05-10 06:20:37 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $user -> societe_id ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-05-10 06:20:37 +02:00
$sql .= " WHERE s.fournisseur = 1 " ;
2018-01-30 15:48:09 +01:00
$sql .= " AND s.entity IN ( " . getEntity ( $companystatic -> element ) . " ) " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $user -> societe_id ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-05-10 06:20:37 +02:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$sql .= " ORDER BY s.datec DESC " ;
$sql .= $db -> plimit ( $max , 0 );
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ( $result );
$i = 0 ;
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2009-05-10 06:20:37 +02:00
print '<table class="noborder" width="100%">' ;
2017-11-12 12:39:23 +01:00
print '<tr class="liste_titre">' ;
print '<th>' . $langs -> trans ( " BoxTitleLastModifiedSuppliers " , min ( $max , $num )) . '</th>' ;
print '<th align="right"><a class="commonlink" href="' . DOL_URL_ROOT . '/societe/list.php?type=f">' . $langs -> trans ( " FullList " ) . '</a></th>' ;
2009-05-10 06:20:37 +02:00
print '</tr>' ;
if ( $num )
{
while ( $i < $num && $i < $max )
{
$objp = $db -> fetch_object ( $result );
2011-02-21 09:58:45 +01:00
$companystatic -> id = $objp -> rowid ;
$companystatic -> name = $objp -> name ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $objp -> code_client ;
$companystatic -> code_fournisseur = $objp -> code_fournisseur ;
2011-02-21 09:58:45 +01:00
$companystatic -> canvas = $objp -> canvas ;
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' . $companystatic -> getNomUrl ( 1 , 'supplier' , 44 ) . '</td>' ;
2010-07-29 17:15:03 +02:00
print '<td align="right">' . 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 ++ ;
}
}
else
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2009-05-10 06:20:37 +02:00
}
2018-02-15 12:57:04 +01:00
print '</table>' ;
print '</div><br>' ;
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
*/
if ( $user -> rights -> agenda -> myactions -> read )
{
show_array_last_actions_done ( $max );
}
/*
* Actions to do
*/
if ( $user -> rights -> agenda -> myactions -> read )
{
show_array_actions_to_do ( 10 );
}
2004-05-08 20:44:22 +02:00
/*
2011-08-08 16:25:44 +02:00
* Last contracts
2004-05-08 20:44:22 +02:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire && 0 ) // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
2004-07-13 09:20:09 +02:00
{
2009-01-23 01:47:23 +01:00
$langs -> load ( " contracts " );
2011-02-21 09:58:45 +01:00
$sql = " SELECT s.nom as name, s.rowid, s.canvas, " ;
2015-10-03 21:32:43 +02:00
$sql .= " , s.code_client " ;
2011-02-21 09:58:45 +01:00
$sql .= " c.statut, c.rowid as contratid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo " ;
2009-04-27 22:37:50 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " , " . MAIN_DB_PREFIX . " contrat as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " product as p " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-04-27 22:37:50 +02:00
$sql .= " WHERE c.fk_soc = s.rowid " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND c.entity IN ( " . getEntity ( 'contract' ) . " ) " ;
2009-04-27 22:37:50 +02:00
$sql .= " AND c.fk_product = p.rowid " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-04-27 22:37:50 +02:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$sql .= " ORDER BY c.tms DESC " ;
$sql .= $db -> plimit ( 5 , 0 );
2009-01-23 01:47:23 +01:00
2010-08-09 17:42:57 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2009-01-23 01:47:23 +01:00
{
2010-08-09 17:42:57 +02:00
$num = $db -> num_rows ( $resql );
2009-01-23 01:47:23 +01:00
if ( $num > 0 )
{
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2009-04-06 19:49:18 +02:00
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th colspan="3">' . $langs -> trans ( " LastContracts " , 5 ) . '</th></tr>' ;
2009-04-06 19:49:18 +02:00
$i = 0 ;
$staticcontrat = new Contrat ( $db );
while ( $i < $num )
{
2010-08-09 17:42:57 +02:00
$obj = $db -> fetch_object ( $resql );
2017-05-06 10:54:28 +02:00
print '<tr class="oddeven"><td><a href=\"../contrat/card.php?id=".$obj->contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."</a></td>' ;
2011-02-21 09:58:45 +01:00
print '<td>' ;
$companystatic -> id = $objp -> rowid ;
$companystatic -> name = $objp -> name ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $objp -> code_client ;
$companystatic -> code_fournisseur = $objp -> code_fournisseur ;
2011-02-21 09:58:45 +01:00
$companystatic -> canvas = $objp -> canvas ;
print $companystatic -> getNomUrl ( 1 , 'customer' , 44 );
print '</td>' . " \n " ;
2009-04-06 19:49:18 +02:00
print " <td align= \" right \" > " . $staticcontrat -> LibStatut ( $obj -> statut , 3 ) . " </td></tr> \n " ;
2017-11-12 12:39:23 +01:00
2009-04-06 19:49:18 +02:00
$i ++ ;
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2009-01-23 01:47:23 +01: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
}
2004-05-08 20:44:22 +02:00
/*
2011-08-08 16:25:44 +02:00
* Opened proposals
2004-05-08 20:44:22 +02:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propal -> lire )
2005-05-14 17:12:15 +02:00
{
2009-01-23 01:47:23 +01:00
$langs -> load ( " propal " );
2018-02-25 17:43:19 +01:00
$sql = " SELECT s.nom as name, s.rowid, s.code_client " ;
$sql .= " , 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 " ;
2009-04-27 22:37:50 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " , " . MAIN_DB_PREFIX . " propal as p " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-04-27 22:37:50 +02:00
$sql .= " WHERE p.fk_soc = s.rowid " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND p.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
2009-04-27 22:37:50 +02:00
$sql .= " AND p.fk_statut = 1 " ;
2012-02-02 07:49:50 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-04-27 22:37:50 +02:00
if ( $socid ) $sql .= " AND s.rowid = " . $socid ;
$sql .= " ORDER BY p.rowid DESC " ;
2009-01-23 01:47:23 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
$total = 0 ;
$num = $db -> num_rows ( $result );
$i = 0 ;
if ( $num > 0 )
{
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2009-01-23 01:47:23 +01:00
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th colspan="5">' . $langs -> trans ( " ProposalsOpened " ) . ' <a href="' . DOL_URL_ROOT . '/comm/propal/list.php?viewstatut=1"><span class="badge">' . $num . '</span></th></tr>' ;
2014-01-20 02:21:30 +01:00
2014-02-12 00:01:22 +01:00
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2014-01-20 02:21:30 +01:00
while ( $i < $nbofloop )
2009-01-23 01:47:23 +01:00
{
$obj = $db -> fetch_object ( $result );
2017-11-12 12:39:23 +01:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2009-01-23 17:44:12 +01:00
// Ref
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" width="140">' ;
2009-01-23 01:47:23 +01:00
$propalstatic -> id = $obj -> propalid ;
$propalstatic -> ref = $obj -> ref ;
2015-01-21 01:06:04 +01:00
$propalstatic -> ref_client = $obj -> ref_client ;
2015-01-25 01:20:58 +01:00
$propalstatic -> total_ht = $obj -> total_ht ;
$propalstatic -> total_tva = $obj -> total_tva ;
$propalstatic -> total_ttc = $obj -> total_ttc ;
2009-01-23 01:47:23 +01:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2013-04-25 01:13:13 +02:00
print '<td class="nobordernopadding nowrap">' ;
2009-01-23 01:47:23 +01:00
print $propalstatic -> getNomUrl ( 1 );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="18" class="nobordernopadding nowrap">' ;
2012-11-09 16:04:30 +01:00
if ( $db -> jdate ( $obj -> dfv ) < ( $now - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
2009-01-23 01:47:23 +01:00
print '</td>' ;
print '<td width="16" align="center" class="nobordernopadding">' ;
2009-04-29 20:02:50 +02:00
$filename = dol_sanitizeFileName ( $obj -> ref );
2018-02-25 17:43:19 +01:00
$filedir = $conf -> propal -> multidir_output [ $obj -> entity ] . '/' . dol_sanitizeFileName ( $obj -> ref );
2010-06-30 17:01:18 +02:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> propalid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $propalstatic -> element , $filename , $filedir );
2009-01-23 01:47:23 +01:00
print '</td></tr></table>' ;
print " </td> " ;
2009-01-23 17:44:12 +01:00
2015-01-08 10:01:02 +01:00
print '<td class="nowrap">' ;
$companystatic -> id = $obj -> rowid ;
$companystatic -> name = $obj -> name ;
$companystatic -> client = $obj -> client ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2015-01-08 10:01:02 +01:00
$companystatic -> canvas = $obj -> canvas ;
2016-06-29 16:16:56 +02:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 44 );
2015-01-08 10:01:02 +01:00
print '</td>' ;
2011-03-16 12:51:17 +01:00
print '<td align="right">' ;
print dol_print_date ( $db -> jdate ( $obj -> dp ), 'day' ) . '</td>' . " \n " ;
2018-05-02 14:36:55 +02:00
if ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT )) {
print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
}
else {
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
}
2011-03-16 12:51:17 +01:00
print '<td align="center" width="14">' . $propalstatic -> LibStatut ( $obj -> fk_statut , 3 ) . '</td>' . " \n " ;
print '</tr>' . " \n " ;
2009-01-23 01:47:23 +01:00
$i ++ ;
$total += $obj -> total_ttc ;
}
2014-01-20 02:21:30 +01:00
if ( $num > $nbofloop )
{
print '<tr class="liste_total"><td colspan="5">' . $langs -> trans ( " XMoreLines " , ( $num - $nbofloop )) . " </td></tr> " ;
}
else if ( $total > 0 )
{
2009-10-29 18:30:29 +01:00
print '<tr class="liste_total"><td colspan="3">' . $langs -> trans ( " Total " ) . " </td><td align= \" right \" > " . price ( $total ) . " </td><td> </td></tr> " ;
2009-01-23 01:47:23 +01:00
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2009-01-23 01:47:23 +01: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
}
2015-04-18 17:49:48 +02:00
/*
* Opened Order
*/
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire )
{
2015-05-04 09:50:49 +02:00
$langs -> load ( " orders " );
2015-04-18 17:49:48 +02:00
2015-05-04 09:50:49 +02:00
$sql = " SELECT s.nom as name, s.rowid, 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 " ;
2015-10-03 21:32:43 +02:00
$sql .= " , s.code_client " ;
2015-04-18 17:49:48 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " , " . MAIN_DB_PREFIX . " commande as c " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
2017-05-30 18:50:54 +02:00
$sql .= " AND c.entity IN ( " . getEntity ( 'commande' ) . " ) " ;
2018-01-20 13:03:18 +01:00
$sql .= " AND (c.fk_statut = " . Commande :: STATUS_VALIDATED . " or c.fk_statut = " . Commande :: STATUS_SHIPMENTONPROCESS . " ) " ;
2015-04-18 17:49:48 +02: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 " ;
$result = $db -> query ( $sql );
if ( $result )
{
$total = 0 ;
$num = $db -> num_rows ( $result );
$i = 0 ;
if ( $num > 0 )
{
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2015-04-18 17:49:48 +02:00
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th class="liste_titre" colspan="5">' . $langs -> trans ( " OrdersOpened " ) . ' <a href="' . DOL_URL_ROOT . '/commande/list.php?viewstatut=1"><span class="badge">' . $num . '</span></th></tr>' ;
2015-04-18 17:49:48 +02:00
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
while ( $i < $nbofloop )
{
$obj = $db -> fetch_object ( $result );
2017-11-12 12:39:23 +01:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2015-04-18 17:49:48 +02:00
// Ref
print '<td class="nowrap" width="140">' ;
$orderstatic -> id = $obj -> commandeid ;
$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 ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
print '<td class="nobordernopadding nowrap">' ;
print $orderstatic -> getNomUrl ( 1 );
print '</td>' ;
print '<td width="18" class="nobordernopadding nowrap">' ;
//if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
print '</td>' ;
print '<td width="16" align="center" class="nobordernopadding">' ;
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> commande -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> propalid ;
print $formfile -> getDocumentsLink ( $orderstatic -> element , $filename , $filedir );
print '</td></tr></table>' ;
print " </td> " ;
print '<td class="nowrap">' ;
$companystatic -> id = $obj -> rowid ;
$companystatic -> name = $obj -> name ;
$companystatic -> client = $obj -> client ;
2015-10-03 21:32:43 +02:00
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
2015-04-18 17:49:48 +02:00
$companystatic -> canvas = $obj -> canvas ;
2016-06-29 16:16:56 +02:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 44 );
2015-04-18 17:49:48 +02:00
print '</td>' ;
print '<td align="right">' ;
print dol_print_date ( $db -> jdate ( $obj -> dp ), 'day' ) . '</td>' . " \n " ;
2018-05-02 14:36:55 +02:00
if ( ! empty ( $conf -> global -> MAIN_DASHBOARD_USE_TOTAL_HT )) {
print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
}
else {
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
}
2015-05-04 09:50:49 +02:00
print '<td align="center" width="14">' . $orderstatic -> LibStatut ( $obj -> fk_statut , $obj -> billed , 3 ) . '</td>' . " \n " ;
2015-04-18 17:49:48 +02:00
print '</tr>' . " \n " ;
$i ++ ;
$total += $obj -> total_ttc ;
}
if ( $num > $nbofloop )
{
print '<tr class="liste_total"><td colspan="5">' . $langs -> trans ( " XMoreLines " , ( $num - $nbofloop )) . " </td></tr> " ;
}
else if ( $total > 0 )
{
print '<tr class="liste_total"><td colspan="3">' . $langs -> trans ( " Total " ) . " </td><td align= \" right \" > " . price ( $total ) . " </td><td> </td></tr> " ;
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2015-04-18 17:49:48 +02:00
}
}
else
{
dol_print_error ( $db );
}
}
2002-04-29 20:01:16 +02:00
2013-03-30 19:40:52 +01:00
print '</div></div></div>' ;
2002-04-29 20:01:16 +02:00
2012-02-02 07:49:50 +01:00
llxFooter ();
2009-01-23 01:47:23 +01:00
2012-02-02 07:49:50 +01:00
$db -> close ();