Fix: bad sql result name

This commit is contained in:
Regis Houssin 2012-05-22 19:11:41 +02:00
parent e8fd068cb0
commit d7d26b9375
4 changed files with 145 additions and 142 deletions

View File

@ -58,27 +58,30 @@ if ($action == 'convert')
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$object = new Product($db);
$object->fetch($obj->rowid);
if ($price_base_type == 'TTC')
$ret=$object->fetch($obj->rowid);
if ($ret)
{
$newprice=price2num($object->price_ttc,'MU');
if ($price_base_type == 'TTC')
{
$newprice=price2num($object->price_ttc,'MU');
}
else
{
$newprice=price2num($object->price,'MU');
}
$newvat=str_replace('*','',$newvatrate);
$ret=$object->updatePrice($object->id, $newprice, $price_base_type, $user, $newvat);
if ($ret < 0) $error++;
}
else
{
$newprice=price2num($object->price,'MU');
}
$newvat=str_replace('*','',$newvatrate);
$ret=$object->updatePrice($object->id, $newprice, $price_base_type, $user, $newvat);
if ($ret < 0) $error++;
$i++;
}
@ -123,7 +126,7 @@ dol_fiche_head($head, 'tools', $tab, 0, 'product');
$form=new Form($db);
$var=true;
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="convert" />';
@ -134,19 +137,19 @@ print '<td align="right" width="60">'.$langs->trans("Value").'</td>'."\n";
print '</tr>'."\n";
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("OldVATRates").'</td>'."\n";
print '<td width="60" align="right">'."\n";
print $form->load_tva('oldvatrate', $oldvatrate);
print '</td>'."\n";
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("OldVATRates").'</td>'."\n";
print '<td width="60" align="right">'."\n";
print $form->load_tva('oldvatrate', $oldvatrate);
print '</td>'."\n";
print '</tr>'."\n";
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("NewVATRates").'</td>'."\n";
print '<td width="60" align="right">'."\n";
print $form->load_tva('newvatrate', $newvatrate);
print '</td>'."\n";
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("NewVATRates").'</td>'."\n";
print '<td width="60" align="right">'."\n";
print $form->load_tva('newvatrate', $newvatrate);
print '</td>'."\n";
print '</tr>'."\n";
$var=!$var;
@ -160,9 +163,9 @@ print '</tr>'."\n";
print '</table>';
print '</div>';
// Boutons actions
print '<div class="tabsAction">';
print '<input type="submit" id="convert_vatrate" name="convert_vatrate" value="'.$langs->trans("Convert").'" />';
// Boutons actions
print '<div class="tabsAction">';
print '<input type="submit" id="convert_vatrate" name="convert_vatrate" value="'.$langs->trans("Convert").'" />';
print '</div>';
print '</form>';

View File

@ -34,9 +34,9 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
$langs->load("other");
$langs->load("products");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action','alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check

View File

@ -304,8 +304,8 @@ if ($id || $ref)
print '</td>';
print '</tr>';
// Vat rate
print '<tr><td class="fieldrequired">'.$langs->trans("VATRate").'</td>';
// Vat rate
print '<tr><td class="fieldrequired">'.$langs->trans("VATRate").'</td>';
print '<td colspan="3">'.$form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc).'</td></tr>';
// Availability
@ -421,9 +421,9 @@ if ($id || $ref)
print $productfourn->fourn_qty;
print '</td>';
// VAT rate
print '<td align="right">';
print vatrate($productfourn->fourn_tva_tx,true);
// VAT rate
print '<td align="right">';
print vatrate($productfourn->fourn_tva_tx,true);
print '</td>';
// Price quantity

View File

@ -46,10 +46,10 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','',
$mesg = '';
$object = new Product($db);
if ($id > 0 || ! empty($ref))
{
if ($id > 0 || ! empty($ref))
{
$result = $object->fetch($id, $ref);
$dir = (! empty($conf->product->multidir_output[$object->entity])?$conf->product->multidir_output[$object->entity]:$conf->service->multidir_output[$object->entity]);
$dir = (! empty($conf->product->multidir_output[$object->entity])?$conf->product->multidir_output[$object->entity]:$conf->service->multidir_output[$object->entity]);
}
@ -83,107 +83,107 @@ if ($object->id)
{
llxHeader("","",$langs->trans("CardProduct".$object->type));
/*
* En mode visu
*/
$head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==1?'service':'product');
dol_fiche_head($head, 'photos', $titre, 0, $picto);
/*
* Confirmation de la suppression de photo
*/
if ($_GET['action'] == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>';
}
print($mesg);
print '<table class="border" width="100%">';
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->libelle.'</td>';
print '</tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
print $object->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
print $object->getLibStatut(2,1);
print '</td></tr>';
print "</table>\n";
print "</div>\n";
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer))
{
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=ajout_photo&amp;id='.$object->id.'">';
print $langs->trans("AddPhoto").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">e';
print $langs->trans("AddPhoto").'</a>';
}
}
print "\n</div>\n";
/*
* Add a photo
*/
if ($action == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans("AddPhoto"),1);
}
// Affiche photos
if ($action != 'ajout_photo')
{
$nbphoto=0;
$nbbyrow=5;
$maxWidth = 160;
$maxHeight = 120;
print $object->show_photos($dir,1,1000,$nbbyrow,1,1);
if ($object->nbphoto < 1)
{
print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>';
print '</table>';
}
/*
* En mode visu
*/
$head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==1?'service':'product');
dol_fiche_head($head, 'photos', $titre, 0, $picto);
/*
* Confirmation de la suppression de photo
*/
if ($_GET['action'] == 'delete')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1);
if ($ret == 'html') print '<br>';
}
print($mesg);
print '<table class="border" width="100%">';
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->libelle.'</td>';
print '</tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
print $object->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
print $object->getLibStatut(2,1);
print '</td></tr>';
print "</table>\n";
print "</div>\n";
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer))
{
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=ajout_photo&amp;id='.$object->id.'">';
print $langs->trans("AddPhoto").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">e';
print $langs->trans("AddPhoto").'</a>';
}
}
print "\n</div>\n";
/*
* Add a photo
*/
if ($action == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
// Affiche formulaire upload
$formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans("AddPhoto"),1);
}
// Affiche photos
if ($action != 'ajout_photo')
{
$nbphoto=0;
$nbbyrow=5;
$maxWidth = 160;
$maxHeight = 120;
print $object->show_photos($dir,1,1000,$nbbyrow,1,1);
if ($object->nbphoto < 1)
{
print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>';
print '</table>';
}
}
}
else