From 59e39b5d916312ce8af21da6c2de62e9c91a5ee3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Jun 2012 21:33:12 +0200 Subject: [PATCH] Fix: A lot of pb into javascript. Javascripts code for same feature was not inserted always at same place (sometinmes at low level, and sometimes at high level). This was creating conflict into javascript. --- htdocs/product/class/product.class.php | 6 ++-- htdocs/product/fiche.php | 39 +++++++++++++++----------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bb364435564..820a66e08d3 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -253,7 +253,7 @@ class Product extends CommonObject return -2; } - dol_syslog(get_class($this)."::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG); + dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG); $now=dol_now(); @@ -359,7 +359,7 @@ class Product extends CommonObject { // Product already exists with this ref $langs->load("products"); - $this->error = $langs->transnoentitiesnoconv("ErrorProductAlreadyExists",$this->ref); + $this->error = "ErrorProductAlreadyExists"; } } else @@ -1901,7 +1901,7 @@ class Product extends CommonObject function clone_fournisseurs($fromId, $toId) { $this->db->begin(); - + $now=dol_now(); // les fournisseurs diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 43d4b12191f..182882bf63f 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -339,6 +339,8 @@ if (empty($reshook)) } else { + $id=$originalId; + if ($object->error == 'ErrorProductAlreadyExists') { $db->rollback(); @@ -354,6 +356,7 @@ if (empty($reshook)) else { $db->rollback(); + $mesg=$object->error; dol_print_error($db,$object->error); } } @@ -1032,18 +1035,13 @@ else // Fiche en mode visu else { + dol_htmloutput_mesg($mesg); + $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==1?'service':'product'); dol_fiche_head($head, 'card', $titre, 0, $picto); - // Confirm delete product - if ($action == 'delete' || $conf->use_javascript_ajax) - { - $ret=$form->form_confirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); - if ($ret == 'html') print '
'; - } - $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); $showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire; @@ -1266,20 +1264,27 @@ else } -// Clone confirmation -if ($action == 'clone' || $conf->use_javascript_ajax) -{ - // Create an array for form - $formquestion=array( - 'text' => $langs->trans("ConfirmClone"), +// Define confirmation messages +$formquestionclone=array( + 'text' => $langs->trans("ConfirmClone"), array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => $langs->trans("CopyOf").' '.$object->ref, 'size'=>24), array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestion,'yes','action-clone',230,600); +); + +// Confirm delete product +if ($action == 'delete' && empty($conf->use_javascript_ajax)) +{ + print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); } +// Clone confirmation +if ($action == 'clone' && empty($conf->use_javascript_ajax)) +{ + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); +} + + /* ************************************************************************** */ /* */ @@ -1300,6 +1305,7 @@ if ($action == '' || $action == 'view') if ($conf->use_javascript_ajax) { print ''.$langs->trans('ToClone').''."\n"; + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); } else { @@ -1317,6 +1323,7 @@ if ($action == '' || $action == 'view') if ($conf->use_javascript_ajax) { print ''.$langs->trans('Delete').''."\n"; + print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); } else {