Qual: Better message for total of buying price

Fix: Little debug of add link feature. Link was broken because of
missing http, fix W3C making output wrong with some browsers.
This commit is contained in:
Laurent Destailleur 2013-11-15 11:43:16 +01:00
parent a0358dc0c2
commit b3a1d695cd
8 changed files with 90 additions and 55 deletions

View File

@ -174,7 +174,7 @@ class FormFile
$out .= '<tr>'; $out .= '<tr>';
$out .= '<td valign="middle" class="nowrap">'; $out .= '<td valign="middle" class="nowrap">';
$out .= $langs->trans("Link") . ': '; $out .= $langs->trans("Link") . ': ';
$out .= '<input type="text" name="link" id="link">'; $out .= '<input type="text" name="link" size="'.$maxlength.'" id="link">';
$out .= ' &nbsp; ' . $langs->trans("Label") . ': '; $out .= ' &nbsp; ' . $langs->trans("Label") . ': ';
$out .= '<input type="text" name="label" id="label">'; $out .= '<input type="text" name="label" id="label">';
$out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">'; $out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">';
@ -1063,6 +1063,9 @@ class FormFile
// Show list of associated links // Show list of associated links
print_titre($langs->trans("LinkedFiles")); print_titre($langs->trans("LinkedFiles"));
print '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">';
print '<table width="100%" class="liste">'; print '<table width="100%" class="liste">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre( print_liste_field_titre(
@ -1076,7 +1079,7 @@ class FormFile
$sortorder $sortorder
); );
print_liste_field_titre( print_liste_field_titre(
$langs->trans("Size"), "",
"", "",
"", "",
"", "",
@ -1104,21 +1107,21 @@ class FormFile
print_liste_field_titre('','',''); print_liste_field_titre('','','');
print '</tr>'; print '</tr>';
$nboflinks = count($links); $nboflinks = count($links);
if ($nboflinks > 0) { if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
}
$var = true; $var = true;
foreach ($links as $link) { foreach ($links as $link)
{
$var =! $var; $var =! $var;
print '<tr ' . $bc[$var] . '>'; print '<tr ' . $bc[$var] . '>';
//edit mode //edit mode
if ($action == 'update' && $selected === $link->id) { if ($action == 'update' && $selected === $link->id)
print '<form action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '" method="post">'; {
print '<td>';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="linkid" value="' . $link->id . '">'; print '<input type="hidden" name="linkid" value="' . $link->id . '">';
print '<input type="hidden" name="action" value="confirm_updateline">'; print '<input type="hidden" name="action" value="confirm_updateline">';
print '<td>'; print $langs->trans('Link') . ': <input type="text" name="link" size="50" value="' . $link->url . '">';
print $langs->trans('Link') . ': <input type="text" name="link" value = "' . $link->url . '">';
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
print $langs->trans('Label') . ': <input type="text" name="label" value="' . $link->label . '">'; print $langs->trans('Label') . ': <input type="text" name="label" value="' . $link->label . '">';
@ -1126,8 +1129,8 @@ class FormFile
print '<td align="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>'; print '<td align="center">' . dol_print_date(dol_now(), "dayhour", "tzuser") . '</td>';
print '<td align="right"></td>'; print '<td align="right"></td>';
print '<td align="right" colspan="2"><input type="submit" name="save" class="button" value="' . $langs->trans('Save') . '">'; print '<td align="right" colspan="2"><input type="submit" name="save" class="button" value="' . $langs->trans('Save') . '">';
print '<input type="submit" name="cancel" class="button" value="' . $langs->trans('Cancel') . '"></td>'; print '<input type="submit" name="cancel" class="button" value="' . $langs->trans('Cancel') . '">';
print '</form>'; print '</td>';
} }
else { else {
print '<td>'; print '<td>';
@ -1142,7 +1145,7 @@ class FormFile
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id print '<a href="' . $_SERVER['PHP_SELF'] . '?action=update&linkid=' . $link->id
. '&id=' . $object->id . '" class="editfilelink" >' . img_edit().'</a>'; . '&id=' . $object->id . '" class="editfilelink" >' . img_edit().'</a>';
if ($permtodelete) { if ($permtodelete) {
print '<a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id print ' &nbsp; <a href="'. $_SERVER['PHP_SELF'] .'?action=delete&linkid=' . $link->id
. '&id=' . $object->id . '" class="deletefilelink" >' . img_delete() . '</a>'; . '&id=' . $object->id . '" class="deletefilelink" >' . img_delete() . '</a>';
} else { } else {
print '&nbsp;'; print '&nbsp;';
@ -1151,13 +1154,16 @@ class FormFile
} }
print "</tr>\n"; print "</tr>\n";
} }
if ($nboflinks == 0) { if ($nboflinks == 0)
{
print '<tr ' . $bc[$var] . '><td colspan="4">'; print '<tr ' . $bc[$var] . '><td colspan="4">';
print $langs->trans("NoLinkFound"); print $langs->trans("NoLinkFound");
print '</td></tr>'; print '</td></tr>';
} }
print "</table>"; print "</table>";
print '</form>';
return $nboflinks; return $nboflinks;
} }

View File

@ -442,7 +442,7 @@ function isValidUrl($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0)
* Clean an url string * Clean an url string
* *
* @param string $url Url * @param string $url Url
* @param string $http 1: keep http://, 0: remove also http:// * @param string $http 1 = keep both http:// and https://, 0: remove http:// but not https://
* @return string Cleaned url * @return string Cleaned url
*/ */
function clean_url($url,$http=1) function clean_url($url,$http=1)

View File

@ -20,7 +20,9 @@
/* /*
* Confirm suppression * Confirm suppression
*/ */
if ($action == 'delete') {
if ($action == 'delete')
{
$ret = $form->form_confirm( $ret = $form->form_confirm(
$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'), $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'),
$langs->trans('DeleteFile'), $langs->trans('DeleteFile'),
@ -35,7 +37,7 @@ if ($action == 'delete') {
$formfile=new FormFile($db); $formfile=new FormFile($db);
// Show upload form // Show upload form (document and links)
$formfile->form_attach_new_file( $formfile->form_attach_new_file(
$_SERVER["PHP_SELF"].'?id='.$object->id, $_SERVER["PHP_SELF"].'?id='.$object->id,
'', '',

View File

@ -25,7 +25,8 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
} elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { } elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($object->id) { if ($object->id) {
$link = GETPOST('link', 'alpha'); $link = GETPOST('link', 'alpha');
if ($link) { if ($link)
{
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') { if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') {
$link = 'http://' . $link; $link = 'http://' . $link;
} }
@ -36,11 +37,14 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
// Delete file/link // Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes') { if ($action == 'confirm_deletefile' && $confirm == 'yes')
if ($object->id) { {
if ($object->id)
{
$urlfile = GETPOST('urlfile', 'alpha'); $urlfile = GETPOST('urlfile', 'alpha');
$linkid = GETPOST('linkid', 'int'); $linkid = GETPOST('linkid', 'int');
if ($urlfile) { if ($urlfile)
{
$file = $upload_dir . "/" . $urlfile; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . "/" . $urlfile; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
@ -49,7 +53,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') {
} else { } else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors');
} }
} elseif ($linkid) { }
elseif ($linkid)
{
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php'; require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$link = new Link($db); $link = new Link($db);
$link->id = $linkid; $link->id = $linkid;
@ -65,23 +71,30 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') {
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
exit; exit;
} }
} elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'alpha')) { }
elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'alpha'))
{
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php'; require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$langs->load('link'); $langs->load('link');
$link = new Link($db); $link = new Link($db);
$link->id = GETPOST('linkid', 'int'); $link->id = GETPOST('linkid', 'int');
$f = $link->fetch(); $f = $link->fetch();
if ($f) { if ($f)
{
$link->url = GETPOST('link', 'alpha'); $link->url = GETPOST('link', 'alpha');
if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://') { if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://')
{
$link->url = 'http://' . $link->url; $link->url = 'http://' . $link->url;
} }
$link->label = GETPOST('label', 'alpha'); $link->label = GETPOST('label', 'alpha');
$res = $link->update($user); $res = $link->update($user);
if (!$res) { if (!$res)
{
setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label)); setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label));
} }
} else { }
else
{
//error fetching //error fetching
} }
} }

