Fix: [ bug #252 ] Contrat : pas d'éditeur WYSIWYG

Fix: Margins information must be visible for orders, proposals and
invoices only.
Fix: Delete button for contracts not visible
This commit is contained in:
Laurent Destailleur 2012-12-28 11:36:31 +01:00
parent a8012d0f18
commit 8436f0666d
3 changed files with 204 additions and 189 deletions

View File

@ -201,7 +201,18 @@ else if ($action == 'classin' && $user->rights->contrat->creer)
else if ($action == 'addline' && $user->rights->contrat->creer)
{
if (GETPOST('pqty') && ((GETPOST('pu') != '' && GETPOST('desc')) || GETPOST('idprod')))
if (! GETPOST('qty'))
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")),'errors');
$error++;
}
if ((GETPOST('price_ht') == '' || ! GETPOST('dp_desc')) && ! GETPOST('idprod'))
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")),'errors');
$error++;
}
if (! $error)
{
$ret=$object->fetch($id);
if ($ret < 0)
@ -286,11 +297,11 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
}
else
{
$pu_ht=GETPOST('pu');
$pu_ht=GETPOST('price_ht');
$price_base_type = 'HT';
$tva_tx=str_replace('*','',GETPOST('tva_tx'));
$tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0;
$desc=GETPOST('desc');
$desc=GETPOST('dp_desc');
}
$localtax1_tx=get_localtax($tva_tx,1,$object->societe);
@ -310,12 +321,12 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$result = $object->addline(
$desc,
$pu_ht,
GETPOST('pqty'),
GETPOST('qty'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
GETPOST('idprod'),
GETPOST('premise'),
GETPOST('remise_percent'),
$date_start,
$date_end,
$price_base_type,
@ -343,6 +354,14 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
contrat_pdf_create($db, $object->id, $object->modelpdf, $outputlangs);
}
*/
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['idprod']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['tva_tx']);
unset($_POST['dp_desc']);
}
else
{
@ -372,7 +391,7 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
$localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty);
$localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty);
$objectline->description=GETPOST('eldesc');
$objectline->description=GETPOST('product_desc');
$objectline->price_ht=GETPOST('elprice');
$objectline->subprice=GETPOST('elprice');
$objectline->qty=GETPOST('elqty');
@ -898,7 +917,7 @@ else
}
else
{
print "<td>".nl2br($objp->description)."</td>\n";
print "<td>".dol_htmlentitiesbr($objp->description)."</td>\n";
}
// TVA
print '<td align="center">'.vatrate($objp->tva_tx,'%',$objp->info_bits).'</td>';
@ -997,7 +1016,16 @@ else
{
print $objp->label?$objp->label.'<br>':'';
}
print '<textarea name="eldesc" cols="70" rows="1">'.$objp->description.'</textarea></td>';
// editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
$doleditor=new DolEditor('product_desc',$objp->description,'',92,'dolibarr_details','',false,true,$enable,$nbrows,70);
$doleditor->Create();
print '</td>';
print '<td align="right">';
print $form->load_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->thirdparty);
print '</td>';
@ -1252,108 +1280,60 @@ else
}
print '</table>';
/*
* Ajouter une ligne produit/service
*/
// Form to add new line
if ($user->rights->contrat->creer && ($object->statut >= 0))
{
$dateSelector=1;
print '<br>';
print '<table class="noborder" width="100%">'; // Array with (n*2)+1 lines
print '<table id="tablelines" class="noborder" width="100%">'; // Array with (n*2)+1 lines
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("Service").'</td>';
print '<td align="center">'.$langs->trans("VAT").'</td>';
print '<td align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td align="center">'.$langs->trans("Qty").'</td>';
print '<td align="right">'.$langs->trans("ReductionShort").'</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
$var=false;
// Service sur produit predefini
print '<form name="addline" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addline">';
print '<input type="hidden" name="mode" value="predefined">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print "<tr ".$bc[$var].">";
print '<td colspan="3">';
// multiprix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
$form->select_produits('','idprod',1,$conf->product->limit_size,$object->thirdparty->price_level);
else
$form->select_produits('','idprod',1,$conf->product->limit_size);
print '<br>';
print '<textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea>';
print '</td>';
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>';
print '<td align="right" nowrap><input type="text" class="flat" size="1" name="premise" value="'.$object->thirdparty->remise_client.'">%</td>';
print '<td align="center" colspan="2" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'."\n";
print "<tr ".$bc[$var].">";
print '<td colspan="8">';
print $langs->trans("DateStartPlanned").' ';
$form->select_date('',"date_start",$usehm,$usehm,1,"addline");
print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
$form->select_date('',"date_end",$usehm,$usehm,1,"addline");
print '</td>';
print '</tr>';
print '</form>';
$var=!$var;
// Service libre
print '<form name="addline_sl" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addline">';
print '<input type="hidden" name="mode" value="libre">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print "<tr $bc[$var]>";
print '<td><textarea name="desc" cols="70" rows="'.ROWS_2.'"></textarea></td>';
print '<td>';
print $form->load_tva("tva_tx",-1,$mysoc,$object->thirdparty);
print '</td>';
print '<td align="right"><input type="text" class="flat" size="4" name="pu" value=""></td>';
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>';
print '<td align="right" nowrap><input type="text" class="flat" size="1" name="premise" value="'.$object->thirdparty->remise_client.'">%</td>';
print '<td align="center" rowspan="2" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'."\n";
print "<tr $bc[$var]>";
print '<td colspan="8">';
print $langs->trans("DateStartPlanned").' ';
$form->select_date('',"date_start_sl",$usehm,$usehm,1,"addline_sl");
print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
$form->select_date('',"date_end_sl",$usehm,$usehm,1,"addline_sl");
print '</td>';
print '</tr>';
// Trick to not show product entries
$savproductenabled=$conf->product->enabled;
$conf->product->enabled = 0;
// Form to add new line
if ($action != 'editline')
{
$var=true;
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
{
// Add free or predefined products/services
$object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty,$hookmanager);
}
else
{
// Add free products/services
$object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager);
// Add predefined products/services
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{
$var=!$var;
$object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager);
}
}
$parameters=array();
$reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
// Restore correct setup
$conf->product->enabled = $savproductenabled;
print '</form>';
print '</table>';
}
//print '</td><td align="center" class="tab" style="padding: 4px; border-right: 1px solid #'.$colorb.'; border-top: 1px solid #'.$colorb.'; border-bottom: 1px solid #'.$colorb.';">';
//print '</td></tr></table>';
print '</div>';
/*************************************************************
* Boutons Actions
*************************************************************/
/*
* Buttons
*/
if ($user->societe_id == 0)
{
@ -1391,6 +1371,10 @@ else
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Delete").'</a>';
}
print "</div>";
print '<br>';
@ -1410,5 +1394,6 @@ else
llxFooter();
$db->close();
?>

