Add possibility to add free text line in documents

This commit is contained in:
Regis Houssin 2010-06-07 09:29:42 +00:00
parent 07f65028d2
commit b6964b5617
3 changed files with 342 additions and 213 deletions

View File

@ -221,6 +221,18 @@ if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer)
$propal->set_ref_client($user, $_POST['ref_client']); $propal->set_ref_client($user, $_POST['ref_client']);
} }
// Add milestone
if ($_POST['action'] == 'addmilestone')
{
$milestone_error=0;
if ($_POST['milestone_label'] == $langs->trans('Label') || $_POST['milestone_desc'] == $langs->trans('Description'))
{
$milestone_error++;
$mesg = '<div class="error">'.$langs->trans("ErrorMilestone").'</div>';
}
}
/* /*
* Creation propale * Creation propale
*/ */
@ -631,13 +643,13 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$result = -1 ; $result = -1 ;
} }
if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not '' if ((empty($_POST['idprod']) && $_POST["type"] < 2) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not ''
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>';
$result = -1 ; $result = -1 ;
} }
if ($result >= 0 && isset($_POST['qty']) && (($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod'])) if ($result >= 0)
{ {
$ret=$propal->fetch($_POST['propalid']); $ret=$propal->fetch($_POST['propalid']);
if ($ret < 0) if ($ret < 0)
@ -647,6 +659,8 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
} }
$ret=$propal->fetch_client(); $ret=$propal->fetch_client();
if ($_POST["type"] < 2 && isset($_POST['qty']) && (($_POST['np_price']!='' && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprod']))
{
$price_base_type = 'HT'; $price_base_type = 'HT';
// Ecrase $pu par celui du produit // Ecrase $pu par celui du produit
@ -725,6 +739,28 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
$info_bits, $info_bits,
$type $type
); );
}
}
else if($_POST["type"] == 9 && $_POST['dp_desc'])
{
$desc=$_POST['dp_desc'];
$type=$_POST["type"];
// Insert line
$result=$propal->addline(
$_POST['propalid'],
$desc,
0,
0,
0,
0,
0,
'HT',
0,
0,
$type
);
}
if ($result > 0) if ($result > 0)
{ {
@ -752,13 +788,14 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
} }
} }
} }
}
/* /*
* Mise a jour d'une ligne dans la propale * Mise a jour d'une ligne dans la propale
*/ */
if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save")) if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save"))
{ {
$error=0;
$propal = new Propal($db); $propal = new Propal($db);
if (! $propal->fetch($_POST['propalid']) > 0) if (! $propal->fetch($_POST['propalid']) > 0)
{ {
@ -767,6 +804,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
} }
$propal->fetch_client(); $propal->fetch_client();
if ($_POST['type'] < 2)
{
// Define info_bits // Define info_bits
$info_bits=0; $info_bits=0;
if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01; if (preg_match('/\*/',$_POST['tva_tx'])) $info_bits |= 0x01;
@ -779,12 +818,13 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
$productid = $_POST['productid'] ; $productid = $_POST['productid'] ;
if ($productid) if ($productid)
{ {
$pruduct = new Product($db) ; $product = new Product($db);
$res=$pruduct->fetch($productid) ; $res=$product->fetch($productid);
} }
if ($productid && $pruduct->price_min && ( price2num($_POST['subprice'])*(1-price2num($_POST['remise_percent'])/100) < price2num($pruduct->price_min))) if ($productid && $product->price_min && ( price2num($_POST['subprice'])*(1-price2num($_POST['remise_percent'])/100) < price2num($product->price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($pruduct->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ; $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
$error++;
} }
else else
{ {
@ -796,7 +836,20 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
$_POST['desc'], $_POST['desc'],
'HT', 'HT',
$info_bits); $info_bits);
}
}
else if ($_POST['type'] == 9 && $_POST['desc'])
{
$result = $propal->updateline($_POST['lineid'],
0,
0,
0,
0,
$_POST['desc']);
}
if (!$error)
{
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
@ -1462,6 +1515,7 @@ if ($id > 0 || ! empty($ref))
else else
{ {
if ($type==1) $text = img_object($langs->trans('Service'),'service'); if ($type==1) $text = img_object($langs->trans('Service'),'service');
else if ($type==9) $text = img_object($langs->trans('Notes'),'generic');
else $text = img_object($langs->trans('Product'),'product'); else $text = img_object($langs->trans('Product'),'product');
print $text.' '.nl2br($objp->description); print $text.' '.nl2br($objp->description);
@ -1525,6 +1579,8 @@ if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
} }
if ($objp->product_type < 2)
{
// VAT Rate // VAT Rate
print '<td align="right" nowrap="nowrap">'.vatrate($objp->tva_tx,'%',$objp->info_bits).'</td>'; print '<td align="right" nowrap="nowrap">'.vatrate($objp->tva_tx,'%',$objp->info_bits).'</td>';
@ -1560,6 +1616,11 @@ if ($id > 0 || ! empty($ref))
{ {
print '<td align="right" nowrap="nowrap">'.price($objp->total_ht)."</td>\n"; print '<td align="right" nowrap="nowrap">'.price($objp->total_ht)."</td>\n";
} }
}
else
{
print '<td align="right" colspan="5" nowrap="nowrap">&nbsp;</td>';
}
// Icone d'edition et suppression // Icone d'edition et suppression
if ($propal->statut == 0 && $user->rights->propale->creer) if ($propal->statut == 0 && $user->rights->propale->creer)
@ -1614,6 +1675,7 @@ if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="action" value="updateligne">'; print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="lineid" value="'.$_GET["lineid"].'">'; print '<input type="hidden" name="lineid" value="'.$_GET["lineid"].'">';
print '<input type="hidden" name="type" value="'.$objp->product_type.'">';
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'; print '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
@ -1621,14 +1683,12 @@ if ($id > 0 || ! empty($ref))
{ {
print '<input type="hidden" name="productid" value="'.$objp->fk_product.'">'; print '<input type="hidden" name="productid" value="'.$objp->fk_product.'">';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
if ($objp->fk_product_type==1) print img_object($langs->trans('ShowService'),'service'); if ($objp->product_type==1) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product'); else print img_object($langs->trans('ShowProduct'),'product');
print ' '.$objp->ref.'</a>'; print ' '.$objp->ref.'</a>';
print ' - '.nl2br($objp->product_label); print ' - '.nl2br($objp->product_label);
print '<br>'; print '<br>';
} }
if ($_GET["action"] == 'editline')
{
// editeur wysiwyg // editeur wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{ {
@ -1642,8 +1702,9 @@ if ($id > 0 || ! empty($ref))
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea name="desc" cols="70" class="flat" rows="'.$nbrows.'">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>'; print '<textarea name="desc" cols="70" class="flat" rows="'.$nbrows.'">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>';
} }
}
print '</td>'; print '</td>';
if ($objp->product_type < 2)
{
if ($conf->global->PRODUIT_USE_MARKUP) if ($conf->global->PRODUIT_USE_MARKUP)
{ {
print '<td align="right">'.vatrate($objp->marge_tx).'%</td>'; print '<td align="right">'.vatrate($objp->marge_tx).'%</td>';
@ -1666,6 +1727,12 @@ if ($id > 0 || ! empty($ref))
} }
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
}
else
{
print '<td align="right" colspan="4">&nbsp;</td>';
}
print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>'; print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
print '</tr>' . "\n"; print '</tr>' . "\n";
@ -1688,6 +1755,61 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline')
{ {
$var=true;
if ($conf->milestone->enabled)
{
$langs->load('@milestone');
print '<tr class="liste_titre">';
print '<td>';
print $langs->trans('AddMilestone').'</td>';
print '<td colspan="10">&nbsp;</td>';
print "</tr>\n";
// Add milestone form
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="action" value="addmilestone">';
// Label
print '<tr '.$bc[$var].'>';
print '<td colspan="5">';
print '<input size="30" type="text" id="milestone_label" name="milestone_label" value="'.(!empty($milestone_error)?$_POST["milestone_label"]:$langs->trans('Label')).'" '.addHelpMessage("milestone_label",$langs->trans('Label')).'>';
print '</td>';
print '<td align="center" valign="middle" rowspan="2" colspan="4">';
print '<input type="submit" class="button" value="'.$langs->trans('Add').'" name="addmilestone">';
print '</td>';
print '</tr>';
// Description
print '<tr '.$bc[$var].'>';
print '<td colspan="5">';
// Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('milestone_desc',(!empty($milestone_error)?$_POST["milestone_desc"]:''),100,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea cols="70" id="milestone_desc" name="milestone_desc" rows="'.$nbrows.'" class="flat" '.addHelpMessage("milestone_desc",$langs->trans('Description')).'>';
print (!empty($milestone_error)?$_POST["milestone_desc"]:$langs->trans('Description'));
print '</textarea>';
}
print '</td></tr>';
print '</form>';
$var=!$var;
}
if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"'; if ($conf->global->PRODUIT_USE_MARKUP) $colspan = 'colspan="2"';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td '.$colspan.'>'; print '<td '.$colspan.'>';
@ -1706,7 +1828,6 @@ if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="propalid" value="'.$propal->id.'">'; print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="action" value="addline">'; print '<input type="hidden" name="action" value="addline">';
$var=true;
print '<tr '.$bc[$var].">\n"; print '<tr '.$bc[$var].">\n";
print '<td '.$colspan.'>'; print '<td '.$colspan.'>';
@ -1727,6 +1848,7 @@ if ($id > 0 || ! empty($ref))
print '<textarea class="flat" cols="70" name="dp_desc" rows="'.$nbrows.'">'.$_POST["dp_desc"].'</textarea>'; print '<textarea class="flat" cols="70" name="dp_desc" rows="'.$nbrows.'">'.$_POST["dp_desc"].'</textarea>';
} }
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
if ($societe->tva_assuj == "0") if ($societe->tva_assuj == "0")
print '<input type="hidden" name="np_tva_tx" value="0">0'; print '<input type="hidden" name="np_tva_tx" value="0">0';

View File

@ -479,6 +479,10 @@ class Form
if (1 == $selected) print ' selected="true"'; if (1 == $selected) print ' selected="true"';
print '>'.$langs->trans("Service"); print '>'.$langs->trans("Service");
print '<option value="9"';
if (9 == $selected) print ' selected="true"';
print '>'.$langs->trans("Notes");
print '</select>'; print '</select>';
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); //if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -251,6 +251,8 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
if ($propale->lignes[$i]->product_type < 2)
{
// TVA // TVA
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
@ -285,6 +287,7 @@ class pdf_propale_azur extends ModelePDFPropales
$total = price($propale->lignes[$i]->total_ht); $total = price($propale->lignes[$i]->total_ht);
$pdf->MultiCell(26, 4, $total, 0, 'R', 0); $pdf->MultiCell(26, 4, $total, 0, 'R', 0);
} }
}
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
$tvaligne=$propale->lignes[$i]->total_tva; $tvaligne=$propale->lignes[$i]->total_tva;