2004-10-19 22:19:58 +02:00
< ? php
2005-08-02 09:23:45 +02:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2006-04-06 20:36:52 +02:00
* Copyright ( C ) 2004 - 2006 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-06-27 23:47:44 +02:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
* Copyright ( C ) 2005 Marc Barilley / Ocebo < marc @ ocebo . com >
2006-02-12 11:59:11 +01:00
* Copyright ( C ) 2005 - 2006 Regis Houssin < regis . houssin @ cap - networks . com >
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
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
2005-04-30 16:49:40 +02:00
/**
2006-01-22 22:08:32 +01:00
\file htdocs / comm / propal . php
\ingroup propale
\brief Page liste des propales ( vision commercial )
2003-09-05 08:58:58 +02:00
*/
2005-07-15 01:52:56 +02:00
require ( " ./pre.inc.php " );
2006-06-04 00:01:38 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /includes/modules/propale/modules_propale.php " );
require_once ( DOL_DOCUMENT_ROOT . " /lib/propal.lib.php " );
2002-04-30 12:44:42 +02:00
2003-08-06 14:40:53 +02:00
$user -> getrights ( 'propale' );
2004-10-30 00:17:32 +02:00
2003-08-06 14:40:53 +02:00
if ( ! $user -> rights -> propale -> lire )
2005-06-27 23:47:44 +02:00
accessforbidden ();
2003-08-06 14:40:53 +02:00
2005-08-21 21:07:13 +02:00
$langs -> load ( 'companies' );
$langs -> load ( 'propal' );
$langs -> load ( 'compta' );
$langs -> load ( 'bills' );
2006-06-18 00:30:55 +02:00
$langs -> load ( 'orders' );
2006-06-08 12:35:21 +02:00
$langs -> load ( 'products' );
2005-08-21 21:07:13 +02:00
2005-08-12 03:34:46 +02:00
if ( $conf -> projet -> enabled ) require_once ( DOL_DOCUMENT_ROOT . '/project.class.php' );
2005-08-13 23:23:02 +02:00
if ( $conf -> commande -> enabled ) require_once ( DOL_DOCUMENT_ROOT . '/commande/commande.class.php' );
2005-09-25 00:28:19 +02:00
require_once ( DOL_DOCUMENT_ROOT . '/propal.class.php' );
require_once ( DOL_DOCUMENT_ROOT . '/actioncomm.class.php' );
2005-07-06 01:50:50 +02:00
require_once ( DOL_DOCUMENT_ROOT . '/lib/CMailFile.class.php' );
2003-09-01 14:40:50 +02:00
2005-08-25 00:38:00 +02:00
$sall = isset ( $_GET [ " sall " ]) ? $_GET [ " sall " ] : $_POST [ " sall " ];
2005-08-24 01:11:26 +02:00
if ( isset ( $_GET [ " msg " ])) { $msg = urldecode ( $_GET [ " msg " ]); }
$year = isset ( $_GET [ " year " ]) ? $_GET [ " year " ] : " " ;
$month = isset ( $_GET [ " month " ]) ? $_GET [ " month " ] : " " ;
2005-07-15 01:52:56 +02:00
// S<> curit<69> acc<63> s client
2005-08-24 01:11:26 +02:00
$socidp = '' ;
if ( $_GET [ " socidp " ]) { $socidp = $_GET [ " socidp " ]; }
2006-06-13 00:20:24 +02:00
if ( $user -> societe_id > 0 )
2003-03-23 16:37:36 +01:00
{
2006-06-19 22:35:22 +02:00
$action = '' ;
$socidp = $user -> societe_id ;
2003-03-23 16:37:36 +01:00
}
2005-02-26 19:33:10 +01:00
// Nombre de ligne pour choix de produit/service pr<70> d<EFBFBD> finis
$NBLINES = 4 ;
2005-04-29 01:56:47 +02:00
2005-06-27 23:47:44 +02:00
$form = new Form ( $db );
2005-04-29 01:56:47 +02:00
2005-08-25 00:38:00 +02:00
2006-06-20 23:53:00 +02:00
2002-12-12 18:04:27 +01:00
/******************************************************************************/
/* Actions */
/******************************************************************************/
2002-04-30 12:44:42 +02:00
2005-06-27 23:47:44 +02:00
if ( $_POST [ 'action' ] == 'confirm_delete' && $_POST [ 'confirm' ] == 'yes' )
2003-09-12 14:58:58 +02:00
{
2006-01-22 22:08:32 +01:00
if ( $user -> rights -> propale -> supprimer )
2005-08-02 09:23:45 +02:00
{
2006-01-22 22:08:32 +01:00
$propal = new Propal ( $db , 0 , $_GET [ 'propalid' ]);
2006-06-09 17:13:09 +02:00
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-01-22 22:08:32 +01:00
$propal -> delete ( $user );
$propalid = 0 ;
$brouillon = 1 ;
2005-08-02 09:23:45 +02:00
}
2006-04-08 13:39:41 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ]);
2006-01-22 22:08:32 +01:00
exit ;
2003-09-12 14:58:58 +02:00
}
2006-06-08 12:35:21 +02:00
if ( $_POST [ 'action' ] == 'confirm_deleteproductline' && $_POST [ 'confirm' ] == 'yes' && $conf -> global -> PRODUIT_CONFIRM_DELETE_LINE )
2006-06-08 11:46:25 +02:00
{
if ( $user -> rights -> propale -> creer )
{
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-06-18 17:48:28 +02:00
$result = $propal -> delete_product ( $_GET [ 'ligne' ]);
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-06-17 01:55:20 +02:00
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
2006-06-08 11:46:25 +02:00
}
2006-06-08 11:46:25 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $_GET [ 'propalid' ]);
2006-06-08 11:46:25 +02:00
exit ;
}
2005-09-01 21:28:15 +02:00
if ( $_POST [ 'action' ] == 'confirm_validate' && $_POST [ 'confirm' ] == 'yes' )
{
2006-01-22 22:08:32 +01:00
if ( $user -> rights -> propale -> valider )
2005-09-01 21:28:15 +02:00
{
2006-01-22 22:08:32 +01:00
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
$result = $propal -> update_price ( $_GET [ 'propalid' ]);
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-06-17 01:55:20 +02:00
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
2006-01-22 22:08:32 +01:00
$result = $propal -> valid ( $user );
2005-09-01 21:28:15 +02:00
}
2006-04-08 13:39:41 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $_GET [ 'propalid' ]);
2006-01-22 22:08:32 +01:00
exit ;
2005-11-04 21:45:02 +01:00
}
if ( $_POST [ 'action' ] == 'setecheance' )
{
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-06-13 00:48:59 +02:00
$result = $propal -> set_echeance ( $user , @ mktime ( 12 , 1 , 1 , $_POST [ 'echmonth' ], $_POST [ 'echday' ], $_POST [ 'echyear' ]));
2005-11-04 21:45:02 +01:00
if ( $result < 0 ) dolibarr_print_error ( $db , $propal -> error );
2005-09-01 21:28:15 +02:00
}
2006-03-01 16:10:17 +01:00
if ( $_POST [ 'action' ] == 'setdate_livraison' )
{
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-06-05 18:26:33 +02:00
$result = $propal -> set_date_livraison ( $user , mktime ( 0 , 0 , 0 , $_POST [ 'liv_month' ], $_POST [ 'liv_day' ], $_POST [ 'liv_year' ]));
2006-03-01 16:10:17 +01:00
if ( $result < 0 ) dolibarr_print_error ( $db , $propal -> error );
}
2006-04-24 17:40:13 +02:00
if ( $_POST [ 'action' ] == 'setdeliveryadress' && $user -> rights -> propale -> creer )
2006-04-24 15:48:15 +02:00
{
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-04-24 16:32:51 +02:00
$result = $propal -> set_adresse_livraison ( $user , $_POST [ 'adresse_livraison_id' ]);
if ( $result < 0 ) dolibarr_print_error ( $db , $propal -> error );
2006-04-24 15:48:15 +02:00
}
2003-09-12 14:58:58 +02:00
2006-06-13 16:31:37 +02:00
// Positionne ref client
if ( $_POST [ 'action' ] == 'set_ref_client' && $user -> rights -> propale -> creer )
{
$propal = new Propal ( $db );
2006-06-13 16:31:37 +02:00
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-06-13 16:31:37 +02:00
$propal -> set_ref_client ( $user , $_POST [ 'ref_client' ]);
}
2006-06-17 01:55:20 +02:00
/*
* Creation propale
*/
2006-06-13 00:20:24 +02:00
if ( $_POST [ 'action' ] == 'add' )
2002-12-12 18:04:27 +01:00
{
2006-06-18 16:18:41 +02:00
$propal = new Propal ( $db , $_POST [ 'socidp' ]);
$db -> begin ();
// Si on a selectionn<6E> une propal <20> copier, on r<> alise la copie
if ( $_POST [ 'createmode' ] == 'copy' && $_POST [ 'copie_propal' ])
{
2006-07-01 01:38:12 +02:00
if ( $propal -> fetch ( $_POST [ 'copie_propal' ]) > 0 )
{
$propal -> datep = mktime ( 12 , 1 , 1 , $_POST [ 'remonth' ], $_POST [ 'reday' ], $_POST [ 'reyear' ]);
$propal -> date_livraison = mktime ( 12 , 1 , 1 , $_POST [ 'liv_month' ] . " - " . $_POST [ 'liv_day' ] . " - " . $_POST [ 'liv_year' ]);
$propal -> adresse_livraison_id = $_POST [ 'adresse_livraison_id' ];
$propal -> duree_validite = $_POST [ 'duree_validite' ];
$propal -> cond_reglement_id = $_POST [ 'cond_reglement_id' ];
$propal -> mode_reglement_id = $_POST [ 'mode_reglement_id' ];
$propal -> remise_percent = $_POST [ 'remise_percent' ];
$propal -> remise_absolue = $_POST [ 'remise_absolue' ];
$propal -> socidp = $_POST [ 'socidp' ];
$propal -> contactid = $_POST [ 'contactidp' ];
$propal -> projetidp = $_POST [ 'projetidp' ];
2006-07-02 15:45:06 +02:00
$propal -> modelpdf = $_POST [ 'model' ];
2006-07-01 01:38:12 +02:00
$propal -> author = $user -> id ;
$propal -> note = $_POST [ 'note' ];
$propal -> ref = $_POST [ 'ref' ];
$propal -> statut = 0 ;
$id = $propal -> create_from ();
}
else
2006-06-18 16:18:41 +02:00
{
$msg = '<div class="error">' . $langs -> trans ( " ErrorFailedToCopyProposal " , $_POST [ 'copie_propal' ]) . '</div>' ;
}
}
else
{
$propal -> datep = mktime ( 12 , 1 , 1 , $_POST [ 'remonth' ], $_POST [ 'reday' ], $_POST [ 'reyear' ]);
2006-06-23 02:09:24 +02:00
$propal -> date_livraison = mktime ( 12 , 1 , 1 , $_POST [ 'liv_month' ] . " - " . $_POST [ 'liv_day' ] . " - " . $_POST [ 'liv_year' ]);
2006-06-18 16:18:41 +02:00
$propal -> adresse_livraison_id = $_POST [ 'adresse_livraison_id' ];
$propal -> duree_validite = $_POST [ 'duree_validite' ];
$propal -> cond_reglement_id = $_POST [ 'cond_reglement_id' ];
$propal -> mode_reglement_id = $_POST [ 'mode_reglement_id' ];
$propal -> contactid = $_POST [ 'contactidp' ];
$propal -> projetidp = $_POST [ 'projetidp' ];
2006-07-02 15:45:06 +02:00
$propal -> modelpdf = $_POST [ 'model' ];
2006-06-18 16:18:41 +02:00
$propal -> author = $user -> id ;
$propal -> note = $_POST [ 'note' ];
$propal -> ref_client = $_POST [ 'ref_client' ];
2006-06-23 02:09:24 +02:00
$propal -> ref = $_POST [ 'ref' ];
2006-06-18 16:18:41 +02:00
2006-06-19 22:35:22 +02:00
for ( $i = 1 ; $i <= $conf -> global -> PROPALE_NEW_FORM_NB_PRODUCT ; $i ++ )
2006-06-18 16:18:41 +02:00
{
2006-04-03 16:28:15 +02:00
if ( $_POST [ 'idprod' . $i ])
{
2006-06-18 16:18:41 +02:00
$xid = 'idprod' . $i ;
$xqty = 'qty' . $i ;
$xremise = 'remise' . $i ;
$propal -> add_product ( $_POST [ $xid ], $_POST [ $xqty ], $_POST [ $xremise ]);
2006-04-03 16:28:15 +02:00
}
2006-06-18 16:18:41 +02:00
}
$id = $propal -> create ();
}
if ( $id > 0 )
{
2006-06-19 22:35:22 +02:00
$error = 0 ;
2006-06-13 00:20:24 +02:00
2006-06-19 22:35:22 +02:00
// Insertion contact par defaut si d<> fini
if ( $_POST [ " contactidp " ])
{
$result = $propal -> add_contact ( $_POST [ " contactidp " ], 'CUSTOMER' , 'external' );
if ( $result > 0 )
{
$error = 0 ;
}
else
{
$msg = '<div class="error">' . $langs -> trans ( " ErrorFailedToAddContact " ) . '</div>' ;
$error = 1 ;
}
}
if ( ! $error )
2006-06-18 16:18:41 +02:00
{
$db -> commit ();
2006-06-13 00:20:24 +02:00
2006-06-18 16:18:41 +02:00
// Generation document PDF
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-07-02 15:45:06 +02:00
propale_pdf_create ( $db , $id , $_REQUEST [ 'model' ], $outputlangs );
2006-06-19 22:35:22 +02:00
dolibarr_syslog ( 'Redirect to ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $id );
2006-06-18 16:18:41 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $id );
exit ;
}
else
{
$db -> rollback ();
}
}
else
{
dolibarr_print_error ( $db , $propal -> error );
$db -> rollback ();
exit ;
}
2002-12-12 18:04:27 +01:00
}
2005-11-04 21:45:02 +01:00
/*
* Cloture de la propale
*/
2006-06-13 00:20:24 +02:00
if ( $_POST [ 'action' ] == 'setstatut' && $user -> rights -> propale -> cloturer )
2002-12-12 18:04:27 +01:00
{
2006-01-22 22:08:32 +01:00
if ( ! $_POST [ 'cancel' ])
{
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
$propal -> cloture ( $user , $_POST [ 'statut' ], $_POST [ 'note' ]);
}
2005-06-27 23:47:44 +02:00
}
2003-06-20 11:50:11 +02:00
2005-06-25 15:02:17 +02:00
/*
2005-06-27 23:47:44 +02:00
* Envoi de la propale par mail
*/
if ( $_POST [ 'action' ] == 'send' )
2005-06-25 15:02:17 +02:00
{
2005-08-25 00:38:00 +02:00
$langs -> load ( 'mails' );
$propal = new Propal ( $db );
if ( $propal -> fetch ( $_POST [ 'propalid' ]) )
2005-08-02 09:23:45 +02:00
{
2005-08-25 00:38:00 +02:00
$propalref = sanitize_string ( $propal -> ref );
$file = $conf -> propal -> dir_output . '/' . $propalref . '/' . $propalref . '.pdf' ;
if ( is_readable ( $file ))
{
$soc = new Societe ( $db , $propal -> socidp );
if ( $_POST [ 'sendto' ])
{
// Le destinataire a <20> t<EFBFBD> fourni via le champ libre
$sendto = $_POST [ 'sendto' ];
$sendtoid = 0 ;
}
elseif ( $_POST [ 'receiver' ])
{
// Le destinataire a <20> t<EFBFBD> fourni via la liste d<> roulante
$sendto = $soc -> contact_get_email ( $_POST [ 'receiver' ]);
$sendtoid = $_POST [ 'receiver' ];
}
2005-08-02 09:23:45 +02:00
2005-08-25 00:38:00 +02:00
if ( strlen ( $sendto ))
{
$from = $_POST [ 'fromname' ] . ' <' . $_POST [ 'frommail' ] . '>' ;
$replyto = $_POST [ 'replytoname' ] . ' <' . $_POST [ 'replytomail' ] . '>' ;
$message = $_POST [ 'message' ];
2006-05-04 15:01:27 +02:00
$sendtocc = $_POST [ 'sendtocc' ];
2006-06-26 17:15:51 +02:00
$deliveryreceipt = $_POST [ 'deliveryreceipt' ];
2006-06-13 00:20:24 +02:00
2005-08-25 00:38:00 +02:00
if ( $_POST [ 'action' ] == 'send' )
{
2006-05-04 15:58:00 +02:00
$subject = $_POST [ 'subject' ];
2006-06-13 00:20:24 +02:00
2006-05-04 15:58:00 +02:00
if ( $subject == '' )
{
$subject = $langs -> trans ( 'Propal' ) . ' ' . $propal -> ref ;
}
2006-06-13 00:20:24 +02:00
2006-05-04 15:58:00 +02:00
$actiontypeid = 3 ;
$actionmsg = 'Mail envoy<6F> par ' . $from . ' <20> ' . $sendto . '.<br>' ;
2006-06-13 00:20:24 +02:00
2006-05-04 15:58:00 +02:00
if ( $message )
{
$actionmsg .= 'Texte utilis<69> dans le corps du message:<br>' ;
$actionmsg .= $message ;
}
2006-06-13 00:20:24 +02:00
2006-05-04 15:58:00 +02:00
$actionmsg2 = 'Envoi Propal par mail' ;
2005-07-12 00:57:19 +02:00
}
2005-08-25 00:38:00 +02:00
$filepath [ 0 ] = $file ;
$filename [ 0 ] = $propal -> ref . '.pdf' ;
$mimetype [ 0 ] = 'application/pdf' ;
if ( $_FILES [ 'addedfile' ][ 'tmp_name' ])
{
$filepath [ 1 ] = $_FILES [ 'addedfile' ][ 'tmp_name' ];
$filename [ 1 ] = $_FILES [ 'addedfile' ][ 'name' ];
$mimetype [ 1 ] = $_FILES [ 'addedfile' ][ 'type' ];
}
2006-04-08 13:39:41 +02:00
// Envoi de la propal
2006-06-26 17:15:51 +02:00
$mailfile = new CMailFile ( $subject , $sendto , $from , $message , $filepath , $mimetype , $filename , $sendtocc , '' , $deliveryreceipt );
2005-08-25 00:38:00 +02:00
if ( $mailfile -> sendfile ())
{
$msg = '<div class="ok">' . $langs -> trans ( 'MailSuccessfulySent' , $from , $sendto ) . '.</div>' ;
// Insertion action
2005-09-07 23:50:09 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /contact.class.php " );
2005-08-25 00:38:00 +02:00
$actioncomm = new ActionComm ( $db );
$actioncomm -> type_id = $actiontypeid ;
$actioncomm -> label = $actionmsg2 ;
$actioncomm -> note = $actionmsg ;
$actioncomm -> date = time (); // L'action est faite maintenant
$actioncomm -> percent = 100 ;
$actioncomm -> contact = new Contact ( $db , $sendtoid );
$actioncomm -> societe = new Societe ( $db , $propal -> socidp );
$actioncomm -> user = $user ; // User qui a fait l'action
$actioncomm -> propalrowid = $propal -> id ;
$ret = $actioncomm -> add ( $user ); // User qui saisi l'action
if ( $ret < 0 )
{
dolibarr_print_error ( $db );
}
else
{
// Renvoie sur la fiche
2006-04-08 13:39:41 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&msg=' . urlencode ( $msg ));
2005-08-25 00:38:00 +02:00
exit ;
}
}
else
{
$msg = '<div class="error">' . $langs -> trans ( 'ErrorFailedToSendMail' , $from , $sendto ) . ' - ' . $actioncomm -> error . '</div>' ;
}
}
else
{
$msg = '<div class="error">' . $langs -> trans ( 'ErrorMailRecipientIsEmpty' ) . ' !</div>' ;
dolibarr_syslog ( 'Le mail du destinataire est vide' );
}
}
else
{
dolibarr_syslog ( 'Impossible de lire :' . $file );
}
2005-08-02 09:23:45 +02:00
}
2005-08-25 00:38:00 +02:00
else
2005-08-02 09:23:45 +02:00
{
2005-08-25 00:38:00 +02:00
dolibarr_syslog ( 'Impossible de lire les donn<6E> es de la propale. Le fichier propal n\'a peut-<2D> tre pas <20> t<EFBFBD> g<> n<EFBFBD> r<EFBFBD> .' );
2005-08-02 09:23:45 +02:00
}
2005-06-25 15:02:17 +02:00
}
2005-06-27 23:47:44 +02:00
if ( $_GET [ 'action' ] == 'commande' )
2003-11-19 15:52:09 +01:00
{
2005-08-02 09:23:45 +02:00
/*
* Cloture de la propale
*/
$propal = new Propal ( $db );
$propal -> fetch ( $propalid );
$propal -> create_commande ( $user );
2005-06-27 23:47:44 +02:00
}
2003-06-20 16:23:17 +02:00
2006-06-13 00:20:24 +02:00
if ( $_GET [ 'action' ] == 'modif' && $user -> rights -> propale -> creer )
2005-06-27 23:47:44 +02:00
{
2005-08-02 09:23:45 +02:00
/*
* Repasse la propale en mode brouillon
*/
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
$propal -> reopen ( $user -> id );
2003-06-20 16:23:17 +02:00
}
2006-02-12 18:01:39 +01:00
2006-06-04 00:01:38 +02:00
if ( $_POST [ 'action' ] == " setabsolutediscount " && $user -> rights -> propale -> creer )
2006-06-01 00:54:32 +02:00
{
2006-06-04 00:01:38 +02:00
if ( $_POST [ " remise_id " ])
2006-06-01 00:54:32 +02:00
{
2006-06-30 01:48:44 +02:00
$propal = new Propal ( $db );
$propal -> id = $_GET [ 'propalid' ];
$ret = $propal -> fetch ( $_GET [ 'propalid' ]);
if ( $ret > 0 )
{
$propal -> insert_discount ( $_POST [ " remise_id " ]);
}
else
{
dolibarr_print_error ( $db , $propal -> error );
}
2006-06-01 00:54:32 +02:00
}
}
2006-02-12 18:01:39 +01:00
/*
* Ajout d ' une ligne produit dans la propale
*/
2006-06-13 00:20:24 +02:00
if ( $_POST [ 'action' ] == " addligne " && $user -> rights -> propale -> creer )
2003-06-20 11:50:11 +02:00
{
2006-06-01 00:54:32 +02:00
if ( $_POST [ 'qty' ] && (( $_POST [ 'np_price' ] != 0 && $_POST [ 'np_desc' ]) || $_POST [ 'idprod' ]))
2006-02-12 18:01:39 +01:00
{
$propal = new Propal ( $db );
$ret = $propal -> fetch ( $_POST [ 'propalid' ]);
2006-06-20 13:59:18 +02:00
$soc = new Societe ( $db , $propal -> socidp );
$soc -> fetch ( $propal -> socidp );
2006-06-13 00:20:24 +02:00
2006-06-17 01:55:20 +02:00
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
if ( $_POST [ 'idprod' ])
{
$prod = new Product ( $db , $_POST [ 'idprod' ]);
$prod -> fetch ( $_POST [ 'idprod' ]);
// multiprix
if ( $conf -> global -> PRODUIT_MULTIPRICES == 1 )
{
$pu = $prod -> multiprices [ $soc -> price_level ];
}
else
{
$pu = $prod -> price ;
}
// La description de la ligne est celle saisie ou
// celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC d<> fini)
$desc = $_POST [ 'np_desc' ];
if ( ! $desc && $conf -> global -> PRODUIT_CHANGE_PROD_DESC )
{
$desc = $prod -> description ;
}
$tva_tx = get_default_tva ( $mysoc , $soc , $prod -> tva_tx );
}
else
{
$pu = $_POST [ 'np_price' ];
$tva_tx = $_POST [ 'np_tva_tx' ];
$desc = $_POST [ 'np_desc' ];
}
$propal -> addline (
$_POST [ 'propalid' ],
$desc ,
$pu ,
$_POST [ 'qty' ],
$tva_tx ,
$_POST [ 'idprod' ],
$_POST [ 'remise_percent' ]
);
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-06-17 01:55:20 +02:00
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
2006-02-12 18:01:39 +01:00
}
2005-06-27 23:47:44 +02:00
}
2006-06-17 01:55:20 +02:00
/*
* Mise <EFBFBD> jour d ' une ligne dans la propale
*/
2006-06-13 00:20:24 +02:00
if ( $_POST [ 'action' ] == 'updateligne' && $user -> rights -> propale -> creer && $_POST [ " save " ] == $langs -> trans ( " Save " ))
2003-08-30 13:45:47 +02:00
{
2005-09-01 21:28:15 +02:00
$propal = new Propal ( $db );
2006-06-17 01:55:20 +02:00
if ( ! $propal -> fetch ( $_POST [ 'propalid' ]) > 0 ) dolibarr_print_error ( $db );
$result = $propal -> updateline ( $_POST [ 'ligne' ],
$_POST [ 'subprice' ],
$_POST [ 'qty' ],
$_POST [ 'remise_percent' ],
$_POST [ 'tva_tx' ],
$_POST [ 'desc' ]);
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-06-17 01:55:20 +02:00
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
2003-09-05 21:36:37 +02:00
}
2006-06-10 20:43:11 +02:00
/*
* Generation doc ( depuis lien ou depuis cartouche doc )
*/
if ( $_REQUEST [ 'action' ] == 'builddoc' && $user -> rights -> propale -> creer )
2003-09-06 17:13:29 +02:00
{
2006-06-10 20:43:11 +02:00
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-07-02 15:45:06 +02:00
if ( $_REQUEST [ 'model' ])
2006-06-27 19:23:43 +02:00
{
2006-07-02 15:45:06 +02:00
$propal -> set_pdf_model ( $user , $_REQUEST [ 'model' ]);
2006-06-27 19:23:43 +02:00
}
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-07-18 09:54:58 +02:00
$result = propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
if ( $result <= 0 )
{
dolibarr_print_error ( $db , $result );
exit ;
}
else
{
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '#builddoc' );
}
2005-06-27 23:47:44 +02:00
}
2003-09-06 17:13:29 +02:00
2003-08-30 13:45:47 +02:00
2006-06-13 00:20:24 +02:00
if ( $_GET [ 'action' ] == 'del_ligne' && $user -> rights -> propale -> creer && ! $conf -> global -> PRODUIT_CONFIRM_DELETE_LINE )
2003-06-20 11:50:11 +02:00
{
2006-06-17 01:55:20 +02:00
/*
* Supprime une ligne produit dans la propale
*/
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
$propal -> delete_product ( $_GET [ 'ligne' ]);
2006-06-18 17:48:28 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
2006-06-17 01:55:20 +02:00
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
2003-06-20 11:50:11 +02:00
}
2006-06-23 02:09:24 +02:00
if ( $_POST [ 'action' ] == 'classin' )
2005-06-27 23:47:44 +02:00
{
2005-08-02 09:23:45 +02:00
$propal = new Propal ( $db );
$propal -> fetch ( $_GET [ 'propalid' ]);
$propal -> set_project ( $user , $_POST [ 'projetidp' ]);
2005-06-27 23:47:44 +02:00
}
2002-12-12 18:04:27 +01:00
2006-02-18 22:43:34 +01:00
// Conditions de r<> glement
2006-02-15 19:05:07 +01:00
if ( $_POST [ " action " ] == 'setconditions' )
2006-06-13 00:20:24 +02:00
{
2006-02-15 19:05:07 +01:00
$propal = new Propal ( $db , $_GET [ " propalid " ]);
2006-02-18 22:43:34 +01:00
$propal -> cond_reglement_id = $_POST [ 'cond_reglement_id' ];
$sql = " UPDATE " . MAIN_DB_PREFIX . " propal " ;
$sql .= " SET fk_cond_reglement=' " . $_POST [ 'cond_reglement_id' ] . " ' " ;
$sql .= " WHERE rowid=' " . $_GET [ " propalid " ] . " ' " ;
$resql = $db -> query ( $sql );
if ( $resql < 0 ) dolibarr_print_error ( $db );
2006-02-15 19:05:07 +01:00
}
2006-04-08 13:39:41 +02:00
if ( $_REQUEST [ 'action' ] == 'setremisepercent' && $user -> rights -> propale -> creer )
{
$propal = new Propal ( $db );
$propal -> fetch ( $_REQUEST [ 'propalid' ]);
$result = $propal -> set_remise_percent ( $user , $_POST [ 'remise_percent' ]);
$_GET [ 'propalid' ] = $_REQUEST [ 'propalid' ];
}
if ( $_REQUEST [ 'action' ] == 'setremiseabsolue' && $user -> rights -> propale -> creer )
{
$propal = new Propal ( $db );
$propal -> fetch ( $_REQUEST [ 'propalid' ]);
$result = $propal -> set_remise_absolue ( $user , $_POST [ 'remise_absolue' ]);
$_GET [ 'propalid' ] = $_REQUEST [ 'propalid' ];
}
2006-02-18 22:43:34 +01:00
// Mode de r<> glement
2006-02-15 19:05:07 +01:00
if ( $_POST [ " action " ] == 'setmode' )
{
2006-02-18 22:43:34 +01:00
$propal = new Propal ( $db , $_GET [ " propalid " ]);
$propal -> mode_reglement_id = $_POST [ 'mode_reglement_id' ];
// \todo Cr<43> er une methode propal->cond_reglement
$sql = " UPDATE " . MAIN_DB_PREFIX . " propal " ;
$sql .= " SET fk_mode_reglement=' " . $_POST [ 'mode_reglement_id' ] . " ' " ;
$sql .= " WHERE rowid=' " . $_GET [ " propalid " ] . " ' " ;
$resql = $db -> query ( $sql );
if ( $resql < 0 ) dolibarr_print_error ( $db );
2006-02-15 19:05:07 +01:00
}
2006-05-27 12:14:32 +02:00
/*
* Ordonnancement des lignes
*/
if ( $_GET [ 'action' ] == 'up' && $user -> rights -> propale -> creer )
{
2006-05-27 12:55:31 +02:00
$propal = new Propal ( $db , '' , $_GET [ " propalid " ]);
2006-07-18 09:54:58 +02:00
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-05-27 12:14:32 +02:00
$propal -> line_up ( $_GET [ 'rowid' ]);
2006-07-18 09:54:58 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $_GET [ " propalid " ] . '#' . $_GET [ 'rowid' ]);
2006-05-27 12:14:32 +02:00
}
if ( $_GET [ 'action' ] == 'down' && $user -> rights -> propale -> creer )
{
2006-05-27 12:55:31 +02:00
$propal = new Propal ( $db , '' , $_GET [ " propalid " ]);
2006-07-18 09:54:58 +02:00
$propal -> fetch ( $_GET [ 'propalid' ]);
2006-05-27 12:14:32 +02:00
$propal -> line_down ( $_GET [ 'rowid' ]);
2006-07-18 09:54:58 +02:00
if ( $_REQUEST [ 'lang_id' ])
{
$outputlangs = new Translate ( DOL_DOCUMENT_ROOT . " /langs " );
$outputlangs -> setDefaultLang ( $_REQUEST [ 'lang_id' ]);
}
propale_pdf_create ( $db , $propal -> id , $propal -> modelpdf , $outputlangs );
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $_GET [ " propalid " ] . '#' . $_GET [ 'rowid' ]);
2006-05-27 12:14:32 +02:00
}
2004-10-30 00:17:32 +02:00
2006-06-19 22:35:22 +02:00
2006-07-01 01:38:12 +02:00
llxHeader ( '' , $langs -> trans ( 'Proposal' ), 'Proposition' );
2003-09-12 14:58:58 +02:00
2005-11-04 21:45:02 +01:00
$html = new Form ( $db );
2004-10-30 00:17:32 +02:00
2002-05-04 01:01:45 +02:00
/*
2004-10-30 00:17:32 +02:00
* Affichage fiche propal en mode visu
2002-05-04 01:01:45 +02:00
*
*/
2005-08-21 18:33:38 +02:00
if ( $_GET [ 'propalid' ] > 0 )
2003-06-28 16:33:27 +02:00
{
2006-06-04 00:01:38 +02:00
if ( $msg ) print " $msg <br> " ;
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
$propal = new Propal ( $db );
2006-06-19 22:35:22 +02:00
$result = $propal -> fetch ( $_GET [ 'propalid' ]);
if ( ! $result > 0 )
{
dolibarr_print_error ( $db , $propal -> error );
exit ;
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
$societe = new Societe ( $db );
2006-06-19 22:35:22 +02:00
$societe -> fetch ( $propal -> socidp );
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
$head = propal_prepare_head ( $propal );
dolibarr_fiche_head ( $head , 'comm' , $langs -> trans ( 'Proposal' ));
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
/*
* Confirmation de la suppression de la propale
*/
if ( $_GET [ 'action' ] == 'delete' )
2005-09-16 03:23:29 +02:00
{
2006-06-04 00:01:38 +02:00
$html -> form_confirm ( $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id , $langs -> trans ( 'DeleteProp' ), $langs -> trans ( 'ConfirmDeleteProp' ), 'confirm_delete' );
print '<br>' ;
}
2006-06-13 00:20:24 +02:00
2006-06-16 02:33:04 +02:00
/*
2006-06-08 11:46:25 +02:00
* Confirmation de la suppression d ' une ligne produit
*/
if ( $_GET [ 'action' ] == 'delete_product_line' && $conf -> global -> PRODUIT_CONFIRM_DELETE_LINE )
{
2006-06-08 12:00:17 +02:00
$html -> form_confirm ( $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&ligne=' . $_GET [ " ligne " ], $langs -> trans ( 'DeleteProductLine' ), $langs -> trans ( 'ConfirmDeleteProductLine' ), 'confirm_deleteproductline' );
2006-06-08 11:46:25 +02:00
print '<br>' ;
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
/*
* Confirmation de la validation de la propale
*/
if ( $_GET [ 'action' ] == 'validate' )
{
$html -> form_confirm ( $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id , $langs -> trans ( 'ValidateProp' ), $langs -> trans ( 'ConfirmValidateProp' ), 'confirm_validate' );
print '<br>' ;
}
2005-09-01 21:28:15 +02:00
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
/*
* Fiche propal
*
*/
2006-06-16 02:33:04 +02:00
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td>' . $langs -> trans ( 'Ref' ) . '</td><td colspan="5">' . $propal -> ref_url . '</td></tr>' ;
// Ref client
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>' ;
print $langs -> trans ( 'RefCustomer' ) . '</td><td align="left">' ;
print '</td>' ;
if ( $_GET [ 'action' ] != 'refclient' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=refclient&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'Edit' )) . '</a></td>' ;
print '</tr></table>' ;
2006-06-18 00:30:55 +02:00
print '</td><td colspan="5">' ;
2006-06-16 02:33:04 +02:00
if ( $user -> rights -> propale -> creer && $_GET [ 'action' ] == 'refclient' )
{
print '<form action="propal.php?propalid=' . $propal -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="set_ref_client">' ;
print '<input type="text" class="flat" size="20" name="ref_client" value="' . $propal -> ref_client . '">' ;
print ' <input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
print $propal -> ref_client ;
}
print '</td>' ;
print '</tr>' ;
$rowspan = 8 ;
// Soci<63> t<EFBFBD>
print '<tr><td>' . $langs -> trans ( 'Company' ) . '</td><td colspan="5">' . $societe -> getNomUrl ( 1 ) . '</td>' ;
print '</tr>' ;
// Ligne info remises tiers
print '<tr><td>' . $langs -> trans ( 'Discounts' ) . '</td><td colspan="5">' ;
if ( $societe -> remise_client ) print $langs -> trans ( " CompanyHasRelativeDiscount " , $societe -> remise_client );
else print $langs -> trans ( " CompanyHasNoRelativeDiscount " );
$absolute_discount = $societe -> getCurrentDiscount ();
print '. ' ;
if ( $absolute_discount )
2006-06-04 00:01:38 +02:00
{
2006-07-01 01:38:12 +02:00
if ( $propal -> statut > 0 )
{
print $langs -> trans ( " CompanyHasAbsoluteDiscount " , $absolute_discount , $langs -> trans ( " Currency " . $conf -> monnaie ));
}
else
{
print '<br>' ;
print $html -> form_remise_dispo ( $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id , 0 , 'remise_id' , $societe -> id , $absolute_discount );
}
2006-06-16 02:33:04 +02:00
}
else print $langs -> trans ( " CompanyHasNoAbsoluteDiscount " ) . '.' ;
print '</td></tr>' ;
// Dates
print '<tr><td>' . $langs -> trans ( 'Date' ) . '</td><td colspan="3">' ;
print dolibarr_print_date ( $propal -> date , '%a %d %B %Y' );
print '</td>' ;
if ( $conf -> projet -> enabled ) $rowspan ++ ;
if ( $conf -> global -> PROPAL_ADD_SHIPPING_DATE ) $rowspan ++ ;
if ( $conf -> global -> PROPAL_ADD_DELIVERY_ADDRESS ) $rowspan ++ ;
// Notes
print '<td valign="top" colspan="2" width="50%" rowspan="' . $rowspan . '">' . $langs -> trans ( 'NotePublic' ) . ' :<br>' . nl2br ( $propal -> note_public ) . '</td>' ;
print '</tr>' ;
// Date fin propal
print '<tr>' ;
print '<td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DateEndPropal' );
print '</td>' ;
if ( $_GET [ 'action' ] != 'editecheance' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editecheance&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '<td colspan="3">' ;
if ( $propal -> brouillon && $_GET [ 'action' ] == 'editecheance' )
{
print '<form name="editecheance" action="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="setecheance">' ;
$html -> select_date ( $propal -> fin_validite , 'ech' , '' , '' , '' , " editecheance " );
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
if ( $propal -> fin_validite )
2006-06-04 00:01:38 +02:00
{
2006-06-16 02:33:04 +02:00
print dolibarr_print_date ( $propal -> fin_validite , '%a %d %B %Y' );
if ( $propal -> statut == 1 && $propal -> fin_validite < ( time () - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
}
else
{
print ' ' ;
}
}
print '</td>' ;
print '</tr>' ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// date de livraison (conditonn<6E> sur PROPAL_ADD_SHIPPING_DATE car carac <20>
// g<> rer par les commandes et non les propal
if ( $conf -> global -> PROPAL_ADD_SHIPPING_DATE )
{
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DateDelivery' );
print '</td>' ;
if ( $_GET [ 'action' ] != 'editdate_livraison' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdate_livraison&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetDateLivraison' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editdate_livraison' )
{
print '<form name="editdate_livraison" action="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '" method="post">' ;
print '<input type="hidden" name="action" value="setdate_livraison">' ;
$html -> select_date ( $propal -> date_livraison , 'liv_' , '' , '' , '' , " editdate_livraison " );
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
print dolibarr_print_date ( $propal -> date_livraison , '%a %d %B %Y' );
}
print '</td>' ;
print '</tr>' ;
}
2006-02-12 17:30:43 +01:00
2006-06-16 02:33:04 +02:00
// adresse de livraison
if ( $conf -> global -> PROPAL_ADD_DELIVERY_ADDRESS )
{
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DeliveryAddress' );
print '</td>' ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
if ( $_GET [ 'action' ] != 'editdelivery_adress' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdelivery_adress&socidp=' . $propal -> socidp . '&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetDeliveryAddress' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
if ( $_GET [ 'action' ] == 'editdelivery_adress' )
{
$html -> form_adresse_livraison ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> adresse_livraison_id , $_GET [ 'socidp' ], 'adresse_livraison_id' , 'propal' , $propal -> id );
}
else
{
$html -> form_adresse_livraison ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> adresse_livraison_id , $_GET [ 'socidp' ], 'none' , 'propal' , $propal -> id );
}
print '</td></tr>' ;
}
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// Conditions et modes de r<> glement
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'PaymentConditionsShort' );
print '</td>' ;
if ( $_GET [ 'action' ] != 'editconditions' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editconditions&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editconditions' )
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> cond_reglement_id , 'cond_reglement_id' );
}
else
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> cond_reglement_id , 'none' );
}
print '</td>' ;
print '</tr>' ;
// Mode paiement
print '<tr>' ;
print '<td width="25%">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'PaymentMode' );
print '</td>' ;
if ( $_GET [ 'action' ] != 'editmode' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'editmode' )
{
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> mode_reglement_id , 'mode_reglement_id' );
}
else
{
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> mode_reglement_id , 'none' );
}
print '</td></tr>' ;
// Projet
if ( $conf -> projet -> enabled )
{
$langs -> load ( " projects " );
2006-06-23 02:09:24 +02:00
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'Project' ) . '</td>' ;
2006-06-16 02:33:04 +02:00
$numprojet = $societe -> has_projects ();
if ( ! $numprojet )
{
2006-06-23 02:09:24 +02:00
print '</td></tr></table>' ;
2006-06-16 02:33:04 +02:00
print '<td colspan="2">' ;
print $langs -> trans ( " NoProject " ) . '</td><td>' ;
print '<a href=../projet/fiche.php?socidp=' . $societe -> id . '&action=create>' . $langs -> trans ( 'AddProject' ) . '</a>' ;
2005-11-04 21:45:02 +01:00
print '</td>' ;
2006-06-16 02:33:04 +02:00
}
else
{
if ( $propal -> statut == 0 && $user -> rights -> propale -> creer )
2006-06-04 00:01:38 +02:00
{
2006-06-23 02:09:24 +02:00
if ( $_GET [ 'action' ] != 'classer' && $propal -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classer&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetProject' )) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $_GET [ 'action' ] == 'classer' )
{
$form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> socidp , $propal -> projetidp , 'projetidp' );
}
else
{
$form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?propalid=' . $propal -> id , $propal -> socidp , $propal -> projetidp , 'none' );
}
print '</td></tr>' ;
2006-06-04 00:01:38 +02:00
}
else
{
2006-06-16 02:33:04 +02:00
if ( ! empty ( $propal -> projetidp ))
2006-06-04 00:01:38 +02:00
{
2006-06-23 02:09:24 +02:00
print '</td></tr></table>' ;
2006-06-16 02:33:04 +02:00
print '<td colspan="3">' ;
$proj = new Project ( $db );
$proj -> fetch ( $propal -> projetidp );
print '<a href="../projet/fiche.php?id=' . $propal -> projetidp . '" title="' . $langs -> trans ( 'ShowProject' ) . '">' ;
print $proj -> title ;
print '</a>' ;
print '</td>' ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
else {
2006-06-23 02:09:24 +02:00
print '</td></tr></table>' ;
2006-06-16 02:33:04 +02:00
print '<td colspan="3"> </td>' ;
2006-06-04 00:01:38 +02:00
}
}
2006-06-16 02:33:04 +02:00
}
print '</tr>' ;
}
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// Amount
print '<tr><td height="10">' . $langs -> trans ( 'AmountHT' ) . '</td>' ;
print '<td align="right" colspan="2"><b>' . price ( $propal -> price ) . '</b></td>' ;
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
print '<tr><td height="10">' . $langs -> trans ( 'AmountVAT' ) . '</td><td align="right" colspan="2">' . price ( $propal -> total_tva ) . '</td>' ;
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
print '<tr><td height="10">' . $langs -> trans ( 'AmountTTC' ) . '</td><td align="right" colspan="2">' . price ( $propal -> total_ttc ) . '</td>' ;
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// Statut
print '<tr><td height="10">' . $langs -> trans ( 'Status' ) . '</td><td align="left" colspan="3">' . $propal -> getLibStatut ( 4 ) . '</td></tr>' ;
print '</table><br>' ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
/*
* Lignes de propale
*/
print '<table class="noborder" width="100%">' ;
2006-06-30 01:48:44 +02:00
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.fk_remise_except,' ;
$sql .= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,' ;
2006-06-16 02:33:04 +02:00
$sql .= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,' ;
$sql .= ' p.description as product_desc' ;
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'propaldet as pt' ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product as p ON pt.fk_product=p.rowid' ;
$sql .= ' WHERE pt.fk_propal = ' . $propal -> id ;
$sql .= ' ORDER BY pt.rang ASC, pt.rowid' ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ; $total = 0 ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
if ( $num )
{
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( 'Description' ) . '</td>' ;
print '<td align="right" width="50">' . $langs -> trans ( 'VAT' ) . '</td>' ;
print '<td align="right" width="80">' . $langs -> trans ( 'PriceUHT' ) . '</td>' ;
print '<td align="right" width="50">' . $langs -> trans ( 'Qty' ) . '</td>' ;
print '<td align="right" width="50">' . $langs -> trans ( 'ReductionShort' ) . '</td>' ;
print '<td align="right" width="50">' . $langs -> trans ( 'AmountHT' ) . '</td>' ;
print '<td width="16"> </td>' ;
print '<td width="16"> </td>' ;
print '<td width="16"> </td>' ;
print " </tr> \n " ;
}
$var = true ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
$var =! $var ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// Ligne en mode visu
if ( $_GET [ 'action' ] != 'editline' || $_GET [ 'ligne' ] != $objp -> rowid )
2005-11-04 21:45:02 +01:00
{
2006-06-16 02:33:04 +02:00
print '<tr ' . $bc [ $var ] . '>' ;
if ( $objp -> fk_product > 0 )
{
2006-06-30 01:48:44 +02:00
print '<td>' ;
2006-07-17 18:49:33 +02:00
print '<a name="' . $objp -> rowid . '"></a>' ; // ancre pour retourner sur la ligne
2006-06-30 01:48:44 +02:00
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' ;
2006-06-16 02:33:04 +02:00
if ( $objp -> fk_product_type ) print img_object ( $langs -> trans ( 'ShowService' ), 'service' );
else print img_object ( $langs -> trans ( 'ShowProduct' ), 'product' );
print ' ' . $objp -> ref . '</a>' ;
2006-07-01 01:38:12 +02:00
print ' - ' . nl2br ( $objp -> product );
2006-06-16 02:33:04 +02:00
if ( $conf -> global -> PROP_ADD_PROD_DESC && ! $conf -> global -> PRODUIT_CHANGE_PROD_DESC )
{
2006-07-01 01:38:12 +02:00
print '<br>' . nl2br ( $objp -> product_desc );
2006-06-16 02:33:04 +02:00
}
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
if ( $objp -> date_start && $objp -> date_end )
{
print ' (Du ' . dolibarr_print_date ( $objp -> date_start ) . ' au ' . dolibarr_print_date ( $objp -> date_end ) . ')' ;
}
if ( $objp -> date_start && ! $objp -> date_end )
{
print ' (A partir du ' . dolibarr_print_date ( $objp -> date_start ) . ')' ;
}
if ( ! $objp -> date_start && $objp -> date_end )
{
print " (Jusqu'au " . dolibarr_print_date ( $objp -> date_end ) . ')' ;
}
print ( $objp -> description && $objp -> description != $objp -> product ) ? '<br>' . stripslashes ( nl2br ( $objp -> description )) : '' ;
2006-06-04 00:01:38 +02:00
print '</td>' ;
}
else
{
2006-06-30 01:48:44 +02:00
print '<td>' ;
2006-07-18 09:54:58 +02:00
print '<a name="' . $objp -> rowid . '"></a>' ; // ancre pour retourner sur la ligne
2006-07-01 01:38:12 +02:00
if (( $objp -> info_bits & 2 ) == 2 )
2006-06-30 01:48:44 +02:00
{
print '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $propal -> socidp . '">' ;
2006-07-01 01:38:12 +02:00
print img_object ( $langs -> trans ( " ShowReduc " ), 'reduc' ) . ' ' . $langs -> trans ( " Discount " );
2006-06-30 01:48:44 +02:00
print '</a>' ;
2006-07-01 15:25:58 +02:00
if ( $objp -> description ) print ' - ' . nl2br ( $objp -> description );
2006-06-30 01:48:44 +02:00
}
else
{
print nl2br ( $objp -> description );
2006-07-01 01:38:12 +02:00
if ( $objp -> date_start && $objp -> date_end )
{
print ' (Du ' . dolibarr_print_date ( $objp -> date_start ) . ' au ' . dolibarr_print_date ( $objp -> date_end ) . ')' ;
}
if ( $objp -> date_start && ! $objp -> date_end )
{
print ' (A partir du ' . dolibarr_print_date ( $objp -> date_start ) . ')' ;
}
if ( ! $objp -> date_start && $objp -> date_end )
{
print " (Jusqu'au " . dolibarr_print_date ( $objp -> date_end ) . ')' ;
}
2006-06-16 02:33:04 +02:00
}
print " </td> \n " ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
print '<td align="right">' . $objp -> tva_tx . '%</td>' ;
print '<td align="right">' . price ( $objp -> subprice ) . " </td> \n " ;
2006-07-01 01:38:12 +02:00
print '<td align="right">' ;
if (( $objp -> info_bits & 2 ) != 2 )
{
print $objp -> qty ;
}
else print ' ' ;
print '</td>' ;
2006-06-16 02:33:04 +02:00
if ( $objp -> remise_percent > 0 )
2006-06-04 00:01:38 +02:00
{
2006-06-16 02:33:04 +02:00
print '<td align="right">' . $objp -> remise_percent . " %</td> \n " ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
else
2006-06-04 00:01:38 +02:00
{
2006-06-16 02:33:04 +02:00
print '<td> </td>' ;
}
print '<td align="right">' . price ( $objp -> subprice * $objp -> qty * ( 100 - $objp -> remise_percent ) / 100 ) . " </td> \n " ;
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// Icone d'edition et suppression
if ( $propal -> statut == 0 && $user -> rights -> propale -> creer )
{
2006-07-17 18:49:33 +02:00
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=editline&ligne=' . $objp -> rowid . '#' . $objp -> rowid . '">' ;
2006-06-16 02:33:04 +02:00
print img_edit ();
print '</a></td>' ;
if ( $conf -> global -> PRODUIT_CONFIRM_DELETE_LINE )
2006-06-04 00:01:38 +02:00
{
2006-06-16 02:33:04 +02:00
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=delete_product_line&ligne=' . $objp -> rowid . '">' ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
else
2006-06-04 00:01:38 +02:00
{
2006-06-16 02:33:04 +02:00
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=del_ligne&ligne=' . $objp -> rowid . '">' ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
print img_delete ();
print '</a></td>' ;
print '<td align="right">' ;
if ( $i > 0 )
{
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=up&rowid=' . $objp -> rowid . '">' ;
print img_up ();
print '</a>' ;
}
if ( $i < $num - 1 )
{
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=down&rowid=' . $objp -> rowid . '">' ;
print img_down ();
print '</a>' ;
}
print '</td>' ;
}
else
{
print '<td colspan="3"> </td>' ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
print '</tr>' ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
// Ligne en mode update
if ( $propal -> statut == 0 && $_GET [ " action " ] == 'editline' && $user -> rights -> propale -> creer && $_GET [ " ligne " ] == $objp -> rowid )
2006-06-04 00:01:38 +02:00
{
2006-07-17 18:49:33 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '#' . $objp -> rowid . '" method="post">' ;
2006-06-16 02:33:04 +02:00
print '<input type="hidden" name="action" value="updateligne">' ;
2006-06-04 00:01:38 +02:00
print '<input type="hidden" name="propalid" value="' . $propal -> id . '">' ;
2006-06-16 02:33:04 +02:00
print '<input type="hidden" name="ligne" value="' . $_GET [ " ligne " ] . '">' ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td>' ;
2006-07-18 09:54:58 +02:00
print '<a name="' . $objp -> rowid . '"></a>' ; // ancre pour retourner sur la ligne
2006-06-16 02:33:04 +02:00
if ( $objp -> fk_product > 0 )
2006-04-08 13:39:41 +02:00
{
2006-06-16 02:33:04 +02:00
print '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=' . $objp -> fk_product . '">' ;
if ( $objp -> fk_product_type ) print img_object ( $langs -> trans ( 'ShowService' ), 'service' );
else print img_object ( $langs -> trans ( 'ShowProduct' ), 'product' );
print ' ' . $objp -> ref . '</a>' ;
2006-07-01 01:38:12 +02:00
print ' - ' . nl2br ( $objp -> product );
2006-06-16 02:33:04 +02:00
print '<br>' ;
2006-04-08 13:39:41 +02:00
}
2006-07-21 15:43:27 +02:00
// <20> diteur wysiwyg
if ( $conf -> fckeditor -> enabled && $conf -> global -> FCKEDITOR_ENABLE_PRODUCTDESC )
2006-07-20 10:57:10 +02:00
{
require_once ( DOL_DOCUMENT_ROOT . " /includes/fckeditor/fckeditor.php " );
$oFCKeditor = new FCKeditor ( 'desc' );
$oFCKeditor -> Value = $objp -> description ;
$oFCKeditor -> Create () ;
}
else
{
print '<textarea name="desc" cols="50" class="flat" rows="' . ROWS_2 . '">' . $objp -> description . '</textarea>' ;
}
print '</td>' ;
2006-06-16 02:33:04 +02:00
print '<td align="right">' ;
if ( $societe -> tva_assuj == " 0 " )
print '<input type="hidden" name="tva_tx" value="0">0' ;
2006-04-08 13:39:41 +02:00
else
2006-06-16 02:33:04 +02:00
print $html -> select_tva ( " tva_tx " , $objp -> tva_tx , $mysoc , $societe );
print '</td>' ;
2006-07-01 01:38:12 +02:00
print '<td align="right"><input size="6" type="text" class="flat" name="subprice" value="' . price ( $objp -> subprice ) . '"></td>' ;
print '<td align="right">' ;
if (( $objp -> info_bits & 2 ) != 2 )
{
print '<input size="2" type="text" class="flat" name="qty" value="' . $objp -> qty . '">' ;
}
else print ' ' ;
print '</td>' ;
print '<td align="right" nowrap>' ;
if (( $objp -> info_bits & 2 ) != 2 )
{
print '<input size="1" type="text" class="flat" name="remise_percent" value="' . $objp -> remise_percent . '">%' ;
}
else print ' ' ;
print '</td>' ;
2006-06-16 02:33:04 +02:00
print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
print '<br /><input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '"></td>' ;
print '</tr>' . " \n " ;
/*
if ( $conf -> service -> enabled )
2006-04-08 13:39:41 +02:00
{
2006-06-16 02:33:04 +02:00
print " <tr $bc[$var] > " ;
print '<td colspan="5">Si produit de type service <20> dur<75> e limit<69> e: Du ' ;
print $html -> select_date ( $objp -> date_start , " date_start " , 0 , 0 , $objp -> date_start ? 0 : 1 );
print ' au ' ;
print $html -> select_date ( $objp -> date_end , " date_end " , 0 , 0 , $objp -> date_end ? 0 : 1 );
print '</td>' ;
print '</tr>' . " \n " ;
2006-04-08 13:39:41 +02:00
}
2006-06-16 02:33:04 +02:00
*/
print " </form> \n " ;
}
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
$total = $total + ( $objp -> qty * $objp -> price );
$i ++ ;
}
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
$db -> free ( $resql );
}
else
{
dolibarr_print_error ( $db );
}
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
/*
* Lignes de remise
*/
2006-06-04 00:01:38 +02:00
2006-06-16 02:33:04 +02:00
// R<> ductions relatives (Remises-Ristournes-Rabbais)
/* Une r<EFBFBD> duction doit s ' appliquer obligatoirement sur des lignes de factures
$var =! $var ;
print '<form name="updateligne" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
print '<input type="hidden" name="action" value="setremisepercent">' ;
print '<input type="hidden" name="propalid" value="' . $propal -> id . '">' ;
print '<tr class="liste_total"><td>' ;
print $langs -> trans ( 'CustomerRelativeDiscount' );
if ( $propal -> brouillon ) print ' <font style="font-weight: normal">(' . ( $soc -> remise_client ? $langs -> trans ( " CompanyHasRelativeDiscount " , $soc -> remise_client ) : $langs -> trans ( " CompanyHasNoRelativeDiscount " )) . ')</font>' ;
print '</td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td align="right"><font style="font-weight: normal">' ;
if ( $_GET [ 'action' ] == 'editrelativediscount' )
{
print '<input type="text" name="remise_percent" size="1" value="' . $propal -> remise_percent . '">%' ;
}
else
{
print $propal -> remise_percent ? $propal -> remise_percent . '%' : ' ' ;
}
print '</font></td>' ;
print '<td align="right"><font style="font-weight: normal">' ;
if ( $_GET [ 'action' ] != 'editrelativediscount' ) print $propal -> remise_percent ? '-' . price ( $propal -> remise_percent * $total / 100 ) : $langs -> trans ( " DiscountNone " );
else print ' ' ;
print '</font></td>' ;
if ( $_GET [ 'action' ] != 'editrelativediscount' )
{
if ( $propal -> brouillon && $user -> rights -> propale -> creer )
{
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editrelativediscount&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetRelativeDiscount' ), 1 ) . '</a></td>' ;
}
else
{
print '<td> </td>' ;
}
if ( $propal -> brouillon && $user -> rights -> propale -> creer && $propal -> remise_percent )
{
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=setremisepercent&rowid=' . $objp -> rowid . '">' ;
print img_delete ();
print '</a></td>' ;
}
else
{
print '<td> </td>' ;
}
print '<td> </td>' ;
}
else
{
print '<td colspan="3"><input type="submit" class="button" value="' . $langs -> trans ( " Save " ) . '"></td>' ;
}
print '</tr>' ;
print '</form>' ;
*/
2006-02-18 22:43:34 +01:00
2006-06-16 02:33:04 +02:00
// R<> ductions absolues (Remises-Ristournes-Rabbais)
/* Les remises absolues doivent s ' appliquer par ajout de lignes sp<EFBFBD> cialis<EFBFBD> es
$var =! $var ;
print '<form name="updateligne" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
print '<input type="hidden" name="action" value="setremiseabsolue">' ;
print '<input type="hidden" name="propalid" value="' . $propal -> id . '">' ;
print '<tr class="liste_total"><td>' ;
print $langs -> trans ( 'CustomerAbsoluteDiscount' );
if ( $propal -> brouillon ) print ' <font style="font-weight: normal">(' . ( $avoir_en_cours ? $langs -> trans ( " CompanyHasAbsoluteDiscount " , $avoir_en_cours , $langs -> trans ( " Currency " . $conf -> monnaie )) : $langs -> trans ( " CompanyHasNoAbsoluteDiscount " )) . ')</font>' ;
print '</td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td align="right"><font style="font-weight: normal">' ;
if ( $_GET [ 'action' ] == 'editabsolutediscount' )
{
print '-<input type="text" name="remise_absolue" size="2" value="' . $propal -> remise_absolue . '">' ;
2006-06-04 00:01:38 +02:00
}
else
{
2006-06-16 02:33:04 +02:00
print $propal -> remise_absolue ? '-' . price ( $propal -> remise_absolue ) : $langs -> trans ( " DiscountNone " );
}
print '</font></td>' ;
if ( $_GET [ 'action' ] != 'editabsolutediscount' )
{
if ( $propal -> brouillon && $user -> rights -> propale -> creer )
{
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editabsolutediscount&propalid=' . $propal -> id . '">' . img_edit ( $langs -> trans ( 'SetAbsoluteDiscount' ), 1 ) . '</a></td>' ;
2006-06-04 00:01:38 +02:00
}
2006-06-16 02:33:04 +02:00
else
{
print '<td> </td>' ;
}
if ( $propal -> brouillon && $user -> rights -> propale -> creer && $propal -> remise_absolue )
{
print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=setremiseabsolue&rowid=' . $objp -> rowid . '">' ;
print img_delete ();
print '</a></td>' ;
}
else
{
print '<td> </td>' ;
}
print '<td> </td>' ;
}
else
{
print '<td colspan="3"><input type="submit" class="button" value="' . $langs -> trans ( " Save " ) . '"></td>' ;
}
print '</tr>' ;
print '</form>' ;
*/
/*
* Ajouter une ligne
*/
if ( $propal -> statut == 0 && $user -> rights -> propale -> creer && $_GET [ " action " ] <> 'editline' )
{
print '<tr class="liste_titre">' ;
2006-07-17 18:49:33 +02:00
print '<td>' ;
print '<a name="add"></a>' ; // ancre
print $langs -> trans ( 'Description' ) . '</td>' ;
2006-06-16 02:33:04 +02:00
print '<td align="right">' . $langs -> trans ( 'VAT' ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( 'PriceUHT' ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( 'Qty' ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( 'ReductionShort' ) . '</td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print '<td> </td>' ;
print " </tr> \n " ;
// Ajout produit produits/services personalis<69> s
2006-07-17 18:49:33 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '#add" method="post">' ;
2006-06-16 02:33:04 +02:00
print '<input type="hidden" name="propalid" value="' . $propal -> id . '">' ;
print '<input type="hidden" name="action" value="addligne">' ;
$var = true ;
print '<tr ' . $bc [ $var ] . " > \n " ;
print '<td><textarea cols="50" name="np_desc" rows="' . ROWS_2 . '"></textarea></td>' ;
print '<td align="center">' ;
if ( $societe -> tva_assuj == " 0 " )
{
print '<input type="hidden" name="np_tva_tx" value="0">0' ;
}
else
{
$html -> select_tva ( 'np_tva_tx' , $conf -> defaulttx , $mysoc , $societe );
}
print " </td> \n " ;
print '<td align="right"><input type="text" size="5" name="np_price"></td>' ;
print '<td align="right"><input type="text" size="2" value="1" name="qty"></td>' ;
2006-06-17 01:55:20 +02:00
print '<td align="right" nowrap><input type="text" size="1" value="' . $societe -> remise_client . '" name="remise_percent">%</td>' ;
2006-06-16 02:33:04 +02:00
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="' . $langs -> trans ( 'Add' ) . '" name="addligne"></td>' ;
print '</tr>' ;
print '</form>' ;
// Ajout de produits/services pr<70> d<EFBFBD> finis
if ( $conf -> produit -> enabled )
{
2006-07-17 18:49:33 +02:00
print '<form id="addpredefinedproduct" action="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '#add" method="post">' ;
2006-06-16 02:33:04 +02:00
print '<input type="hidden" name="propalid" value="' . $propal -> id . '">' ;
print '<input type="hidden" name="action" value="addligne">' ;
$var =! $var ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td colspan="2">' ;
// multiprix
if ( $conf -> global -> PRODUIT_MULTIPRICES == 1 )
{
$html -> select_produits ( '' , 'idprod' , '' , $conf -> produit -> limit_size , $societe -> price_level );
}
else
{
$html -> select_produits ( '' , 'idprod' , '' , $conf -> produit -> limit_size );
}
if ( ! $conf -> use_ajax ) print '<br>' ;
print '<textarea cols="50" name="np_desc" rows="' . ROWS_2 . '"></textarea>' ;
print '</td>' ;
print '<td> </td>' ;
print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>' ;
2006-06-17 01:55:20 +02:00
print '<td align="right" nowrap><input type="text" size="1" name="remise_percent" value="' . $societe -> remise_client . '">%</td>' ;
2006-06-16 02:33:04 +02:00
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '" name="addligne">' ;
print '</td></tr>' . " \n " ;
print '</form>' ;
}
}
print '</table>' ;
2006-02-18 22:43:34 +01:00
2006-03-26 16:56:21 +02:00
print '</div>' ;
print " \n " ;
2005-08-02 09:23:45 +02:00
2006-03-26 16:56:21 +02:00
/*
2006-06-04 00:01:38 +02:00
* Formulaire cloture ( sign<EFBFBD> ou non )
*/
if ( $_GET [ 'action' ] == 'statut' )
{
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '" method="post">' ;
print '<table class="border" width="100%">' ;
print '<tr><td>' . $langs -> trans ( 'Note' ) . '</td><td><textarea cols="60" rows="' . ROWS_3 . '" wrap="soft" name="note">' ;
print $propal -> note ;
print '</textarea></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " CloseAs " ) . '</td><td>' ;
print '<input type="hidden" name="action" value="setstatut">' ;
print '<select name="statut">' ;
2006-06-16 02:33:04 +02:00
print '<option value="0"> </option>' ;
2006-06-04 00:01:38 +02:00
print '<option value="2">' . $propal -> labelstatut [ 2 ] . '</option>' ;
print '<option value="3">' . $propal -> labelstatut [ 3 ] . '</option>' ;
print '</select>' ;
print '</td></tr>' ;
print '<tr><td align="center" colspan="2">' ;
print '<input type="submit" class="button" name="validate" value="' . $langs -> trans ( 'Validate' ) . '">' ;
print ' <input type="submit" class="button" name="cancel" value="' . $langs -> trans ( 'Cancel' ) . '">' ;
print '</td>' ;
print '</tr></table></form>' ;
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
/*
* Boutons Actions
*/
print '<div class="tabsAction">' ;
2005-08-14 03:25:05 +02:00
2006-06-04 00:01:38 +02:00
if ( $_GET [ 'action' ] != 'statut' )
{
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
// Valid
if ( $propal -> statut == 0 )
{
if ( $user -> rights -> propale -> valider && $propal -> total_ttc > 0 )
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=validate">' . $langs -> trans ( 'Validate' ) . '</a>' ;
}
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
// Save
if ( $propal -> statut == 1 )
{
if ( $user -> rights -> propale -> creer )
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=modif">' . $langs -> trans ( 'Edit' ) . '</a>' ;
}
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
// Build PDF
if ( $user -> rights -> propale -> creer )
{
if ( $propal -> statut < 2 )
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=builddoc">' . $langs -> trans ( " BuildPDF " ) . '</a>' ;
}
else
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=builddoc">' . $langs -> trans ( " RebuildPDF " ) . '</a>' ;
}
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
// Send
if ( $propal -> statut == 1 )
{
if ( $user -> rights -> propale -> envoyer )
{
$propref = sanitize_string ( $propal -> ref );
$file = $conf -> propal -> dir_output . '/' . $propref . '/' . $propref . '.pdf' ;
if ( file_exists ( $file ))
{
2006-07-01 01:38:12 +02:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=presend">' . $langs -> trans ( 'SendByMail' ) . '</a>' ;
2006-06-04 00:01:38 +02:00
}
}
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
// Close
if ( $propal -> statut != 0 )
{
if ( $propal -> statut == 1 && $user -> rights -> propale -> cloturer )
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=statut">' . $langs -> trans ( 'Close' ) . '</a>' ;
}
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
// Delete
if ( $propal -> statut == 0 )
{
if ( $user -> rights -> propale -> supprimer )
{
print '<a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $propal -> id . '&action=delete">' . $langs -> trans ( 'Delete' ) . '</a>' ;
}
}
2005-08-02 09:23:45 +02:00
2005-07-10 16:51:20 +02:00
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
print '</div>' ;
print " <br> \n " ;
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
print '<table width="100%"><tr><td width="50%" valign="top">' ;
2006-07-18 09:54:58 +02:00
print '<a name="builddoc"></a>' ; // ancre
2006-06-04 00:01:38 +02:00
/*
* Documents g<EFBFBD> n<EFBFBD> r<EFBFBD> s
*/
$filename = sanitize_string ( $propal -> ref );
$filedir = $conf -> propal -> dir_output . " / " . sanitize_string ( $propal -> ref );
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?propalid= " . $propal -> id ;
$genallowed = $user -> rights -> propale -> creer ;
$delallowed = $user -> rights -> propale -> supprimer ;
$var = true ;
2005-08-02 09:23:45 +02:00
2006-07-02 15:45:06 +02:00
$somethingshown = $html -> show_documents ( 'propal' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $propal -> modelpdf );
2006-06-04 00:01:38 +02:00
/*
* Commandes rattach<EFBFBD> es
*/
if ( $conf -> commande -> enabled )
2005-08-21 21:07:13 +02:00
{
2006-06-04 00:01:38 +02:00
$coms = $propal -> associated_orders ();
if ( sizeof ( $coms ) > 0 )
{
print '<br>' ;
print_titre ( $langs -> trans ( 'RelatedOrders' ));
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Date " ) . '</td>' ;
print '<td align="right">' . $langs -> trans ( " Price " ) . '</td>' ;
print '</tr>' ;
$var = true ;
for ( $i = 0 ; $i < sizeof ( $coms ) ; $i ++ )
{
$var =! $var ;
print '<tr ' . $bc [ $var ] . '><td>' ;
print '<a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $coms [ $i ] -> id . '">' . img_object ( $langs -> trans ( " ShowOrder " ), " order " ) . ' ' . $coms [ $i ] -> ref . " </a></td> \n " ;
print '<td align="center">' . dolibarr_print_date ( $coms [ $i ] -> date ) . '</td>' ;
print '<td align="right">' . $coms [ $i ] -> total_ttc . '</td>' ;
print " </tr> \n " ;
}
print '</table>' ;
}
2005-08-21 21:07:13 +02:00
}
2005-08-02 09:23:45 +02:00
2006-06-04 00:01:38 +02:00
print '</td><td valign="top" width="50%">' ;
/*
* Liste des actions propres <EFBFBD> la propal
*/
$sql = 'SELECT id, ' . $db -> pdate ( 'a.datea' ) . ' as da, label, note, fk_user_author' ;
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm as a' ;
$sql .= ' WHERE a.propalrowid = ' . $propal -> id ;
if ( $socidp ) $sql .= ' AND a.fk_soc = ' . $socidp ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
if ( $num )
{
print_titre ( $langs -> trans ( 'ActionsOnPropal' ));
$i = 0 ;
$total = 0 ;
$var = true ;
print '<table class="border" width="100%">' ;
print '<tr ' . $bc [ $var ] . '><td>' . $langs -> trans ( 'Ref' ) . '</td><td>' . $langs -> trans ( 'Date' ) . '</td><td>' . $langs -> trans ( 'Action' ) . '</td><td>' . $langs -> trans ( 'By' ) . '</td></tr>' ;
print " \n " ;
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
$var =! $var ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td><a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $objp -> id . '">' . img_object ( $langs -> trans ( 'ShowTask' ), 'task' ) . ' ' . $objp -> id . '</a></td>' ;
print '<td>' . dolibarr_print_date ( $objp -> da ) . " </td> \n " ;
print '<td>' . stripslashes ( $objp -> label ) . '</td>' ;
$authoract = new User ( $db );
$authoract -> id = $objp -> fk_user_author ;
$authoract -> fetch ( '' );
print '<td>' . $authoract -> code . '</td>' ;
print " </tr> \n " ;
$i ++ ;
}
print '</table>' ;
}
}
else
{
dolibarr_print_error ( $db );
}
print '</td></tr></table>' ;
/*
* Action presend
*
*/
if ( $_GET [ 'action' ] == 'presend' )
{
print '<br>' ;
print_titre ( $langs -> trans ( 'SendPropalByMail' ));
$liste [ 0 ] = " " ;
foreach ( $societe -> contact_email_array () as $key => $value )
{
$liste [ $key ] = $value ;
}
// Cr<43> <72> l'objet formulaire mail
include_once ( '../html.formmail.class.php' );
$formmail = new FormMail ( $db );
$formmail -> fromname = $user -> fullname ;
$formmail -> frommail = $user -> email ;
$formmail -> withfrom = 1 ;
$formmail -> withto = $liste ;
$formmail -> withcc = 1 ;
$formmail -> withtopic = $langs -> trans ( 'SendPropalRef' , '__PROPREF__' );
$formmail -> withfile = 1 ;
$formmail -> withbody = 1 ;
2006-06-26 17:15:51 +02:00
$formmail -> withdeliveryreceipt = 1 ;
2006-06-04 00:01:38 +02:00
// Tableau des substitutions
$formmail -> substit [ '__PROPREF__' ] = $propal -> ref ;
// Tableau des param<61> tres compl<70> mentaires
$formmail -> param [ 'action' ] = 'send' ;
$formmail -> param [ 'models' ] = 'propal_send' ;
$formmail -> param [ 'propalid' ] = $propal -> id ;
$formmail -> param [ 'returnurl' ] = DOL_URL_ROOT . '/comm/propal.php?propalid=' . $propal -> id ;
$formmail -> show_form ();
}
2005-07-10 16:51:20 +02:00
2004-10-30 00:17:32 +02:00
}
else
{
2005-08-02 09:23:45 +02:00
/****************************************************************************
* *
* Mode Liste des propales *
* *
****************************************************************************/
$sortorder = $_GET [ 'sortorder' ];
$sortfield = $_GET [ 'sortfield' ];
$page = $_GET [ 'page' ];
$viewstatut = $_GET [ 'viewstatut' ];
if ( ! $sortfield ) $sortfield = 'p.datep' ;
if ( ! $sortorder ) $sortorder = 'DESC' ;
$limit = $conf -> liste_limit ;
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
$sql = 'SELECT s.nom, s.idp, s.client, p.rowid as propalid, p.price, p.ref, p.fk_statut, ' . $db -> pdate ( 'p.datep' ) . ' as dp,' . $db -> pdate ( 'p.fin_validite' ) . ' as dfv' ;
2006-03-08 17:48:36 +01:00
if ( ! $user -> rights -> commercial -> client -> voir && ! $socidp ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2005-08-02 09:23:45 +02:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s, ' . MAIN_DB_PREFIX . 'propal as p' ;
2006-03-08 17:48:36 +01:00
if ( ! $user -> rights -> commercial -> client -> voir && ! $socidp ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2005-08-25 00:38:00 +02:00
if ( $sall ) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'propaldet as pd ON p.rowid=pd.fk_propal' ;
2005-08-02 09:23:45 +02:00
$sql .= ' WHERE p.fk_soc = s.idp' ;
2006-06-13 00:20:24 +02:00
2006-03-08 17:48:36 +01:00
if ( ! $user -> rights -> commercial -> client -> voir && ! $socidp ) //restriction
2006-03-08 16:04:37 +01:00
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " . $user -> id ;
}
2005-08-02 09:23:45 +02:00
if ( ! empty ( $_GET [ 'search_ref' ]))
{
2006-02-25 01:43:24 +01:00
$sql .= " AND p.ref LIKE '% " . addslashes ( $_GET [ 'search_ref' ]) . " %' " ;
2005-08-02 09:23:45 +02:00
}
if ( ! empty ( $_GET [ 'search_societe' ]))
{
2006-02-25 01:43:24 +01:00
$sql .= " AND s.nom LIKE '% " . addslashes ( $_GET [ 'search_societe' ]) . " %' " ;
2005-08-02 09:23:45 +02:00
}
if ( ! empty ( $_GET [ 'search_montant_ht' ]))
{
2006-02-25 01:43:24 +01:00
$sql .= " AND p.price=' " . addslashes ( $_GET [ 'search_montant_ht' ]) . " ' " ;
2005-08-02 09:23:45 +02:00
}
2006-02-25 01:43:24 +01:00
if ( $sall ) $sql .= " AND (s.nom like '% " . addslashes ( $sall ) . " %' OR p.note like '% " . addslashes ( $sall ) . " %' OR pd.description like '% " . addslashes ( $sall ) . " %') " ;
2006-06-13 00:20:24 +02:00
if ( $socidp ) $sql .= ' AND s.idp = ' . $socidp ;
2005-08-02 09:23:45 +02:00
if ( $_GET [ 'viewstatut' ] <> '' )
{
2006-06-13 00:20:24 +02:00
$sql .= ' AND p.fk_statut in (' . $_GET [ 'viewstatut' ] . ')' ;
2005-08-02 09:23:45 +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 " ;
}
if ( strlen ( $_POST [ 'sf_ref' ]) > 0 )
{
2006-02-25 01:43:24 +01:00
$sql .= " AND p.ref like '% " . addslashes ( $_POST [ " sf_ref " ]) . " %' " ;
2005-08-02 09:23:45 +02:00
}
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ', p.ref DESC' ;
$sql .= $db -> plimit ( $limit + 1 , $offset );
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ( $result );
print_barre_liste ( $langs -> trans ( 'ListOfProposals' ), $page , 'propal.php' , '&socidp=' . $socidp , $sortfield , $sortorder , '' , $num );
$i = 0 ;
2005-08-15 18:22:20 +02:00
print '<table class="liste" width="100%">' ;
2005-08-02 09:23:45 +02:00
print '<tr class="liste_titre">' ;
2006-04-08 13:39:41 +02:00
print_liste_field_titre ( $langs -> trans ( 'Ref' ), $_SERVER [ " PHP_SELF " ], 'p.ref' , '' , '&socidp=' . $socidp . '&viewstatut=' . $viewstatut , '' , $sortfield );
print_liste_field_titre ( $langs -> trans ( 'Company' ), $_SERVER [ " PHP_SELF " ], 's.nom' , '' , '&socidp=' . $socidp . '&viewstatut=' . $viewstatut , '' , $sortfield );
print_liste_field_titre ( $langs -> trans ( 'Date' ), $_SERVER [ " PHP_SELF " ], 'p.datep' , '' , '&socidp=' . $socidp . '&viewstatut=' . $viewstatut , 'align="center"' , $sortfield );
print_liste_field_titre ( $langs -> trans ( 'DateEndPropalShort' ), $_SERVER [ " PHP_SELF " ], 'dfv' , '' , '&socidp=' . $socidp . '&viewstatut=' . $viewstatut , 'align="center"' , $sortfield );
print_liste_field_titre ( $langs -> trans ( 'Price' ), $_SERVER [ " PHP_SELF " ], 'p.price' , '' , '&socidp=' . $socidp . '&viewstatut=' . $viewstatut , 'align="right"' , $sortfield );
print_liste_field_titre ( $langs -> trans ( 'Status' ), $_SERVER [ " PHP_SELF " ], 'p.fk_statut' , '' , '&socidp=' . $socidp . '&viewstatut=' . $viewstatut , 'align="right"' , $sortfield );
2005-08-02 09:23:45 +02:00
print " </tr> \n " ;
// Lignes des champs de filtre
2006-04-08 13:39:41 +02:00
print '<form method="get" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2005-08-21 21:07:13 +02:00
2005-08-02 09:23:45 +02:00
print '<tr class="liste_titre">' ;
2005-08-15 18:22:20 +02:00
print '<td class="liste_titre" valign="right">' ;
2005-08-02 09:23:45 +02:00
print '<input class="flat" size="10" type="text" name="search_ref" value="' . $_GET [ 'search_ref' ] . '">' ;
print '</td>' ;
2005-08-15 18:22:20 +02:00
print '<td class="liste_titre" align="left">' ;
2005-08-02 09:23:45 +02:00
print '<input class="flat" type="text" size="40" name="search_societe" value="' . $_GET [ 'search_societe' ] . '">' ;
print '</td>' ;
2005-08-15 18:22:20 +02:00
print '<td class="liste_titre" colspan="2"> </td>' ;
print '<td class="liste_titre" align="right">' ;
2005-08-02 09:23:45 +02:00
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="' . $_GET [ 'search_montant_ht' ] . '">' ;
print '</td>' ;
print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/search.png" alt="' . $langs -> trans ( " Search " ) . '">' ;
print '</td>' ;
print " </tr> \n " ;
print '</form>' ;
$var = true ;
while ( $i < min ( $num , $limit ))
2005-11-04 21:45:02 +01:00
{
$objp = $db -> fetch_object ( $result );
$now = time ();
$var =! $var ;
print '<tr ' . $bc [ $var ] . '>' ;
2006-04-08 13:39:41 +02:00
print '<td><a href="' . $_SERVER [ " PHP_SELF " ] . '?propalid=' . $objp -> propalid . '">' . img_object ( $langs -> trans ( 'ShowPropal' ), 'propal' ) . ' ' . $objp -> ref . " </a></td> \n " ;
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
if ( $objp -> client == 1 )
{
$url = DOL_URL_ROOT . '/comm/fiche.php?socid=' . $objp -> idp ;
}
else
{
$url = DOL_URL_ROOT . '/comm/prospect/fiche.php?socid=' . $objp -> idp ;
}
2006-05-25 16:41:44 +02:00
// Soci<63> t<EFBFBD>
2005-11-04 21:45:02 +01:00
print '<td><a href="' . $url . '">' . img_object ( $langs -> trans ( 'ShowCompany' ), 'company' ) . ' ' . $objp -> nom . '</a></td>' ;
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
// Date propale
print '<td align="center">' ;
$y = strftime ( '%Y' , $objp -> dp );
$m = strftime ( '%m' , $objp -> dp );
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
print strftime ( '%d' , $objp -> dp ) . " \n " ;
2006-04-08 13:39:41 +02:00
print ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?year=' . $y . '&month=' . $m . '">' ;
2005-11-04 21:45:02 +01:00
print dolibarr_print_date ( $objp -> dp , '%b' ) . " </a> \n " ;
2006-04-08 13:39:41 +02:00
print ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?year=' . $y . '">' ;
2005-11-04 21:45:02 +01:00
print strftime ( '%Y' , $objp -> dp ) . " </a></td> \n " ;
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
// Date fin validite
if ( $objp -> dfv )
{
print '<td align="center">' . dolibarr_print_date ( $objp -> dfv );
if ( $objp -> fk_statut == 1 && $objp -> dfv < ( time () - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
print '</td>' ;
}
else
{
print '<td> </td>' ;
}
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
print '<td align="right">' . price ( $objp -> price ) . " </td> \n " ;
$propal = New Propal ( $db );
2006-04-04 03:02:31 +02:00
print '<td align="right">' . $propal -> LibStatut ( $objp -> fk_statut , 5 ) . " </td> \n " ;
2005-11-04 21:45:02 +01:00
print " </tr> \n " ;
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
$total = $total + $objp -> price ;
$subtotal = $subtotal + $objp -> price ;
2006-06-13 00:20:24 +02:00
2005-11-04 21:45:02 +01:00
$i ++ ;
}
2005-08-02 09:23:45 +02:00
print '</table>' ;
$db -> free ( $result );
}
else
{
dolibarr_print_error ( $db );
}
2002-04-30 12:44:42 +02:00
}
$db -> close ();
2004-10-30 00:17:32 +02:00
2005-04-30 16:49:40 +02:00
llxFooter ( '$Date$ - $Revision$' );
2004-10-30 00:17:32 +02:00
2002-04-30 12:44:42 +02:00
?>