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

View File

@ -20,22 +20,24 @@
/*
* Confirm suppression
*/
if ($action == 'delete') {
$ret = $form->form_confirm(
$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'),
$langs->trans('DeleteFile'),
$langs->trans('ConfirmDeleteFile'),
'confirm_deletefile',
'',
0,
1
);
if ($ret == 'html') print '<br>';
if ($action == 'delete')
{
$ret = $form->form_confirm(
$_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'),
$langs->trans('DeleteFile'),
$langs->trans('ConfirmDeleteFile'),
'confirm_deletefile',
'',
0,
1
);
if ($ret == 'html') print '<br>';
}
$formfile=new FormFile($db);
// Show upload form
// Show upload form (document and links)
$formfile->form_attach_new_file(
$_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)) {
if ($object->id) {
$link = GETPOST('link', 'alpha');
if ($link) {
if ($link)
{
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') {
$link = 'http://' . $link;
}
@ -36,11 +37,14 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
// Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes') {
if ($object->id) {
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id)
{
$urlfile = GETPOST('urlfile', 'alpha');
$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).
$ret = dol_delete_file($file, 0, 0, 0, $object);
@ -49,7 +53,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') {
} else {
setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors');
}
} elseif ($linkid) {
}
elseif ($linkid)
{
require_once DOL_DOCUMENT_ROOT . '/link/class/link.class.php';
$link = new Link($db);
$link->id = $linkid;
@ -65,23 +71,30 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') {
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
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';
$langs->load('link');
$link = new Link($db);
$link->id = GETPOST('linkid', 'int');
$f = $link->fetch();
if ($f) {
if ($f)
{
$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->label = GETPOST('label', 'alpha');
$res = $link->update($user);
if (!$res) {
if (!$res)
{
setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label));
}
} else {
}
else
{
//error fetching
}
}

View File

@ -12,6 +12,8 @@ OrderDate=Order date
BuyingPrice=Buying price
BuyingPriceMin=Minimum buying price
BuyingPriceMinShort=Min buying price
TotalBuyingPriceMin=Total of subproducts buying prices
SomeSubProductHaveNoPrices=Some sub-products have no price defined
AddSupplierPrice=Add supplier price
ChangeSupplierPrice=Change supplier price
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
BuyingPriceMin=Prix d'achat minimum
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
ChangeSupplierPrice=Modifier prix 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;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("errors");
$error=0;
dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger);
// Check parameters
if (empty($this->url)) {
if (empty($this->url))
{
$this->error = $langs->trans("NoURL");
return -1;
}
// Clean parameters
$this->url = clean_url($this->url,0);
if(empty($this->label)) {
$this->label = basename($this->url);
}
$this->url = clean_url($this->url,1);
if (empty($this->label)) $this->label = basename($this->url);
$this->label = trim($this->label);
@ -189,7 +189,8 @@ class Link extends CommonObject
$resql = $this->db->query($sql);
if ($resql)
{
if ($call_trigger) {
if ($call_trigger)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface = new Interfaces($this->db);
@ -201,7 +202,8 @@ class Link extends CommonObject
// Fin appel triggers
}
if (! $error) {
if (! $error)
{
dol_syslog(get_class($this) . "::Update success");
$this->db->commit();
return 1;
@ -209,14 +211,19 @@ class Link extends CommonObject
$this->db->rollback();
return -1;
}
} else {
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
}
else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
// Doublon
$this->error = $langs->trans("ErrorDuplicateField");
$result = -1;
} else {
}
else
{
$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;
}
$this->db->rollback();

View File

@ -71,7 +71,7 @@ $cancel <> $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer))
{
$error=0;
for($i=0;$i<$_POST["max_prod"];$i++)
for ($i=0; $i<$_POST["max_prod"]; $i++)
{
if ($_POST["prod_id_chk".$i] > 0)
{
@ -328,6 +328,7 @@ if ($id > 0 || ! empty($ref))
// List of subproducts
if (count($prods_arbo) > 0)
{
$atleastonenotdefined=0;
print '<tr><td colspan="2">';
print $langs->trans("ProductAssociationList").'<br>';
print '<table class="nobordernopadding centpercent">';
@ -343,13 +344,13 @@ if ($id > 0 || ! empty($ref))
{
$notdefined=0;
$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">';
if ($product_fourn->find_min_price_product_fournisseur($productstatic->id, $value['nb']) > 0)
{
print $langs->trans("BuyingPriceMinShort").': ';
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>';
$totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT');
@ -364,7 +365,7 @@ if ($id > 0 || ! empty($ref))
{
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>';
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 '<td>'.$langs->trans("BuyingPriceMin").': '.price($total,'','',0,0,-1,$conf->currency).'</td>';
print '<td></td>';
print '<td colspan="2">'.$langs->trans("TotalBuyingPriceMin").': ';
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>';
print '</tr>';
print '</table>';