2002-04-30 12:44:42 +02:00
< ? PHP
2004-01-30 11:32:21 +01:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-02-10 23:16:57 +01:00
* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
2002-04-30 12:44:42 +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
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
2003-03-23 16:37:36 +01:00
* $Id $
* $Source $
*
2002-04-30 12:44:42 +02:00
*/
2003-09-05 08:58:58 +02:00
/**
* Gestion d ' une proposition commerciale
* @ package propale
*/
2003-09-11 22:18:51 +02:00
require ( " ./pre.inc.php " );
2002-04-30 12:44:42 +02:00
2003-08-06 14:40:53 +02:00
$user -> getrights ( 'propale' );
if ( ! $user -> rights -> propale -> lire )
accessforbidden ();
2002-04-30 12:44:42 +02:00
/*
* Modules optionnels
*/
2003-09-11 22:18:51 +02:00
require ( " ../project.class.php " );
require ( " ./propal_model_pdf.class.php " );
require ( " ../propal.class.php " );
require ( " ../actioncomm.class.php " );
require ( " ../lib/CMailFile.class.php " );
2003-09-01 14:40:50 +02:00
2003-03-23 16:37:36 +01:00
/*
* S<EFBFBD> curit<EFBFBD> acc<EFBFBD> s client
*/
if ( $user -> societe_id > 0 )
{
$action = '' ;
$socidp = $user -> societe_id ;
}
2002-12-12 18:04:27 +01:00
/******************************************************************************/
/* Actions */
/******************************************************************************/
2002-04-30 12:44:42 +02:00
2003-09-12 14:58:58 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'confirm_delete' && $HTTP_POST_VARS [ " confirm " ] == yes )
{
if ( $user -> rights -> propale -> supprimer )
{
$propal = new Propal ( $db , 0 , $propalid );
$propal -> delete ();
$propalid = 0 ;
$brouillon = 1 ;
}
Header ( " Location: propal.php " );
}
2003-11-19 15:52:09 +01:00
if ( $HTTP_POST_VARS [ " action " ] == 'add' )
2002-12-12 18:04:27 +01:00
{
2003-11-27 12:39:08 +01:00
$propal = new Propal ( $db , $_GET [ " socidp " ]);
2002-12-12 18:04:27 +01:00
2003-11-19 15:52:09 +01:00
$propal -> datep = mktime ( 12 , 1 , 1 ,
$HTTP_POST_VARS [ " remonth " ],
$HTTP_POST_VARS [ " reday " ],
$HTTP_POST_VARS [ " reyear " ]);
$propal -> duree_validite = $HTTP_POST_VARS [ " duree_validite " ];
2003-07-07 18:28:55 +02:00
$propal -> contactid = $HTTP_POST_VARS [ " contactidp " ];
$propal -> projetidp = $HTTP_POST_VARS [ " projetidp " ];
$propal -> modelpdf = $HTTP_POST_VARS [ " modelpdf " ];
2002-12-12 18:04:27 +01:00
$propal -> author = $user -> id ;
2003-07-07 18:28:55 +02:00
$propal -> note = $HTTP_POST_VARS [ " note " ];
2002-12-12 18:04:27 +01:00
2003-11-27 12:39:08 +01:00
$propal -> ref = $HTTP_POST_VARS [ " ref " ];
2002-12-12 18:04:27 +01:00
2003-09-23 14:03:08 +02:00
for ( $i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i ++ )
{
$xid = " idprod " . $i ;
$xqty = " qty " . $i ;
2003-09-23 19:50:20 +02:00
$xremise = " remise " . $i ;
2003-09-23 14:03:08 +02:00
2003-11-27 12:39:08 +01:00
$propal -> add_product ( $HTTP_POST_VARS [ $xid ], $HTTP_POST_VARS [ $xqty ], $HTTP_POST_VARS [ $xremise ]);
2003-09-23 14:03:08 +02:00
}
2002-12-12 18:04:27 +01:00
$id = $propal -> create ();
/*
* Generation
*/
if ( $id )
{
2003-07-07 18:47:37 +02:00
propale_pdf_create ( $db , $id , $HTTP_POST_VARS [ " modelpdf " ]);
2004-03-05 16:48:09 +01:00
$_GET [ " propalid " ] = $id ;
2002-12-12 18:04:27 +01:00
}
}
2003-06-19 15:12:27 +02:00
if ( $action == 'pdf' )
{
2003-07-07 18:28:55 +02:00
$propal = new Propal ( $db );
$propal -> fetch ( $propalid );
propale_pdf_create ( $db , $propalid , $propal -> modelpdf );
2003-06-19 15:12:27 +02:00
}
2002-12-12 18:04:27 +01:00
2003-11-07 11:49:04 +01:00
if ( $HTTP_POST_VARS [ " action " ] == 'setstatut' && $user -> rights -> propale -> cloturer )
2002-12-12 18:04:27 +01:00
{
2002-05-01 02:11:24 +02:00
/*
* Cloture de la propale
*/
$propal = new Propal ( $db );
2003-11-27 12:39:08 +01:00
$propal -> fetch ( $_GET [ " propalid " ]);
$propal -> cloture ( $user , $HTTP_POST_VARS [ " statut " ], $HTTP_POST_VARS [ " note " ]);
2002-12-12 18:04:27 +01:00
}
2003-06-20 11:50:11 +02:00
2003-11-19 15:52:09 +01:00
if ( $_GET [ " action " ] == 'commande' )
{
/*
* Cloture de la propale
*/
$propal = new Propal ( $db );
$propal -> fetch ( $propalid );
$propal -> create_commande ( $user );
}
2003-08-11 21:12:13 +02:00
if ( $action == 'modif' && $user -> rights -> propale -> creer )
2003-06-20 16:23:17 +02:00
{
/*
* Repasse la propale en mode brouillon
*/
$propal = new Propal ( $db );
2003-09-17 17:54:42 +02:00
$propal -> fetch ( $propalid );
2003-06-20 16:23:17 +02:00
$propal -> reopen ( $user -> id );
}
2003-10-24 10:09:48 +02:00
if ( $HTTP_POST_VARS [ " addligne " ] == 'Ajouter' && $user -> rights -> propale -> creer )
2003-06-20 11:50:11 +02:00
{
/*
* Ajout d ' une ligne produit dans la propale
*/
if ( $HTTP_POST_VARS [ " idprod " ])
{
$propal = new Propal ( $db );
2003-09-17 17:54:42 +02:00
$propal -> fetch ( $propalid );
2003-09-23 19:50:20 +02:00
$propal -> insert_product ( $HTTP_POST_VARS [ " idprod " ], $HTTP_POST_VARS [ " qty " ], $HTTP_POST_VARS [ " remise " ]);
2003-11-27 12:39:08 +01:00
propale_pdf_create ( $db , $_GET [ " propalid " ], $propal -> modelpdf );
2003-06-20 11:50:11 +02:00
}
}
2003-10-24 10:09:48 +02:00
if ( $HTTP_POST_VARS [ " addproduct " ] == 'Ajouter' && $user -> rights -> propale -> creer )
2003-08-30 13:45:47 +02:00
{
/*
* Ajout d ' une ligne produit dans la propale
*/
2003-09-05 21:36:37 +02:00
if ( strlen ( $HTTP_POST_VARS [ " np_desc " ]) &&
strlen ( $HTTP_POST_VARS [ " np_price " ]))
{
$propal = new Propal ( $db );
2003-09-17 17:54:42 +02:00
$propal -> fetch ( $propalid );
2003-10-09 00:58:53 +02:00
2003-09-05 21:36:37 +02:00
$propal -> insert_product_generic ( $HTTP_POST_VARS [ " np_desc " ],
$HTTP_POST_VARS [ " np_price " ],
$HTTP_POST_VARS [ " np_qty " ],
2003-10-09 00:58:53 +02:00
$HTTP_POST_VARS [ " np_tva_tx " ],
$HTTP_POST_VARS [ " np_remise " ]);
2003-09-05 21:36:37 +02:00
}
}
if ( $HTTP_POST_VARS [ " action " ] == 'setremise' && $user -> rights -> propale -> creer )
{
2003-08-30 13:45:47 +02:00
$propal = new Propal ( $db );
2003-09-17 17:54:42 +02:00
$propal -> fetch ( $propalid );
2003-09-05 21:36:37 +02:00
$propal -> set_remise ( $user , $HTTP_POST_VARS [ " remise " ]);
2003-11-27 12:39:08 +01:00
propale_pdf_create ( $db , $_GET [ " propalid " ], $propal -> modelpdf );
2003-08-30 13:45:47 +02:00
}
2003-09-06 17:13:29 +02:00
if ( $HTTP_POST_VARS [ " action " ] == 'setpdfmodel' && $user -> rights -> propale -> creer )
{
$propal = new Propal ( $db , 0 , $propalid );
$propal -> set_pdf_model ( $user , $HTTP_POST_VARS [ " modelpdf " ]);
2003-09-14 10:38:36 +02:00
propale_pdf_create ( $db , $propalid , $HTTP_POST_VARS [ " modelpdf " ]);
2003-09-06 17:13:29 +02:00
}
2003-08-30 13:45:47 +02:00
2003-08-11 21:12:13 +02:00
if ( $action == 'del_ligne' && $user -> rights -> propale -> creer )
2003-06-20 11:50:11 +02:00
{
/*
* Supprime une ligne produit dans la propale
*/
$propal = new Propal ( $db );
2003-09-17 17:54:42 +02:00
$propal -> fetch ( $propalid );
2003-06-20 11:50:11 +02:00
$propal -> delete_product ( $ligne );
2003-11-27 12:39:08 +01:00
propale_pdf_create ( $db , $_GET [ " propalid " ], $propal -> modelpdf );
2003-06-20 11:50:11 +02:00
}
2003-11-27 12:39:08 +01:00
if ( $_GET [ " valid " ] == 1 && $user -> rights -> propale -> valider )
2003-09-05 21:36:37 +02:00
{
$propal = new Propal ( $db );
2003-11-27 12:39:08 +01:00
$propal -> fetch ( $_GET [ " propalid " ]);
$propal -> update_price ( $_GET [ " propalid " ]);
propale_pdf_create ( $db , $_GET [ " propalid " ], $propal -> modelpdf );
2003-09-05 21:36:37 +02:00
$propal -> valid ( $user );
}
2002-12-12 18:04:27 +01:00
2003-09-12 14:58:58 +02:00
llxHeader ();
2002-12-12 18:04:27 +01:00
/******************************************************************************/
/* Fin des Actions */
/******************************************************************************/
2002-05-04 01:01:45 +02:00
/*
*
* Mode fiche
*
*
*/
2003-11-27 12:39:08 +01:00
if ( $_GET [ " propalid " ])
2003-06-28 16:33:27 +02:00
{
2003-09-12 14:58:58 +02:00
$html = new Form ( $db );
2002-05-04 01:01:45 +02:00
$propal = new Propal ( $db );
2003-11-27 12:39:08 +01:00
$propal -> fetch ( $_GET [ " propalid " ]);
2002-04-30 12:44:42 +02:00
2004-03-05 16:48:09 +01:00
$societe = new Societe ( $db );
$societe -> fetch ( $propal -> soc_id );
$head [ 0 ][ 0 ] = DOL_URL_ROOT . '/comm/propal.php?propalid=' . $propal -> id ;
$head [ 0 ][ 1 ] = " Proposition commerciale : $propal->ref " ;
$h = 1 ;
$a = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/comm/propal/note.php?propalid=' . $propal -> id ;
$head [ $h ][ 1 ] = " Note " ;
dolibarr_fiche_head ( $head , $a );
2003-09-12 14:58:58 +02:00
/*
2003-10-21 18:28:02 +02:00
* Confirmation de la suppression de la propale
2003-09-12 14:58:58 +02:00
*
*/
if ( $action == 'delete' )
{
2003-11-27 12:39:08 +01:00
$html -> form_confirm ( " $PHP_SELF ?propalid= $propal->id " , " Supprimer la proposition " , " Etes-vous s<> r de vouloir supprimer cette proposition ? " , " confirm_delete " );
2003-09-12 14:58:58 +02:00
}
2002-04-30 12:44:42 +02:00
/*
*
*/
2002-05-01 02:11:24 +02:00
$sql = " SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref, " . $db -> pdate ( " p.datep " ) . " as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c, " . MAIN_DB_PREFIX . " socpeople as x " ;
2003-11-27 12:39:08 +01:00
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = $propal->id " ;
2002-04-30 12:44:42 +02:00
2003-06-28 16:33:27 +02:00
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
2003-03-23 16:37:36 +01:00
2002-04-30 12:44:42 +02:00
$result = $db -> query ( $sql );
2002-12-12 17:11:54 +01:00
if ( $result )
{
$obj = $db -> fetch_object ( 0 );
2002-04-30 12:44:42 +02:00
2002-12-12 17:11:54 +01:00
if ( $db -> num_rows ())
{
$color1 = " #e0e0e0 " ;
2003-10-14 13:29:16 +02:00
print " <table class= \" border \" cellspacing= \" 0 \" cellpadding= \" 2 \" width= \" 100% \" > " ;
2002-12-12 17:11:54 +01:00
2004-03-04 18:47:20 +01:00
print '<tr><td>Soci<63> t<EFBFBD> </td><td colspan="3">' ;
2004-03-05 16:48:09 +01:00
if ( $societe -> client == 1 )
2004-03-04 18:47:20 +01:00
{
2004-03-05 16:48:09 +01:00
$url = 'fiche.php?socid=' . $societe -> id ;
2004-03-04 18:47:20 +01:00
}
else
{
2004-03-05 16:48:09 +01:00
$url = DOL_URL_ROOT . '/comm/prospect/fiche.php?socid=' . $societe -> id ;
2004-03-04 18:47:20 +01:00
}
2004-03-05 16:48:09 +01:00
print '<a href="' . $url . '">' . $societe -> nom . '</a></td>' ;
2003-06-28 15:31:44 +02:00
print '<td>Statut</td><td align="center"><b>' . $obj -> lst . '</b></td></tr>' ;
2003-06-21 14:58:04 +02:00
2004-03-05 16:48:09 +01:00
print '<tr><td>Date</td><td colspan="3">' . strftime ( " %A %d %B %Y " , $propal -> date );
2003-11-19 15:52:09 +01:00
if ( $propal -> fin_validite )
{
print " ( " . strftime ( " %d %B %Y " , $propal -> fin_validite ) . " ) " ;
}
print '</td>' ;
2003-06-21 14:58:04 +02:00
2003-06-28 15:54:27 +02:00
print '<td>Auteur</td><td>' ;
2003-06-21 14:58:04 +02:00
$author = new User ( $db , $obj -> fk_user_author );
$author -> fetch ( '' );
print $author -> fullname . '</td></tr>' ;
2002-12-12 17:11:54 +01:00
2003-09-05 21:43:41 +02:00
print " <tr><td>Destinataire</td><td colspan= \" 3 \" > $obj->firstname $obj->name < $obj->email ></td> " ;
2003-06-21 14:58:04 +02:00
2003-11-07 11:49:04 +01:00
print '<td valign="top" colspan="2" width="50%" rowspan="4">Note :<br>' . nl2br ( $propal -> note ) . " </td></tr> " ;
2003-06-21 14:58:04 +02:00
2004-03-05 16:48:09 +01:00
if ( $propal -> projet_id )
2002-12-12 17:11:54 +01:00
{
$projet = new Project ( $db );
2004-03-05 16:48:09 +01:00
$projet -> fetch ( $propal -> projet_id );
2003-09-06 16:49:45 +02:00
print '<tr><td>Projet</td><td colspan="3">' ;
2003-09-07 19:41:33 +02:00
print '<a href="../projet/fiche.php?id=' . $projet -> id . '">' ;
2002-12-12 17:11:54 +01:00
print $projet -> title . '</a></td></tr>' ;
}
2003-06-21 14:58:04 +02:00
2002-12-12 17:11:54 +01:00
/*
*
*/
2003-09-23 19:50:20 +02:00
print '<tr><td>Remise</td><td align="right">' . $propal -> remise_percent . ' %</td>' ;
print '<td> </td><td align="right">' . price ( $propal -> remise ) . ' euros</td></tr>' ;
2002-12-12 17:11:54 +01:00
/*
*
*/
2003-09-05 21:43:41 +02:00
print '<tr><td>Montant HT</td><td align="right">' . price ( $obj -> price + $obj -> remise ) . ' euros</td>' ;
print '<td align="right">TVA</td><td align="right">' . price ( $propal -> total_tva ) . ' euros</td></tr>' ;
2002-12-12 17:11:54 +01:00
/*
*
*/
2003-09-05 21:43:41 +02:00
print '<tr><td>Total HT</td><td align="right"><b>' . price ( $obj -> price ) . '</b> euros</td>' ;
print '<td align="right">Total TTC</td><td align="right"><b>' . price ( $propal -> total_ttc ) . '</b> euros</td></tr>' ;
2002-12-12 17:11:54 +01:00
/*
*
*/
2003-06-21 14:58:04 +02:00
2002-12-12 17:11:54 +01:00
print " </table> " ;
2003-11-27 12:39:08 +01:00
if ( $_GET [ " action " ] == 'statut' )
2002-12-12 17:11:54 +01:00
{
2003-11-27 12:39:08 +01:00
print " <form action= \" $PHP_SELF ?propalid= $propal->id\ " method = \ " post \" > " ;
2003-11-07 11:49:04 +01:00
print '<br><table class="border" cellpadding="3" cellspacing="0">' ;
print '<tr><td>Cl<43> turer comme : <input type="hidden" name="action" value="setstatut">' ;
2002-12-12 17:11:54 +01:00
print " <select name= \" statut \" > " ;
print " <option value= \" 2 \" >Sign<67> e " ;
print " <option value= \" 3 \" >Non Sign<67> e " ;
print '</select>' ;
2003-09-09 15:10:49 +02:00
print '</td></tr><tr><td>Commentaires : <br><textarea cols="60" rows="6" wrap="soft" name="note">' ;
print $obj -> note ;
print '</textarea></td></tr><tr><td align="center"><input type="submit" value="Valider"></td>' ;
print " </tr></table></form> " ;
2002-12-12 17:11:54 +01:00
}
2003-09-05 21:36:37 +02:00
/*
*
*
*/
2002-12-12 17:11:54 +01:00
/*
* Produits
*/
2003-06-20 11:50:11 +02:00
print_titre ( " Produits " );
2003-11-27 12:39:08 +01:00
print '<form action="propal.php?propalid=' . $propal -> id . '" method="post">' ;
2003-10-24 10:09:48 +02:00
print '<table border="0" width="100%" cellspacing="0" cellpadding="3">' ;
2003-06-20 11:50:11 +02:00
print " <TR class= \" liste_titre \" > " ;
print " <td>R<> f</td><td>Produit</td> " ;
2003-10-09 00:58:53 +02:00
print '<td align="center">Tva</td><td align="center">Qt<51> .</td><td align="center">Remise</td><td align="right">P.U.</td>' ;
2003-09-09 17:59:11 +02:00
if ( $propal -> statut == 0 )
2003-06-20 11:50:11 +02:00
{
print " <td> </td> " ;
}
2004-03-05 16:48:09 +01:00
print " </tr> \n " ;
2003-06-20 11:50:11 +02:00
2003-09-23 19:50:20 +02:00
$sql = " SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.tva_tx, pt.remise_percent, pt.subprice " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propaldet as pt, " . MAIN_DB_PREFIX . " product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propal->id " ;
2003-09-23 19:55:31 +02:00
$sql .= " ORDER BY pt.rowid ASC " ;
2002-12-12 17:11:54 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
2003-06-20 11:50:11 +02:00
$i = 0 ;
2002-12-12 17:11:54 +01:00
$var = True ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <TR $bc[$var] > " ;
2003-09-23 19:50:20 +02:00
print " <td>[ $objp->ref ]</td> \n " ;
2003-10-14 17:30:39 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> prodid . '">' . $objp -> product . '</a></td>' ;
2003-09-04 23:29:25 +02:00
print '<td align="center">' . $objp -> tva_tx . ' %</td>' ;
2003-08-30 14:10:37 +02:00
print " <td align= \" center \" > " . $objp -> qty . " </td> \n " ;
2003-10-09 00:58:53 +02:00
print '<td align="center">' . $objp -> remise_percent . ' %</td>' ;
2003-09-23 19:50:20 +02:00
print '<td align="right">' . price ( $objp -> subprice ) . '</td>' ;
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 0 && $user -> rights -> propale -> creer )
2003-06-20 11:50:11 +02:00
{
2003-11-27 12:39:08 +01:00
print '<td align="center"><a href="propal.php?propalid=' . $propal -> id . '&ligne=' . $objp -> rowid . '&action=del_ligne">' ;
2003-11-09 18:24:14 +01:00
print img_delete ();
print '</a></td>' ;
2003-06-20 11:50:11 +02:00
}
2002-12-12 17:11:54 +01:00
print " </tr> " ;
2003-06-20 11:50:11 +02:00
2002-12-12 17:11:54 +01:00
$i ++ ;
}
}
2003-08-30 13:45:47 +02:00
2003-10-09 00:58:53 +02:00
$sql = " SELECT pt.rowid, pt.description, pt.price, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " propaldet as pt WHERE pt.fk_propal = $propal->id AND pt.fk_product = 0 " ;
2003-08-30 13:45:47 +02:00
2003-09-23 19:50:20 +02:00
if ( $db -> query ( $sql ))
2003-08-30 13:45:47 +02:00
{
$num = $db -> num_rows ();
$i = 0 ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
$var =! $var ;
print " <TR $bc[$var] ><td> </td> \n " ;
print '<td>' . $objp -> description . '</td>' ;
2003-09-04 23:29:25 +02:00
print '<td align="center">' . $objp -> tva_tx . ' %</td>' ;
print " <td align= \" center \" > " . $objp -> qty . " </td> \n " ;
2003-09-23 19:50:20 +02:00
print '<td align="center">' . $objp -> remise_percent . ' %</td>' ;
2003-10-09 00:58:53 +02:00
print " <TD align= \" right \" > " . price ( $objp -> subprice ) . " </td> " ;
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 0 && $user -> rights -> propale -> creer )
2003-08-30 13:45:47 +02:00
{
2003-11-27 12:39:08 +01:00
print '<td align="center"><a href="propal.php?propalid=' . $propal -> id . '&ligne=' . $objp -> rowid . '&action=del_ligne">' ;
2003-11-19 15:52:09 +01:00
print img_delete ();
print '</a></td>' ;
2003-08-30 13:45:47 +02:00
}
else
{
print '<td>-</td>' ;
}
print " </tr> " ;
$i ++ ;
}
}
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 0 && $user -> rights -> propale -> creer )
2003-06-20 11:50:11 +02:00
{
2004-01-30 11:32:21 +01:00
$sql = " SELECT p.rowid,p.label,p.ref,p.price FROM " . MAIN_DB_PREFIX . " product as p WHERE p.envente=1 ORDER BY p.nbvente DESC LIMIT 20 " ;
2004-01-08 12:43:33 +01:00
// RyX<79> o on a ORDER BY p.ref et pas de limit
2003-06-20 11:50:11 +02:00
if ( $db -> query ( $sql ) )
{
$opt = " <option value= \" 0 \" SELECTED></option> " ;
if ( $result )
{
$num = $db -> num_rows (); $i = 0 ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
2003-09-23 19:50:20 +02:00
$opt .= " <option value= \" $objp->rowid\ " > [ $objp -> ref ] " .substr( $objp->label ,0,40). " </ option > \n " ;
2003-06-20 11:50:11 +02:00
$i ++ ;
}
}
$db -> free ();
}
else
{
print $db -> error ();
}
2003-08-30 13:45:47 +02:00
/*
2003-10-09 00:58:53 +02:00
* Produits g<EFBFBD> n<EFBFBD> riques
2003-08-30 13:45:47 +02:00
*
*/
$var =! $var ;
2003-10-24 10:09:48 +02:00
2003-08-30 13:45:47 +02:00
print '<tr ' . $bc [ $var ] . '>' ;
print '<td> </td>' ;
print '<td><input type="text" size="28" name="np_desc"></td>' ;
2003-09-23 19:50:20 +02:00
print '<td align="center">' ;
2003-08-30 14:10:37 +02:00
print $html -> select_tva ( " np_tva_tx " ) . '</td>' ;
2003-09-05 08:58:58 +02:00
print '<td align="center"><input type="text" size="3" value="1" name="np_qty"></td>' ;
2003-10-09 00:58:53 +02:00
print '<td align="center"><input type="text" size="3" value="0" name="np_remise"> %</td>' ;
2003-09-23 19:50:20 +02:00
print '<td align="right"><input type="text" size="6" name="np_price"></td>' ;
2003-10-24 10:09:48 +02:00
print '<td align="center"><input type="submit" value="Ajouter" name="addproduct"></td>' ;
print '</tr>' ;
2003-08-30 13:45:47 +02:00
2003-09-23 19:50:20 +02:00
/*
2003-10-09 00:58:53 +02:00
* Produits
2003-09-23 19:50:20 +02:00
*
*/
2003-08-30 13:45:47 +02:00
$var =! $var ;
2003-09-23 19:50:20 +02:00
print " <tr $bc[$var] ><td> </td><td colspan= \" 2 \" ><select name= \" idprod \" > $opt </select></td> " ;
2003-08-30 13:45:47 +02:00
print '<td align="center"><input type="text" size="3" name="qty" value="1"></td>' ;
2003-10-09 00:58:53 +02:00
print '<td align="center"><input type="text" size="3" name="remise" value="0"> %</td>' ;
2003-09-23 19:50:20 +02:00
print '<td> </td>' ;
2003-10-24 10:09:48 +02:00
print '<td align="center"><input type="submit" value="Ajouter" name="addligne"></td>' ;
2003-06-20 11:50:11 +02:00
print " </tr> \n " ;
}
2002-12-12 17:11:54 +01:00
print " </table> " ;
2003-10-24 10:09:48 +02:00
print '</form>' ;
2003-06-20 11:50:11 +02:00
2003-09-23 19:50:20 +02:00
if ( $propal -> brouillon == 1 )
{
2003-11-27 12:39:08 +01:00
print '<form action="propal.php?propalid=' . $propal -> id . '" method="post">' ;
2003-09-23 19:50:20 +02:00
print '<input type="hidden" name="action" value="setremise">' ;
2003-10-19 01:43:21 +02:00
print '<table class="border" cellpadding="3" cellspacing="0" border="1"><tr><td>Remise</td><td align="right">' ;
2003-09-23 19:50:20 +02:00
print '<input type="text" name="remise" size="3" value="' . $propal -> remise_percent . '">%' ;
print '<input type="submit" value="Appliquer">' ;
print '</td></tr></table></form>' ;
}
2002-12-12 17:11:54 +01:00
/*
* Actions
*/
2004-03-05 16:48:09 +01:00
print '</div>' ;
if ( $propal -> statut < 2 )
2003-06-20 11:50:11 +02:00
{
2004-03-05 16:48:09 +01:00
print '<p><div class="tabsAction">' ;
2003-07-25 02:04:44 +02:00
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 0 )
2003-07-25 02:04:44 +02:00
{
2003-08-11 21:12:13 +02:00
if ( $user -> rights -> propale -> supprimer )
{
2004-03-05 16:48:09 +01:00
print " <a class= \" tabAction \" href= \" $PHP_SELF ?propalid= $propal->id &action=delete \" >Supprimer</a> " ;
2003-08-11 21:12:13 +02:00
}
2004-03-05 16:48:09 +01:00
2003-07-25 02:04:44 +02:00
}
else
{
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 1 && $user -> rights -> propale -> cloturer )
2003-07-25 02:04:44 +02:00
{
2004-03-05 16:48:09 +01:00
print " <a class= \" tabAction \" href= \" $PHP_SELF ?propalid= $propal->id &action=statut \" >Cloturer</a> " ;
2003-07-25 02:04:44 +02:00
}
}
2004-03-05 16:48:09 +01:00
2003-07-25 02:04:44 +02:00
/*
*
*/
2004-03-05 16:48:09 +01:00
if ( $propal -> statut < 2 && $user -> rights -> propale -> creer )
2003-06-20 11:50:11 +02:00
{
2004-03-05 16:48:09 +01:00
print '<a class="tabAction" href="' . $PHP_SELF . " ?propalid= $propal->id &action=pdf \" >G<> n<EFBFBD> rer</a> " ;
2003-06-20 11:50:11 +02:00
}
2004-03-05 16:48:09 +01:00
2003-06-19 15:12:27 +02:00
2003-07-25 02:04:44 +02:00
/*
*
*/
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 1 )
2003-06-20 11:50:11 +02:00
{
2003-07-25 02:04:44 +02:00
$file = PROPALE_OUTPUTDIR . " / $obj->ref / $obj->ref .pdf " ;
if ( file_exists ( $file ))
{
2003-08-11 21:12:13 +02:00
if ( $user -> rights -> propale -> envoyer )
{
2004-03-05 16:48:09 +01:00
print " <a class= \" tabAction \" href= \" $PHP_SELF ?propalid= $propal->id &action=presend \" >Envoyer la proposition</a> " ;
2003-08-11 21:12:13 +02:00
}
2004-03-05 16:48:09 +01:00
2003-07-25 02:04:44 +02:00
}
2003-06-20 11:50:11 +02:00
}
2003-07-25 02:04:44 +02:00
/*
*
*/
2004-03-05 16:48:09 +01:00
if ( $propal -> statut == 0 )
2003-07-25 02:04:44 +02:00
{
2003-08-11 21:12:13 +02:00
if ( $user -> rights -> propale -> valider )
{
2004-03-05 16:48:09 +01:00
print " <a class= \" tabAction \" href= \" $PHP_SELF ?propalid= $propal->id &valid=1 \" >Valider</a> " ;
2003-08-11 21:12:13 +02:00
}
2004-03-05 16:48:09 +01:00
2003-07-25 02:04:44 +02:00
}
2004-03-05 16:48:09 +01:00
elseif ( $propal -> statut == 1 )
2003-07-25 02:04:44 +02:00
{
2003-08-11 21:12:13 +02:00
if ( $user -> rights -> propale -> creer )
{
2004-03-05 16:48:09 +01:00
print " <a class= \" tabAction \" href= \" $PHP_SELF ?propalid= $propal->id &action=modif \" >Modifier</a> " ;
2003-08-11 21:12:13 +02:00
}
2003-07-25 02:04:44 +02:00
}
2004-03-05 16:48:09 +01:00
print " </div> " ;
2003-06-20 11:50:11 +02:00
}
2003-09-01 14:45:26 +02:00
2002-12-12 17:11:54 +01:00
/*
2003-09-01 14:45:26 +02:00
* Envoi de la propale par mail
2002-12-12 17:11:54 +01:00
*
*/
2003-06-20 11:50:11 +02:00
if ( $action == 'send' )
{
2004-03-05 16:48:09 +01:00
$file = PROPALE_OUTPUTDIR . " / $propal->ref / $propal->ref .pdf " ;
2003-06-20 11:50:11 +02:00
if ( file_exists ( $file ))
{
2002-12-12 17:11:54 +01:00
2004-03-05 16:48:09 +01:00
$subject = " Notre proposition commerciale $propal->ref " ;
2004-01-08 12:43:33 +01:00
$filepath [ 0 ] = $file ;
2004-03-05 16:48:09 +01:00
$filename [ 0 ] = " $propal->ref .pdf " ;
2004-01-08 12:43:33 +01:00
$mimetype [ 0 ] = " application/pdf " ;
$filepath [ 1 ] = $_FILES [ 'addedfile' ][ 'tmp_name' ];
$filename [ 1 ] = $_FILES [ 'addedfile' ][ 'name' ];
$mimetype [ 1 ] = $_FILES [ 'addedfile' ][ 'type' ];
2003-06-20 11:50:11 +02:00
$replyto = " $replytoname < $replytomail > " ;
2002-12-12 17:11:54 +01:00
2004-02-10 23:16:57 +01:00
$mailfile = new CMailFile ( $subject , $sendto , $replyto , $message , $filepath , $mimetype , $filename , $sendtocc );
2002-12-12 17:11:54 +01:00
2003-08-31 01:38:13 +02:00
if ( ! $mailfile -> sendfile () )
{
2003-06-20 11:50:11 +02:00
print " <b>!! erreur d'envoi " ;
}
}
/*
* Enregistre l ' action
*
*/
2003-09-01 14:40:50 +02:00
$actioncomm = new ActionComm ( $db );
$actioncomm -> priority = 2 ;
$actioncomm -> type = 3 ;
$actioncomm -> date = $db -> idate ( time ());
$actioncomm -> percent = 100 ;
$actioncomm -> contact = $propal -> contactid ;
$actioncomm -> user = $user ;
$actioncomm -> societe = $propal -> socidp ;
$actioncomm -> propalrowid = $propal -> id ;
$actioncomm -> note = " Envoy<EFBFBD> e <20> $sendto " ;
$actioncomm -> add ( $user );
2003-06-20 11:50:11 +02:00
}
/*
*
*/
2003-10-24 10:09:48 +02:00
if ( $propal -> brouillon == 1 )
{
2003-11-27 12:39:08 +01:00
print '<form action="propal.php?propalid=' . $propal -> id . '" method="post">' ;
2003-10-24 10:09:48 +02:00
print '<input type="hidden" name="action" value="setpdfmodel">' ;
}
2003-10-14 13:29:16 +02:00
print '<table width="100%" cellspacing="2"><tr><td width="50%" valign="top">' ;
2003-08-28 17:29:37 +02:00
print_titre ( '<a href="propal/document.php?id=' . $propal -> id . '">Documents</a>' );
2003-10-24 10:09:48 +02:00
2003-10-14 13:29:16 +02:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="3">' ;
2003-06-20 11:50:11 +02:00
2004-03-05 16:48:09 +01:00
$file = PROPALE_OUTPUTDIR . " / $propal->ref / $propal->ref .pdf " ;
2003-06-20 11:50:11 +02:00
if ( file_exists ( $file ))
{
2003-11-19 15:52:09 +01:00
print " <tr $bc[0] ><td>PDF</td> " ;
2003-08-28 17:29:37 +02:00
print '<td><a href="' . PROPALE_OUTPUT_URL . '/' . $propal -> ref . '/' . $propal -> ref . '.pdf">' . $propal -> ref . '.pdf</a></td>' ;
2003-06-20 11:50:11 +02:00
print '<td align="right">' . filesize ( $file ) . ' bytes</td>' ;
print '<td align="right">' . strftime ( " %d %b %Y %H:%M:%S " , filemtime ( $file )) . '</td></tr>' ;
}
2003-09-06 17:13:29 +02:00
if ( $propal -> brouillon == 1 )
{
2003-09-13 15:39:12 +02:00
print " <tr $bc[1] ><td>Mod<6F> le</td><td align= \" right \" > " ;
2003-09-06 17:13:29 +02:00
$html = new Form ( $db );
$modelpdf = new Propal_Model_pdf ( $db );
$html -> select_array ( " modelpdf " , $modelpdf -> liste_array (), $propal -> modelpdf );
print '</td><td colspan="2"><input type="submit" value="Changer">' ;
2003-10-24 10:09:48 +02:00
print '</td></tr>' ;
2003-09-06 17:13:29 +02:00
}
2003-06-20 11:50:11 +02:00
print " </table> \n " ;
2003-11-19 15:52:09 +01:00
/*
*
*/
$nb_commande = sizeof ( $propal -> commande_liste_array ());
if ( $nb_commande > 0 )
{
$coms = $propal -> commande_liste_array ();
print '<br><table class="border" width="100%" cellspacing="0" cellpadding="3">' ;
print " <tr><td>Commande Num.</td></tr> \n " ;
for ( $i = 0 ; $i < $nb_commande ; $i ++ )
{
print '<tr><td><a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $coms [ $i ] . '">' . $coms [ $i ] . " </a></td> \n " ;
print " </tr> \n " ;
}
print " </table> " ;
}
// print '<a href="'.$PHP_SELF."?propalid=$propalid&action=commande\">G<> n<EFBFBD> rer</a>";
2003-06-20 11:50:11 +02:00
/*
*
*/
print " </td><td valign= \" top \" width= \" 50% \" > " ;
/*
*
*/
$sql = " SELECT " . $db -> pdate ( " a.datea " ) . " as da, note, fk_user_author " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a WHERE a.fk_soc = $obj->idp AND a.propalrowid = $propal->id " ;
2003-06-20 11:50:11 +02:00
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
$i = 0 ; $total = 0 ;
2003-09-16 21:53:09 +02:00
if ( $num > 0 )
2003-06-20 11:50:11 +02:00
{
2003-09-16 21:53:09 +02:00
print_titre ( " Propale envoy<6F> e " );
2003-11-19 15:52:09 +01:00
print '<table class="border" width="100%" cellspacing="0" cellpadding="3">' ;
2003-09-16 21:53:09 +02:00
print " <tr><td>Date</td><td>Auteur</td></TR> \n " ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $i );
print " <TR><TD> " . strftime ( " %d %B %Y %H:%M:%S " , $objp -> da ) . " </TD> \n " ;
$authoract = new User ( $db );
$authoract -> id = $objp -> fk_user_author ;
$authoract -> fetch ( '' );
print " <TD> $authoract->code </TD></tr> \n " ;
print " <tr><td colspan= \" 2 \" > $objp->note </td></tr> " ;
$i ++ ;
}
print " </table> " ;
2003-06-20 11:50:11 +02:00
}
$db -> free ();
}
else
{
print $db -> error ();
}
/*
*
*/
print " </td></tr></table> " ;
2003-10-24 10:09:48 +02:00
if ( $propal -> brouillon == 1 )
{
print '</form>' ;
}
2003-06-20 11:50:11 +02:00
/*
*
*
*/
if ( $action == 'presend' )
{
2003-06-24 13:34:59 +02:00
$replytoname = $user -> fullname ;
$replytomail = $user -> email ;
2003-06-20 11:50:11 +02:00
$from_name = $user -> fullname ; //$conf->propal->fromtoname;
$from_mail = $user -> email ; //conf->propal->fromtomail;
2004-03-05 16:48:09 +01:00
$message = " Veuillez trouver ci-joint notre proposition commerciale $propal->ref\n\nCordialement\n\n " ;
2004-01-08 12:43:33 +01:00
print " <form method= \" post \" ENCTYPE= \" multipart/form-data \" action= \" $PHP_SELF ?propalid= $propal->id &action=send \" > \n " ;
2003-06-20 11:50:11 +02:00
print " <input type= \" hidden \" name= \" replytoname \" value= \" $replytoname\ " > \n " ;
print " <input type= \" hidden \" name= \" replytomail \" value= \" $replytomail\ " > \n " ;
2004-01-08 12:43:33 +01:00
print '<input type="hidden" name="max_file_size" value="2000000">' ;
2003-06-20 11:50:11 +02:00
print_titre ( " Envoyer la propale par mail " );
print " <table cellspacing=0 border=1 cellpadding=3> " ;
2004-01-08 12:43:33 +01:00
print " <tr><td>Destinataire</td> " ;
print " <td colspan= \" 6 \" align= \" right \" ><input size= \" 50 \" name= \" sendto \" value= \" " . ucfirst ( strtolower ( $obj -> firstname )) . " " . ucfirst ( strtolower ( $obj -> name )) . " < $obj->email > \" ></td></tr> " ;
print " <tr><td>Copie <20> </td> " ;
print " <td colspan= \" 6 \" align= \" right \" ><input size= \" 50 \" name= \" sendtocc \" ></td></tr> " ;
2003-06-20 11:50:11 +02:00
print " <tr><td>Expediteur</td><td colspan= \" 5 \" > $from_name </td><td> $from_mail </td></tr> " ;
print " <tr><td>Reply-to</td><td colspan= \" 5 \" > $replytoname </td> " ;
print " <td> $replytomail </td></tr> " ;
2004-01-08 12:43:33 +01:00
print " <tr><td valign= \" top \" >Joindre un fichier en plus de la propale<br>(conditions g<> n<EFBFBD> rales de ventes ...)</td><td colspan= \" 6 \" ><input type= \" file \" name= \" addedfile \" size= \" 40 \" maxlength= \" 80 \" ></td></tr> " ;
print " <tr><td valign= \" top \" >Message</td><td colspan= \" 6 \" ><textarea rows= \" 5 \" cols= \" 40 \" name= \" message \" > $message </textarea></td></tr> " ;
2003-06-20 11:50:11 +02:00
print " </table> " ;
print " <input type= \" submit \" value= \" Envoyer \" > " ;
print " </form> " ;
}
}
else
2003-06-19 15:12:27 +02:00
{
2003-06-20 11:50:11 +02:00
print " Num rows = " . $db -> num_rows ();
print " <p><b> $sql " ;
2002-04-30 12:44:42 +02:00
}
/*
2003-06-20 11:50:11 +02:00
* Voir le suivi des actions
2002-04-30 12:44:42 +02:00
*
*
*
*/
2003-06-20 11:50:11 +02:00
if ( $suivi )
{
$validor = new User ( $db , $obj -> fk_user_valid );
$validor -> fetch ( '' );
$cloturor = new User ( $db , $obj -> fk_user_cloture );
$cloturor -> fetch ( '' );
print 'Suivi des actions<br>' ;
print '<table cellspacing=0 border=1 cellpadding=3>' ;
print '<tr><td> </td><td>Nom</td><td>Date</td></tr>' ;
print '<tr><td>Cr<43> ation</td><td>' . $author -> fullname . '</td>' ;
print '<td>' . $obj -> datec . '</td></tr>' ;
print '<tr><td>Validation</td><td>' . $validor -> fullname . ' </td>' ;
print '<td>' . $obj -> date_valid . ' </td></tr>' ;
print '<tr><td>Cloture</td><td>' . $cloturor -> fullname . ' </td>' ;
print '<td>' . $obj -> date_cloture . ' </td></tr>' ;
print '</table>' ;
}
else
{
2003-10-23 12:50:04 +02:00
print '<p><a href="' . $PHP_SELF . '?propalid=' . $propal -> id . '&suivi=1">Voir le suivi des actions </a>' ;
2003-06-20 11:50:11 +02:00
}
2002-05-04 01:01:45 +02:00
}
2003-06-20 11:50:11 +02:00
else
{
print $db -> error ();
print " <p><b> $sql " ;
}
2002-04-30 12:44:42 +02:00
/*
*
*
*
*/
} else {
2003-09-03 15:49:34 +02:00
/****************************************************************************
* *
* *
* Mode Liste des propales *
* *
* *
****************************************************************************/
2002-07-29 12:26:12 +02:00
2003-05-25 18:37:00 +02:00
if ( $sortfield == " " )
{
$sortfield = " p.datep " ;
}
if ( $sortorder == " " )
{
$sortorder = " DESC " ;
}
2002-07-29 12:26:12 +02:00
2003-06-24 22:52:25 +02:00
$limit = $conf -> liste_limit ;
2003-11-27 12:39:08 +01:00
$offset = $limit * $_GET [ " page " ] ;
$pageprev = $_GET [ " page " ] - 1 ;
$pagenext = $_GET [ " page " ] + 1 ;
2002-07-29 12:26:12 +02:00
2004-03-04 15:57:49 +01:00
$sql = " SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref, " . $db -> pdate ( " p.datep " ) . " as dp, " . $db -> pdate ( " p.fin_validite " ) . " as dfv, c.label as statut, c.id as statutid " ;
2004-01-30 11:32:21 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " propal as p, " . MAIN_DB_PREFIX . " c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id " ;
2002-04-30 12:44:42 +02:00
2003-06-21 14:58:04 +02:00
if ( $socidp )
{
$sql .= " AND s.idp = $socidp " ;
}
2003-11-27 12:39:08 +01:00
if ( $_GET [ " viewstatut " ] <> '' )
2003-06-21 14:58:04 +02:00
{
2003-11-27 12:39:08 +01:00
$sql .= " AND c.id = " . $_GET [ " viewstatut " ];
2003-06-21 14:58:04 +02:00
}
if ( $month > 0 )
{
$sql .= " AND date_format(p.datep, '%Y-%m') = ' $year - $month ' " ;
}
if ( $year > 0 )
{
$sql .= " AND date_format(p.datep, '%Y') = $year " ;
}
2002-04-30 12:44:42 +02:00
2003-09-03 15:49:34 +02:00
if ( strlen ( $HTTP_POST_VARS [ " sf_ref " ]) > 0 )
{
$sql .= " AND p.ref like '% " . $HTTP_POST_VARS [ " sf_ref " ] . " %' " ;
}
2003-05-17 17:38:34 +02:00
$sql .= " ORDER BY $sortfield $sortorder " ;
2003-07-10 15:21:41 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2002-04-30 12:44:42 +02:00
2003-06-21 14:58:04 +02:00
if ( $db -> query ( $sql ) )
{
$num = $db -> num_rows ();
2003-11-27 12:39:08 +01:00
print_barre_liste ( " Propositions commerciales " , $_GET [ " page " ], $PHP_SELF , " &socidp= $socidp " , $sortfield , $sortorder , '' , $num );
2003-07-10 15:21:41 +02:00
2003-06-21 14:58:04 +02:00
$i = 0 ;
2004-02-13 14:12:05 +01:00
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">' ;
2003-06-21 14:58:04 +02:00
print '<TR class="liste_titre">' ;
2003-06-21 16:56:17 +02:00
2003-10-14 17:30:39 +02:00
print_liste_field_titre_new ( " R<EFBFBD> f " , $PHP_SELF , " p.ref " , " " , " &socidp= $socidp " , 'width="15%"' , $sortfield );
2003-06-21 16:56:17 +02:00
2003-10-14 17:30:39 +02:00
print_liste_field_titre_new ( " Soci<EFBFBD> t<EFBFBD> " , $PHP_SELF , " s.nom " , " " , " &socidp= $socidp " , 'width="30%"' , $sortfield );
2003-06-21 16:56:17 +02:00
2003-10-14 17:30:39 +02:00
print_liste_field_titre_new ( " Date " , $PHP_SELF , " p.datep " , " " , " &socidp= $socidp " , 'width="25%" align="right" colspan="2"' , $sortfield );
print_liste_field_titre_new ( " Prix " , $PHP_SELF , " p.price " , " " , " &socidp= $socidp " , ' width="20%" align="right"' , $sortfield );
2003-06-21 16:56:17 +02:00
2003-10-14 17:30:39 +02:00
print_liste_field_titre_new ( " Statut " , $PHP_SELF , " p.fk_statut " , " " , " &socidp= $socidp " , 'width="10%" align="center"' , $sortfield );
2003-06-21 16:56:17 +02:00
print " </tr> \n " ;
2003-06-21 14:58:04 +02:00
$var = True ;
2002-04-30 12:44:42 +02:00
2003-07-10 20:09:12 +02:00
while ( $i < min ( $num , $limit ))
2003-06-21 14:58:04 +02:00
{
$objp = $db -> fetch_object ( $i );
2003-11-19 15:52:09 +01:00
$now = time ();
2003-06-21 14:58:04 +02:00
$var =! $var ;
2004-02-09 10:29:51 +01:00
print " <tr $bc[$var] > " ;
print '<td><a href="propal.php?propalid=' . $objp -> propalid . '">' ;
print img_file ();
print " </a> <a href= \" $PHP_SELF ?propalid= $objp->propalid\ " > $objp -> ref </ a ></ TD > \n " ;
2004-03-04 15:57:49 +01:00
if ( $objp -> client == 1 )
{
$url = 'fiche.php?socid=' . $objp -> idp ;
}
else
{
$url = DOL_URL_ROOT . '/comm/prospect/fiche.php?socid=' . $objp -> idp ;
}
print '<td><a href="' . $url . '">' . $objp -> nom . '</a></td>' ;
2003-11-19 15:52:09 +01:00
if ( $now > $objp -> dfv && $objp -> dfv > 0 )
2003-06-21 14:58:04 +02:00
{
2003-11-19 15:52:09 +01:00
print " <td> " . strftime ( " %d %b %Y " , $objp -> dfv ) . " </td> " ;
2003-06-21 14:58:04 +02:00
}
else
{
print " <td> </td> " ;
}
print " <TD align= \" right \" > " ;
$y = strftime ( " %Y " , $objp -> dp );
$m = strftime ( " %m " , $objp -> dp );
print strftime ( " %d " , $objp -> dp ) . " \n " ;
2003-10-14 17:30:39 +02:00
print " <a href= \" propal.php?year= $y &month= $m\ " > " ;
2003-06-21 14:58:04 +02:00
print strftime ( " %B " , $objp -> dp ) . " </a> \n " ;
2003-09-11 22:18:51 +02:00
print " <a href= \" propal.php?year= $y\ " > " ;
2003-06-21 14:58:04 +02:00
print strftime ( " %Y " , $objp -> dp ) . " </a></TD> \n " ;
print " <TD align= \" right \" > " . price ( $objp -> price ) . " </TD> \n " ;
print " <TD align= \" center \" > $objp->statut </TD> \n " ;
print " </TR> \n " ;
$total = $total + $objp -> price ;
$subtotal = $subtotal + $objp -> price ;
$i ++ ;
}
2003-09-01 14:45:26 +02:00
print " </table> " ;
2003-06-21 14:58:04 +02:00
$db -> free ();
2002-04-30 12:44:42 +02:00
}
2003-05-17 17:38:34 +02:00
else
{
print $db -> error ();
}
2002-04-30 12:44:42 +02:00
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>