View File

@ -12,6 +12,8 @@ OrderDate=Order date
BuyingPrice=Buying price BuyingPrice=Buying price
BuyingPriceMin=Minimum buying price BuyingPriceMin=Minimum buying price
BuyingPriceMinShort=Min buying price BuyingPriceMinShort=Min buying price
TotalBuyingPriceMin=Total of subproducts buying prices
SomeSubProductHaveNoPrices=Some sub-products have no price defined
AddSupplierPrice=Add supplier price AddSupplierPrice=Add supplier price
ChangeSupplierPrice=Change supplier price ChangeSupplierPrice=Change supplier price
ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price defined on this product for this supplier ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price defined on this product for this supplier

View File

@ -12,6 +12,8 @@ OrderDate=Date de commande
BuyingPrice=Prix d'achat BuyingPrice=Prix d'achat
BuyingPriceMin=Prix d'achat minimum BuyingPriceMin=Prix d'achat minimum
BuyingPriceMinShort=Prix achat min. BuyingPriceMinShort=Prix achat min.
TotalBuyingPriceMin=Total des prix d'achats des sous-produits
SomeSubProductHaveNoPrices=Certains sous-produits n'ont pas de prix définis
AddSupplierPrice=Ajouter prix fournisseur AddSupplierPrice=Ajouter prix fournisseur
ChangeSupplierPrice=Modifier prix fournisseur ChangeSupplierPrice=Modifier prix fournisseur
ErrorQtyTooLowForThisSupplier=Quantité trop basse pour ce fournisseur ou prix de ce produit non défini pour ce fournisseur ErrorQtyTooLowForThisSupplier=Quantité trop basse pour ce fournisseur ou prix de ce produit non défini pour ce fournisseur

