diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 3d3368cc5c094..0e77f8512d3d1 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -31,7 +31,8 @@ */ require("./pre.inc.php"); -require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); $user->getrights('propale'); @@ -359,15 +360,14 @@ } -if ($_POST['action'] == "adddiscount" && $user->rights->propale->creer) +if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer) { $propal = new Propal($db); $ret=$propal->fetch($_POST['propalid']); - if ($_POST["amount"]) + if ($_POST["remise_id"]) { -// \todo a completer -// $propal->insert_discount($_POST["amount"]); + $propal->insert_discount($_POST["remise_id"]); } } @@ -514,107 +514,70 @@ */ if ($_GET['propalid'] > 0) { - if ($msg) print "$msg
"; + if ($msg) print "$msg
"; - $propal = new Propal($db); - $propal->fetch($_GET['propalid']); + $propal = new Propal($db); + $propal->fetch($_GET['propalid']); - $societe = new Societe($db); - $societe->fetch($propal->soc_id); - $h=0; + $societe = new Societe($db); + $societe->fetch($propal->soc_id); - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('CommercialCard'); - $hselected=$h; - $h++; + $head = propal_prepare_head($propal); + dolibarr_fiche_head($head, 'comm', $langs->trans('Proposal')); - $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('AccountancyCard'); - $h++; - if ($conf->use_preview_tabs) + /* + * Confirmation de la suppression de la propale + */ + if ($_GET['action'] == 'delete') { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Preview"); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Note'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Info'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Documents'); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal')); - - /* - * Confirmation de la suppression de la propale - */ - if ($_GET['action'] == 'delete') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); - print '
'; - } + $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete'); + print '
'; + } - /* - * Confirmation de la validation de la propale - */ - if ($_GET['action'] == 'validate') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate'); - print '
'; - } + /* + * Confirmation de la validation de la propale + */ + if ($_GET['action'] == 'validate') + { + $html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate'); + print '
'; + } - /* - * Fiche propal - * - */ + /* + * Fiche propal + * + */ $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, p.fk_cond_reglement, p.fk_mode_reglement, '.$db->pdate('p.datep').' as dp, p.note,'; $sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'socpeople as x'; $sql.= ' WHERE p.fk_soc = s.idp AND p.fk_soc_contact = x.idp AND p.rowid = '.$propal->id; if ($socidp) $sql .= ' AND s.idp = '.$socidp; - + $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 ''; + { + if ($db->num_rows($resql)) + { + $obj = $db->fetch_object($resql); - // Ref - print ''; + $societe = new Societe($db); + $societe->fetch($obj->idp); + + print '
'.$langs->trans('Ref').''.$propal->ref_url.'
'; + + // Ref + print ''; + + $rowspan=9; + + // Société + print ''; + print ''; - $rowspan=9; - - // Société - print ''; - print ''; - // Ligne info remises tiers - print ''; - - // Dates - print ''; - - if ($conf->projet->enabled) $rowspan++; - if ($conf->global->PROPAL_ADD_SHIPPING_DATE) $rowspan++; - if ($conf->global->PROPAL_ADD_DELIVERY_ADDRESS) $rowspan++; - - // Notes - print ''; - print ''; - - // Date fin propal - print ''; + + // Dates + print ''; + + if ($conf->projet->enabled) $rowspan++; + if ($conf->global->PROPAL_ADD_SHIPPING_DATE) $rowspan++; + if ($conf->global->PROPAL_ADD_DELIVERY_ADDRESS) $rowspan++; + + // Notes + print ''; + print ''; + + // Date fin propal + print ''; print ''; - print ''; - - + print ''; + print ''; + + // date de livraison (conditonné sur PROPAL_ADD_SHIPPING_DATE car carac à // gérer par les commandes et non les propal if ($conf->global->PROPAL_ADD_SHIPPING_DATE) @@ -687,10 +651,10 @@ if ($_GET['action'] == 'editdate_livraison') { print ''; - print ''; - $html->select_date($propal->date_livraison,'liv_','','','',"editdate_livraison"); - print ''; - print ''; + print ''; + $html->select_date($propal->date_livraison,'liv_','','','',"editdate_livraison"); + print ''; + print ''; } else { @@ -699,30 +663,30 @@ print ''; print ''; } - + // adresse de livraison if ($conf->global->PROPAL_ADD_DELIVERY_ADDRESS) - { - print ''; + { + print ''; } - + // Conditions et modes de réglement print '
'.$langs->trans('Ref').''.$propal->ref_url.'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$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.''; - print '
'.$langs->trans('Discounts').''; + print '
'.$langs->trans('Discounts').''; if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); $absolute_discount=$societe->getCurrentDiscount(); @@ -623,56 +586,57 @@ { print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); print '.'; +// print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id); } else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; print '
'.$langs->trans('Date').''; - print dolibarr_print_date($propal->date,'%a %d %B %Y'); - print ''.$langs->trans('NotePublic').' :
'. nl2br($propal->note_public).'
'.$langs->trans('Date').''; + print dolibarr_print_date($propal->date,'%a %d %B %Y'); + print ''.$langs->trans('NotePublic').' :
'. nl2br($propal->note_public).'
'; print ''; if ($_GET['action'] != 'editecheance' && $propal->brouillon) print ''; print '
'; print $langs->trans('DateEndPropal'); print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; - print '
'; - if ($propal->brouillon && $_GET['action'] == 'editecheance') - { - print '
'; - print ''; - $html->select_date($propal->fin_validite,'ech','','','',"editecheance"); - print ''; - print '
'; - } - else - { - 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 '
'; + if ($propal->brouillon && $_GET['action'] == 'editecheance') + { + print '
'; + print ''; + $html->select_date($propal->fin_validite,'ech','','','',"editecheance"); + print ''; + print '
'; + } + else + { + 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 '
'; - print ''; - - if ($_GET['action'] != 'editdelivery_adress' && $propal->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socidp.'&propalid='.$propal->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print '
'; - - if ($_GET['action'] == 'editdelivery_adress') - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'adresse_livraison_id','propal',$propal->id); - } - else - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'none','propal',$propal->id); - } - print '
'; + print ''; + + if ($_GET['action'] != 'editdelivery_adress' && $propal->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socidp.'&propalid='.$propal->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; + print '
'; + + if ($_GET['action'] == 'editdelivery_adress') + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'adresse_livraison_id','propal',$propal->id); + } + else + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->adresse_livraison_id,$_GET['socidp'],'none','propal',$propal->id); + } + print '
'; print ''; print ''; - + // Mode paiement print ''; print ''; - // Destinataire - $langs->load('mails'); - print ''; print ''; - + // Projet - 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 ''; - } - - // Amount - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - // Statut - print ''; - print '
'; @@ -741,7 +705,7 @@ } print '
'; @@ -761,11 +725,11 @@ } print '
'; + // Destinataire + $langs->load('mails'); + print '
'; print ''; if ($_GET['action'] != 'editcontact' && $propal->brouillon) print ''; print '
'; - print $langs->trans('MailTo'); + print $langs->trans('MailTo'); print 'id.'">'.img_edit($langs->trans('SetReceiver'),1).'
'; @@ -780,264 +744,264 @@ } print '
'.$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('AmountHT').''.price($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountVAT').''.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(4).'

'; - - /* - * 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,'; - $sql.= ' p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; - $sql.= ' WHERE pt.fk_propal = '.$propal->id; - $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - 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 ''; + } + + // Amount + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // Statut + print ''; + print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').''.$langs->trans('AmountHT').'  
'.$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('AmountHT').''.price($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountVAT').''.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(4).'

