diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 3fdc965575f..6f66c017c28 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -361,7 +361,7 @@ if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer) propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf); } -if ($_POST['action'] == 'setremise' && $user->rights->propale->creer) +if ($_POST['action'] == 'set_discount' && $user->rights->propale->creer) { $propal = new Propal($db); $propal->fetch($_GET['propalid']); @@ -383,22 +383,29 @@ if ($_POST['action'] == 'set_contact') $propal->set_contact($user, $_POST['contactidp']); } -// conditions de règlement +// Conditions de règlement if ($_POST["action"] == 'setconditions') { $propal = new Propal($db, $_GET["propalid"]); - $propal->cond_reglement_id = $_POST['cond_reglement_id']; - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_cond_reglement='".$_POST['cond_reglement_id']."' WHERE rowid='".$propalid."'"; - $result = $db->query($sql); + $propal->cond_reglement_id = $_POST['cond_reglement_id']; + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_cond_reglement='".$_POST['cond_reglement_id']."'"; + $sql.= " WHERE rowid='".$_GET["propalid"]."'"; + $resql = $db->query($sql); + if ($resql < 0) dolibarr_print_error($db); } -// mode de règlement +// Mode de règlement if ($_POST["action"] == 'setmode') { - $propal = new Propal($db, $_GET["propalid"]); - $propal->mode_reglement_id = $_POST['mode_reglement_id']; - $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_mode_reglement='".$_POST['mode_reglement_id']."' WHERE rowid='".$propalid."'"; - $result = $db->query($sql); + $propal = new Propal($db, $_GET["propalid"]); + $propal->mode_reglement_id = $_POST['mode_reglement_id']; + // \todo Créer une methode propal->cond_reglement + $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; + $sql.= " SET fk_mode_reglement='".$_POST['mode_reglement_id']."'"; + $sql.= " WHERE rowid='".$_GET["propalid"]."'"; + $resql = $db->query($sql); + if ($resql < 0) dolibarr_print_error($db); } @@ -483,7 +490,7 @@ if ($_GET['propalid'] > 0) $resql = $db->query($sql); if ($resql) { - if($db->num_rows($resql)) + if ($db->num_rows($resql)) { $obj = $db->fetch_object($resql); @@ -561,6 +568,7 @@ if ($_GET['propalid'] > 0) $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'none'); } print ''; + print ''; print ''; - print ''; - - $dests=$societe->contact_array($societe->id); - $numdest = count($dests); - if ($numdest==0) - { - print ''; - } - else - { - if ($propal->statut == 0 && $user->rights->propale->creer) - { - print ''; - } - else - { - if (!empty($propal->contactid)) - { - print ''; - } - else { - print ''; - } - } - } - + print ''; + if ($conf->projet->enabled) $rowspan++; print ''; + // Projet if ($conf->projet->enabled) { $langs->load("projects"); @@ -673,24 +655,30 @@ if ($_GET['propalid'] > 0) print ''; } - print ''; - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { + // Remise globale + print ''; print ''; - } - else - { - print ''; - } - print ''; - + } + else + { + print $propal->remise_percent.'%'; + } + print ''; + + // Amount print ''; print ''; print ''; @@ -703,23 +691,16 @@ if ($_GET['propalid'] > 0) // Statut print ''; print '
'; print $langs->trans('PaymentMode'); @@ -580,54 +588,28 @@ if ($_GET['propalid'] > 0) // Destinataire $langs->load('mails'); - print '
'.$langs->trans('MailTo').''; - print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale
'; - print ''.$langs->trans('AddContact').''; - print '
'; - print '
'; - print ''; - $html->select_contacts($societe->id, $propal->contactid, 'contactidp'); - print '
'; - print ''; - print ''; - print ''; - require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); - $contact=new Contact($db); - $contact->fetch($propal->contactid); - print ''; - print $contact->firstname.' '.$contact->name; - print ''; - print ' 
'; + print ''; + if ($_GET['action'] != 'editcontact' && $propal->brouillon) print ''; + print '
'; + print $langs->trans('MailTo'); + print 'id.'">'.img_edit($langs->trans('SetReceiver'),1).'
'; + print '
'; + if ($_GET['action'] == 'editcontact') + { + $html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'contactidp'); + } + else + { + $html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'none'); + } + print ''.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('GlobalDiscount').'
'; + print ''; + if ($_GET['action'] != 'editdiscount' && $propal->brouillon) print ''; + print '
'; + print $langs->trans('GlobalDiscount'); + print 'id.'">'.img_edit($langs->trans('SetGlobalDiscount'),1).'
'; + print '
'; + if ($_GET['action'] == 'editdiscount' && $propal->brouillon == 1 && $user->rights->propale->creer) + { print '
'; - print ''; - print '
% '; - print ''; + print ''; + print '% '; print ''; print ' ?'; - print ''.$propal->remise_percent.'%
'.$langs->trans('AmountHT').''.price($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Status').''.$propal->getLibStatut().'

'; - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - } /* * Lignes de propale * */ + print ''; + $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,'; - $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; - - if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC) - { - $sql.= ', p.description as product_desc'; - } - + $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,'; + $sql.= ' p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_propal = '.$propal->id; @@ -730,7 +711,6 @@ if ($_GET['propalid'] > 0) $num = $db->num_rows($resql); $i = 0; $total = 0; - print '
'; if ($num) { print ''; @@ -740,7 +720,8 @@ if ($_GET['propalid'] > 0) print ''; print ''; print ''; - print ''; + print ''; + print ''; print "\n"; } $var=true; @@ -759,9 +740,9 @@ if ($_GET['propalid'] > 0) if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); else print img_object($langs->trans('ShowProduct'),'product'); print ' '.$objp->ref.''; - print ' - '.nl2br(stripslashes($objp->product)); + print ' - '.nl2br(stripslashes($objp->product)); - if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC) + if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->CHANGE_PROD_DESC) { print '
'.nl2br(stripslashes($objp->product_desc)); } @@ -883,8 +864,9 @@ if ($_GET['propalid'] > 0) } /* - * Ajouter une ligne - */ + * Ajouter une ligne + */ + if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') { print ''; @@ -902,20 +884,22 @@ if ($_GET['propalid'] > 0) print ''; print ''; print ''; - + $var=true; + print '\n"; - print ' '; - print ' \n"; - print ' '; - print ' '; - print ' '; - print ' '; + print ''; + print '\n"; + print ''; + print ''; + print ''; + print ''; print ''; print ''; - + // Ajout de produits/services prédéfinis if ($conf->produit->enabled) { @@ -924,6 +908,7 @@ if ($_GET['propalid'] > 0) print ''; $var=!$var; + print ''; print ''; print ''; print "\n"; - + print ''; } } - + print '
'.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'    
'; - $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe) . "%'; + $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); + print "%
'; // multiprix @@ -939,11 +924,11 @@ if ($_GET['propalid'] > 0) print '%
'; } diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 0383b2f3a21..ca499f44667 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Destailleur Laurent + * Copyright (C) 2004-2006 Destailleur Laurent * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2006 Regis Houssin * @@ -43,12 +43,19 @@ require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); // Sécurité accés client +$socidp=''; +if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + if ($_GET["action"] == 'setstatut') { /* @@ -195,32 +202,32 @@ if ($_GET["propalid"] > 0) print ''; - if ($_GET['action'] != 'editconditions' && $prop->brouillon) print ''; + if ($_GET['action'] != 'editconditions' && $propal->brouillon) print ''; print '
'; print $langs->trans('PaymentConditions'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; print ''; if ($_GET['action'] == 'editconditions') { - $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->cond_reglement_id,'cond_reglement_id'); + $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id'); } else { - $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->cond_reglement_id,'none'); + $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'none'); } print ''; print ''; print ''; - if ($_GET['action'] != 'editmode' && $prop->brouillon) print ''; + if ($_GET['action'] != 'editmode' && $propal->brouillon) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print ''; if ($_GET['action'] == 'editmode') { - $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->mode_reglement_id,'mode_reglement_id'); + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'mode_reglement_id'); } else { - $html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$prop->id,$propal->mode_reglement_id,'none'); + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->mode_reglement_id,'none'); } print ''; @@ -242,13 +249,13 @@ if ($_GET["propalid"] > 0) { if ($propal->statut == 0 && $user->rights->propale->creer) { - print ''; - print '
'; - print ''; - $html->select_contacts($societe->id, $propal->contactid, 'contactidp'); - print ''; - print ''; - print '
'; + print ''; +// print '
'; +// print ''; + $html->select_contacts($societe->id, $propal->contactid, 'none'); +// print ''; +// print ''; +// print '
'; print ''; } else @@ -269,13 +276,12 @@ if ($_GET["propalid"] > 0) } } } - print ''; - if ($conf->projet->enabled) - $rowspan++; + if ($conf->projet->enabled) $rowspan++; print ''.$langs->trans('Note').' :
'. nl2br($propal->note).''; + // Projet if ($conf->projet->enabled) { $langs->load("projects"); @@ -292,13 +298,13 @@ if ($_GET["propalid"] > 0) { if ($propal->statut == 0 && $user->rights->propale->creer) { - print ''; - print '
'; - print ''; + print ''; +// print ''; +// print ''; $html->select_projects($societe->id, $propal->projetidp, 'projetidp'); - print ''; - print ''; - print '
'; +// print ''; +// print ''; +// print ''; print ''; } else @@ -321,17 +327,18 @@ if ($_GET["propalid"] > 0) print ''; } + // Remise globale print ''.$langs->trans('GlobalDiscount').''; if ($propal->brouillon == 1 && $user->rights->propale->creer) { - print '
'; - print ''; - print '% '; - print ''; - print ''; - print ' ?'; +// print ''; +// print ''; + print ''.$propal->remise_percent.'%'; +// print ''; +// print ''; +// print ' ?'; print ''; - print '
'; +// print ''; } else { @@ -351,10 +358,6 @@ if ($_GET["propalid"] > 0) // Statut print ''.$langs->trans('Status').''.$propal->getLibStatut().''; print '
'; - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - } /* * Lignes de propale