2008-08-12 20:20:18 +02:00
< ? php
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2011-01-14 20:28:55 +01:00
* Copyright ( C ) 2004 - 2011 Laurent Destailleur < eldy @ users . sourceforge . net >
2008-08-12 20:20:18 +02:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
* Copyright ( C ) 2005 Marc Barilley / Ocebo < marc @ ocebo . com >
2011-01-14 20:28:55 +01:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis @ dolibarr . fr >
2008-08-12 20:20:18 +02:00
* Copyright ( C ) 2006 Andre Cianfarani < acianfa @ free . fr >
2011-04-08 12:10:08 +02:00
* Copyright ( C ) 2010 - 2011 Juanjo Menent < jmenent @ 2 byte . es >
2011-04-27 10:49:51 +02:00
* Copyright ( C ) 2010 - 2011 Philippe Grand < philippe . grand @ atoo - net . com >
2008-08-12 20:20:18 +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
2011-08-03 02:45:22 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2008-08-12 20:20:18 +02:00
*/
/**
2008-10-28 21:05:23 +01:00
* \file htdocs / comm / propal . php
* \ingroup propale
2010-02-27 13:05:47 +01:00
* \brief Page of commercial proposals card and list
2008-08-12 20:20:18 +02:00
*/
2010-03-27 03:35:08 +01:00
require ( " ../main.inc.php " );
2010-04-30 08:57:28 +02:00
require_once ( DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' );
2008-08-12 20:20:18 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /includes/modules/propale/modules_propale.php " );
2010-06-05 17:20:09 +02:00
require_once ( DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' );
2011-05-20 17:59:18 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /core/class/html.formother.class.php " );
2010-05-03 10:43:32 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /core/class/html.formfile.class.php " );
2008-08-12 20:20:18 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/propal.lib.php " );
2009-01-07 11:57:36 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/functions2.lib.php " );
2010-04-30 08:57:28 +02:00
if ( $conf -> projet -> enabled ) require_once ( DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' );
2008-08-12 20:20:18 +02:00
$langs -> load ( 'companies' );
$langs -> load ( 'propal' );
$langs -> load ( 'compta' );
$langs -> load ( 'bills' );
$langs -> load ( 'orders' );
$langs -> load ( 'products' );
2011-03-11 15:59:35 +01:00
$id = GETPOST ( 'id' );
$ref = GETPOST ( 'ref' );
$socid = GETPOST ( 'socid' );
$action = GETPOST ( 'action' );
$confirm = GETPOST ( 'confirm' );
2011-04-18 17:06:23 +02:00
$lineid = GETPOST ( 'lineid' );
2011-03-11 15:59:35 +01:00
2011-01-31 17:35:55 +01:00
$sall = GETPOST ( " sall " );
2011-01-31 18:08:12 +01:00
$mesg = ( GETPOST ( " msg " ) ? GETPOST ( " msg " ) : GETPOST ( " mesg " ));
2011-01-31 17:35:55 +01:00
$year = GETPOST ( " year " );
$month = GETPOST ( " month " );
2008-08-12 20:20:18 +02:00
2011-06-30 00:29:50 +02:00
// Nombre de ligne pour choix de produit/service predefinis
$NBLINES = 4 ;
$object = new Propal ( $db );
2008-08-12 20:20:18 +02:00
// Security check
$module = 'propale' ;
2011-03-11 15:59:35 +01:00
if ( isset ( $socid ))
2008-08-12 20:20:18 +02:00
{
2011-03-11 15:59:35 +01:00
$objectid = $socid ;
2008-08-12 20:20:18 +02:00
$module = 'societe' ;
$dbtable = '' ;
}
2011-03-11 15:59:35 +01:00
else if ( isset ( $id ) && $id > 0 )
2008-08-12 20:20:18 +02:00
{
2011-03-11 15:59:35 +01:00
$objectid = $id ;
2008-08-12 20:20:18 +02:00
$module = 'propale' ;
$dbtable = 'propal' ;
}
if ( $user -> societe_id ) $socid = $user -> societe_id ;
$result = restrictedArea ( $user , $module , $objectid , $dbtable );
2011-08-10 12:55:34 +02:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
include_once ( DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php' );
$hookmanager = new HookManager ( $db );
$hookmanager -> callHooks ( array ( 'propalcard' ));
2010-08-06 18:10:03 +02:00
2008-08-12 20:20:18 +02:00
/******************************************************************************/
/* Actions */
/******************************************************************************/
2011-08-11 00:47:33 +02:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2010-08-07 12:15:34 +02:00
2009-01-14 16:53:52 +01:00
// Action clone object
2011-04-25 12:10:34 +02:00
if ( $action == 'confirm_clone' && $confirm == 'yes' )
2009-01-14 16:53:52 +01:00
{
2011-04-25 12:10:34 +02:00
if ( 1 == 0 && ! GETPOST ( 'clone_content' ) && ! GETPOST ( 'clone_receivers' ) )
2009-01-14 16:53:52 +01:00
{
$mesg = '<div class="error">' . $langs -> trans ( " NoCloneOptionsSpecified " ) . '</div>' ;
}
else
{
2011-08-10 21:55:21 +02:00
$result = $object -> createFromClone ( $id , 0 , GETPOST ( 'socid' ), $hookmanager );
2009-01-14 16:53:52 +01:00
if ( $result > 0 )
{
2010-06-30 17:01:18 +02:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $result );
2009-01-14 16:53:52 +01:00
exit ;
}
else
{
2010-09-18 11:40:24 +02:00
$mesg = $object -> error ;
2011-04-28 19:15:03 +02:00
$action = '' ;
//$_GET['id']=$_REQUEST['id'];
2009-01-14 16:53:52 +01:00
}
}
}
2008-08-12 20:20:18 +02:00
// Suppression de la propale
2011-04-28 19:15:03 +02:00
if ( $action == 'confirm_delete' && $confirm == 'yes' )
2008-08-12 20:20:18 +02:00
{
if ( $user -> rights -> propale -> supprimer )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$result = $object -> delete ( $user );
2010-06-30 17:01:18 +02:00
$id = 0 ;
2008-08-12 20:20:18 +02:00
$brouillon = 1 ;
2008-12-30 23:42:28 +01:00
if ( $result > 0 )
{
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ]);
exit ;
}
else
{
$langs -> load ( " errors " );
2010-09-18 11:40:24 +02:00
if ( $object -> error == 'ErrorFailToDeleteDir' ) $mesg = '<div class="error">' . $langs -> trans ( 'ErrorFailedToDeleteJoinedFiles' ) . '</div>' ;
else $mesg = '<div class="error">' . $object -> error . '</div>' ;
2008-12-30 23:42:28 +01:00
}
2008-08-12 20:20:18 +02:00
}
}
2009-03-04 01:14:51 +01:00
// Remove line
2011-04-28 19:15:03 +02:00
if ( $action == 'confirm_deleteline' && $confirm == 'yes' )
2008-08-12 20:20:18 +02:00
{
if ( $user -> rights -> propale -> creer )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
2011-04-28 19:15:03 +02:00
$result = $object -> deleteline ( $lineid );
2010-07-02 17:38:32 +02:00
// reorder lines
2010-09-18 11:40:24 +02:00
if ( $result ) $object -> line_order ( true );
2008-10-29 00:36:36 +01:00
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2010-09-14 22:27:47 +02:00
2010-09-18 11:40:24 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id );
2010-09-08 15:17:28 +02:00
exit ;
2008-08-12 20:20:18 +02:00
}
2009-05-06 19:09:45 +02:00
else
{
2010-09-18 11:40:24 +02:00
$mesg = '<div class="error">' . $object -> error . '</div>' ;
2009-05-06 19:09:45 +02:00
}
2008-08-12 20:20:18 +02:00
}
2009-03-04 01:14:51 +01:00
// Validation
2011-04-28 19:15:03 +02:00
if ( $action == 'confirm_validate' && $confirm == 'yes' && $user -> rights -> propale -> valider )
2008-08-12 20:20:18 +02:00
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
2008-08-12 20:20:18 +02:00
2010-09-18 11:40:24 +02:00
$result = $object -> valid ( $user );
2008-08-12 20:20:18 +02:00
if ( $result >= 0 )
{
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 13:05:47 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 13:05:47 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 13:05:47 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2008-08-12 20:20:18 +02:00
}
else
{
2010-09-18 11:40:24 +02:00
$mesg = '<div class="error">' . $object -> error . '</div>' ;
2008-08-12 20:20:18 +02:00
}
}
2009-03-04 01:14:51 +01:00
if ( $_POST [ 'action' ] == 'setdate' )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$result = $object -> set_date ( $user , dol_mktime ( 12 , 0 , 0 , $_POST [ 'remonth' ], $_POST [ 'reday' ], $_POST [ 'reyear' ]));
if ( $result < 0 ) dol_print_error ( $db , $object -> error );
2009-03-04 01:14:51 +01:00
}
2008-08-12 20:20:18 +02:00
if ( $_POST [ 'action' ] == 'setecheance' )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$result = $object -> set_echeance ( $user , dol_mktime ( 12 , 0 , 0 , $_POST [ 'echmonth' ], $_POST [ 'echday' ], $_POST [ 'echyear' ]));
if ( $result < 0 ) dol_print_error ( $db , $object -> error );
2008-08-12 20:20:18 +02:00
}
if ( $_POST [ 'action' ] == 'setdate_livraison' )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$result = $object -> set_date_livraison ( $user , dol_mktime ( 12 , 0 , 0 , $_POST [ 'liv_month' ], $_POST [ 'liv_day' ], $_POST [ 'liv_year' ]));
if ( $result < 0 ) dol_print_error ( $db , $object -> error );
2008-08-12 20:20:18 +02:00
}
2010-08-07 13:52:53 +02:00
if ( $_POST [ 'action' ] == 'setaddress' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$result = $object -> set_adresse_livraison ( $user , $_POST [ 'fk_address' ]);
if ( $result < 0 ) dol_print_error ( $db , $object -> error );
2008-08-12 20:20:18 +02:00
}
// Positionne ref client
if ( $_POST [ 'action' ] == 'set_ref_client' && $user -> rights -> propale -> creer )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> set_ref_client ( $user , $_POST [ 'ref_client' ]);
2008-08-12 20:20:18 +02:00
}
/*
* Creation propale
*/
if ( $_POST [ 'action' ] == 'add' && $user -> rights -> propale -> creer )
{
2010-09-18 11:40:24 +02:00
$object -> socid = $_POST [ 'socid' ];
$object -> fetch_thirdparty ();
2008-08-12 20:20:18 +02:00
$db -> begin ();
// Si on a selectionne une propal a copier, on realise la copie
if ( $_POST [ 'createmode' ] == 'copy' && $_POST [ 'copie_propal' ])
{
2010-09-18 11:40:24 +02:00
if ( $object -> fetch ( $_POST [ 'copie_propal' ]) > 0 )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$object -> ref = $_POST [ 'ref' ];
$object -> datep = dol_mktime ( 12 , 0 , 0 , $_POST [ 'remonth' ], $_POST [ 'reday' ], $_POST [ 'reyear' ]);
$object -> date_livraison = dol_mktime ( 12 , 0 , 0 , $_POST [ 'liv_month' ], $_POST [ 'liv_day' ], $_POST [ 'liv_year' ]);
2011-04-06 17:36:45 +02:00
$object -> availability_id = $_POST [ 'availability_id' ];
2011-04-27 10:49:51 +02:00
$object -> demand_reason_id = $_POST [ 'demand_reason_id' ];
2010-09-18 11:40:24 +02:00
$object -> fk_delivery_address = $_POST [ 'fk_address' ];
$object -> duree_validite = $_POST [ 'duree_validite' ];
$object -> cond_reglement_id = $_POST [ 'cond_reglement_id' ];
$object -> mode_reglement_id = $_POST [ 'mode_reglement_id' ];
$object -> remise_percent = $_POST [ 'remise_percent' ];
$object -> remise_absolue = $_POST [ 'remise_absolue' ];
$object -> socid = $_POST [ 'socid' ];
$object -> contactid = $_POST [ 'contactidp' ];
$object -> fk_project = $_POST [ 'projectid' ];
$object -> modelpdf = $_POST [ 'model' ];
$object -> author = $user -> id ; // deprecated
$object -> note = $_POST [ 'note' ];
$object -> statut = 0 ;
$id = $object -> create_from ( $user );
2008-08-12 20:20:18 +02:00
}
else
{
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFailedToCopyProposal " , $_POST [ 'copie_propal' ]) . '</div>' ;
}
}
else
{
2010-09-18 11:40:24 +02:00
$object -> ref = $_POST [ 'ref' ];
$object -> ref_client = $_POST [ 'ref_client' ];
$object -> datep = dol_mktime ( 12 , 0 , 0 , $_POST [ 'remonth' ], $_POST [ 'reday' ], $_POST [ 'reyear' ]);
$object -> date_livraison = dol_mktime ( 12 , 0 , 0 , $_POST [ 'liv_month' ], $_POST [ 'liv_day' ], $_POST [ 'liv_year' ]);
2011-04-06 17:36:45 +02:00
$object -> availability_id = $_POST [ 'availability_id' ];
2011-04-27 10:49:51 +02:00
$object -> demand_reason_id = $_POST [ 'demand_reason_id' ];
2010-09-18 11:40:24 +02:00
$object -> fk_delivery_address = $_POST [ 'fk_address' ];
$object -> duree_validite = $_POST [ 'duree_validite' ];
$object -> cond_reglement_id = $_POST [ 'cond_reglement_id' ];
$object -> mode_reglement_id = $_POST [ 'mode_reglement_id' ];
2008-08-12 20:20:18 +02:00
2010-09-18 11:40:24 +02:00
$object -> contactid = $_POST [ 'contactidp' ];
$object -> fk_project = $_POST [ 'projectid' ];
$object -> modelpdf = $_POST [ 'model' ];
$object -> author = $user -> id ; // deprecated
$object -> note = $_POST [ 'note' ];
2010-05-01 16:28:48 +02:00
2010-09-18 11:40:24 +02:00
$object -> origin = $_POST [ 'origin' ];
$object -> origin_id = $_POST [ 'originid' ];
2008-08-12 20:20:18 +02:00
2010-06-02 10:43:35 +02:00
for ( $i = 1 ; $i <= $conf -> global -> PRODUCT_SHOW_WHEN_CREATE ; $i ++ )
2008-08-12 20:20:18 +02:00
{
if ( $_POST [ 'idprod' . $i ])
{
$xid = 'idprod' . $i ;
$xqty = 'qty' . $i ;
$xremise = 'remise' . $i ;
2010-09-18 11:40:24 +02:00
$object -> add_product ( $_POST [ $xid ], $_POST [ $xqty ], $_POST [ $xremise ]);
2008-08-12 20:20:18 +02:00
}
}
2010-09-18 11:40:24 +02:00
$id = $object -> create ( $user );
2008-08-12 20:20:18 +02:00
}
if ( $id > 0 )
{
$error = 0 ;
// Insertion contact par defaut si defini
if ( $_POST [ " contactidp " ])
{
2010-09-18 11:40:24 +02:00
$result = $object -> add_contact ( $_POST [ " contactidp " ], 'CUSTOMER' , 'external' );
2008-08-12 20:20:18 +02:00
if ( $result > 0 )
{
$error = 0 ;
}
else
{
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFailedToAddContact " ) . '</div>' ;
$error = 1 ;
}
}
if ( ! $error )
{
$db -> commit ();
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2010-02-27 14:37:13 +01:00
2010-06-30 17:01:18 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id );
2008-08-12 20:20:18 +02:00
exit ;
}
else
{
$db -> rollback ();
}
}
else
{
2010-09-18 11:40:24 +02:00
dol_print_error ( $db , $object -> error );
2008-08-12 20:20:18 +02:00
$db -> rollback ();
exit ;
}
}
2010-09-10 18:51:33 +02:00
// Classify billed
2011-04-28 19:15:03 +02:00
if ( $action == 'classifybilled' )
2010-09-10 18:51:33 +02:00
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> cloture ( $user , 4 , '' );
2010-09-10 18:51:33 +02:00
}
2008-08-12 20:20:18 +02:00
/*
* Cloture de la propale
*/
2011-01-31 17:35:55 +01:00
if ( GETPOST ( 'action' ) == 'setstatut' && $user -> rights -> propale -> cloturer )
2008-08-12 20:20:18 +02:00
{
if ( ! $_POST [ 'cancel' ])
{
2011-01-31 17:35:55 +01:00
if ( ! GETPOST ( 'statut' ))
2008-08-12 20:20:18 +02:00
{
2008-09-09 01:48:01 +02:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " CloseAs " )) . '</div>' ;
2011-04-28 19:15:03 +02:00
$action = 'statut' ;
$action = 'statut' ;
2008-09-09 01:48:01 +02:00
}
else
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2008-09-09 01:48:01 +02:00
// prevent browser refresh from closing proposal several times
2010-09-18 11:40:24 +02:00
if ( $object -> statut == 1 )
2008-09-09 01:48:01 +02:00
{
2010-09-18 11:40:24 +02:00
$object -> cloture ( $user , $_REQUEST [ 'statut' ], $_REQUEST [ 'note' ]);
2008-09-09 01:48:01 +02:00
}
2008-08-12 20:20:18 +02:00
}
}
}
/*
2010-01-13 11:30:33 +01:00
* Add file in email form
2008-08-12 20:20:18 +02:00
*/
if ( $_POST [ 'addfile' ])
{
2010-05-01 16:28:48 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/files.lib.php " );
2010-05-12 13:29:21 +02:00
// Set tmp user directory TODO Use a dedicated directory for temp mails files
2009-10-14 18:13:20 +02:00
$vardir = $conf -> user -> dir_output . " / " . $user -> id ;
2011-07-10 22:03:38 +02:00
$upload_dir_tmp = $vardir . '/temp' ;
2008-08-12 20:20:18 +02:00
2011-07-10 22:03:38 +02:00
$mesg = dol_add_file_process ( $upload_dir_tmp , 0 , 0 );
2008-08-12 20:20:18 +02:00
2011-04-28 19:15:03 +02:00
$action = 'presend' ;
2010-05-12 13:29:21 +02:00
$_POST [ " action " ] = 'presend' ;
2008-08-12 20:20:18 +02:00
}
2010-01-13 11:30:33 +01:00
/*
* Remove file in email form
*/
if ( ! empty ( $_POST [ 'removedfile' ]))
{
2010-05-12 13:29:21 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/files.lib.php " );
2010-01-13 11:30:33 +01:00
// Set tmp user directory
$vardir = $conf -> user -> dir_output . " / " . $user -> id ;
2011-07-10 22:03:38 +02:00
$upload_dir_tmp = $vardir . '/temp' ;
2010-01-13 11:30:33 +01:00
2010-05-12 13:29:21 +02:00
$mesg = dol_remove_file_process ( $_POST [ 'removedfile' ], 0 );
2010-01-13 11:30:33 +01:00
2011-04-28 19:15:03 +02:00
$action = 'presend' ;
2010-05-12 13:29:21 +02:00
$_POST [ " action " ] = 'presend' ;
2010-01-13 11:30:33 +01:00
}
2008-08-12 20:20:18 +02:00
/*
* Send mail
*/
2010-01-13 11:30:33 +01:00
if ( $_POST [ 'action' ] == 'send' && ! $_POST [ 'addfile' ] && ! $_POST [ 'removedfile' ] && ! $_POST [ 'cancel' ])
2008-08-12 20:20:18 +02:00
{
$langs -> load ( 'mails' );
2010-09-18 11:40:24 +02:00
$result = $object -> fetch ( $_POST [ " id " ]);
$result = $object -> fetch_thirdparty ();
2010-05-12 13:58:58 +02:00
if ( $result > 0 )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$objectref = dol_sanitizeFileName ( $object -> ref );
$file = $conf -> propale -> dir_output . '/' . $objectref . '/' . $objectref . '.pdf' ;
2008-08-12 20:20:18 +02:00
if ( is_readable ( $file ))
{
if ( $_POST [ 'sendto' ])
{
// Le destinataire a ete fourni via le champ libre
$sendto = $_POST [ 'sendto' ];
$sendtoid = 0 ;
}
2011-07-07 23:32:18 +02:00
elseif ( $_POST [ 'receiver' ] != '-1' )
2008-08-12 20:20:18 +02:00
{
2011-07-07 23:32:18 +02:00
// Recipient was provided from combo list
if ( $_POST [ 'receiver' ] == 'thirdparty' ) // Id of third party
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$sendto = $object -> client -> email ;
2008-08-12 20:20:18 +02:00
$sendtoid = 0 ;
}
else // Id du contact
{
2011-03-05 17:27:26 +01:00
$sendto = $object -> client -> contact_get_property ( $_POST [ 'receiver' ], 'email' );
2008-08-12 20:20:18 +02:00
$sendtoid = $_POST [ 'receiver' ];
}
}
2010-08-24 16:42:18 +02:00
if ( dol_strlen ( $sendto ))
2008-08-12 20:20:18 +02:00
{
$langs -> load ( " commercial " );
$from = $_POST [ 'fromname' ] . ' <' . $_POST [ 'frommail' ] . '>' ;
$replyto = $_POST [ 'replytoname' ] . ' <' . $_POST [ 'replytomail' ] . '>' ;
$message = $_POST [ 'message' ];
$sendtocc = $_POST [ 'sendtocc' ];
$deliveryreceipt = $_POST [ 'deliveryreceipt' ];
if ( $_POST [ 'action' ] == 'send' )
{
2010-08-24 16:42:18 +02:00
if ( dol_strlen ( $_POST [ 'subject' ])) $subject = $_POST [ 'subject' ];
2010-09-18 11:40:24 +02:00
else $subject = $langs -> transnoentities ( 'Propal' ) . ' ' . $object -> ref ;
2008-08-12 20:20:18 +02:00
$actiontypecode = 'AC_PROP' ;
$actionmsg = $langs -> transnoentities ( 'MailSentBy' ) . ' ' . $from . ' ' . $langs -> transnoentities ( 'To' ) . ' ' . $sendto . " . \n " ;
if ( $message )
{
$actionmsg .= $langs -> transnoentities ( 'MailTopic' ) . " : " . $subject . " \n " ;
$actionmsg .= $langs -> transnoentities ( 'TextUsedInTheMessageBody' ) . " : \n " ;
$actionmsg .= $message ;
}
$actionmsg2 = $langs -> transnoentities ( 'Action' . $actiontypecode );
}
// Create form object
2010-05-12 13:58:58 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' );
2008-08-12 20:20:18 +02:00
$formmail = new FormMail ( $db );
$attachedfiles = $formmail -> get_attached_files ();
$filepath = $attachedfiles [ 'paths' ];
$filename = $attachedfiles [ 'names' ];
$mimetype = $attachedfiles [ 'mimes' ];
// Envoi de la propal
require_once ( DOL_DOCUMENT_ROOT . '/lib/CMailFile.class.php' );
$mailfile = new CMailFile ( $subject , $sendto , $from , $message , $filepath , $mimetype , $filename , $sendtocc , '' , $deliveryreceipt );
if ( $mailfile -> error )
{
$mesg = '<div class="error">' . $mailfile -> error . '</div>' ;
}
else
{
$result = $mailfile -> sendfile ();
if ( $result )
{
2011-07-02 18:48:31 +02:00
$mesg = $langs -> trans ( 'MailSuccessfulySent' , $mailfile -> getValidAddress ( $from , 2 ), $mailfile -> getValidAddress ( $sendto , 2 )); // Must not contain "
2008-08-12 20:20:18 +02:00
$error = 0 ;
// Initialisation donnees
2011-06-04 15:12:44 +02:00
$object -> sendtoid = $sendtoid ;
$object -> actiontypecode = $actiontypecode ;
$object -> actionmsg = $actionmsg ;
$object -> actionmsg2 = $actionmsg2 ;
$object -> fk_element = $object -> id ;
$object -> elementtype = $object -> element ;
2008-08-12 20:20:18 +02:00
// Appel des triggers
2010-04-28 12:33:16 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
2008-08-12 20:20:18 +02:00
$interface = new Interfaces ( $db );
2010-09-18 11:40:24 +02:00
$result = $interface -> run_triggers ( 'PROPAL_SENTBYMAIL' , $object , $user , $langs , $conf );
2008-08-12 20:20:18 +02:00
if ( $result < 0 ) { $error ++ ; $this -> errors = $interface -> errors ; }
// Fin appel triggers
if ( $error )
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2008-08-12 20:20:18 +02:00
}
else
{
// Redirect here
// This avoid sending mail twice if going out and then back to page
2010-09-18 11:40:24 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&mesg=' . urlencode ( $mesg ));
2008-08-12 20:20:18 +02:00
exit ;
}
}
else
{
$langs -> load ( " other " );
$mesg = '<div class="error">' ;
if ( $mailfile -> error )
{
$mesg .= $langs -> trans ( 'ErrorFailedToSendMail' , $from , $sendto );
$mesg .= '<br>' . $mailfile -> error ;
}
else
{
$mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS' ;
}
$mesg .= '</div>' ;
}
}
}
else
{
$langs -> load ( " other " );
$mesg = '<div class="error">' . $langs -> trans ( 'ErrorMailRecipientIsEmpty' ) . ' !</div>' ;
2009-02-20 23:53:15 +01:00
dol_syslog ( 'Recipient email is empty' );
2008-08-12 20:20:18 +02:00
}
}
else
{
$langs -> load ( " other " );
$mesg = '<div class="error">' . $langs -> trans ( 'ErrorCantReadFile' , $file ) . '</div>' ;
2009-02-20 23:53:15 +01:00
dol_syslog ( 'Failed to read file: ' . $file );
2008-08-12 20:20:18 +02:00
}
}
else
{
$langs -> load ( " other " );
$mesg = '<div class="error">' . $langs -> trans ( 'ErrorFailedToReadEntity' , $langs -> trans ( " Proposal " )) . '</div>' ;
2009-02-20 23:53:15 +01:00
dol_syslog ( 'Impossible de lire les donnees de la facture. Le fichier propal n\'a peut-etre pas ete genere.' );
2008-08-12 20:20:18 +02:00
}
}
2011-04-28 19:15:03 +02:00
if ( $action == 'modif' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
/*
* Repasse la propale en mode brouillon
*/
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
$object -> set_draft ( $user );
2008-08-12 20:20:18 +02:00
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2010-02-27 14:37:13 +01:00
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2008-08-12 20:20:18 +02:00
}
if ( $_POST [ 'action' ] == " setabsolutediscount " && $user -> rights -> propale -> creer )
{
if ( $_POST [ " remise_id " ])
{
2011-04-28 19:15:03 +02:00
$object -> id = $id ;
$ret = $object -> fetch ( $id );
2008-08-12 20:20:18 +02:00
if ( $ret > 0 )
{
2010-09-18 11:40:24 +02:00
$result = $object -> insert_discount ( $_POST [ " remise_id " ]);
2008-08-12 20:20:18 +02:00
if ( $result < 0 )
{
2010-09-18 11:40:24 +02:00
$mesg = '<div class="error">' . $object -> error . '</div>' ;
2008-08-12 20:20:18 +02:00
}
}
else
{
2010-09-18 11:40:24 +02:00
dol_print_error ( $db , $object -> error );
2008-08-12 20:20:18 +02:00
}
}
}
/*
* Ajout d ' une ligne produit dans la propale
*/
2009-05-27 17:52:08 +02:00
if ( $_POST [ 'action' ] == " addline " && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2009-06-04 02:59:06 +02:00
$result = 0 ;
if ( empty ( $_POST [ 'idprod' ]) && $_POST [ " type " ] < 0 )
{
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Type " )) . '</div>' ;
$result = - 1 ;
}
2010-06-08 10:27:57 +02:00
if ( empty ( $_POST [ 'idprod' ]) && ( ! isset ( $_POST [ " np_price " ]) || $_POST [ " np_price " ] == '' )) // Unit price can be 0 but not ''
2009-06-04 02:59:06 +02:00
{
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " UnitPriceHT " )) . '</div>' ;
$result = - 1 ;
}
2010-06-08 10:27:57 +02:00
if ( $result >= 0 && isset ( $_POST [ 'qty' ]) && (( $_POST [ 'np_price' ] != '' && ( $_POST [ 'np_desc' ] || $_POST [ 'dp_desc' ])) || $_POST [ 'idprod' ]))
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$ret = $object -> fetch ( $_POST [ " id " ]);
2008-08-12 20:20:18 +02:00
if ( $ret < 0 )
{
2010-09-18 11:40:24 +02:00
dol_print_error ( $db , $object -> error );
2008-08-12 20:20:18 +02:00
exit ;
}
2010-09-18 11:40:24 +02:00
$ret = $object -> fetch_thirdparty ();
2010-06-08 10:27:57 +02:00
$price_base_type = 'HT' ;
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
if ( $_POST [ 'idprod' ])
2008-08-12 20:20:18 +02:00
{
2011-09-11 20:35:38 +02:00
$prod = new Product ( $db );
2010-06-08 10:27:57 +02:00
$prod -> fetch ( $_POST [ 'idprod' ]);
2010-09-18 11:40:24 +02:00
$tva_tx = get_default_tva ( $mysoc , $object -> client , $prod -> id );
$localtax1_tx = get_localtax ( $tva_tx , 1 , $object -> client ); //get_default_localtax($mysoc,$object->client,1,$prod->id);
$localtax2_tx = get_localtax ( $tva_tx , 2 , $object -> client ); //get_default_localtax($mysoc,$object->client,2,$prod->id);
$tva_npr = get_default_npr ( $mysoc , $object -> client , $prod -> id );
2010-06-08 10:27:57 +02:00
// On defini prix unitaire
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> PRODUIT_MULTIPRICES && $object -> client -> price_level )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$pu_ht = $prod -> multiprices [ $object -> client -> price_level ];
$pu_ttc = $prod -> multiprices_ttc [ $object -> client -> price_level ];
2011-01-29 17:26:56 +01:00
$price_min = $prod -> multiprices_min [ $object -> client -> price_level ];
2010-09-18 11:40:24 +02:00
$price_base_type = $prod -> multiprices_base_type [ $object -> client -> price_level ];
2010-06-07 11:29:42 +02:00
}
else
{
2010-06-08 10:27:57 +02:00
$pu_ht = $prod -> price ;
$pu_ttc = $prod -> price_ttc ;
2011-01-29 17:26:56 +01:00
$price_min = $prod -> price_min ;
2010-06-08 10:27:57 +02:00
$price_base_type = $prod -> price_base_type ;
2010-06-07 11:29:42 +02:00
}
2010-06-08 10:27:57 +02:00
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ( $tva_tx != $prod -> tva_tx )
2010-06-07 11:29:42 +02:00
{
2010-06-08 10:27:57 +02:00
if ( $price_base_type != 'HT' )
{
$pu_ht = price2num ( $pu_ttc / ( 1 + ( $tva_tx / 100 )), 'MU' );
}
else
{
$pu_ttc = price2num ( $pu_ht * ( 1 + ( $tva_tx / 100 )), 'MU' );
}
2008-08-12 20:20:18 +02:00
}
2010-06-08 10:27:57 +02:00
$desc = $prod -> description ;
2011-08-31 17:30:56 +02:00
$desc .= ( $prod -> description && $_POST [ 'np_desc' ]) ? (( dol_textishtml ( $prod -> description ) || dol_textishtml ( $_POST [ 'np_desc' ])) ? " <br> \n " : " \n " ) : " " ;
2010-06-08 10:27:57 +02:00
$desc .= $_POST [ 'np_desc' ];
$type = $prod -> type ;
2008-08-12 20:20:18 +02:00
}
2010-06-08 10:27:57 +02:00
else
2008-08-12 20:20:18 +02:00
{
2010-06-08 10:27:57 +02:00
$pu_ht = $_POST [ 'np_price' ];
$tva_tx = str_replace ( '*' , '' , $_POST [ 'np_tva_tx' ]);
$tva_npr = preg_match ( '/\*/' , $_POST [ 'np_tva_tx' ]) ? 1 : 0 ;
2008-08-12 20:20:18 +02:00
$desc = $_POST [ 'dp_desc' ];
2009-03-12 23:33:26 +01:00
$type = $_POST [ " type " ];
2010-09-18 11:40:24 +02:00
$localtax1_tx = get_localtax ( $tva_tx , 1 , $object -> client );
$localtax2_tx = get_localtax ( $tva_tx , 2 , $object -> client );
2010-06-08 10:27:57 +02:00
}
$info_bits = 0 ;
if ( $tva_npr ) $info_bits |= 0x01 ;
2010-08-28 01:42:10 +02:00
2011-01-29 17:26:56 +01:00
if ( $price_min && ( price2num ( $pu_ht ) * ( 1 - price2num ( $_POST [ 'remise_percent' ]) / 100 ) < price2num ( $price_min )))
2010-06-08 10:27:57 +02:00
{
2011-01-29 17:26:56 +01:00
$mesg = '<div class="error">' . $langs -> trans ( " CantBeLessThanMinPrice " , price2num ( $price_min , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie )) . '</div>' ;
2010-06-08 10:27:57 +02:00
}
else
{
2008-08-28 01:00:37 +02:00
// Insert line
2010-09-18 11:40:24 +02:00
$result = $object -> addline (
2010-06-30 17:01:18 +02:00
$_POST [ " id " ],
2008-08-28 01:00:37 +02:00
$desc ,
2010-06-08 10:27:57 +02:00
$pu_ht ,
$_POST [ 'qty' ],
$tva_tx ,
2010-06-17 19:12:34 +02:00
$localtax1_tx ,
$localtax2_tx ,
2010-06-08 10:27:57 +02:00
$_POST [ 'idprod' ],
$_POST [ 'remise_percent' ],
$price_base_type ,
$pu_ttc ,
$info_bits ,
2011-04-06 09:32:54 +02:00
$type ,
- 1 ,
0 ,
$_POST [ 'fk_parent_line' ]
2008-08-28 01:00:37 +02:00
);
2010-06-08 10:27:57 +02:00
if ( $result > 0 )
2008-08-28 01:00:37 +02:00
{
2010-06-08 10:27:57 +02:00
// Define output language
$outputlangs = $langs ;
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-06-08 10:27:57 +02:00
if ( ! empty ( $newlang ))
{
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( $newlang );
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2010-06-08 10:27:57 +02:00
unset ( $_POST [ 'qty' ]);
unset ( $_POST [ 'type' ]);
unset ( $_POST [ 'np_price' ]);
unset ( $_POST [ 'dp_desc' ]);
unset ( $_POST [ 'np_tva_tx' ]);
}
else
{
2010-09-18 11:40:24 +02:00
$mesg = '<div class="error">' . $object -> error . '</div>' ;
2008-08-28 01:00:37 +02:00
}
2008-08-12 20:20:18 +02:00
}
}
}
/*
* Mise a jour d ' une ligne dans la propale
*/
if ( $_POST [ 'action' ] == 'updateligne' && $user -> rights -> propale -> creer && $_POST [ " save " ] == $langs -> trans ( " Save " ))
{
2010-09-18 11:40:24 +02:00
if ( ! $object -> fetch ( $_POST [ " id " ]) > 0 )
2008-09-08 14:51:29 +02:00
{
2010-09-18 11:40:24 +02:00
dol_print_error ( $db , $object -> error );
2008-09-08 14:51:29 +02:00
exit ;
}
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
2010-06-08 10:27:57 +02:00
// Define info_bits
$info_bits = 0 ;
if ( preg_match ( '/\*/' , $_POST [ 'tva_tx' ])) $info_bits |= 0x01 ;
// Define vat_rate
$vat_rate = $_POST [ 'tva_tx' ];
$vat_rate = str_replace ( '*' , '' , $vat_rate );
2010-09-18 11:40:24 +02:00
$localtax1_rate = get_localtax ( $vat_rate , 1 , $object -> client );
$localtax2_rate = get_localtax ( $vat_rate , 2 , $object -> client );
2010-10-31 19:57:11 +01:00
$up_ht = GETPOST ( 'pu' ) ? GETPOST ( 'pu' ) : GETPOST ( 'subprice' );
2010-06-08 10:27:57 +02:00
2011-08-08 03:53:25 +02:00
// Define special_code for special lines
$special_code = 0 ;
if ( empty ( $_POST [ 'qty' ])) $special_code = 3 ;
2010-06-08 10:27:57 +02:00
// On verifie que le prix minimum est respecte
$productid = $_POST [ 'productid' ] ;
if ( $productid )
2008-09-08 14:51:29 +02:00
{
2010-06-08 10:27:57 +02:00
$product = new Product ( $db ) ;
$res = $product -> fetch ( $productid ) ;
2011-01-29 17:26:56 +01:00
$price_min = $product -> price_min ;
if ( $conf -> global -> PRODUIT_MULTIPRICES && $object -> client -> price_level ) $price_min = $product -> multiprices_min [ $object -> client -> price_level ];
2008-09-08 14:51:29 +02:00
}
2011-01-29 17:26:56 +01:00
if ( $productid && $price_min && ( price2num ( $up_ht ) * ( 1 - price2num ( $_POST [ 'remise_percent' ]) / 100 ) < price2num ( $price_min )))
2008-08-12 20:20:18 +02:00
{
2011-01-29 17:26:56 +01:00
$mesg = '<div class="error">' . $langs -> trans ( " CantBeLessThanMinPrice " , price2num ( $price_min , 'MU' ) . ' ' . $langs -> trans ( " Currency " . $conf -> monnaie )) . '</div>' ;
2008-08-28 01:00:37 +02:00
}
2010-06-08 10:27:57 +02:00
else
2008-08-28 01:00:37 +02:00
{
2010-09-18 11:40:24 +02:00
$result = $object -> updateline ( $_POST [ 'lineid' ],
2010-10-31 19:57:11 +01:00
$up_ht ,
2010-06-08 10:27:57 +02:00
$_POST [ 'qty' ],
$_POST [ 'remise_percent' ],
$vat_rate ,
2010-06-17 19:12:34 +02:00
$localtax1_rate ,
$localtax2_rate ,
2010-06-08 10:27:57 +02:00
$_POST [ 'desc' ],
2010-10-31 19:57:11 +01:00
'HT' ,
2011-04-08 12:10:08 +02:00
$info_bits ,
2011-08-08 03:53:25 +02:00
$special_code ,
2011-04-08 12:10:08 +02:00
$_POST [ 'fk_parent_line' ]
);
2010-06-08 10:27:57 +02:00
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-28 01:00:37 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-28 01:00:37 +02:00
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2008-08-12 20:20:18 +02:00
}
}
/*
* Generation doc ( depuis lien ou depuis cartouche doc )
*/
2011-04-28 19:15:03 +02:00
if ( $action == 'builddoc' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
2010-02-27 14:37:13 +01:00
2008-08-12 20:20:18 +02:00
if ( $_REQUEST [ 'model' ])
{
2010-09-18 11:40:24 +02:00
$object -> setDocModel ( $user , $_REQUEST [ 'model' ]);
2008-08-12 20:20:18 +02:00
}
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2011-08-10 19:40:42 +02:00
$result = propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2008-08-12 20:20:18 +02:00
if ( $result <= 0 )
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db , $result );
2008-08-12 20:20:18 +02:00
exit ;
}
else
{
2010-09-18 11:40:24 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . ( empty ( $conf -> global -> MAIN_JUMP_TAG ) ? '' : '#builddoc' ));
2008-08-12 20:20:18 +02:00
exit ;
}
}
2009-02-18 16:00:34 +01:00
// Set project
2008-08-12 20:20:18 +02:00
if ( $_POST [ 'action' ] == 'classin' )
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> setProject ( $_POST [ 'projectid' ]);
2008-08-12 20:20:18 +02:00
}
2011-04-06 17:36:45 +02:00
// Delai de livraison
if ( $_POST [ " action " ] == 'setavailability' )
{
$object -> fetch ( $_REQUEST [ 'id' ]);
$result = $object -> availability ( $_POST [ 'availability_id' ]);
2011-04-28 19:15:03 +02:00
$id = $_REQUEST [ 'id' ];
2011-04-06 17:36:45 +02:00
}
2011-04-27 10:49:51 +02:00
// Origine de la propale
if ( $_POST [ " action " ] == 'setdemandreason' )
{
$object -> fetch ( $_REQUEST [ 'id' ]);
$result = $object -> demand_reason ( $_POST [ 'demand_reason_id' ]);
2011-04-28 19:15:03 +02:00
$id = $_REQUEST [ 'id' ];
2011-04-27 10:49:51 +02:00
}
2008-08-12 20:20:18 +02:00
// Conditions de reglement
if ( $_POST [ " action " ] == 'setconditions' )
{
2010-09-18 11:40:24 +02:00
$object -> fetch ( $_REQUEST [ 'id' ]);
$result = $object -> cond_reglement ( $_POST [ 'cond_reglement_id' ]);
2011-04-28 19:15:03 +02:00
$id = $_REQUEST [ 'id' ];
2008-08-12 20:20:18 +02:00
}
2011-04-28 19:15:03 +02:00
if ( $action == 'setremisepercent' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$object -> fetch ( $_REQUEST [ " id " ]);
$result = $object -> set_remise_percent ( $user , $_POST [ 'remise_percent' ]);
2011-04-28 19:15:03 +02:00
$id = $_REQUEST [ " id " ];
2008-08-12 20:20:18 +02:00
}
2011-04-28 19:15:03 +02:00
if ( $action == 'setremiseabsolue' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$object -> fetch ( $_REQUEST [ " id " ]);
$result = $object -> set_remise_absolue ( $user , $_POST [ 'remise_absolue' ]);
2011-04-28 19:15:03 +02:00
$id = $_REQUEST [ " id " ];
2008-08-12 20:20:18 +02:00
}
// Mode de reglement
if ( $_POST [ " action " ] == 'setmode' )
{
2010-09-18 11:40:24 +02:00
$object -> fetch ( $_REQUEST [ " id " ]);
$result = $object -> mode_reglement ( $_POST [ 'mode_reglement_id' ]);
2011-04-28 19:15:03 +02:00
$id = $_REQUEST [ " id " ];
2008-08-12 20:20:18 +02:00
}
/*
* Ordonnancement des lignes
*/
2011-04-28 19:15:03 +02:00
if ( $action == 'up' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
2011-04-28 19:15:03 +02:00
$object -> line_up ( GETPOST ( 'rowid' ));
2008-10-29 00:36:36 +01:00
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2010-02-27 14:37:13 +01:00
2011-04-28 19:15:03 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '#' . GETPOST ( 'rowid' ));
2008-10-29 00:36:36 +01:00
exit ;
2008-08-12 20:20:18 +02:00
}
2011-04-28 19:15:03 +02:00
if ( $action == 'down' && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2011-04-28 19:15:03 +02:00
$object -> fetch ( $id );
2010-09-18 11:40:24 +02:00
$object -> fetch_thirdparty ();
2011-04-28 19:15:03 +02:00
$object -> line_down ( GETPOST ( 'rowid' ));
2008-10-29 00:36:36 +01:00
2010-02-27 14:37:13 +01:00
// Define output language
2008-10-29 00:36:36 +01:00
$outputlangs = $langs ;
2010-02-27 14:37:13 +01:00
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ])) $newlang = $_REQUEST [ 'lang_id' ];
2010-09-18 11:40:24 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $object -> client -> default_lang ;
2010-02-27 14:37:13 +01:00
if ( ! empty ( $newlang ))
2008-08-12 20:20:18 +02:00
{
$outputlangs = new Translate ( " " , $conf );
2010-02-27 14:37:13 +01:00
$outputlangs -> setDefaultLang ( $newlang );
2008-08-12 20:20:18 +02:00
}
2011-08-10 20:04:41 +02:00
propale_pdf_create ( $db , $object , $object -> modelpdf , $outputlangs , GETPOST ( 'hidedetails' ), GETPOST ( 'hidedesc' ), GETPOST ( 'hideref' ), $hookmanager );
2010-02-27 14:37:13 +01:00
2011-04-28 19:15:03 +02:00
Header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '#' . GETPOST ( 'rowid' ));
2008-08-12 20:20:18 +02:00
exit ;
}
/*
2009-03-10 01:54:53 +01:00
* View
2008-08-12 20:20:18 +02:00
*/
2009-08-05 19:49:12 +02:00
llxHeader ( '' , $langs -> trans ( 'Proposal' ), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos' );
2008-08-12 20:20:18 +02:00
$html = new Form ( $db );
2011-05-20 17:59:18 +02:00
$htmlother = new FormOther ( $db );
2008-08-12 20:20:18 +02:00
$formfile = new FormFile ( $db );
2009-08-05 20:11:27 +02:00
$companystatic = new Societe ( $db );
2008-08-12 20:20:18 +02:00
2010-05-12 13:29:21 +02:00
$now = dol_now ();
2011-01-31 17:35:55 +01:00
$id = GETPOST ( 'id' );
$ref = GETPOST ( 'ref' );
2009-01-14 16:53:52 +01:00
if ( $id > 0 || ! empty ( $ref ))
2008-08-12 20:20:18 +02:00
{
/*
2009-01-14 16:53:52 +01:00
* Show object in view mode
2008-08-12 20:20:18 +02:00
*/
2011-07-02 18:48:31 +02:00
2011-06-30 15:27:20 +02:00
dol_htmloutput_mesg ( $mesg , $mesgs );
2008-08-12 20:20:18 +02:00
2010-09-18 11:40:24 +02:00
$object -> fetch ( $id , $ref );
2008-08-12 20:20:18 +02:00
2010-08-05 12:07:05 +02:00
$soc = new Societe ( $db );
2010-09-18 11:40:24 +02:00
$soc -> fetch ( $object -> socid );
2008-08-12 20:20:18 +02:00
2010-09-18 11:40:24 +02:00
$head = propal_prepare_head ( $object );
2009-08-05 19:49:12 +02:00
dol_fiche_head ( $head , 'comm' , $langs -> trans ( 'Proposal' ), 0 , 'propal' );
2011-05-03 13:29:09 +02:00
2011-04-20 15:59:51 +02:00
$formconfirm = '' ;
2011-05-03 13:29:09 +02:00
2009-01-14 16:53:52 +01:00
// Clone confirmation
2011-04-20 15:59:51 +02:00
if ( $action == 'clone' )
2009-01-14 16:53:52 +01:00
{
// Create an array for form
$formquestion = array (
//'text' => $langs->trans("ConfirmClone"),
2011-04-25 12:10:34 +02:00
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
array ( 'type' => 'other' , 'name' => 'socid' , 'label' => $langs -> trans ( " SelectThirdParty " ), 'value' => $html -> select_company ( GETPOST ( 'socid' ), 'socid' , '(s.client=1 OR s.client=3)' ))
2009-01-14 16:53:52 +01:00
);
// Paiement incomplet. On demande si motif = escompte ou autre
2011-04-20 15:59:51 +02:00
$formconfirm = $html -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ClonePropal' ), $langs -> trans ( 'ConfirmClonePropal' , $object -> ref ), 'confirm_clone' , $formquestion , 'yes' , 1 );
2009-01-14 16:53:52 +01:00
}
2008-08-12 20:20:18 +02:00
/*
* Confirmation de la suppression de la propale
*/
2011-04-20 15:59:51 +02:00
if ( $action == 'delete' )
2008-08-12 20:20:18 +02:00
{
2011-04-20 15:59:51 +02:00
$formconfirm = $html -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'DeleteProp' ), $langs -> trans ( 'ConfirmDeleteProp' ), 'confirm_delete' , '' , 0 , 1 );
2008-08-12 20:20:18 +02:00
}
/*
* Confirmation de la suppression d ' une ligne produit / service
*/
2011-04-20 15:59:51 +02:00
if ( $action == 'ask_deleteline' )
2010-09-08 15:17:28 +02:00
{
2011-04-20 15:59:51 +02:00
$formconfirm = $html -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&lineid=' . $lineid , $langs -> trans ( 'DeleteProductLine' ), $langs -> trans ( 'ConfirmDeleteProductLine' ), 'confirm_deleteline' , '' , 0 , 1 );
2010-09-08 15:17:28 +02:00
}
2008-08-12 20:20:18 +02:00
/*
* Confirmation de la validation de la propale
*/
2011-04-20 15:59:51 +02:00
if ( $action == 'validate' )
2008-08-12 20:20:18 +02:00
{
2010-01-09 15:48:27 +01:00
// on verifie si l'objet est en numerotation provisoire
2010-09-18 11:40:24 +02:00
$ref = substr ( $object -> ref , 1 , 4 );
2010-01-09 15:48:27 +01:00
if ( $ref == 'PROV' )
{
2010-09-18 11:40:24 +02:00
$numref = $object -> getNextNumRef ( $soc );
2010-01-09 15:48:27 +01:00
}
else
{
2010-09-18 11:40:24 +02:00
$numref = $object -> ref ;
2010-01-09 15:48:27 +01:00
}
$text = $langs -> trans ( 'ConfirmValidateProp' , $numref );
if ( $conf -> notification -> enabled )
{
2010-04-28 12:11:41 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /core/class/notify.class.php " );
2010-01-09 15:48:27 +01:00
$notify = new Notify ( $db );
$text .= '<br>' ;
2010-09-18 11:40:24 +02:00
$text .= $notify -> confirmMessage ( 'NOTIFY_VAL_PROPAL' , $object -> socid );
2010-01-09 15:48:27 +01:00
}
2011-04-20 15:59:51 +02:00
$formconfirm = $html -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ValidateProp' ), $text , 'confirm_validate' , '' , 0 , 1 );
}
2011-08-11 00:47:33 +02:00
if ( ! $formconfirm )
{
$parameters = array ( 'lineid' => $lineid );
$formconfirm = $hookmanager -> executeHooks ( 'formconfirm' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
}
2011-05-03 13:29:09 +02:00
2011-04-20 15:59:51 +02:00
// Print form confirm
print $formconfirm ;
2008-08-12 20:20:18 +02:00
print '<table class="border" width="100%">' ;
2009-03-11 09:48:56 +01:00
$linkback = " <a href= \" propal.php?page= $page &socid= $socid &viewstatut= $viewstatut &sortfield= $sortfield & $sortorder\ " > " . $langs->trans ( " BackToList " ). " </ a > " ;
2008-08-12 20:20:18 +02:00
// Ref
2009-01-14 16:53:52 +01:00
print '<tr><td>' . $langs -> trans ( 'Ref' ) . '</td><td colspan="5">' ;
2010-09-18 11:40:24 +02:00
print $html -> showrefnav ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , '' );
2009-01-14 16:53:52 +01:00
print '</td></tr>' ;
2008-08-12 20:20:18 +02:00
// Ref client
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>' ;
print $langs -> trans ( 'RefCustomer' ) . '</td><td align="left">' ;
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'refclient' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=refclient&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'Modify' )) . '</a></td>' ;
2008-08-12 20:20:18 +02:00
print '</tr></table>' ;
print '</td><td colspan="5">' ;
2011-04-28 19:15:03 +02:00
if ( $user -> rights -> propale -> creer && $action == 'refclient' )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
print '<form action="propal.php?id=' . $object -> id . '" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2008-08-12 20:20:18 +02:00
print '<input type="hidden" name="action" value="set_ref_client">' ;
2010-09-18 11:40:24 +02:00
print '<input type="text" class="flat" size="20" name="ref_client" value="' . $object -> ref_client . '">' ;
2008-08-12 20:20:18 +02:00
print ' <input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
2010-09-18 11:40:24 +02:00
print $object -> ref_client ;
2008-08-12 20:20:18 +02:00
}
print '</td>' ;
print '</tr>' ;
2011-04-27 10:49:51 +02:00
$rowspan = 11 ;
2008-08-12 20:20:18 +02:00
2009-10-04 15:33:06 +02:00
// Company
2010-08-05 12:07:05 +02:00
print '<tr><td>' . $langs -> trans ( 'Company' ) . '</td><td colspan="5">' . $soc -> getNomUrl ( 1 ) . '</td>' ;
2008-08-12 20:20:18 +02:00
print '</tr>' ;
// Ligne info remises tiers
print '<tr><td>' . $langs -> trans ( 'Discounts' ) . '</td><td colspan="5">' ;
2010-08-05 12:07:05 +02:00
if ( $soc -> remise_client ) print $langs -> trans ( " CompanyHasRelativeDiscount " , $soc -> remise_client );
2008-08-12 20:20:18 +02:00
else print $langs -> trans ( " CompanyHasNoRelativeDiscount " );
2009-05-07 14:13:34 +02:00
print '. ' ;
2010-08-05 12:07:05 +02:00
$absolute_discount = $soc -> getAvailableDiscounts ( '' , 'fk_facture_source IS NULL' );
$absolute_creditnote = $soc -> getAvailableDiscounts ( '' , 'fk_facture_source IS NOT NULL' );
2009-05-07 14:13:34 +02:00
$absolute_discount = price2num ( $absolute_discount , 'MT' );
$absolute_creditnote = price2num ( $absolute_creditnote , 'MT' );
2008-08-12 20:20:18 +02:00
if ( $absolute_discount )
{
2010-09-18 11:40:24 +02:00
if ( $object -> statut > 0 )
2008-08-12 20:20:18 +02:00
{
print $langs -> trans ( " CompanyHasAbsoluteDiscount " , price ( $absolute_discount ), $langs -> transnoentities ( " Currency " . $conf -> monnaie ));
}
else
{
// Remise dispo de type non avoir
$filter = 'fk_facture_source IS NULL' ;
print '<br>' ;
2010-09-18 11:40:24 +02:00
$html -> form_remise_dispo ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , 0 , 'remise_id' , $soc -> id , $absolute_discount , $filter );
2008-08-12 20:20:18 +02:00
}
}
if ( $absolute_creditnote )
{
print $langs -> trans ( " CompanyHasCreditNote " , price ( $absolute_creditnote ), $langs -> transnoentities ( " Currency " . $conf -> monnaie )) . '. ' ;
}
if ( ! $absolute_discount && ! $absolute_creditnote ) print $langs -> trans ( " CompanyHasNoAbsoluteDiscount " ) . '.' ;
print '</td></tr>' ;
2009-03-04 01:14:51 +01:00
// Date of proposal
print '<tr>' ;
print '<td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'Date' );
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'editdate' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdate&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetDate' ), 1 ) . '</a></td>' ;
2009-03-04 01:14:51 +01:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2011-04-28 19:15:03 +02:00
if ( $object -> brouillon && $action == 'editdate' )
2009-03-04 01:14:51 +01:00
{
2010-09-18 11:40:24 +02:00
print '<form name="editdate" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2009-03-04 01:14:51 +01:00
print '<input type="hidden" name="action" value="setdate">' ;
2010-09-18 11:40:24 +02:00
$html -> select_date ( $object -> date , 're' , '' , '' , 0 , " editdate " );
2009-03-04 01:14:51 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
2010-09-18 11:40:24 +02:00
if ( $object -> date )
2009-03-04 01:14:51 +01:00
{
2010-09-18 11:40:24 +02:00
print dol_print_date ( $object -> date , 'daytext' );
2009-03-04 01:14:51 +01:00
}
else
{
print ' ' ;
}
}
2008-08-12 20:20:18 +02:00
print '</td>' ;
if ( $conf -> projet -> enabled ) $rowspan ++ ;
2009-02-18 15:29:56 +01:00
if ( $conf -> global -> PROPALE_ADD_DELIVERY_ADDRESS ) $rowspan ++ ;
2010-05-01 16:28:48 +02:00
2010-04-24 18:00:48 +02:00
//Local taxes
2010-07-15 09:23:04 +02:00
if ( $mysoc -> pays_code == 'ES' )
2010-04-24 18:00:48 +02:00
{
if ( $mysoc -> localtax1_assuj == " 1 " ) $rowspan ++ ;
if ( $mysoc -> localtax2_assuj == " 1 " ) $rowspan ++ ;
}
2010-05-01 16:28:48 +02:00
2008-08-12 20:20:18 +02:00
// Notes
2010-09-18 11:40:24 +02:00
print '<td valign="top" colspan="2" width="50%" rowspan="' . $rowspan . '">' . $langs -> trans ( 'NotePublic' ) . ' :<br>' . nl2br ( $object -> note_public ) . '</td>' ;
2008-08-12 20:20:18 +02:00
print '</tr>' ;
2011-07-17 21:01:26 +02:00
// Date end proposal
2008-08-12 20:20:18 +02:00
print '<tr>' ;
print '<td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DateEndPropal' );
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'editecheance' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editecheance&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
2008-08-12 20:20:18 +02:00
print '</tr></table>' ;
2009-03-04 01:14:51 +01:00
print '</td><td colspan="3">' ;
2011-04-28 19:15:03 +02:00
if ( $object -> brouillon && $action == 'editecheance' )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
print '<form name="editecheance" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2008-08-12 20:20:18 +02:00
print '<input type="hidden" name="action" value="setecheance">' ;
2010-09-18 11:40:24 +02:00
$html -> select_date ( $object -> fin_validite , 'ech' , '' , '' , '' , " editecheance " );
2008-08-12 20:20:18 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
2010-09-18 11:40:24 +02:00
if ( $object -> fin_validite )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
print dol_print_date ( $object -> fin_validite , 'daytext' );
if ( $object -> statut == 1 && $object -> fin_validite < ( $now - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
2008-08-12 20:20:18 +02:00
}
else
{
print ' ' ;
}
}
print '</td>' ;
print '</tr>' ;
2011-07-17 21:01:26 +02:00
// Payment term
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'PaymentConditionsShort' );
print '</td>' ;
if ( $action != 'editconditions' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editconditions&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetConditions' ), 1 ) . '</a></td>' ;
print '</tr></table>' ;
print '</td><td colspan="3">' ;
if ( $action == 'editconditions' )
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> cond_reglement_id , 'cond_reglement_id' );
}
else
{
$html -> form_conditions_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> cond_reglement_id , 'none' );
}
print '</td>' ;
print '</tr>' ;
2009-02-18 16:00:34 +01:00
// Delivery date
2009-02-18 15:29:56 +01:00
$langs -> load ( 'deliveries' );
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DeliveryDate' );
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'editdate_livraison' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdate_livraison&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetDeliveryDate' ), 1 ) . '</a></td>' ;
2009-02-18 15:29:56 +01:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2011-04-28 19:15:03 +02:00
if ( $action == 'editdate_livraison' )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
print '<form name="editdate_livraison" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2009-02-18 15:29:56 +01:00
print '<input type="hidden" name="action" value="setdate_livraison">' ;
2010-09-18 11:40:24 +02:00
$html -> select_date ( $object -> date_livraison , 'liv_' , '' , '' , '' , " editdate_livraison " );
2009-02-18 15:29:56 +01:00
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Modify' ) . '">' ;
print '</form>' ;
}
else
{
2010-09-18 11:40:24 +02:00
print dol_print_date ( $object -> date_livraison , 'daytext' );
2009-02-18 15:29:56 +01:00
}
print '</td>' ;
print '</tr>' ;
2008-08-12 20:20:18 +02:00
2011-07-10 22:03:38 +02:00
// Delivery address (deprecated)
2009-02-18 15:29:56 +01:00
if ( $conf -> global -> PROPALE_ADD_DELIVERY_ADDRESS )
{
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'DeliveryAddress' );
print '</td>' ;
2008-08-12 20:20:18 +02:00
2011-04-28 19:15:03 +02:00
if ( $action != 'editdelivery_address' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdelivery_address&socid=' . $object -> socid . '&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetDeliveryAddress' ), 1 ) . '</a></td>' ;
2009-02-18 15:29:56 +01:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2008-08-12 20:20:18 +02:00
2011-04-28 19:15:03 +02:00
if ( $action == 'editdelivery_address' )
2009-02-18 15:29:56 +01:00
{
2011-04-28 19:15:03 +02:00
$html -> form_address ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_delivery_address , GETPOST ( 'socid' ), 'fk_address' , 'propal' , $object -> id );
2009-02-18 15:29:56 +01:00
}
else
{
2011-04-28 19:15:03 +02:00
$html -> form_address ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_delivery_address , GETPOST ( 'socid' ), 'none' , 'propal' , $object -> id );
2008-08-12 20:20:18 +02:00
}
2009-02-18 15:29:56 +01:00
print '</td></tr>' ;
2008-08-12 20:20:18 +02:00
}
2011-07-17 21:01:26 +02:00
// Delivery delay
2011-04-01 12:04:49 +02:00
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
2011-04-01 12:49:57 +02:00
print $langs -> trans ( 'AvailabilityPeriod' );
2011-04-07 09:39:21 +02:00
if ( $conf -> commande -> enabled ) print ' (' . $langs -> trans ( 'AfterOrder' ) . ')' ;
2011-04-01 12:04:49 +02:00
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'editavailability' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editavailability&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetAvailability' ), 1 ) . '</a></td>' ;
2011-04-01 12:04:49 +02:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2011-04-28 19:15:03 +02:00
if ( $action == 'editavailability' )
2011-04-01 12:04:49 +02:00
{
2011-07-17 21:01:26 +02:00
$html -> form_availability ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> availability_id , 'availability_id' , 1 );
2011-04-01 12:04:49 +02:00
}
else
{
2011-07-17 21:01:26 +02:00
$html -> form_availability ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> availability_id , 'none' , 1 );
2011-04-01 12:04:49 +02:00
}
2011-04-07 09:39:21 +02:00
2011-04-27 10:49:51 +02:00
print '</td>' ;
print '</tr>' ;
2011-05-03 13:29:09 +02:00
2011-07-10 22:03:38 +02:00
// Origin of demand
2011-04-27 10:49:51 +02:00
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'Source' );
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'editdemandreason' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editdemandreason&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetDemandReason' ), 1 ) . '</a></td>' ;
2011-04-27 10:49:51 +02:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2011-05-07 13:36:47 +02:00
//print $object->demand_reason_id;
2011-04-28 19:15:03 +02:00
if ( $action == 'editdemandreason' )
2011-04-27 10:49:51 +02:00
{
2011-05-07 13:36:47 +02:00
$html -> form_demand_reason ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> demand_reason_id , 'demand_reason_id' , 1 );
2011-04-27 10:49:51 +02:00
}
else
{
$html -> form_demand_reason ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> demand_reason_id , 'none' );
}
2011-04-01 12:04:49 +02:00
print '</td>' ;
print '</tr>' ;
2009-02-18 16:00:34 +01:00
// Payment mode
2008-08-12 20:20:18 +02:00
print '<tr>' ;
print '<td width="25%">' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'PaymentMode' );
print '</td>' ;
2011-04-28 19:15:03 +02:00
if ( $action != 'editmode' && $object -> brouillon ) print '<td align="right"><a href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
2008-08-12 20:20:18 +02:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2011-04-28 19:15:03 +02:00
if ( $action == 'editmode' )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> mode_reglement_id , 'mode_reglement_id' );
2008-08-12 20:20:18 +02:00
}
else
{
2010-09-18 11:40:24 +02:00
$html -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> mode_reglement_id , 'none' );
2008-08-12 20:20:18 +02:00
}
print '</td></tr>' ;
2008-12-28 00:40:25 +01:00
// Project
2008-08-12 20:20:18 +02:00
if ( $conf -> projet -> enabled )
{
$langs -> load ( " projects " );
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'Project' ) . '</td>' ;
2009-02-18 16:00:34 +01:00
if ( $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2011-08-23 20:40:45 +02:00
if ( $action != 'classify' ) print '<td align="right"><a href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classify&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetProject' )) . '</a></td>' ;
2008-12-28 00:40:25 +01:00
print '</tr></table>' ;
print '</td><td colspan="3">' ;
2011-08-23 20:40:45 +02:00
if ( $action == 'classify' )
2008-12-28 00:40:25 +01:00
{
2010-09-18 11:40:24 +02:00
$html -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> socid , $object -> fk_project , 'projectid' );
2008-12-28 00:40:25 +01:00
}
else
{
2010-09-18 11:40:24 +02:00
$html -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> socid , $object -> fk_project , 'none' );
2008-12-28 00:40:25 +01:00
}
print '</td></tr>' ;
2008-08-12 20:20:18 +02:00
}
else
{
2008-12-28 00:40:25 +01:00
print '</td></tr></table>' ;
2010-09-18 11:40:24 +02:00
if ( ! empty ( $object -> fk_project ))
2008-08-12 20:20:18 +02:00
{
2008-12-28 00:40:25 +01:00
print '<td colspan="3">' ;
$proj = new Project ( $db );
2010-09-18 11:40:24 +02:00
$proj -> fetch ( $object -> fk_project );
print '<a href="../projet/fiche.php?id=' . $object -> fk_project . '" title="' . $langs -> trans ( 'ShowProject' ) . '">' ;
2009-02-18 16:00:34 +01:00
print $proj -> ref ;
2008-12-28 00:40:25 +01:00
print '</a>' ;
print '</td>' ;
2008-08-12 20:20:18 +02:00
}
2008-12-28 00:40:25 +01:00
else {
print '<td colspan="3"> </td>' ;
2008-08-12 20:20:18 +02:00
}
}
print '</tr>' ;
}
2011-08-31 17:30:56 +02:00
2011-08-23 17:23:19 +02:00
// Insert hooks
2011-08-23 20:40:45 +02:00
$parameters = array ( 'colspan' => ' colspan="3"' );
2011-08-23 17:23:19 +02:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2008-08-12 20:20:18 +02:00
// Amount HT
print '<tr><td height="10">' . $langs -> trans ( 'AmountHT' ) . '</td>' ;
2010-09-18 11:40:24 +02:00
print '<td align="right" colspan="2" nowrap><b>' . price ( $object -> total_ht ) . '</b></td>' ;
2008-08-12 20:20:18 +02:00
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
// Amount VAT
print '<tr><td height="10">' . $langs -> trans ( 'AmountVAT' ) . '</td>' ;
2010-09-18 11:40:24 +02:00
print '<td align="right" colspan="2" nowrap>' . price ( $object -> total_tva ) . '</td>' ;
2008-08-12 20:20:18 +02:00
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
2010-05-01 16:28:48 +02:00
2010-04-24 18:00:48 +02:00
// Amount Local Taxes
2010-07-15 09:23:04 +02:00
if ( $mysoc -> pays_code == 'ES' )
2010-04-24 18:00:48 +02:00
{
if ( $mysoc -> localtax1_assuj == " 1 " ) //Localtax1 RE
{
print '<tr><td height="10">' . $langs -> transcountry ( " AmountLT1 " , $mysoc -> pays_code ) . '</td>' ;
2010-09-18 11:40:24 +02:00
print '<td align="right" colspan="2" nowrap>' . price ( $object -> total_localtax1 ) . '</td>' ;
2010-04-24 18:00:48 +02:00
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
}
if ( $mysoc -> localtax2_assuj == " 1 " ) //Localtax2 IRPF
{
print '<tr><td height="10">' . $langs -> transcountry ( " AmountLT2 " , $mysoc -> pays_code ) . '</td>' ;
2010-09-18 11:40:24 +02:00
print '<td align="right" colspan="2" nowrap>' . price ( $object -> total_localtax2 ) . '</td>' ;
2010-04-24 18:00:48 +02:00
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
}
}
2010-05-01 16:28:48 +02:00
2008-08-12 20:20:18 +02:00
// Amount TTC
print '<tr><td height="10">' . $langs -> trans ( 'AmountTTC' ) . '</td>' ;
2010-09-18 11:40:24 +02:00
print '<td align="right" colspan="2" nowrap>' . price ( $object -> total_ttc ) . '</td>' ;
2008-08-12 20:20:18 +02:00
print '<td>' . $langs -> trans ( " Currency " . $conf -> monnaie ) . '</td></tr>' ;
// Statut
2010-09-18 11:40:24 +02:00
print '<tr><td height="10">' . $langs -> trans ( 'Status' ) . '</td><td align="left" colspan="3">' . $object -> getLibStatut ( 4 ) . '</td></tr>' ;
2008-08-12 20:20:18 +02:00
print '</table><br>' ;
/*
2009-03-12 01:14:56 +01:00
* Lines
2008-08-12 20:20:18 +02:00
*/
2010-10-02 22:47:55 +02:00
if ( $conf -> use_javascript_ajax && $object -> statut == 0 )
2010-09-07 16:42:50 +02:00
{
2010-09-18 09:52:17 +02:00
include ( DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php' );
2010-09-07 16:42:50 +02:00
}
2010-09-14 22:27:47 +02:00
2011-04-15 17:47:42 +02:00
// TODO test using div instead of tables
2011-04-16 10:05:01 +02:00
//print '<div class="table" id="tablelines">';
2010-10-02 22:47:55 +02:00
print '<table id="tablelines" class="noborder" width="100%">' ;
2011-04-13 15:44:58 +02:00
2011-04-11 09:11:10 +02:00
// Show object lines
2011-08-10 12:55:34 +02:00
$result = $object -> getLinesArray ();
if ( ! empty ( $object -> lines )) $object -> printObjectLines ( $action , $mysoc , $soc , $lineid , 0 , $hookmanager );
2011-05-03 13:29:09 +02:00
2011-04-16 10:05:01 +02:00
//print '<table id="tablelines" class="noborder" width="100%">';
2010-09-07 15:07:32 +02:00
2008-08-12 20:20:18 +02:00
/*
2009-03-10 01:54:53 +01:00
* Form to add new line
2008-08-12 20:20:18 +02:00
*/
2010-09-18 11:40:24 +02:00
if ( $object -> statut == 0 && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2011-04-18 17:06:23 +02:00
if ( $action != 'editline' )
2008-08-12 20:20:18 +02:00
{
2010-08-05 17:33:28 +02:00
$var = true ;
2010-08-28 01:42:10 +02:00
2010-08-06 08:53:22 +02:00
// Add free products/services
2011-08-10 12:55:34 +02:00
$object -> formAddFreeProduct ( 0 , $mysoc , $soc , $hookmanager );
2010-08-28 01:42:10 +02:00
2010-08-05 17:33:28 +02:00
// Add predefined products/services
if ( $conf -> product -> enabled || $conf -> service -> enabled )
{
$var =! $var ;
2011-08-10 12:55:34 +02:00
$object -> formAddPredefinedProduct ( 0 , $mysoc , $soc , $hookmanager );
2010-08-05 17:33:28 +02:00
}
2010-08-28 01:42:10 +02:00
2011-08-11 00:47:33 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formAddObject' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2008-08-12 20:20:18 +02:00
}
}
2011-04-15 17:47:42 +02:00
// TODO test using div instead of tables
2008-08-12 20:20:18 +02:00
print '</table>' ;
2011-04-16 10:05:01 +02:00
//print '</div>';
2008-08-12 20:20:18 +02:00
print '</div>' ;
print " \n " ;
2011-04-18 17:06:23 +02:00
if ( $action == 'statut' )
2008-08-12 20:20:18 +02:00
{
2009-05-06 19:09:45 +02:00
/*
* Formulaire cloture ( signe ou non )
*/
2010-09-18 11:40:24 +02:00
$form_close = '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="post">' ;
2009-05-17 10:01:54 +02:00
$form_close .= '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2009-05-06 19:09:45 +02:00
$form_close .= '<table class="border" width="100%">' ;
2011-03-02 11:33:24 +01:00
$form_close .= '<tr><td width="150" align="left">' . $langs -> trans ( " CloseAs " ) . '</td><td align="left">' ;
$form_close .= '<input type="hidden" name="action" value="setstatut">' ;
$form_close .= '<select id="statut" name="statut" class="flat">' ;
$form_close .= '<option value="0"> </option>' ;
$form_close .= '<option value="2">' . $object -> labelstatut [ 2 ] . '</option>' ;
$form_close .= '<option value="3">' . $object -> labelstatut [ 3 ] . '</option>' ;
$form_close .= '</select>' ;
$form_close .= '</td></tr>' ;
2009-05-06 19:09:45 +02:00
$form_close .= '<tr><td width="150" align="left">' . $langs -> trans ( 'Note' ) . '</td><td align="left"><textarea cols="70" rows="' . ROWS_3 . '" wrap="soft" name="note">' ;
2010-09-18 11:40:24 +02:00
$form_close .= $object -> note ;
2009-05-06 19:09:45 +02:00
$form_close .= '</textarea></td></tr>' ;
$form_close .= '<tr><td align="center" colspan="2">' ;
$form_close .= '<input type="submit" class="button" name="validate" value="' . $langs -> trans ( 'Validate' ) . '">' ;
2008-08-12 20:20:18 +02:00
$form_close .= ' <input type="submit" class="button" name="cancel" value="' . $langs -> trans ( 'Cancel' ) . '">' ;
2009-05-06 22:27:56 +02:00
$form_close .= '<a name="close"> </a>' ;
2009-05-06 19:09:45 +02:00
$form_close .= '</td>' ;
$form_close .= '</tr></table></form>' ;
2008-08-12 20:20:18 +02:00
print $form_close ;
}
/*
* Boutons Actions
*/
2011-04-18 17:06:23 +02:00
if ( $action != 'presend' )
2008-08-12 20:20:18 +02:00
{
print '<div class="tabsAction">' ;
2011-04-18 17:06:23 +02:00
if ( $action != 'statut' && $action <> 'editline' )
2008-08-12 20:20:18 +02:00
{
2011-04-07 09:52:19 +02:00
// Validate
if ( $object -> statut == 0 && $user -> rights -> propale -> valider )
2008-08-12 20:20:18 +02:00
{
2011-04-07 09:52:19 +02:00
if ( sizeof ( $object -> lines ) > 0 ) print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=validate">' . $langs -> trans ( 'Validate' ) . '</a>' ;
else print '<a class="butActionRefused" href="#">' . $langs -> trans ( 'Validate' ) . '</a>' ;
2008-08-12 20:20:18 +02:00
}
// Edit
2010-09-18 11:40:24 +02:00
if ( $object -> statut == 1 && $user -> rights -> propale -> creer )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=modif">' . $langs -> trans ( 'Modify' ) . '</a>' ;
2008-08-12 20:20:18 +02:00
}
// Send
2011-05-05 09:25:31 +02:00
if ( $object -> statut == 1 )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$propref = dol_sanitizeFileName ( $object -> ref );
2009-04-28 15:52:08 +02:00
$file = $conf -> propale -> dir_output . '/' . $propref . '/' . $propref . '.pdf' ;
2008-08-12 20:20:18 +02:00
if ( file_exists ( $file ))
{
2011-05-05 09:25:31 +02:00
if ( empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) || $user -> rights -> propale -> propal_advance -> send )
{
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=presend&mode=init">' . $langs -> trans ( 'SendByMail' ) . '</a>' ;
}
else print '<a class="butActionRefused" href="#">' . $langs -> trans ( 'SendByMail' ) . '</a>' ;
2008-08-12 20:20:18 +02:00
}
}
2010-09-14 22:27:47 +02:00
2011-03-02 11:33:24 +01:00
// Create an order
if ( $conf -> commande -> enabled && $object -> statut == 2 && $user -> societe_id == 0 )
{
if ( $user -> rights -> commande -> creer )
{
2011-03-02 11:38:32 +01:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/commande/fiche.php?action=create&origin=' . $object -> element . '&originid=' . $object -> id . '&socid=' . $object -> socid . '">' . $langs -> trans ( " AddOrder " ) . '</a>' ;
2011-03-02 11:33:24 +01:00
}
}
// Create an invoice and classify billed
2010-09-18 11:40:24 +02:00
if ( $conf -> facture -> enabled && $object -> statut == 2 && $user -> societe_id == 0 )
2010-09-10 18:51:33 +02:00
{
if ( $user -> rights -> facture -> creer )
{
2011-03-02 11:38:32 +01:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture.php?action=create&origin=' . $object -> element . '&originid=' . $object -> id . '&socid=' . $object -> socid . '">' . $langs -> trans ( " AddBill " ) . '</a>' ;
2010-09-10 18:51:33 +02:00
}
2010-09-14 22:27:47 +02:00
2010-09-18 11:40:24 +02:00
$arraypropal = $object -> getInvoiceArrayList ();
2010-09-10 18:51:33 +02:00
if ( is_array ( $arraypropal ) && sizeof ( $arraypropal ) > 0 )
{
2010-09-18 11:40:24 +02:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=classifybilled&socid=' . $object -> socid . '">' . $langs -> trans ( " ClassifyBilled " ) . '</a>' ;
2010-09-10 18:51:33 +02:00
}
}
2008-08-12 20:20:18 +02:00
// Close
2010-09-18 11:40:24 +02:00
if ( $object -> statut == 1 && $user -> rights -> propale -> cloturer )
2008-08-12 20:20:18 +02:00
{
2011-03-01 10:37:32 +01:00
print '<a class="butAction" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=statut' . ( empty ( $conf -> global -> MAIN_JUMP_TAG ) ? '' : '#close' ) . '"' ;
2008-08-12 20:20:18 +02:00
print '>' . $langs -> trans ( 'Close' ) . '</a>' ;
}
2009-01-14 16:53:52 +01:00
// Clone
2010-09-18 11:40:24 +02:00
if ( $object -> type == 0 && $user -> rights -> propale -> creer )
2009-01-14 16:53:52 +01:00
{
2011-04-25 12:10:34 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&socid=' . $object -> socid . '&action=clone&object=propal">' . $langs -> trans ( " ToClone " ) . '</a>' ;
2009-01-14 16:53:52 +01:00
}
2008-08-12 20:20:18 +02:00
// Delete
2010-09-10 18:51:33 +02:00
if ( $user -> rights -> propale -> supprimer )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
print '<a class="butActionDelete" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=delete"' ;
2008-08-12 20:20:18 +02:00
print '>' . $langs -> trans ( 'Delete' ) . '</a>' ;
}
}
print '</div>' ;
print " <br> \n " ;
}
2011-04-18 17:06:23 +02:00
if ( $action != 'presend' )
2008-08-12 20:20:18 +02:00
{
print '<table width="100%"><tr><td width="50%" valign="top">' ;
print '<a name="builddoc"></a>' ; // ancre
/*
* Documents generes
*/
2010-09-18 11:40:24 +02:00
$filename = dol_sanitizeFileName ( $object -> ref );
$filedir = $conf -> propale -> dir_output . " / " . dol_sanitizeFileName ( $object -> ref );
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
2008-08-12 20:20:18 +02:00
$genallowed = $user -> rights -> propale -> creer ;
$delallowed = $user -> rights -> propale -> supprimer ;
$var = true ;
2011-08-10 12:55:34 +02:00
$somethingshown = $formfile -> show_documents ( 'propal' , $filename , $filedir , $urlsource , $genallowed , $delallowed , $object -> modelpdf , 1 , 0 , 0 , 28 , 0 , '' , 0 , '' , $soc -> default_lang , $hookmanager );
2008-08-12 20:20:18 +02:00
/*
2010-04-08 21:44:45 +02:00
* Linked object block
2008-08-12 20:20:18 +02:00
*/
2011-05-06 20:27:18 +02:00
$somethingshown = $object -> showLinkedObjectBlock ();
2010-04-09 08:20:10 +02:00
2008-08-12 20:20:18 +02:00
print '</td><td valign="top" width="50%">' ;
// List of actions on element
2010-05-03 10:22:35 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' );
2008-08-12 20:20:18 +02:00
$formactions = new FormActions ( $db );
2010-09-18 11:40:24 +02:00
$somethingshown = $formactions -> showactions ( $object , 'propal' , $socid );
2008-08-12 20:20:18 +02:00
print '</td></tr></table>' ;
}
/*
* Action presend
*
*/
2011-04-18 17:06:23 +02:00
if ( $action == 'presend' )
2008-08-12 20:20:18 +02:00
{
2010-09-18 11:40:24 +02:00
$ref = dol_sanitizeFileName ( $object -> ref );
2009-04-28 15:52:08 +02:00
$file = $conf -> propale -> dir_output . '/' . $ref . '/' . $ref . '.pdf' ;
2008-08-12 20:20:18 +02:00
print '<br>' ;
print_titre ( $langs -> trans ( 'SendPropalByMail' ));
// Create form object
2010-05-12 13:58:58 +02:00
include_once ( DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' );
2008-08-12 20:20:18 +02:00
$formmail = new FormMail ( $db );
$formmail -> fromtype = 'user' ;
$formmail -> fromid = $user -> id ;
2010-07-18 12:39:07 +02:00
$formmail -> fromname = $user -> getFullName ( $langs );
2008-08-12 20:20:18 +02:00
$formmail -> frommail = $user -> email ;
$formmail -> withfrom = 1 ;
2009-10-14 18:13:20 +02:00
$formmail -> withto = empty ( $_POST [ " sendto " ]) ? 1 : $_POST [ " sendto " ];
2010-08-05 12:07:05 +02:00
$formmail -> withtosocid = $soc -> id ;
2008-08-12 20:20:18 +02:00
$formmail -> withtocc = 1 ;
2009-10-14 18:13:20 +02:00
$formmail -> withtoccsocid = 0 ;
$formmail -> withtoccc = $conf -> global -> MAIN_EMAIL_USECCC ;
$formmail -> withtocccsocid = 0 ;
2008-08-12 20:20:18 +02:00
$formmail -> withtopic = $langs -> trans ( 'SendPropalRef' , '__PROPREF__' );
$formmail -> withfile = 2 ;
$formmail -> withbody = 1 ;
$formmail -> withdeliveryreceipt = 1 ;
$formmail -> withcancel = 1 ;
2009-11-04 21:16:11 +01:00
2008-08-12 20:20:18 +02:00
// Tableau des substitutions
2010-09-18 11:40:24 +02:00
$formmail -> substit [ '__PROPREF__' ] = $object -> ref ;
2008-08-12 20:20:18 +02:00
// Tableau des parametres complementaires
$formmail -> param [ 'action' ] = 'send' ;
$formmail -> param [ 'models' ] = 'propal_send' ;
2010-09-18 11:40:24 +02:00
$formmail -> param [ 'id' ] = $object -> id ;
$formmail -> param [ 'returnurl' ] = $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id ;
2008-08-12 20:20:18 +02:00
// Init list of files
if ( ! empty ( $_REQUEST [ " mode " ]) && $_REQUEST [ " mode " ] == 'init' )
{
$formmail -> clear_attached_files ();
2011-01-14 02:24:00 +01:00
$formmail -> add_attached_files ( $file , dol_sanitizeFilename ( $object -> ref ) . '.pdf' , 'application/pdf' );
2008-08-12 20:20:18 +02:00
}
$formmail -> show_form ();
print '<br>' ;
}
}
else
{
/****************************************************************************
* *
* Mode Liste des propales *
* *
****************************************************************************/
2009-01-14 16:53:52 +01:00
2010-05-12 13:29:21 +02:00
$now = dol_now ();
2008-08-12 20:20:18 +02:00
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
if ( $page == - 1 ) { $page = 0 ; }
$offset = $conf -> liste_limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2011-04-28 19:15:03 +02:00
$viewstatut = $db -> escape ( GETPOST ( 'viewstatut' ));
$object_statut = $db -> escape ( GETPOST ( 'propal_statut' ));
2010-09-18 11:40:24 +02:00
if ( $object_statut != '' )
$viewstatut = $object_statut ;
2008-08-12 20:20:18 +02:00
if ( ! $sortfield ) $sortfield = 'p.datep' ;
if ( ! $sortorder ) $sortorder = 'DESC' ;
$limit = $conf -> liste_limit ;
$sql = 'SELECT s.nom, s.rowid, s.client, ' ;
2010-02-27 23:53:27 +01:00
$sql .= 'p.rowid as propalid, p.total_ht, p.ref, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,' ;
2009-02-25 22:03:40 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " sc.fk_soc, sc.fk_user, " ;
$sql .= ' u.login' ;
2009-08-29 01:02:47 +02:00
$sql .= ' FROM (' . MAIN_DB_PREFIX . 'societe as s, ' . MAIN_DB_PREFIX . 'propal as p' ;
2008-08-12 20:20:18 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-08-29 01:02:47 +02:00
$sql .= ')' ;
2008-08-12 20:20:18 +02:00
if ( $sall ) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'propaldet as pd ON p.rowid=pd.fk_propal' ;
2009-02-25 22:03:40 +01:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as u ON p.fk_user_author = u.rowid' ;
2008-08-12 20:20:18 +02:00
$sql .= ' WHERE p.fk_soc = s.rowid' ;
2009-04-27 22:37:50 +02:00
$sql .= ' AND s.entity = ' . $conf -> entity ;
2008-08-12 20:20:18 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) //restriction
{
2009-04-27 22:37:50 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2008-08-12 20:20:18 +02:00
}
2011-04-28 19:15:03 +02:00
if ( GETPOST ( 'search_ref' ))
2008-08-12 20:20:18 +02:00
{
2011-04-28 19:15:03 +02:00
$sql .= " AND p.ref LIKE '% " . $db -> escape ( GETPOST ( 'search_ref' )) . " %' " ;
2008-08-12 20:20:18 +02:00
}
if ( ! empty ( $_GET [ 'search_societe' ]))
{
2011-04-28 19:15:03 +02:00
$sql .= " AND s.nom LIKE '% " . $db -> escape ( GETPOST ( 'search_societe' )) . " %' " ;
2008-08-12 20:20:18 +02:00
}
if ( ! empty ( $_GET [ 'search_montant_ht' ]))
{
2011-04-28 19:15:03 +02:00
$sql .= " AND p.total_ht=' " . $db -> escape ( GETPOST ( 'search_montant_ht' )) . " ' " ;
2008-08-12 20:20:18 +02:00
}
2011-02-24 19:36:27 +01:00
if ( $sall ) $sql .= " AND (s.nom like '% " . $db -> escape ( $sall ) . " %' OR p.note like '% " . $db -> escape ( $sall ) . " %' OR pd.description like '% " . $db -> escape ( $sall ) . " %') " ;
2009-04-27 22:37:50 +02:00
if ( $socid ) $sql .= ' AND s.rowid = ' . $socid ;
2008-08-12 20:20:18 +02:00
if ( $viewstatut <> '' )
{
2009-04-27 22:37:50 +02:00
$sql .= ' AND p.fk_statut in (' . $viewstatut . ')' ;
2008-08-12 20:20:18 +02:00
}
if ( $month > 0 )
{
if ( $year > 0 )
2011-07-04 12:30:00 +02:00
$sql .= " AND date_format(p.datep, '%Y-%m') = ' " . $year . " - " . $month . " ' " ;
2008-10-29 00:36:36 +01:00
else
2011-07-04 12:30:00 +02:00
$sql .= " AND date_format(p.datep, '%m') = ' " . $month . " ' " ;
2008-08-12 20:20:18 +02:00
}
if ( $year > 0 )
{
2011-07-04 12:30:00 +02:00
$sql .= " AND date_format(p.datep, '%Y') = ' " . $year . " ' " ;
2008-08-12 20:20:18 +02:00
}
2010-08-24 16:42:18 +02:00
if ( dol_strlen ( $_POST [ 'sf_ref' ]) > 0 )
2008-08-12 20:20:18 +02:00
{
2011-02-24 19:36:27 +01:00
$sql .= " AND p.ref like '% " . $db -> escape ( $_POST [ " sf_ref " ]) . " %' " ;
2008-08-12 20:20:18 +02:00
}
2009-04-27 22:37:50 +02:00
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ', p.ref DESC' ;
$sql .= $db -> plimit ( $limit + 1 , $offset );
2008-08-12 20:20:18 +02:00
$result = $db -> query ( $sql );
if ( $result )
{
2010-09-18 11:40:24 +02:00
$objectstatic = new Propal ( $db );
2009-02-25 22:03:40 +01:00
$userstatic = new User ( $db );
2009-03-03 01:12:56 +01:00
2008-09-08 14:51:29 +02:00
$num = $db -> num_rows ( $result );
2008-10-29 00:36:36 +01:00
2011-07-20 17:33:00 +02:00
if ( $socid )
{
$soc = new Societe ( $db );
$soc -> fetch ( $socid );
}
2011-08-08 03:53:25 +02:00
2008-09-08 14:51:29 +02:00
$param = '&socid=' . $socid . '&viewstatut=' . $viewstatut ;
if ( $month ) $param .= '&month=' . $month ;
if ( $year ) $param .= '&year=' . $year ;
2011-07-20 21:22:14 +02:00
print_barre_liste ( $langs -> trans ( 'ListOfProposals' ) . ' ' . ( $socid ? '- ' . $soc -> nom : '' ), $page , 'propal.php' , $param , $sortfield , $sortorder , '' , $num );
2008-10-29 00:36:36 +01:00
2008-08-12 20:20:18 +02:00
$i = 0 ;
print '<table class="liste" width="100%">' ;
print '<tr class="liste_titre">' ;
2008-09-08 14:51:29 +02:00
print_liste_field_titre ( $langs -> trans ( 'Ref' ), $_SERVER [ " PHP_SELF " ], 'p.ref' , '' , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( 'Company' ), $_SERVER [ " PHP_SELF " ], 's.nom' , '' , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( 'Date' ), $_SERVER [ " PHP_SELF " ], 'p.datep' , '' , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( 'DateEndPropalShort' ), $_SERVER [ " PHP_SELF " ], 'dfv' , '' , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( $langs -> trans ( 'Price' ), $_SERVER [ " PHP_SELF " ], 'p.total_ht' , '' , $param , 'align="right"' , $sortfield , $sortorder );
2009-02-25 22:03:40 +01:00
print_liste_field_titre ( $langs -> trans ( 'Author' ), $_SERVER [ " PHP_SELF " ], 'u.login' , '' , $param , 'align="right"' , $sortfield , $sortorder );
2008-09-08 14:51:29 +02:00
print_liste_field_titre ( $langs -> trans ( 'Status' ), $_SERVER [ " PHP_SELF " ], 'p.fk_statut' , '' , $param , 'align="right"' , $sortfield , $sortorder );
2011-09-03 01:57:26 +02:00
print_liste_field_titre ( '' );
2008-10-29 00:36:36 +01:00
print " </tr> \n " ;
2008-08-12 20:20:18 +02:00
// Lignes des champs de filtre
print '<form method="get" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<tr class="liste_titre">' ;
2008-08-29 23:16:34 +02:00
print '<td class="liste_titre">' ;
2011-04-28 19:15:03 +02:00
print '<input class="flat" size="10" type="text" name="search_ref" value="' . GETPOST ( 'search_ref' ) . '">' ;
2008-08-12 20:20:18 +02:00
print '</td>' ;
print '<td class="liste_titre" align="left">' ;
2011-04-28 19:15:03 +02:00
print '<input class="flat" type="text" size="16" name="search_societe" value="' . GETPOST ( 'search_societe' ) . '">' ;
2008-08-12 20:20:18 +02:00
print '</td>' ;
2008-10-29 00:36:36 +01:00
print '<td class="liste_titre" colspan="1" align="right">' ;
print $langs -> trans ( 'Month' ) . ': <input class="flat" type="text" size="1" maxlength="2" name="month" value="' . $month . '">' ;
print ' ' . $langs -> trans ( 'Year' ) . ': ' ;
$syear = $year ;
//if($syear == '') $syear = date("Y");
2011-05-20 17:59:18 +02:00
$htmlother -> select_year ( $syear , 'year' , 1 , 20 , 5 );
2008-10-29 00:36:36 +01:00
print '</td>' ;
2008-08-12 20:20:18 +02:00
print '<td class="liste_titre" colspan="1"> </td>' ;
print '<td class="liste_titre" align="right">' ;
2011-04-28 19:15:03 +02:00
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="' . GETPOST ( 'search_montant_ht' ) . '">' ;
2008-08-12 20:20:18 +02:00
print '</td>' ;
2010-07-01 22:51:40 +02:00
print '<td class="liste_titre"> </td>' ;
print '<td class="liste_titre" align="right">' ;
2011-08-12 23:29:29 +02:00
$html -> select_propal_statut ( $viewstatut , 1 );
2008-10-29 00:36:36 +01:00
print '</td>' ;
2011-02-18 11:45:38 +01:00
print '<td class="liste_titre" align="right"><input class="liste_titre" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '" title="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '">' ;
2008-08-12 20:20:18 +02:00
print '</td>' ;
print " </tr> \n " ;
print '</form>' ;
$var = true ;
while ( $i < min ( $num , $limit ))
{
$objp = $db -> fetch_object ( $result );
$now = time ();
$var =! $var ;
print '<tr ' . $bc [ $var ] . '>' ;
print '<td nowrap="nowrap">' ;
2010-09-18 11:40:24 +02:00
$objectstatic -> id = $objp -> propalid ;
$objectstatic -> ref = $objp -> ref ;
2008-08-12 20:20:18 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2009-08-05 20:11:27 +02:00
print '<td class="nobordernopadding" nowrap="nowrap">' ;
2010-09-18 11:40:24 +02:00
print $objectstatic -> getNomUrl ( 1 );
2008-08-12 20:20:18 +02:00
print '</td>' ;
print '<td width="20" class="nobordernopadding" nowrap="nowrap">' ;
2009-01-07 16:21:16 +01:00
if ( $objp -> fk_statut == 1 && $objp -> dfv < ( $now - $conf -> propal -> cloture -> warning_delay )) print img_warning ( $langs -> trans ( " Late " ));
2008-08-12 20:20:18 +02:00
print '</td>' ;
print '<td width="16" align="right" class="nobordernopadding">' ;
2009-04-29 20:02:50 +02:00
$filename = dol_sanitizeFileName ( $objp -> ref );
$filedir = $conf -> propale -> dir_output . '/' . dol_sanitizeFileName ( $objp -> ref );
2010-06-30 17:01:18 +02:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $objp -> propalid ;
2010-03-27 01:33:28 +01:00
$formfile -> show_documents ( 'propal' , $filename , $filedir , $urlsource , '' , '' , '' , 1 , '' , 1 );
2008-08-12 20:20:18 +02:00
print '</td></tr></table>' ;
if ( $objp -> client == 1 )
{
$url = DOL_URL_ROOT . '/comm/fiche.php?socid=' . $objp -> rowid ;
}
else
{
$url = DOL_URL_ROOT . '/comm/prospect/fiche.php?socid=' . $objp -> rowid ;
}
2009-08-05 20:11:27 +02:00
// Company
$companystatic -> id = $objp -> rowid ;
$companystatic -> nom = $objp -> nom ;
$companystatic -> client = $objp -> client ;
print '<td>' ;
print $companystatic -> getNomUrl ( 1 , 'customer' );
print '</td>' ;
2008-08-12 20:20:18 +02:00
// Date propale
print '<td align="center">' ;
2010-02-27 23:53:27 +01:00
$y = dol_print_date ( $db -> jdate ( $objp -> dp ), '%Y' );
$m = dol_print_date ( $db -> jdate ( $objp -> dp ), '%m' );
$mt = dol_print_date ( $db -> jdate ( $objp -> dp ), '%b' );
$d = dol_print_date ( $db -> jdate ( $objp -> dp ), '%d' );
2008-10-26 16:55:50 +01:00
print $d . " \n " ;
2008-08-12 20:20:18 +02:00
print ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?year=' . $y . '&month=' . $m . '">' ;
2008-10-26 16:55:50 +01:00
print $mt . " </a> \n " ;
2008-08-12 20:20:18 +02:00
print ' <a href="' . $_SERVER [ " PHP_SELF " ] . '?year=' . $y . '">' ;
2008-10-26 16:55:50 +01:00
print $y . " </a></td> \n " ;
2008-08-12 20:20:18 +02:00
// Date fin validite
if ( $objp -> dfv )
{
2010-02-27 23:53:27 +01:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $objp -> dfv ), 'day' );
2008-08-12 20:20:18 +02:00
print '</td>' ;
}
else
{
print '<td> </td>' ;
}
print '<td align="right">' . price ( $objp -> total_ht ) . " </td> \n " ;
2009-02-25 22:03:40 +01:00
$userstatic -> id = $objp -> fk_user_author ;
$userstatic -> login = $objp -> login ;
2009-03-03 01:12:56 +01:00
print '<td align="center">' ;
if ( $userstatic -> id ) print $userstatic -> getLoginUrl ( 1 );
else print ' ' ;
print " </td> \n " ;
2010-09-18 11:40:24 +02:00
print '<td align="right">' . $objectstatic -> LibStatut ( $objp -> fk_statut , 5 ) . " </td> \n " ;
2009-03-03 01:12:56 +01:00
2009-02-25 22:03:40 +01:00
print '<td> </td>' ;
2009-03-03 01:12:56 +01:00
2008-08-12 20:20:18 +02:00
print " </tr> \n " ;
$total = $total + $objp -> total_ht ;
$subtotal = $subtotal + $objp -> total_ht ;
$i ++ ;
}
print '</table>' ;
$db -> free ( $result );
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2008-08-12 20:20:18 +02:00
}
}
$db -> close ();
2011-08-27 16:24:16 +02:00
llxFooter ();
2008-08-12 20:20:18 +02:00
?>