From fe9e69b416c36c7e608b902f365d78c52e0e744b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Aug 2005 23:11:26 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Mauvaise=20variable=20utilis=E9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/propal.php | 740 +++++++++++++++++++++-------------------- 1 file changed, 371 insertions(+), 369 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index ee35efdd596..cd9c65ae9cd 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -46,18 +46,19 @@ require_once('../propal.class.php'); require_once('../actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); +if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } +$year=isset($_GET["year"])?$_GET["year"]:""; +$month=isset($_GET["month"])?$_GET["month"]:""; + // Sécurité accés client +$socidp=''; +if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } -if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; } -if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); } -$year=isset($_GET["year"])?$_GET["year"]:""; -$month=isset($_GET["month"])?$_GET["month"]:""; - // Nombre de ligne pour choix de produit/service prédéfinis $NBLINES=4; @@ -420,369 +421,369 @@ if ($_GET['propalid'] > 0) $resql = $db->query($sql); if ($resql) { - if ($db->num_rows($resql)) - { - $obj = $db->fetch_object($resql); - - $societe = new Societe($db); - $societe->fetch($obj->idp); - - print ''; - $rowspan=6; - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - - // Destinataire - $langs->load('mails'); - 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 ''; - - if ($conf->projet->enabled) - { - $langs->load("projects"); - print ''; - $numprojet = $societe->has_projects(); - if (! $numprojet) - { - print ''; - } - else - { - if ($propal->statut == 0 && $user->rights->propale->creer) - { - print ''; - } - else - { - if (!empty($propal->projetidp)) - { - print ''; - } - else { - print ''; - } - } - } - print ''; - } - - print ''; - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - print ''; - print ''; - print ''; - } - else - { - print ''; - } - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - // Statut - print ''; - print '
'.$langs->trans('Company').''; - if ($societe->client == 1) - { - $url ='fiche.php?socid='.$societe->id; - } - else - { - $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; - } - print ''.$societe->nom.'Conditions de réglement'.' '.'
'.$langs->trans('Date').''; - print dolibarr_print_date($propal->date,'%a %d %B %Y'); - print ''.$langs->trans('DateEndPropal').''; - if ($propal->fin_validite) - { - print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); - if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - } - else - { - print $langs->trans("Unknown"); - } - 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 ''; - $form->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 ' '.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('Project').''; - print $langs->trans("NoProject").''; - print 'id.'&action=create>'.$langs->trans('AddProject').''; - print ''; - print '
'; - print ''; - $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); - print '
'; - print ''; - print ''; - print ''; - $proj = new Project($db); - $proj->fetch($propal->projetidp); - print ''; - print $proj->title; - print ''; - print ' 
'.$langs->trans('GlobalDiscount').'
% '; - print ''; - print ''; - print ' ?'; - print ''.$propal->remise_percent.'%
'.$langs->trans('AmountHT').''.price($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('VAT').''.price($propal->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($propal->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Status').''.$propal->getLibStatut().'

'; - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - } - - /* - * Lignes de propale - * - */ - $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'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; - $sql.= ' WHERE pt.fk_propal = '.$propal->id; - $sql.= ' ORDER BY pt.rowid ASC'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - - print ''; - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - - // Update ligne de propale - if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) - { - print ''; - if ($objp->fk_product > 0) - { - print ''; + } + else + { + if (!empty($propal->contactid)) + { + print ''; + } + else { + print ''; + } + } + } + print ''; + + if ($conf->projet->enabled) + $rowspan++; + + print ''; + + if ($conf->projet->enabled) + { + $langs->load("projects"); + print ''; + $numprojet = $societe->has_projects(); + if (! $numprojet) + { + print ''; + } + else + { + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print ''; + } + else + { + if (!empty($propal->projetidp)) + { + print ''; + } + else { + print ''; + } + } + } + print ''; + } + + print ''; + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + } + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Statut + print ''; + print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
'; - if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); - else print img_object($langs->trans('ShowProduct'),'product'); - print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product)); - if ($objp->date_start && $objp->date_end) - { - print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; - } - if ($objp->date_start && ! $objp->date_end) - { - print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; - } - if (! $objp->date_start && $objp->date_end) - { - print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; - } - print ($objp->description && $objp->description!=$obj->product)?'
'.$objp->description:''; + if($db->num_rows($resql)) + { + $obj = $db->fetch_object($resql); + + $societe = new Societe($db); + $societe->fetch($obj->idp); + + print ''; + $rowspan=6; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + + // Destinataire + $langs->load('mails'); + print ''; + print ''; + + $dests=$societe->contact_array($societe->id); + $numdest = count($dests); + if ($numdest==0) + { + print ''; } - else - { - print '\n"; - } - print ''; - print '\n"; - print ''; - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - print '\n"; - - // Icone d'edition et suppression - if ($propal->statut == 0 && $user->rights->propale->creer) - { - print ''; - print ''; - } - else - { - print ''; - } - print ''; - } - - // Update ligne de propal - if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] == 'editline' && $_GET["ligne"] == $objp->rowid) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - $total = $total + ($objp->qty * $objp->price); - $i++; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - - /* - * Ajouter une ligne - */ - if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - // Ajout produit produits/services personalisés - print ''; - print ''; - print ''; - - $var=true; - print '\n"; - print ' '; - print ' \n"; - print ' '; - print ' '; - print ' '; - print ' '; - print ''; - - print ''; - - // Ajout de produits/services prédéfinis - print ''; - print ''; - print ''; - - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - print ''; - } - - print '
'.$langs->trans('Company').''; + if ($societe->client == 1) + { + $url ='fiche.php?socid='.$societe->id; + } + else + { + $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; + } + print ''.$societe->nom.'Conditions de réglement'.' '.'
'.$langs->trans('Date').''; + print dolibarr_print_date($propal->date,'%a %d %B %Y'); + print ''.$langs->trans('DateEndPropal').''; + if ($propal->fin_validite) + { + print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); + if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + } + else + { + print $langs->trans("Unknown"); + } + 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 '
'.stripslashes(nl2br($objp->description)); - if ($objp->date_start && $objp->date_end) - { - print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; - } - if ($objp->date_start && ! $objp->date_end) - { - print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; - } - if (! $objp->date_start && $objp->date_end) - { - print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; - } - print "'.$objp->tva_tx.'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."'; - print img_edit(); - print ''; - print img_delete(); - print '  
  %
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').'   
'; - print $html->select_tva('np_tva_tx', $conf->defaulttx) . "%
'; - $html->select_produits('','idprod','',20); - print '
'; - print ''; - print '
 %