'; + + /* + * 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,'; + $sql.= ' p.description as product_desc'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; + $sql.= ' WHERE pt.fk_propal = '.$propal->id; + $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - - // Ligne en mode visu - if ($_GET['action'] != 'editline' || $_GET['ligne'] != $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 ''; - print ''; - } - else - { - print ''; - } - - print ''; - } - - // Ligne en mode update - if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["ligne"] == $objp->rowid) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print "\n"; + } + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + + // Ligne en mode visu + if ($_GET['action'] != 'editline' || $_GET['ligne'] != $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 ''; + print ''; + } + else + { + print ''; + } + + print ''; + } + + // Ligne en mode update + if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["ligne"] == $objp->rowid) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - /* + print $html->select_tva("tva_tx",$objp->tva_tx,$mysoc,$societe); + print ''; + print ''; + print ''; + print ''; + print ''; + print '' . "\n"; + /* if ($conf->service->enabled) - { - print ""; - print ''; - print '' . "\n"; - } + { + print ""; + print ''; + print '' . "\n"; + } */ - print "\n"; - } - - $total = $total + ($objp->qty * $objp->price); - $i++; - } - - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - + print "\n"; + } + + $total = $total + ($objp->qty * $objp->price); + $i++; + } + + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + /* - * Lignes de remise - */ - - // Réductions relatives (Remises-Ristournes-Rabbais) -/* Une réduction doit s'appliquer obligatoirement sur des lignes de factures + * Lignes de remise + */ + + // Réductions relatives (Remises-Ristournes-Rabbais) + /* Une réduction doit s'appliquer obligatoirement sur des lignes de factures $var=!$var; print ''; print ''; @@ -1052,11 +1016,11 @@ print ''; print ''; if ($_GET['action'] != 'editrelativediscount') { - if ($propal->brouillon && $user->rights->propale->creer) - { - print ''; - } - else - { - print ''; - } - if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_percent) - { - print ''; - } - else - { - print ''; - } - print ''; + if ($propal->brouillon && $user->rights->propale->creer) + { + print ''; + } + else + { + print ''; + } + if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_percent) + { + print ''; + } + else + { + print ''; + } + print ''; } else { - print ''; + print ''; } print ''; print ''; -*/ + */ - // Réductions absolues (Remises-Ristournes-Rabbais) -/* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées + // Réductions absolues (Remises-Ristournes-Rabbais) + /* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées $var=!$var; print ''; print ''; @@ -1110,367 +1074,367 @@ print ''; if ($_GET['action'] != 'editabsolutediscount') { - if ($propal->brouillon && $user->rights->propale->creer) + if ($propal->brouillon && $user->rights->propale->creer) + { + print ''; + } + else + { + print ''; + } + if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_absolue) + { + print ''; + } + else + { + print ''; + } + print ''; + } + else + { + print ''; + } + print ''; + print ''; + */ + + /* + * Ajouter une ligne + */ + if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') + { + print ''; + 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 ''; + print '0'; } else { - print ''; - } - if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_absolue) - { - print ''; + $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); } - else + print "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + // Ajout de produits/services prédéfinis + if ($conf->produit->enabled) { + print ''; + print ''; + print ''; + + $var=!$var; + + print ''; + print ''; print ''; + print ''; + print ''; + + print ''."\n"; + + print ''; } - print ''; } - else - { - print ''; - } - print ''; - print ''; -*/ - - /* - * Ajouter une ligne - */ - if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') - { - print ''; - 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 - if ($conf->produit->enabled) - { - print ''; - print ''; - print ''; - - $var=!$var; - - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''."\n"; - - print ''; - } - } + print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').''.$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.''; - print ' - '.nl2br(stripslashes($objp->product)); - - if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC) - { - print '
'.nl2br(stripslashes($objp->product_desc)); - } - - if ($objp->date_start && $objp->date_end) - { - print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; - } - if ($objp->date_start && ! $objp->date_end) - { - print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; - } - if (! $objp->date_start && $objp->date_end) - { - print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; - } - print ($objp->description && $objp->description!=$objp->product)?'
'.stripslashes(nl2br($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)."rowid.'">'; - print img_edit(); - print 'rowid.'">'; - print img_delete(); - print ''; - if ($i > 0) - { - print 'rowid.'">'; - print img_up(); - print ''; - } - if ($i < $num-1) - { - print 'rowid.'">'; - print img_down(); - print ''; - } - print ' 
'; - if ($objp->fk_product > 0) - { - print ''; - if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); - else print img_object($langs->trans('ShowProduct'),'product'); - print ' '.$objp->ref.''; - print ' - '.stripslashes(nl2br($objp->product)); - print '
'; - } - print '
'; + print '  
'; + 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)); + + if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC) + { + print '
'.nl2br(stripslashes($objp->product_desc)); + } + + if ($objp->date_start && $objp->date_end) + { + print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')'; + } + if ($objp->date_start && ! $objp->date_end) + { + print ' (A partir du '.dolibarr_print_date($objp->date_start).')'; + } + if (! $objp->date_start && $objp->date_end) + { + print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; + } + print ($objp->description && $objp->description!=$objp->product)?'
'.stripslashes(nl2br($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)."rowid.'">'; + print img_edit(); + print 'rowid.'">'; + print img_delete(); + print ''; + if ($i > 0) + { + print 'rowid.'">'; + print img_up(); + print ''; + } + if ($i < $num-1) + { + print 'rowid.'">'; + print img_down(); + print ''; + } + print ' 
'; + if ($objp->fk_product > 0) + { + print ''; + if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + print ' '.$objp->ref.''; + print ' - '.stripslashes(nl2br($objp->product)); + print '
'; + } + print '
'; if($societe->tva_assuj == "0") - print '0'; + print '0'; else - print $html->select_tva("tva_tx",$objp->tva_tx,$mysoc,$societe); - print '%'; - print '
%'; + print '
Si produit de type service à durée limitée: Du '; - print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); - print ' au '; - print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); - print '
Si produit de type service à durée limitée: Du '; + print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); + print ' au '; + print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); + print '
'; if ($_GET['action'] == 'editrelativediscount') { - print '%'; + print '%'; } else { - print $propal->remise_percent?$propal->remise_percent.'%':' '; + print $propal->remise_percent?$propal->remise_percent.'%':' '; } print ''; @@ -1065,36 +1029,36 @@ print 'id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).' rowid.'">'; - print img_delete(); - print '  id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).' rowid.'">'; + print img_delete(); + print '  
'; if ($_GET['action'] == 'editabsolutediscount') { - print '-'; + print '-'; } else { - print $propal->remise_absolue?'-'.price($propal->remise_absolue):$langs->trans("DiscountNone"); + print $propal->remise_absolue?'-'.price($propal->remise_absolue):$langs->trans("DiscountNone"); } print 'id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).' rowid.'">'; + print img_delete(); + print '  
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'    
'; + if($societe->tva_assuj == "0") { - print 'id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).' rowid.'">'; - print img_delete(); - print '%
'; + // multiprix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + $html->select_produits('','idprod','',$conf->produit->limit_size,$societe->price_level); + } + else + { + $html->select_produits('','idprod','',$conf->produit->limit_size); + } + print '
'; + print ''; + print '
 %'; + print '
 
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'    
'; - if($societe->tva_assuj == "0") - { - print '0'; - } - else - { - $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); - } - print "%
'; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - $html->select_produits('','idprod','',$conf->produit->limit_size,$societe->price_level); - } - else - { - $html->select_produits('','idprod','',$conf->produit->limit_size); - } - print '
'; - print ''; - print '
 %'; - print '
