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.
This commit is contained in:
Laurent Destailleur 2012-06-08 21:33:12 +02:00
parent 85f31fc0cb
commit 59e39b5d91
2 changed files with 26 additions and 19 deletions

View File

@ -253,7 +253,7 @@ class Product extends CommonObject
return -2; 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(); $now=dol_now();
@ -359,7 +359,7 @@ class Product extends CommonObject
{ {
// Product already exists with this ref // Product already exists with this ref
$langs->load("products"); $langs->load("products");
$this->error = $langs->transnoentitiesnoconv("ErrorProductAlreadyExists",$this->ref); $this->error = "ErrorProductAlreadyExists";
} }
} }
else else

View File

@ -339,6 +339,8 @@ if (empty($reshook))
} }
else else
{ {
$id=$originalId;
if ($object->error == 'ErrorProductAlreadyExists') if ($object->error == 'ErrorProductAlreadyExists')
{ {
$db->rollback(); $db->rollback();
@ -354,6 +356,7 @@ if (empty($reshook))
else else
{ {
$db->rollback(); $db->rollback();
$mesg=$object->error;
dol_print_error($db,$object->error); dol_print_error($db,$object->error);
} }
} }
@ -1032,18 +1035,13 @@ else
// Fiche en mode visu // Fiche en mode visu
else else
{ {
dol_htmloutput_mesg($mesg);
$head=product_prepare_head($object, $user); $head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$object->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==1?'service':'product'); $picto=($object->type==1?'service':'product');
dol_fiche_head($head, 'card', $titre, 0, $picto); 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 '<br>';
}
$showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]);
$showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire; $showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire;
@ -1266,20 +1264,27 @@ else
} }
// Clone confirmation // Define confirmation messages
if ($action == 'clone' || $conf->use_javascript_ajax) $formquestionclone=array(
{ 'text' => $langs->trans("ConfirmClone"),
// Create an array for form
$formquestion=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' => '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_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true) 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) if ($conf->use_javascript_ajax)
{ {
print '<span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span>'."\n"; print '<span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span>'."\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 else
{ {
@ -1317,6 +1323,7 @@ if ($action == '' || $action == 'view')
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
print '<span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span>'."\n"; print '<span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span>'."\n";
print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete");
} }
else else
{ {