2011-06-06 18:15:02 +02:00
< ? php
/* Copyright ( C ) 2003 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2017-11-23 20:00:54 +01:00
* Copyright ( C ) 2004 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2019-06-18 14:07:52 +02:00
* Copyright ( C ) 2019 Nicolas ZABOURI < info @ inovea - conseil . com >
2011-06-06 18:15:02 +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
2011-06-06 18:15:02 +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 />.
2011-06-06 18:15:02 +02:00
*/
/**
* \file htdocs / comm / propal / index . php
* \ingroup propal
* \brief Home page of proposal area
*/
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' ;
2019-11-13 19:35:02 +01:00
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
2011-06-06 18:15:02 +02:00
2019-06-18 14:07:52 +02:00
$hookmanager = new HookManager ( $db );
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager -> initHooks ( array ( 'proposalindex' ));
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'propal' , 'companies' ));
2011-06-06 18:15:02 +02:00
// Security check
2019-11-13 19:35:02 +01:00
$socid = GETPOST ( 'socid' , 'int' );
if ( isset ( $user -> socid ) && $user -> socid > 0 )
2011-06-06 18:15:02 +02:00
{
$action = '' ;
2019-10-31 20:46:31 +01:00
$socid = $user -> socid ;
2011-06-06 18:15:02 +02:00
}
2012-08-01 18:40:47 +02:00
$result = restrictedArea ( $user , 'propal' );
2011-06-06 18:15:02 +02:00
/*
* View
*/
2019-11-13 19:35:02 +01:00
$now = dol_now ();
$propalstatic = new Propal ( $db );
$companystatic = new Societe ( $db );
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2011-06-06 18:15:02 +02:00
$formfile = new FormFile ( $db );
2019-11-13 19:35:02 +01:00
$help_url = " EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos " ;
2011-06-06 18:15:02 +02:00
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $langs -> trans ( " ProspectionArea " ), $help_url );
2011-06-06 18:15:02 +02:00
2020-04-25 13:49:44 +02:00
print load_fiche_titre ( $langs -> trans ( " ProspectionArea " ), '' , 'propal' );
2011-06-06 18:15:02 +02:00
2013-03-16 14:53:15 +01:00
//print '<table width="100%" class="notopnoleftnoright">';
//print '<tr><td valign="top" width="30%" class="notopnoleft">';
2013-03-30 14:27:13 +01:00
print '<div class="fichecenter"><div class="fichethirdleft">' ;
2011-06-06 18:15:02 +02:00
2019-11-13 19:35:02 +01:00
if ( ! empty ( $conf -> global -> MAIN_SEARCH_FORM_ON_HOME_AREAS )) // This is useless due to the global search combo
2017-02-21 14:17:44 +01:00
{
print '<form method="post" action="' . DOL_URL_ROOT . '/comm/propal/list.php">' ;
2019-11-11 20:33:34 +01:00
print '<div class="div-table-responsive-no-min">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder nohover centpercent">' ;
2017-02-21 14:17:44 +01:00
print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " Search " ) . '</td></tr>' ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td>' ;
2017-02-21 14:17:44 +01:00
print $langs -> trans ( " Proposal " ) . ':</td><td><input type="text" class="flat" name="sall" size=18></td><td><input type="submit" value="' . $langs -> trans ( " Search " ) . '" class="button"></td></tr>' ;
2019-11-11 20:33:34 +01:00
print " </table></div></form><br> \n " ;
2017-02-21 14:17:44 +01:00
}
2011-06-06 18:15:02 +02:00
/*
* Statistics
*/
2020-03-14 02:17:08 +01:00
$sql = " SELECT count(p.rowid) as nb, p.fk_statut as status " ;
2019-11-13 19:35:02 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " , " . MAIN_DB_PREFIX . " propal as p " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE p.fk_soc = s.rowid " ;
$sql .= " AND p.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
if ( $user -> socid ) $sql .= ' AND p.fk_soc = ' . $user -> socid ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
$sql .= " AND p.fk_statut IN (0,1,2,3,4) " ;
$sql .= " GROUP BY p.fk_statut " ;
2011-06-06 18:15:02 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
2019-11-13 19:35:02 +01:00
$total = 0 ;
$totalinprocess = 0 ;
$dataseries = array ();
2020-03-14 02:17:08 +01:00
$colorseries = array ();
2019-11-13 19:35:02 +01:00
$vals = array ();
2020-03-14 02:17:08 +01:00
2011-06-06 18:15:02 +02:00
// -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
while ( $i < $num )
{
2020-03-14 02:17:08 +01:00
$obj = $db -> fetch_object ( $resql );
if ( $obj )
2011-06-06 18:15:02 +02:00
{
2020-03-14 02:17:08 +01:00
$vals [ $obj -> status ] = $obj -> nb ;
$totalinprocess += $obj -> nb ;
$total += $obj -> nb ;
2011-06-06 18:15:02 +02:00
}
$i ++ ;
}
$db -> free ( $resql );
2020-03-14 02:17:08 +01:00
include_once DOL_DOCUMENT_ROOT . '/theme/' . $conf -> theme . '/theme_vars.inc.php' ;
2019-11-11 20:33:34 +01:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder nohover centpercent">' ;
2011-06-06 18:15:02 +02:00
print '<tr class="liste_titre"><td colspan="2">' . $langs -> trans ( " Statistics " ) . ' - ' . $langs -> trans ( " Proposals " ) . '</td></tr>' . " \n " ;
2019-11-13 19:35:02 +01:00
$listofstatus = array ( 0 , 1 , 2 , 3 , 4 );
2011-06-06 18:15:02 +02:00
foreach ( $listofstatus as $status )
{
2019-11-13 19:35:02 +01:00
$dataseries [] = array ( $propalstatic -> LibStatut ( $status , 1 ), ( isset ( $vals [ $status ]) ? ( int ) $vals [ $status ] : 0 ));
2020-03-14 02:17:08 +01:00
if ( $status == Propal :: STATUS_DRAFT ) $colorseries [ $status ] = '-' . $badgeStatus0 ;
if ( $status == Propal :: STATUS_VALIDATED ) $colorseries [ $status ] = $badgeStatus1 ;
if ( $status == Propal :: STATUS_SIGNED ) $colorseries [ $status ] = $badgeStatus4 ;
if ( $status == Propal :: STATUS_NOTSIGNED ) $colorseries [ $status ] = $badgeStatus9 ;
if ( $status == Propal :: STATUS_BILLED ) $colorseries [ $status ] = $badgeStatus6 ;
if ( empty ( $conf -> use_javascript_ajax ))
2011-06-06 18:15:02 +02:00
{
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2019-01-27 11:55:16 +01:00
print '<td>' . $propalstatic -> LibStatut ( $status , 0 ) . '</td>' ;
2019-11-13 19:35:02 +01:00
print '<td class="right"><a href="list.php?statut=' . $status . '">' . ( isset ( $vals [ $status ]) ? $vals [ $status ] : 0 ) . '</a></td>' ;
2011-06-06 18:15:02 +02:00
print " </tr> \n " ;
}
}
if ( $conf -> use_javascript_ajax )
{
2017-11-23 20:00:54 +01:00
print '<tr><td align="center" colspan="2">' ;
include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php' ;
$dolgraph = new DolGraph ();
$dolgraph -> SetData ( $dataseries );
2020-03-14 02:17:08 +01:00
$dolgraph -> SetDataColor ( array_values ( $colorseries ));
2020-03-05 17:23:19 +01:00
$dolgraph -> setShowLegend ( 2 );
2017-11-23 20:00:54 +01:00
$dolgraph -> setShowPercent ( 1 );
$dolgraph -> SetType ( array ( 'pie' ));
2020-03-05 02:55:06 +01:00
$dolgraph -> setHeight ( '200' );
2017-11-23 20:00:54 +01:00
$dolgraph -> draw ( 'idgraphthirdparties' );
2019-11-13 19:35:02 +01:00
print $dolgraph -> show ( $total ? 0 : 1 );
2017-11-23 20:00:54 +01:00
2011-06-06 18:15:02 +02:00
print '</td></tr>' ;
}
//if ($totalinprocess != $total)
2019-01-22 14:04:33 +01:00
//print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')</td><td class="right">'.$totalinprocess.'</td></tr>';
print '<tr class="liste_total"><td>' . $langs -> trans ( " Total " ) . '</td><td class="right">' . $total . '</td></tr>' ;
2019-11-11 20:33:34 +01:00
print " </table></div><br> " ;
2020-05-21 15:05:19 +02:00
} else {
2011-06-06 18:15:02 +02:00
dol_print_error ( $db );
}
/*
* Draft proposals
*/
2019-11-13 19:35:02 +01:00
if ( ! empty ( $conf -> propal -> enabled ))
2011-06-06 18:15:02 +02:00
{
2012-04-18 12:42:41 +02:00
$sql = " SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client " ;
2019-11-13 19:35:02 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND c.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
$sql .= " AND c.fk_statut = 0 " ;
if ( $socid ) $sql .= " AND c.fk_soc = " . $socid ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
$resql = $db -> query ( $sql );
2011-06-06 18:15:02 +02:00
if ( $resql )
{
$num = $db -> num_rows ( $resql );
if ( $num )
{
2019-03-11 12:58:03 +01:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2019-03-11 12:58:03 +01:00
print '<tr class="liste_titre">' ;
$langs -> load ( " propal " );
2020-04-15 15:01:00 +02:00
print '<td colspan="2">' . $langs -> trans ( " DraftPropals " ) . ' <a href="' . DOL_URL_ROOT . '/comm/propal/list.php?search_status=0"><span class="badge">' . $num . '</span></a></td></tr>' ;
2019-03-11 12:58:03 +01:00
2011-06-06 18:15:02 +02:00
$i = 0 ;
2019-11-13 19:35:02 +01:00
$nbofloop = min ( $num , ( empty ( $conf -> global -> MAIN_MAXLIST_OVERLOAD ) ? 500 : $conf -> global -> MAIN_MAXLIST_OVERLOAD ));
2019-03-11 12:58:03 +01:00
while ( $i < $nbofloop )
2011-06-06 18:15:02 +02:00
{
$obj = $db -> fetch_object ( $resql );
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2012-04-18 12:42:41 +02:00
2019-11-13 19:35:02 +01:00
$propalstatic -> id = $obj -> rowid ;
$propalstatic -> ref = $obj -> ref ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' . $propalstatic -> getNomUrl ( 1 ) . '</td>' ;
2012-04-18 12:42:41 +02:00
2019-11-13 19:35:02 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> socname ;
$companystatic -> client = $obj -> client ;
$companystatic -> canvas = $obj -> canvas ;
2019-01-27 11:55:16 +01:00
print '<td>' . $companystatic -> getNomUrl ( 1 , 'customer' , 24 ) . '</td>' ;
2012-07-12 19:14:13 +02:00
2012-04-18 12:42:41 +02:00
print '</tr>' ;
2011-06-06 18:15:02 +02:00
$i ++ ;
}
2019-03-11 12:58:03 +01:00
if ( $num > $nbofloop )
{
2019-03-12 10:24:11 +01:00
print '<tr class="liste_total"><td colspan="2" class="right">' . $langs -> trans ( " XMoreLines " , ( $num - $nbofloop )) . " </td></tr> " ;
2020-05-21 15:05:19 +02:00
} elseif ( $total > 0 )
2019-03-11 12:58:03 +01:00
{
2019-03-12 10:24:11 +01:00
print '<tr class="liste_total"><td class="right">' . $langs -> trans ( " Total " ) . '</td><td class="right">' . price ( $total ) . " </td></tr> " ;
2019-03-11 12:58:03 +01:00
}
print " </table> " ;
print " </div><br> " ;
2011-06-06 18:15:02 +02:00
}
}
}
2013-03-16 14:53:15 +01:00
//print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
2013-03-30 14:27:13 +01:00
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">' ;
2011-06-06 18:15:02 +02:00
2019-11-13 19:35:02 +01:00
$max = 5 ;
2011-06-06 18:15:02 +02:00
/*
* Last modified proposals
*/
2018-02-25 17:43:19 +01:00
$sql = " SELECT c.rowid, c.entity, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client, " ;
2019-11-13 19:35:02 +01:00
$sql .= " date_cloture as datec " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND c.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
2011-06-06 18:15:02 +02:00
//$sql.= " AND c.fk_statut > 2";
if ( $socid ) $sql .= " AND c.fk_soc = " . $socid ;
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 ;
$sql .= " ORDER BY c.tms DESC " ;
$sql .= $db -> plimit ( $max , 0 );
2011-06-06 18:15:02 +02:00
2019-11-13 19:35:02 +01:00
$resql = $db -> query ( $sql );
2011-06-06 18:15:02 +02:00
if ( $resql )
{
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2011-06-06 18:15:02 +02:00
print '<tr class="liste_titre">' ;
2019-01-27 11:55:16 +01:00
print '<td colspan="4">' . $langs -> trans ( " LastModifiedProposals " , $max ) . '</td></tr>' ;
2011-06-06 18:15:02 +02:00
$num = $db -> num_rows ( $resql );
if ( $num )
{
$i = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2013-04-25 01:13:13 +02:00
print '<td width="20%" class="nowrap">' ;
2011-06-06 18:15:02 +02:00
2019-11-13 19:35:02 +01:00
$propalstatic -> id = $obj -> rowid ;
$propalstatic -> ref = $obj -> ref ;
2011-06-06 18:15:02 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2013-04-25 01:13:13 +02:00
print '<td width="96" class="nobordernopadding nowrap">' ;
2011-08-08 16:25:44 +02:00
print $propalstatic -> getNomUrl ( 1 );
2011-06-06 18:15:02 +02:00
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="16" class="nobordernopadding nowrap">' ;
2011-06-06 18:15:02 +02:00
print ' ' ;
print '</td>' ;
2019-01-22 14:04:33 +01:00
print '<td width="16" class="nobordernopadding right">' ;
2019-11-13 19:35:02 +01:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> propal -> multidir_output [ $obj -> entity ] . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> rowid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $propalstatic -> element , $filename , $filedir );
2011-06-06 18:15:02 +02:00
print '</td></tr></table>' ;
print '</td>' ;
2019-11-13 19:35:02 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> socname ;
$companystatic -> client = $obj -> client ;
$companystatic -> canvas = $obj -> canvas ;
2019-01-27 11:55:16 +01:00
print '<td>' . $companystatic -> getNomUrl ( 1 , 'customer' ) . '</td>' ;
2012-07-12 19:14:13 +02:00
2019-01-27 11:55:16 +01:00
print '<td>' . dol_print_date ( $db -> jdate ( $obj -> datec ), 'day' ) . '</td>' ;
2020-03-24 19:06:37 +01:00
print '<td class="right">' . $propalstatic -> LibStatut ( $obj -> fk_statut , 3 ) . '</td>' ;
2011-06-06 18:15:02 +02:00
print '</tr>' ;
$i ++ ;
}
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2020-05-21 15:05:19 +02:00
} else dol_print_error ( $db );
2011-06-06 18:15:02 +02:00
2011-08-08 16:25:44 +02:00
/*
2020-03-24 19:06:37 +01:00
* Open proposals
2011-08-08 16:25:44 +02:00
*/
2019-11-13 19:35:02 +01:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> lire )
2011-08-08 16:25:44 +02:00
{
$langs -> load ( " propal " );
2019-11-13 19:35:02 +01:00
$now = dol_now ();
2012-07-12 19:14:13 +02:00
2018-02-25 17:43:19 +01:00
$sql = " SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client " ;
2019-11-13 19:35:02 +01:00
$sql .= " , p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " , " . MAIN_DB_PREFIX . " propal as p " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE p.fk_soc = s.rowid " ;
$sql .= " AND p.entity IN ( " . getEntity ( 'propal' ) . " ) " ;
$sql .= " AND p.fk_statut = 1 " ;
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 " ;
$result = $db -> query ( $sql );
2011-08-08 16:25:44 +02:00
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">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2020-04-15 15:01:00 +02:00
print '<tr class="liste_titre"><td colspan="5">' . $langs -> trans ( " ProposalsOpened " ) . ' <a href="' . DOL_URL_ROOT . '/comm/propal/list.php?search_status=1"><span class="badge">' . $num . '</span></a></td></tr>' ;
2014-01-20 02:21:30 +01:00
2019-11-13 19:35:02 +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 )
2011-08-08 16:25:44 +02:00
{
$obj = $db -> fetch_object ( $result );
2017-11-23 20:00:54 +01:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2011-08-08 16:25:44 +02:00
// Ref
2013-04-25 01:13:13 +02:00
print '<td class="nowrap" width="140">' ;
2011-08-08 16:25:44 +02:00
2019-11-13 19:35:02 +01:00
$propalstatic -> id = $obj -> propalid ;
$propalstatic -> ref = $obj -> ref ;
2011-08-08 16:25:44 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2013-04-25 01:13:13 +02:00
print '<td class="nobordernopadding nowrap">' ;
2011-08-08 16:25:44 +02:00
print $propalstatic -> getNomUrl ( 1 );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="18" class="nobordernopadding nowrap">' ;
2012-11-14 22:32:20 +01:00
if ( $db -> jdate ( $obj -> dfv ) < ( $now - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
2011-08-08 16:25:44 +02:00
print '</td>' ;
print '<td width="16" align="center" class="nobordernopadding">' ;
2019-11-13 19:35:02 +01:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> propal -> multidir_output [ $obj -> entity ] . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> propalid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $propalstatic -> element , $filename , $filedir );
2011-08-08 16:25:44 +02:00
print '</td></tr></table>' ;
print " </td> " ;
2012-07-12 19:14:13 +02:00
2019-11-13 19:35:02 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> socname ;
$companystatic -> client = $obj -> client ;
$companystatic -> canvas = $obj -> canvas ;
2019-01-27 11:55:16 +01:00
print '<td class="left">' . $companystatic -> getNomUrl ( 1 , 'customer' , 44 ) . '</td>' . " \n " ;
2011-08-08 16:25:44 +02:00
2020-03-24 19:06:37 +01:00
print '<td class="right">' . dol_print_date ( $db -> jdate ( $obj -> dp ), 'day' ) . '</td>' . " \n " ;
2019-01-22 14:04:33 +01:00
print '<td class="right">' . price ( $obj -> total_ttc ) . '</td>' ;
2020-03-24 19:06:37 +01:00
2019-01-27 11:55:16 +01:00
print '<td align="center" width="14">' . $propalstatic -> LibStatut ( $obj -> fk_statut , 3 ) . '</td>' . " \n " ;
2011-08-08 16:25:44 +02:00
print '</tr>' . " \n " ;
$i ++ ;
$total += $obj -> total_ttc ;
}
2014-01-20 02:21:30 +01:00
if ( $num > $nbofloop )
{
2019-03-12 10:24:11 +01:00
print '<tr class="liste_total"><td colspan="5" class="right">' . $langs -> trans ( " XMoreLines " , ( $num - $nbofloop )) . " </td></tr> " ;
2020-05-21 15:05:19 +02:00
} elseif ( $total > 0 )
2014-01-20 02:21:30 +01:00
{
2019-03-12 10:24:11 +01:00
print '<tr class="liste_total"><td colspan="3" class="right">' . $langs -> trans ( " Total " ) . " </td><td align= \" right \" > " . price ( $total ) . " </td><td> </td></tr> " ;
2011-08-08 16:25:44 +02:00
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2011-08-08 16:25:44 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2011-08-08 16:25:44 +02:00
dol_print_error ( $db );
}
}
2011-06-06 18:15:02 +02:00
/*
* Proposals to process
*/
/*
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> propal -> enabled ))
2011-06-06 18:15:02 +02:00
{
2014-10-04 17:20:17 +02:00
$sql = " SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid " ;
2011-06-06 18:15:02 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propal as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND c.entity = " . $conf -> entity ;
$sql .= " AND c.fk_statut = 1 " ;
if ( $socid ) $sql .= " AND c.fk_soc = " . $socid ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
$sql .= " ORDER BY c.rowid DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2011-06-06 18:15:02 +02:00
print '<tr class="liste_titre">' ;
2020-04-15 15:01:00 +02:00
print '<td colspan="3">' . $langs -> trans ( " ProposalsToProcess " ) . ' <a href="' . DOL_URL_ROOT . '/commande/list.php?search_status=1"><span class="badge">' . $num . '</span></a></td></tr>' ;
2011-06-06 18:15:02 +02:00
if ( $num )
{
$i = 0 ;
while ( $i < $num )
{
2017-11-23 20:00:54 +01:00
2011-06-06 18:15:02 +02:00
$obj = $db -> fetch_object ( $resql );
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2011-06-06 18:15:02 +02:00
2011-08-08 16:25:44 +02:00
$propalstatic -> id = $obj -> rowid ;
$propalstatic -> ref = $obj -> ref ;
2011-06-06 18:15:02 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2013-04-25 01:13:13 +02:00
print '<td width="96" class="nobordernopadding nowrap">' ;
2011-08-08 16:25:44 +02:00
print $propalstatic -> getNomUrl ( 1 );
2011-06-06 18:15:02 +02:00
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="16" class="nobordernopadding nowrap">' ;
2011-06-06 18:15:02 +02:00
print ' ' ;
print '</td>' ;
2019-02-04 10:32:33 +01:00
print '<td width="16" class="nobordernopadding right">' ;
2011-06-06 18:15:02 +02:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> commande -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> rowid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $propalstatic -> element , $filename , $filedir );
2011-06-06 18:15:02 +02:00
print '</td></tr></table>' ;
print '</td>' ;
2014-10-04 17:20:17 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $obj -> socid . '">' . img_object ( $langs -> trans ( " ShowCompany " ), " company " ) . ' ' . dol_trunc ( $obj -> name , 24 ) . '</a></td>' ;
2011-06-06 18:15:02 +02:00
2019-01-22 14:04:33 +01:00
print '<td class="right">' . $propalstatic -> LibStatut ( $obj -> fk_statut , $obj -> facture , 5 ) . '</td>' ;
2011-06-06 18:15:02 +02:00
print '</tr>' ;
$i ++ ;
}
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2011-06-06 18:15:02 +02:00
}
else dol_print_error ( $db );
}
*/
/*
* Proposal that are in a shipping process
*/
2012-09-15 10:01:35 +02:00
/* if ( ! empty ( $conf -> propal -> enabled ))
2011-06-06 18:15:02 +02:00
{
2014-10-04 17:20:17 +02:00
$sql = " SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid " ;
2011-06-06 18:15:02 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND c.entity = " . $conf -> entity ;
$sql .= " AND c.fk_statut = 2 " ;
if ( $socid ) $sql .= " AND c.fk_soc = " . $socid ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
$sql .= " ORDER BY c.rowid DESC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
2018-02-15 12:57:04 +01:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2011-06-06 18:15:02 +02:00
print '<tr class="liste_titre">' ;
2020-04-15 15:01:00 +02:00
print '<td colspan="3">' . $langs -> trans ( " OnProcessOrders " ) . ' <a href="' . DOL_URL_ROOT . '/commande/list.php?search_status=2"><span class="badge">' . $num . '</span></a></td></tr>' ;
2011-06-06 18:15:02 +02:00
if ( $num )
{
$i = 0 ;
while ( $i < $num )
{
2017-11-23 20:00:54 +01:00
2011-06-06 18:15:02 +02:00
$obj = $db -> fetch_object ( $resql );
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2013-04-25 01:13:13 +02:00
print '<td width="20%" class="nowrap">' ;
2011-06-06 18:15:02 +02:00
2011-08-08 16:25:44 +02:00
$propalstatic -> id = $obj -> rowid ;
$propalstatic -> ref = $obj -> ref ;
2011-06-06 18:15:02 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2013-04-25 01:13:13 +02:00
print '<td width="96" class="nobordernopadding nowrap">' ;
2011-08-08 16:25:44 +02:00
print $propalstatic -> getNomUrl ( 1 );
2011-06-06 18:15:02 +02:00
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="16" class="nobordernopadding nowrap">' ;
2011-06-06 18:15:02 +02:00
print ' ' ;
print '</td>' ;
2019-02-04 10:32:33 +01:00
print '<td width="16" class="nobordernopadding right">' ;
2011-06-06 18:15:02 +02:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> commande -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> rowid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $propalstatic -> element , $filename , $filedir );
2011-06-06 18:15:02 +02:00
print '</td></tr></table>' ;
print '</td>' ;
2014-10-04 17:20:17 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $obj -> socid . '">' . img_object ( $langs -> trans ( " ShowCompany " ), " company " ) . ' ' . $obj -> name . '</a></td>' ;
2011-06-06 18:15:02 +02:00
2019-02-04 10:32:33 +01:00
print '<td class="right">' . $propalstatic -> LibStatut ( $obj -> fk_statut , $obj -> facture , 5 ) . '</td>' ;
2011-06-06 18:15:02 +02:00
print '</tr>' ;
$i ++ ;
}
}
2018-02-15 12:57:04 +01:00
print " </table> " ;
print " </div><br> " ;
2011-06-06 18:15:02 +02:00
}
else dol_print_error ( $db );
}
*/
2013-03-16 14:53:15 +01:00
//print '</td></tr></table>';
2013-03-30 19:40:52 +01:00
print '</div></div></div>' ;
2011-06-06 18:15:02 +02:00
2019-06-18 14:07:52 +02:00
$parameters = array ( 'user' => $user );
$reshook = $hookmanager -> executeHooks ( 'dashboardPropals' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2018-07-29 17:17:29 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2013-03-16 14:53:15 +01:00
$db -> close ();