View File

@ -154,22 +154,22 @@ class Link extends CommonObject
{ {
global $langs,$conf; global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("errors"); $langs->load("errors");
$error=0; $error=0;
dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger); dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger);
// Check parameters // Check parameters
if (empty($this->url)) { if (empty($this->url))
{
$this->error = $langs->trans("NoURL"); $this->error = $langs->trans("NoURL");
return -1; return -1;
} }
// Clean parameters // Clean parameters
$this->url = clean_url($this->url,0); $this->url = clean_url($this->url,1);
if(empty($this->label)) { if (empty($this->label)) $this->label = basename($this->url);
$this->label = basename($this->url);
}
$this->label = trim($this->label); $this->label = trim($this->label);
@ -189,7 +189,8 @@ class Link extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($call_trigger) { if ($call_trigger)
{
// Appel des triggers // Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($this->db); $interface = new Interfaces($this->db);
@ -201,7 +202,8 @@ class Link extends CommonObject
// Fin appel triggers // Fin appel triggers
} }
if (! $error) { if (! $error)
{
dol_syslog(get_class($this) . "::Update success"); dol_syslog(get_class($this) . "::Update success");
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -209,14 +211,19 @@ class Link extends CommonObject
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} else { }
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
// Doublon // Doublon
$this->error = $langs->trans("ErrorDuplicateField"); $this->error = $langs->trans("ErrorDuplicateField");
$result = -1; $result = -1;
} else { }
else
{
$this->error = $langs->trans("Error sql = " . $sql); $this->error = $langs->trans("Error sql = " . $sql);
dol_syslog(get_class($this) . "::Update fails update sql = " . $sql, LOG_ERR); dol_syslog(get_class($this) . "::Update fails update = " . $this->error, LOG_ERR);
$result = -2; $result = -2;
} }
$this->db->rollback(); $this->db->rollback();

View File

@ -328,6 +328,7 @@ if ($id > 0 || ! empty($ref))
// List of subproducts // List of subproducts
if (count($prods_arbo) > 0) if (count($prods_arbo) > 0)
{ {
$atleastonenotdefined=0;
print '<tr><td colspan="2">'; print '<tr><td colspan="2">';
print $langs->trans("ProductAssociationList").'<br>'; print $langs->trans("ProductAssociationList").'<br>';
print '<table class="nobordernopadding centpercent">'; print '<table class="nobordernopadding centpercent">';
@ -343,13 +344,13 @@ if ($id > 0 || ! empty($ref))
{ {
$notdefined=0; $notdefined=0;
$productstatic->ref=$value['fullpath']; $productstatic->ref=$value['fullpath'];
print '<td>'.$productstatic->getNomUrl(1,'composition').' ('.$value['nb'].') &nbsp;</td>'; print '<td>'.$productstatic->getNomUrl(1,'composition').' ('.$value['nb'].')</td>';
print '<td align="right">'; print '<td align="right">';
if ($product_fourn->find_min_price_product_fournisseur($productstatic->id, $value['nb']) > 0) if ($product_fourn->find_min_price_product_fournisseur($productstatic->id, $value['nb']) > 0)
{ {
print $langs->trans("BuyingPriceMinShort").': '; print $langs->trans("BuyingPriceMinShort").': ';
if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(0,0); if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(0,0);
else { print $langs->trans("NotDefined"); $notdefined=1; } else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; }
} }
print '</td>'; print '</td>';
$totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT'); $totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT');
@ -364,7 +365,7 @@ if ($id > 0 || ! empty($ref))
{ {
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';
} }
print $productstatic->getNomUrl(1,'composition').' ('.$value['nb'].') &nbsp;</td>'; print $productstatic->getNomUrl(1,'composition').' ('.$value['nb'].')</td>';
print '<td><td>'; print '<td><td>';
print '<td><td>'; print '<td><td>';
if (! empty($conf->stock->enabled)) print '<td align="right"></td>'; // Real stock if (! empty($conf->stock->enabled)) print '<td align="right"></td>'; // Real stock
@ -372,8 +373,10 @@ if ($id > 0 || ! empty($ref))
print '</tr>'; print '</tr>';
} }
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("BuyingPriceMin").': '.price($total,'','',0,0,-1,$conf->currency).'</td>'; print '<td colspan="2">'.$langs->trans("TotalBuyingPriceMin").': ';
print '<td></td>'; if ($atleastonenotdefined) print $langs->trans("Unknown").' ('.$langs->trans("SomeSubProductHaveNoPrices").')';
print '</td>';
print '<td>'.($atleastonenotdefined?'':price($total,'','',0,0,-1,$conf->currency)).'</td>';
if (! empty($conf->stock->enabled)) print '<td class="liste_total" align="right">&nbsp;</td>'; if (! empty($conf->stock->enabled)) print '<td class="liste_total" align="right">&nbsp;</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';