'; - - } + else + { + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print '
'; + print '
'; + print ''; + $form->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 ' '.$langs->trans('Note').' :
'. nl2br($propal->note).'
'.$langs->trans('Project').''; + print $langs->trans("NoProject").''; + print 'id.'&action=create>'.$langs->trans('AddProject').''; + print ''; + print '
'; + print ''; + $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); + print '
'; + print ''; + print ''; + print ''; + $proj = new Project($db); + $proj->fetch($propal->projetidp); + print ''; + print $proj->title; + print ''; + print ' 
'.$langs->trans('GlobalDiscount').'
% '; + print ''; + print ''; + print ' ?'; + print ''.$propal->remise_percent.'%
'.$langs->trans('AmountHT').''.price($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('VAT').''.price($propal->total_tva).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($propal->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Status').''.$propal->getLibStatut().'

'; + if ($propal->brouillon == 1 && $user->rights->propale->creer) + { + print ''; + } + + /* + * Lignes de propale + * + */ + $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'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; + $sql.= ' WHERE pt.fk_propal = '.$propal->id; + $sql.= ' ORDER BY pt.rowid ASC'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + + print ''; + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + + // Update ligne de propale + if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) + { + print ''; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print '\n"; + } + print ''; + print '\n"; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + + // Icone d'edition et suppression + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print ''; + print ''; + } + else + { + print ''; + } + print ''; + } + + // Update ligne de propal + if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] == 'editline' && $_GET["ligne"] == $objp->rowid) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + $total = $total + ($objp->qty * $objp->price); + $i++; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + + /* + * Ajouter une ligne + */ + if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + // Ajout produit produits/services personalisés + print ''; + print ''; + print ''; + + $var=true; + print '\n"; + print ' '; + print ' \n"; + print ' '; + print ' '; + print ' '; + print ' '; + print ''; + + print ''; + + // Ajout de produits/services prédéfinis + print ''; + print ''; + print ''; + + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + } + + print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
'; + if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product)); + if ($objp->date_start && $objp->date_end) + { + print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; + } + if ($objp->date_start && ! $objp->date_end) + { + print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; + } + if (! $objp->date_start && $objp->date_end) + { + print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; + } + print ($objp->description && $objp->description!=$obj->product)?'
'.$objp->description:''; + print '
'.stripslashes(nl2br($objp->description)); + if ($objp->date_start && $objp->date_end) + { + print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; + } + if ($objp->date_start && ! $objp->date_end) + { + print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; + } + if (! $objp->date_start && $objp->date_end) + { + print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; + } + print "'.$objp->tva_tx.'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."'; + print img_edit(); + print ''; + print img_delete(); + print '  
  %
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').'   
'; + print $html->select_tva('np_tva_tx', $conf->defaulttx) . "%
'; + $html->select_produits('','idprod','',20); + print '
'; + print ''; + print '
 %
'; + + } } else { @@ -799,7 +800,7 @@ if ($_GET['propalid'] > 0) print '
'; print ''; print ''; print '
'.$langs->trans('Note').'
'.$langs->trans("CloseAs").''; print ''; @@ -854,7 +855,7 @@ if ($_GET['propalid'] > 0) { if ($user->rights->propale->envoyer) { - $propref = sanitize_string($obj->ref); + $propref = sanitize_string($propal->ref); $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; if (file_exists($file)) { @@ -940,7 +941,8 @@ if ($_GET['propalid'] > 0) */ $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.fk_soc = '.$obj->idp.' AND a.propalrowid = '.$propal->id ; + $sql .= ' WHERE a.propalrowid = '.$propal->id ; + if ($socidp) $sql .= ' AND a.fk_soc = '.$socidp; $resql = $db->query($sql); if ($resql) {