From d7d26b93750ab80847f24580ef2c0fe87a778948 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 May 2012 19:11:41 +0200 Subject: [PATCH] Fix: bad sql result name --- htdocs/product/admin/product_tools.php | 63 ++++---- htdocs/product/document.php | 6 +- htdocs/product/fournisseurs.php | 10 +- htdocs/product/photos.php | 208 ++++++++++++------------- 4 files changed, 145 insertions(+), 142 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index f3ade70dbac..db47e8cfdf8 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -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 '
'; +print ''; print ''; print ''; @@ -134,19 +137,19 @@ print ''.$langs->trans("Value").''."\n"; print ''."\n"; $var=!$var; -print ''."\n"; -print ''.$langs->trans("OldVATRates").''."\n"; -print ''."\n"; -print $form->load_tva('oldvatrate', $oldvatrate); -print ''."\n"; +print ''."\n"; +print ''.$langs->trans("OldVATRates").''."\n"; +print ''."\n"; +print $form->load_tva('oldvatrate', $oldvatrate); +print ''."\n"; print ''."\n"; $var=!$var; -print ''."\n"; -print ''.$langs->trans("NewVATRates").''."\n"; -print ''."\n"; -print $form->load_tva('newvatrate', $newvatrate); -print ''."\n"; +print ''."\n"; +print ''.$langs->trans("NewVATRates").''."\n"; +print ''."\n"; +print $form->load_tva('newvatrate', $newvatrate); +print ''."\n"; print ''."\n"; $var=!$var; @@ -160,9 +163,9 @@ print ''."\n"; print ''; print ''; -// Boutons actions -print '
'; -print ''; +// Boutons actions +print '
'; +print ''; print '
'; print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 0a4bab631c8..1d7e5d5ff50 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -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 diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index e7670f77974..5a06d6fae25 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -304,8 +304,8 @@ if ($id || $ref) print ''; print ''; - // Vat rate - print ''.$langs->trans("VATRate").''; + // Vat rate + print ''.$langs->trans("VATRate").''; print ''.$form->load_tva('tva_tx',$product->tva_tx,$supplier,$mysoc).''; // Availability @@ -421,9 +421,9 @@ if ($id || $ref) print $productfourn->fourn_qty; print ''; - // VAT rate - print ''; - print vatrate($productfourn->fourn_tva_tx,true); + // VAT rate + print ''; + print vatrate($productfourn->fourn_tva_tx,true); print ''; // Price quantity diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index e5aa4bf123d..eeaebbc448e 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -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 '
'; - } - - print($mesg); - - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - print "
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->libelle.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
\n"; - - print "
\n"; - - - - /* ************************************************************************** */ - /* */ - /* Barre d'action */ - /* */ - /* ************************************************************************** */ - - print "\n
\n"; - - if ($_GET["action"] != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer)) - { - if (! empty($conf->global->MAIN_UPLOAD_DOC)) - { - print 'id.'">'; - print $langs->trans("AddPhoto").''; - } - else - { - print 'e'; - print $langs->trans("AddPhoto").''; - } - } - - print "\n
\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 '
'; - print ''; print ''; - print '
'; - print "
".$langs->trans("NoPhotoYet")."

"; - print '
'; - } + /* + * 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 '
'; + } + + print($mesg); + + print ''; + + // Reference + print ''; + print ''; + print ''; + + // Libelle + print ''; + print ''; + + // Status (to sell) + print ''; + + // Status (to buy) + print ''; + + print "
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$object->libelle.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; + print $object->getLibStatut(2,0); + print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; + print $object->getLibStatut(2,1); + print '
\n"; + + print "\n"; + + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + print "\n
\n"; + + if ($_GET["action"] != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer)) + { + if (! empty($conf->global->MAIN_UPLOAD_DOC)) + { + print 'id.'">'; + print $langs->trans("AddPhoto").''; + } + else + { + print 'e'; + print $langs->trans("AddPhoto").''; + } + } + + print "\n
\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 '
'; + print ''; print ''; + print '
'; + print "
".$langs->trans("NoPhotoYet")."

"; + print '
'; + } } } else