View File

@ -23,6 +23,10 @@
* $this (invoice, order, ...)
* $line defined
*/
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
?>
<!-- BEGIN PHP TEMPLATE freeproductline_create.tpl.php -->
@ -37,23 +41,23 @@
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
<?php
$colspan = 4;
if (! empty($conf->margin->enabled)) {
if (! empty($usemargins))
{
?>
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
$colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES))
$colspan++;
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
}
?>
?>
<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
</tr>
<form name="addproduct" id="addproduct" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="action" value="addline" />
<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="addline">
<input type="hidden" name="mode" value="libre">
<input type="hidden" name="id" value="<?php echo $this->id; ?>">
<tr <?php echo $bcnd[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
@ -92,40 +96,49 @@
<td align="right" nowrap><input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" name="remise_percent">%</td>
<?php
$colspan = 4;
if (! empty($conf->margin->enabled)) {
?>
if (! empty($usemargins))
{
?>
<td align="right"><input type="text" size="5" name="buying_price"
value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
</td>
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
$colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES))
$colspan++;
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
}
?>
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline"></td>
</tr>
<?php if (! empty($conf->service->enabled) && $dateSelector) {
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
$colspan = 10;
else
$colspan = 9;
if (! empty($conf->margin->enabled)) {
<?php
if (! empty($conf->service->enabled) && $dateSelector)
{
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
else $colspan = 9;
if (! empty($usemargins))
{
$colspan++; // For the buying price
if($conf->global->DISPLAY_MARGIN_RATES)
$colspan++;
if($conf->global->DISPLAY_MARK_RATES)
$colspan++;
if($conf->global->DISPLAY_MARGIN_RATES) $colspan++;
if($conf->global->DISPLAY_MARK_RATES) $colspan++;
}
?>
?>
<tr <?php echo $bcnd[$var]; ?>>
<td colspan="<?php echo $colspan; ?>"><?php
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
echo ' '.$langs->trans('to').' ';
echo $form->select_date('','date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
if (! empty($object->element) && $object->element == 'contrat')
{
print $langs->trans("DateStartPlanned").' ';
$form->select_date('',"date_start_sl",$usehm,$usehm,1,"addline_sl");
print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
$form->select_date('',"date_end_sl",$usehm,$usehm,1,"addline_sl");
}
else
{
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
echo ' '.$langs->trans('to').' ';
echo $form->select_date('','date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
}
?>
</td>
</tr>

View File

@ -24,6 +24,10 @@
* $this (invoice, order, ...)
* $line defined
*/
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
?>
<!-- BEGIN PHP TEMPLATE predefinedproductline_create.tpl.php -->
@ -42,22 +46,23 @@
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
<?php
$colspan = 4;
if (! empty($conf->margin->enabled))
if (! empty($usemargins))
{
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
?>
?>
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php
<?php
}
?>
<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
</tr>
<form name="addpredefinedproduct" id="addpredefinedproduct" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="action" value="addline" />
<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="addline">
<input type="hidden" name="mode" value="predefined">
<input type="hidden" name="id" value="<?php echo $this->id; ?>">
<script type="text/javascript">
jQuery(document).ready(function() {
@ -72,7 +77,9 @@ jQuery(document).ready(function() {
<?php
echo '<span>';
$form->select_produits('','idprod','',$conf->product->limit_size,$buyer->price_level);
$filtertype='';
if (! empty($object->element) && $object->element == 'contrat') $filtertype='1';
$form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level);
echo '</span>';
if (is_object($hookmanager))
@ -94,20 +101,20 @@ jQuery(document).ready(function() {
</td>
<td align="right"><input type="text" size="2" name="qty" value="1"></td>
<td align="right" nowrap><input type="text" size="1" name="remise_percent" value="<?php echo $buyer->remise_client; ?>">%</td>
<?php
$colspan = 4;
if (! empty($conf->margin->enabled))
{
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
?>
<td align="right">
<select id="fournprice" name="fournprice" style="display: none;"></select>
<input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
</td>
<?php
}
?>
<?php
$colspan = 4;
if (! empty($usemargins))
{
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
?>
<td align="right">
<select id="fournprice" name="fournprice" style="display: none;"></select>
<input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
</td>
<?php
}
?>
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
<input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline">
</td>
@ -118,7 +125,7 @@ if (! empty($conf->service->enabled) && $dateSelector)
{
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
else $colspan = 9;
if (! empty($conf->margin->enabled))
if (! empty($usemargins))
{
$colspan++; // For the buying price
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
@ -128,10 +135,20 @@ if (! empty($conf->service->enabled) && $dateSelector)
<tr <?php echo $bcnd[$var]; ?>>
<td colspan="<?php echo $colspan; ?>">
<?php
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct");
echo ' '.$langs->trans('to').' ';
echo $form->select_date('','date_end_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct");
if (! empty($object->element) && $object->element == 'contrat')
{
print $langs->trans("DateStartPlanned").' ';
$form->select_date('',"date_start",$usehm,$usehm,1,"addline");
print ' &nbsp; '.$langs->trans("DateEndPlanned").' ';
$form->select_date('',"date_end",$usehm,$usehm,1,"addline");
}
else
{
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct");
echo ' '.$langs->trans('to').' ';
echo $form->select_date('','date_end_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct");
}
?>
</td>
</tr>
@ -142,42 +159,42 @@ if (! empty($conf->service->enabled) && $dateSelector)
</form>
<?php
if (! empty($conf->margin->enabled))
if (! empty($usemargins))
{
?>
<script type="text/javascript">
$("#idprod").change(function() {
$("#fournprice options").remove();
$("#fournprice").hide();
$("#buying_price").val("").show();
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
if (data && data.length > 0) {
var options = '';
var i = 0;
$(data).each(function() {
i++;
options += '<option value="'+this.id+'" price="'+this.price+'"';
if (i == 1) {
options += ' selected';
$("#buying_price").val(this.price);
}
options += '>'+this.label+'</option>';
});
options += '<option value=null><?php echo $langs->trans("InputPrice"); ?></option>';
$("#buying_price").hide();
$("#fournprice").html(options).show();
$("#fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#buying_price").val(selval).hide();
else
$('#buying_price').show();
});
}
},
'json');
});
</script>
<script type="text/javascript">
$("#idprod").change(function() {
$("#fournprice options").remove();
$("#fournprice").hide();
$("#buying_price").val("").show();
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
if (data && data.length > 0) {
var options = '';
var i = 0;
$(data).each(function() {
i++;
options += '<option value="'+this.id+'" price="'+this.price+'"';
if (i == 1) {
options += ' selected';
$("#buying_price").val(this.price);
}
options += '>'+this.label+'</option>';
});
options += '<option value=null><?php echo $langs->trans("InputPrice"); ?></option>';
$("#buying_price").hide();
$("#fournprice").html(options).show();
$("#fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#buying_price").val(selval).hide();
else
$('#buying_price').show();
});
}
},
'json');
});
</script>
<?php
}
?>