'; + } + } + else + { + dolibarr_print_error($db); + } - print '
'; - } - } - else - { - dolibarr_print_error($db); - } - print ''; print "\n"; /* - * Formulaire cloture (signé ou non) - */ - if ($_GET['action'] == 'statut') - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('Note').'
'.$langs->trans("CloseAs").''; - print ''; - print ''; - print '
'; - print ''; - print '   '; - print '
'; - } + * Formulaire cloture (signé ou non) + */ + if ($_GET['action'] == 'statut') + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Note').'
'.$langs->trans("CloseAs").''; + print ''; + print ''; + print '
'; + print ''; + print '   '; + print '
'; + } - /* - * Boutons Actions - */ - print '
'; - - if ($_GET['action'] != 'statut') - { - - // Valid - if ($propal->statut == 0) - { - if ($user->rights->propale->valider && $propal->total_ttc > 0) - { - print ''.$langs->trans('Validate').''; - } - } - - // Save - if ($propal->statut == 1) - { - if ($user->rights->propale->creer) - { - print ''.$langs->trans('Edit').''; - } - } - - // Build PDF - if ($user->rights->propale->creer) - { - if ($propal->statut < 2) - { - print ''.$langs->trans("BuildPDF").''; - } - else - { - print ''.$langs->trans("RebuildPDF").''; - } - } - - // Send - if ($propal->statut == 1) - { - if ($user->rights->propale->envoyer) - { - $propref = sanitize_string($propal->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - if (file_exists($file)) - { - print ''.$langs->trans('Send').''; - } - } - } - - // Close - if ($propal->statut != 0) - { - if ($propal->statut == 1 && $user->rights->propale->cloturer) - { - print ''.$langs->trans('Close').''; - } - } - - // Delete - if ($propal->statut == 0) - { - if ($user->rights->propale->supprimer) - { - print ''.$langs->trans('Delete').''; - } - } - - } - - print '
'; - print "
\n"; - - - print '
'; + /* + * Boutons Actions + */ + print '
'; + if ($_GET['action'] != 'statut') + { - /* - * Documents générés - */ - $filename=sanitize_string($propal->ref); - $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); - $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; - $genallowed=$user->rights->propale->creer; - $delallowed=$user->rights->propale->supprimer; - - $var=true; - - $html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); + // Valid + if ($propal->statut == 0) + { + if ($user->rights->propale->valider && $propal->total_ttc > 0) + { + print ''.$langs->trans('Validate').''; + } + } + // Save + if ($propal->statut == 1) + { + if ($user->rights->propale->creer) + { + print ''.$langs->trans('Edit').''; + } + } - /* - * Commandes rattachées - */ - if($conf->commande->enabled) - { - $coms = $propal->associated_orders(); - if (sizeof($coms) > 0) - { - print '
'; - print_titre($langs->trans('RelatedOrders')); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=true; - for ($i = 0 ; $i < sizeof($coms) ; $i++) - { - $var=!$var; - print '\n"; - print ''; - print ''; - print "\n"; - } - print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'; - print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date).''.$coms[$i]->total_ttc.'
'; - } - } + // Build PDF + if ($user->rights->propale->creer) + { + if ($propal->statut < 2) + { + print ''.$langs->trans("BuildPDF").''; + } + else + { + print ''.$langs->trans("RebuildPDF").''; + } + } - print '
'; + // Send + if ($propal->statut == 1) + { + if ($user->rights->propale->envoyer) + { + $propref = sanitize_string($propal->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + if (file_exists($file)) + { + print ''.$langs->trans('Send').''; + } + } + } - /* - * Liste des actions propres à la propal - */ - $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql .= ' WHERE a.propalrowid = '.$propal->id ; - if ($socidp) $sql .= ' AND a.fk_soc = '.$socidp; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - print_titre($langs->trans('ActionsOnPropal')); - $i = 0; - $total = 0; - $var=true; + // Close + if ($propal->statut != 0) + { + if ($propal->statut == 1 && $user->rights->propale->cloturer) + { + print ''.$langs->trans('Close').''; + } + } - print ''; - print ''; - print "\n"; + // Delete + if ($propal->statut == 0) + { + if ($user->rights->propale->supprimer) + { + print ''.$langs->trans('Delete').''; + } + } - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print '\n"; - print ''; - $authoract = new User($db); - $authoract->id = $objp->fk_user_author; - $authoract->fetch(''); - print ''; - print "\n"; - $i++; - } - print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->code.'
'; } - } - else - { - dolibarr_print_error($db); - } - print '
'; + print ''; + print "
\n"; - /* - * Action presend - * - */ - if ($_GET['action'] == 'presend') - { - print '
'; - print_titre($langs->trans('SendPropalByMail')); + print '
'; + + + /* + * Documents générés + */ + $filename=sanitize_string($propal->ref); + $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); + $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; + $genallowed=$user->rights->propale->creer; + $delallowed=$user->rights->propale->supprimer; + + $var=true; - $liste[0]=" "; - foreach ($societe->contact_email_array() as $key=>$value) + $html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); + + + /* + * Commandes rattachées + */ + if($conf->commande->enabled) { - $liste[$key]=$value; + $coms = $propal->associated_orders(); + if (sizeof($coms) > 0) + { + print '
'; + print_titre($langs->trans('RelatedOrders')); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + for ($i = 0 ; $i < sizeof($coms) ; $i++) + { + $var=!$var; + print '\n"; + print ''; + print ''; + print "\n"; + } + print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").'
'; + print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date).''.$coms[$i]->total_ttc.'
'; + } } - // Créé l'objet formulaire mail - include_once('../html.formmail.class.php'); - $formmail = new FormMail($db); - $formmail->fromname = $user->fullname; - $formmail->frommail = $user->email; - $formmail->withfrom=1; - $formmail->withto=$liste; - $formmail->withcc=1; - $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); - $formmail->withfile=1; - $formmail->withbody=1; - // Tableau des substitutions - $formmail->substit['__PROPREF__']=$propal->ref; - // Tableau des paramètres complémentaires - $formmail->param['action']='send'; - $formmail->param['models']='propal_send'; - $formmail->param['propalid']=$propal->id; - $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - - $formmail->show_form(); - } + print '
'; + + /* + * Liste des actions propres à la propal + */ + $sql = 'SELECT id, '.$db->pdate('a.datea'). ' as da, label, note, fk_user_author' ; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.propalrowid = '.$propal->id ; + if ($socidp) $sql .= ' AND a.fk_soc = '.$socidp; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + print_titre($langs->trans('ActionsOnPropal')); + $i = 0; + $total = 0; + $var=true; + + print ''; + print ''; + print "\n"; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ''; + print ''; + print '\n"; + print ''; + $authoract = new User($db); + $authoract->id = $objp->fk_user_author; + $authoract->fetch(''); + print ''; + print "\n"; + $i++; + } + print '
'.$langs->trans('Ref').''.$langs->trans('Date').''.$langs->trans('Action').''.$langs->trans('By').'
'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.''.dolibarr_print_date($objp->da)."'.stripslashes($objp->label).''.$authoract->code.'
'; + } + } + else + { + dolibarr_print_error($db); + } + + print '
'; + + + /* + * Action presend + * + */ + if ($_GET['action'] == 'presend') + { + print '
'; + print_titre($langs->trans('SendPropalByMail')); + + $liste[0]=" "; + foreach ($societe->contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } + + // Créé l'objet formulaire mail + include_once('../html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->fromname = $user->fullname; + $formmail->frommail = $user->email; + $formmail->withfrom=1; + $formmail->withto=$liste; + $formmail->withcc=1; + $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); + $formmail->withfile=1; + $formmail->withbody=1; + // Tableau des substitutions + $formmail->substit['__PROPREF__']=$propal->ref; + // Tableau des paramètres complémentaires + $formmail->param['action']='send'; + $formmail->param['models']='propal_send'; + $formmail->param['propalid']=$propal->id; + $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + + $formmail->show_form(); + } } else diff --git a/htdocs/comm/propal/apercu.php b/htdocs/comm/propal/apercu.php index f40c41ed988e6..7864f3eba8d22 100644 --- a/htdocs/comm/propal/apercu.php +++ b/htdocs/comm/propal/apercu.php @@ -30,6 +30,12 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); +if ($conf->projet->enabled) { + require_once(DOL_DOCUMENT_ROOT."/project.class.php"); +} + $user->getrights('propale'); @@ -40,22 +46,15 @@ $langs->load("bills"); $langs->load('compta'); - -require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); -if ($conf->projet->enabled) { - require_once(DOL_DOCUMENT_ROOT."/project.class.php"); -} - - -/* - * Sécurité accés client -*/ +// Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } + + llxHeader(); $html = new Form($db); @@ -66,45 +65,17 @@ /* */ /* *************************************************************************** */ -if ($_GET["propalid"] > 0) { +if ($_GET["propalid"] > 0) +{ $propal = new Propal($db); if ( $propal->fetch($_GET["propalid"], $user->societe_id) > 0) - { + { $soc = new Societe($db, $propal->socidp); $soc->fetch($propal->socidp); - $h=0; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('CommercialCard'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('AccountancyCard'); - $h++; - - if ($conf->use_preview_tabs) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Preview"); - $hselected=$h; - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Note'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Info'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Documents'); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal')); + $head = propal_prepare_head($propal); + dolibarr_fiche_head($head, 'preview', $langs->trans('Proposal')); /* @@ -131,18 +102,11 @@ print ''.$langs->trans('Ref').''.$propal->ref_url.''; $rowspan=3; + // ligne 1 // partie Gauche - print ''.$langs->trans('Company').''; - if ($societe->client == 1) - { - $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id; - } - else - { - $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; - } - print ''.$societe->nom.''; + print ''.$langs->trans('Company').''.$societe->getNomUrl(1).''; + // partie Droite print ''.$langs->trans("PaymentConditions").''; print ''.' '.''; diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index a86b2d28a1962..91aeb06a15d68 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -31,6 +31,7 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); $user->getrights('propale'); @@ -110,37 +111,8 @@ $societe = new Societe($db); $societe->fetch($propal->socidp); - $h=0; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('CommercialCard'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('AccountancyCard'); - $h++; - - if ($conf->use_preview_tabs) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Preview"); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Note'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Info'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Documents'); - $hselected=$h; - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal')); + $head = propal_prepare_head($propal); + dolibarr_fiche_head($head, 'document', $langs->trans('Proposal')); // Construit liste des fichiers clearstatcache(); @@ -178,17 +150,7 @@ print ''.$langs->trans('Ref').''.$propal->ref_url.''; // Société - 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.''; - print ''; + print ''.$langs->trans('Company').''.$societe->getNomUrl(1).''; print ''.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").''; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index fdfeb7ebe6086..2b11118dba803 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -30,6 +30,7 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); $langs->load('propal'); $langs->load('compta'); @@ -56,37 +57,9 @@ $societe = new Societe($db); $societe->fetch($propal->soc_id); -$h=0; -$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; -$head[$h][1] = $langs->trans('CommercialCard'); -$h++; - -$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; -$head[$h][1] = $langs->trans('AccountancyCard'); -$h++; - -if ($conf->use_preview_tabs) -{ - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Preview"); - $h++; -} - -$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; -$head[$h][1] = $langs->trans('Note'); -$h++; - -$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; -$head[$h][1] = $langs->trans('Info'); -$hselected=$h; -$h++; - -$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; -$head[$h][1] = $langs->trans('Documents'); -$h++; - -dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal')); +$head = propal_prepare_head($propal); +dolibarr_fiche_head($head, 'info', $langs->trans('Proposal')); $propal->info($propal->id); diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 2f613e6e0cd98..da6b1150a5488 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -31,6 +31,7 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); $langs->load('propal'); $langs->load('compta'); @@ -109,55 +110,27 @@ $societe = new Societe($db); if ( $societe->fetch($propal->soc_id) ) { - $h=0; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('CommercialCard'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('AccountancyCard'); - $h++; - - if ($conf->use_preview_tabs) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Preview"); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Note'); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Info'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Documents'); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal")); + $head = propal_prepare_head($propal); + dolibarr_fiche_head($head, 'note', $langs->trans('Proposal')); print ''; print ''; // Société - print ''; - print ''; + print ''; + // Ligne info remises tiers + print ''; + // Date print ''; - print ''; + print ''; // Ligne info remises tiers print '
'.$langs->trans('Ref').''.$propal->ref_url.'
'.$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.'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Discounts').''; + if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount=$societe->getCurrentDiscount(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'.$langs->trans('Date').''; print dolibarr_print_date($propal->date,'%a %d %B %Y'); diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 105c73b2b702e..f535d5daf6bb7 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -30,6 +30,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); @@ -121,37 +122,9 @@ $propal = new Propal($db); $propal->fetch($_GET["propalid"]); - $h=0; - $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('CommercialCard'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('AccountancyCard'); - $hselected=$h; - $h++; - - if ($conf->use_preview_tabs) - { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans("Preview"); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Note'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Info'); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; - $head[$h][1] = $langs->trans('Documents'); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal')); + $head = propal_prepare_head($propal); + dolibarr_fiche_head($head, 'compta', $langs->trans('Proposal')); /* @@ -182,17 +155,7 @@ $rowspan=9; // Société - 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.'
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Discounts').''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 1d56818a26398..0865827c189a1 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -450,13 +450,13 @@ function select_type_comptes_financiers($selected=1,$htmlname='type') } - /** - * \brief Retourne la liste déroulante des sociétés - * \param selected Societe présélectionnée - * \param htmlname Nom champ formulaire - * \param filter Criteres optionnels de filtre - */ - function select_societes($selected='',$htmlname='soc_id',$filter='') + /** + * \brief Retourne la liste déroulante des sociétés + * \param selected Societe présélectionnée + * \param htmlname Nom champ formulaire + * \param filter Criteres optionnels de filtre + */ + function select_societes($selected='',$htmlname='soc_id',$filter='') { // On recherche les societes $sql = "SELECT s.idp, s.nom FROM"; @@ -494,6 +494,54 @@ function select_societes($selected='',$htmlname='soc_id',$filter='') } + /** + * \brief Retourne la liste déroulante des remises fixes + * \param selected Id remise fixe présélectionnée + * \param htmlname Nom champ formulaire + * \param filter Criteres optionnels de filtre + */ + function select_remises($selected='',$htmlname='remise_id',$filter='',$socid) + { + global $langs,$conf; + + // On recherche les societes + $sql = "SELECT re.rowid, re.amount_ht as amount, re.description FROM"; + $sql.= " ".MAIN_DB_PREFIX ."societe_remise_except as re"; + $sql.= " WHERE fk_soc = ".$socid; + if ($filter) $sql.= " AND $filter"; + $sql.= " ORDER BY re.description ASC"; + + $resql=$this->db->query($sql); + if ($resql) + { + print ''; + } + else { + dolibarr_print_error($this->db); + } + } + + /** * \brief Retourne la liste déroulante des contacts d'une société donnée * \param socid Id de la société @@ -1588,23 +1636,24 @@ function form_remise_percent($page, $selected='', $htmlname='remise_percent') /** - * \brief Affiche formulaire de selection de la remise avoir + * \brief Affiche formulaire de selection de la remise fixe * \param page Page * \param selected Valeur à appliquer * \param htmlname Nom du formulaire select. Si none, non modifiable */ - function form_remise($page, $selected='', $htmlname='remise') + function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid) { global $langs; if ($htmlname != "none") { print '
'; - print ''; - print ''; + print ''; + print '
'; print ''; - print ''; + print ''; print '
'; - print ''; + print $langs->trans("AvailableGlobalDiscounts").': '; + print $this->select_remises('',$htmlname,'fk_facture IS NULL',$socid); print '
'; } else diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 7084683fdd43a..3948516cc05d3 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -82,6 +82,8 @@ CompanyHasAbsoluteDiscount=This customer has a %s %s discount credit CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself) +DefaultDiscount=Default discount +AvailableGlobalDiscounts=Absolute discounts available DiscountNone=None Supplier=Supplier CompanyList=Companies' list diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index e117d557be63f..992e2918a0b95 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -83,6 +83,7 @@ CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remises fixes disponib CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur) CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement) DefaultDiscount=Remise par défaut +AvailableGlobalDiscounts=Remises fixes disponibles DiscountNone=Aucune Supplier=Fournisseur CompanyList=Liste des sociétés diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 2425fe7a81db3..084c67233554f 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -532,6 +532,27 @@ function dolibarr_trunc($string,$size=40) return $string; } +/** + \brief Complète une chaine à une taille donnée par des espaces + \param string Chaine à compléter + \param size Longueur de la chaine. + \param side 0=Complétion à droite, 1=Complétion à gauche + \param char Chaine de complétion + \return string Chaine complétée +*/ +function dolibarr_pad($string,$size,$side,$char=' ') +{ + $taille=sizeof($string); + $i=0; + while($i < ($size - $taille)) + { + if ($side > 0) $string.=$char; + else $string=$char.$string; + $i++; + } + return $string; +} + /** \brief Affiche picto propre à une notion/module (fonction générique) \param alt Texte sur le alt de l'image