Ajout popup de confirmation ajax
Fix: bug sur l'enregistrement des lignes produits
This commit is contained in:
parent
2537cef00d
commit
b44066375d
@ -85,13 +85,13 @@ $form=new Form($db);
|
|||||||
if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
|
if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
|
||||||
{
|
{
|
||||||
if ($user->rights->propale->supprimer)
|
if ($user->rights->propale->supprimer)
|
||||||
{
|
{
|
||||||
$propal = new Propal($db, 0, $_GET['propalid']);
|
$propal = new Propal($db, 0, $_GET['propalid']);
|
||||||
$propal->fetch($_GET['propalid']);
|
$propal->fetch($_GET['propalid']);
|
||||||
$propal->delete($user);
|
$propal->delete($user);
|
||||||
$propalid = 0;
|
$propalid = 0;
|
||||||
$brouillon = 1;
|
$brouillon = 1;
|
||||||
}
|
}
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ if (($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes
|
|||||||
{
|
{
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET['propalid']);
|
$propal->fetch($_GET['propalid']);
|
||||||
$result = $propal->delete_product($_GET['ligne']);
|
$result = $propal->delete_product($_GET['lineid']);
|
||||||
if ($_REQUEST['lang_id'])
|
if ($_REQUEST['lang_id'])
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
||||||
@ -558,7 +558,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
|
|||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
if (! $propal->fetch($_POST['propalid']) > 0) dolibarr_print_error($db);
|
if (! $propal->fetch($_POST['propalid']) > 0) dolibarr_print_error($db);
|
||||||
|
|
||||||
$result = $propal->updateline($_POST['ligne'],
|
$result = $propal->updateline($_POST['lineid'],
|
||||||
$_POST['subprice'],
|
$_POST['subprice'],
|
||||||
$_POST['qty'],
|
$_POST['qty'],
|
||||||
$_POST['remise_percent'],
|
$_POST['remise_percent'],
|
||||||
@ -719,7 +719,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||||
{
|
{
|
||||||
$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&ligne='.$_GET["ligne"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline');
|
$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1050,7 +1050,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
// Ligne en mode visu
|
// Ligne en mode visu
|
||||||
if ($_GET['action'] != 'editline' || $_GET['ligne'] != $objp->rowid)
|
if ($_GET['action'] != 'editline' || $_GET['lineid'] != $objp->rowid)
|
||||||
{
|
{
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
|
|
||||||
@ -1216,7 +1216,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=editline&ligne='.$objp->rowid.'#'.$objp->rowid.'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=editline&lineid='.$objp->rowid.'#'.$objp->rowid.'">';
|
||||||
print img_edit();
|
print img_edit();
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
@ -1226,21 +1226,19 @@ if ($_GET['propalid'] > 0)
|
|||||||
{
|
{
|
||||||
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
||||||
{
|
{
|
||||||
$url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&ligne='.$objp->rowid.'&action=confirm_deleteline&confirm=yes';
|
$url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&lineid='.$objp->rowid.'&action=confirm_deleteline&confirm=yes';
|
||||||
print '<a href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProductLine').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'deleteline'.$i.'\')">';
|
print '<a href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProductLine').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'deleteline'.$i.'\')">';
|
||||||
print img_delete();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=ask_deleteline&ligne='.$objp->rowid.'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=ask_deleteline&lineid='.$objp->rowid.'">';
|
||||||
print img_delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=deleteline&ligne='.$objp->rowid.'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||||
print img_delete();
|
|
||||||
}
|
}
|
||||||
|
print img_delete();
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
if ($num > 1)
|
if ($num > 1)
|
||||||
{
|
{
|
||||||
@ -1269,12 +1267,12 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ligne en mode update
|
// Ligne en mode update
|
||||||
if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["ligne"] == $objp->rowid)
|
if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["lineid"] == $objp->rowid)
|
||||||
{
|
{
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'#'.$objp->rowid.'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'#'.$objp->rowid.'" method="post">';
|
||||||
print '<input type="hidden" name="action" value="updateligne">';
|
print '<input type="hidden" name="action" value="updateligne">';
|
||||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||||
print '<input type="hidden" name="ligne" value="'.$_GET["ligne"].'">';
|
print '<input type="hidden" name="lineid" value="'.$_GET["lineid"].'">';
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||||
|
|||||||
@ -641,8 +641,8 @@ class Commande extends CommonObject
|
|||||||
$pu_ht=price2num($pu_ht);
|
$pu_ht=price2num($pu_ht);
|
||||||
$pu_ttc=price2num($pu_ttc);
|
$pu_ttc=price2num($pu_ttc);
|
||||||
$txtva = price2num($txtva);
|
$txtva = price2num($txtva);
|
||||||
|
|
||||||
if ($price_base_type=='HT') $pu=$pu;
|
if ($price_base_type=='HT') $pu=$pu_ht;
|
||||||
else $pu=$pu_ttc;
|
else $pu=$pu_ttc;
|
||||||
|
|
||||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||||
|
|||||||
@ -82,7 +82,7 @@ if ($_GET["projetid"])
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// Suppression de la commande
|
// Suppression de la commande
|
||||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->supprimer )
|
if ($user->rights->commande->supprimer )
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
|||||||
/*
|
/*
|
||||||
* Supprime une ligne produit AVEC ou SANS confirmation
|
* Supprime une ligne produit AVEC ou SANS confirmation
|
||||||
*/
|
*/
|
||||||
if (($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
if (($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||||
|| ($_GET['action'] == 'deleteline' && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE))
|
|| ($_GET['action'] == 'deleteline' && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE))
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->creer)
|
if ($user->rights->commande->creer)
|
||||||
@ -105,12 +105,19 @@ if (($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'ye
|
|||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET['id']);
|
$commande->fetch($_GET['id']);
|
||||||
$result = $commande->delete_line($_GET['lineid']);
|
$result = $commande->delete_line($_GET['lineid']);
|
||||||
if ($_REQUEST['lang_id'])
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
if ($_REQUEST['lang_id'])
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
{
|
||||||
|
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
||||||
|
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||||
|
}
|
||||||
|
commande_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $commande->error;
|
||||||
}
|
}
|
||||||
commande_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs);
|
|
||||||
}
|
}
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']);
|
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']);
|
||||||
exit;
|
exit;
|
||||||
@ -320,16 +327,16 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
|||||||
// multiprix
|
// multiprix
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES == 1)
|
if ($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
{
|
{
|
||||||
$pu = $prod->multiprices[$commande->client->price_level];
|
$pu = $prod->multiprices[$commande->client->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$commande->client->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$commande->client->price_level];
|
||||||
$price_base_type = $prod->multiprices_base_type[$commande->client->price_level];
|
$price_base_type = $prod->multiprices_base_type[$commande->client->price_level];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$pu = $prod->price;
|
$pu = $prod->price;
|
||||||
$pu_ttc = $prod->price_ttc;
|
$pu_ttc = $prod->price_ttc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La description de la ligne est celle saisie ou
|
// La description de la ligne est celle saisie ou
|
||||||
// celle du produit si PRODUIT_CHANGE_PROD_DESC est défini
|
// celle du produit si PRODUIT_CHANGE_PROD_DESC est défini
|
||||||
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
|
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
|
||||||
@ -350,7 +357,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
|||||||
$desc=$_POST['np_desc'];
|
$desc=$_POST['np_desc'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$commande->addline(
|
$result = $commande->addline(
|
||||||
$_POST['id'],
|
$_POST['id'],
|
||||||
$desc,
|
$desc,
|
||||||
$pu,
|
$pu,
|
||||||
@ -364,12 +371,19 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
|||||||
$pu_ttc
|
$pu_ttc
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($_REQUEST['lang_id'])
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
if ($_REQUEST['lang_id'])
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
{
|
||||||
|
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
||||||
|
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||||
|
}
|
||||||
|
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $commande->error;
|
||||||
}
|
}
|
||||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,47 +427,37 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->commande->valider)
|
if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET['id']);
|
$commande->fetch($_GET['id']);
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->socid);
|
$soc->fetch($commande->socid);
|
||||||
$result = $commande->valid($user);
|
if ($_REQUEST['lang_id'])
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
||||||
|
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||||
|
}
|
||||||
|
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||||
|
$result=$commande->valid($user);
|
||||||
|
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'confirm_close' && $_POST['confirm'] == 'yes' && $user->rights->commande->creer)
|
if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET['id']);
|
$commande->fetch($_GET['id']);
|
||||||
$result = $commande->cloture($user);
|
$result = $commande->cloture($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'confirm_cancel' && $_POST['confirm'] == 'yes' && $user->rights->commande->valider)
|
if ($_REQUEST['action'] == 'confirm_cancel' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET['id']);
|
$commande->fetch($_GET['id']);
|
||||||
$result = $commande->cancel($user);
|
$result = $commande->cancel($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
|
||||||
{
|
|
||||||
if ($user->rights->commande->creer)
|
|
||||||
{
|
|
||||||
$commande = new Commande($db);
|
|
||||||
$commande->fetch($_GET['id']);
|
|
||||||
$commande->delete_line($_GET['lineid']);
|
|
||||||
if ($_REQUEST['lang_id'])
|
|
||||||
{
|
|
||||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf);
|
|
||||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
|
||||||
}
|
|
||||||
commande_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs);
|
|
||||||
}
|
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1013,30 +1017,29 @@ else
|
|||||||
/*
|
/*
|
||||||
* Confirmation de la validation
|
* Confirmation de la validation
|
||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'valid')
|
if ($_GET['action'] == 'validate')
|
||||||
|
{
|
||||||
|
// on vérifie si la facture est en numérotation provisoire
|
||||||
|
$ref = substr($commande->ref, 1, 4);
|
||||||
|
if ($ref == 'PROV')
|
||||||
{
|
{
|
||||||
// on vérifie si la facture est en numérotation provisoire
|
$num = $commande->getNextNumRef($soc);
|
||||||
$ref = substr($commande->ref, 1, 4);
|
|
||||||
if ($ref == 'PROV')
|
|
||||||
{
|
|
||||||
$num = $commande->getNextNumRef($soc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$num = $commande->ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
$text=$langs->trans('ConfirmValidateOrder',$num);
|
|
||||||
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_valid');
|
|
||||||
print '<br />';
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$num = $commande->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text=$langs->trans('ConfirmValidateOrder',$num);
|
||||||
|
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate');
|
||||||
|
print '<br />';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la cloture
|
* Confirmation de la cloture
|
||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'cloture')
|
if ($_GET['action'] == 'close')
|
||||||
{
|
{
|
||||||
//$numfa = commande_get_num($soc);
|
|
||||||
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close');
|
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close');
|
||||||
print '<br />';
|
print '<br />';
|
||||||
}
|
}
|
||||||
@ -1044,7 +1047,7 @@ else
|
|||||||
/*
|
/*
|
||||||
* Confirmation de l'annulation
|
* Confirmation de l'annulation
|
||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'annuler')
|
if ($_GET['action'] == 'cancel')
|
||||||
{
|
{
|
||||||
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel');
|
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel');
|
||||||
print '<br />';
|
print '<br />';
|
||||||
@ -1053,9 +1056,9 @@ else
|
|||||||
/*
|
/*
|
||||||
* Confirmation de la suppression d'une ligne produit
|
* Confirmation de la suppression d'une ligne produit
|
||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'delete_product_line' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||||
{
|
{
|
||||||
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline');
|
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1425,7 +1428,15 @@ else
|
|||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
if ($conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||||
{
|
{
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=delete_product_line&lineid='.$objp->rowid.'">';
|
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
||||||
|
{
|
||||||
|
$url = $_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$objp->rowid.'&action=confirm_deleteline&confirm=yes';
|
||||||
|
print '<a href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProductLine').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'deleteline'.$i.'\')">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=ask_deleteline&lineid='.$objp->rowid.'">';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1649,12 +1660,29 @@ else
|
|||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
// Valid
|
// Valid
|
||||||
if ($commande->statut == 0)
|
if ($commande->statut == 0 && $commande->total_ttc > 0 && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->valider)
|
print '<a class="butAction" ';
|
||||||
|
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans('Valid').'</a>';
|
// on vérifie si la facture est en numérotation provisoire
|
||||||
|
$ref = substr($commande->ref, 1, 4);
|
||||||
|
if ($ref == 'PROV')
|
||||||
|
{
|
||||||
|
$num = $commande->getNextNumRef($soc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$num = $commande->ref;
|
||||||
|
}
|
||||||
|
$url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_validate&confirm=yes';
|
||||||
|
print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmValidateOrder',$num).'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=validate"';
|
||||||
|
}
|
||||||
|
print '>'.$langs->trans('Validate').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
@ -1711,26 +1739,59 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cloturer
|
||||||
if ($commande->statut == 1 || $commande->statut == 2)
|
if ($commande->statut == 1 || $commande->statut == 2)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->cloturer)
|
if ($user->rights->commande->cloturer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=cloture">'.$langs->trans('Close').'</a>';
|
print '<a class="butAction" ';
|
||||||
|
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
||||||
|
{
|
||||||
|
$url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_close&confirm=yes';
|
||||||
|
print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmCloseOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'close\')"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=close"';
|
||||||
|
}
|
||||||
|
print '>'.$langs->trans('Close').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Annuler commande
|
||||||
if ($commande->statut == 1)
|
if ($commande->statut == 1)
|
||||||
{
|
{
|
||||||
$nb_expedition = $commande->nb_expedition();
|
$nb_expedition = $commande->nb_expedition();
|
||||||
if ($user->rights->commande->annuler && $nb_expedition == 0)
|
if ($user->rights->commande->annuler && $nb_expedition == 0)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans('CancelOrder').'</a>';
|
print '<a class="butActionDelete" ';
|
||||||
|
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
||||||
|
{
|
||||||
|
$url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_cancel&confirm=yes';
|
||||||
|
print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmCancelOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'cancel\')"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=cancel"';
|
||||||
|
}
|
||||||
|
print '>'.$langs->trans('CancelOrder').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supprimer commande
|
||||||
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
print '<a class="butActionDelete" ';
|
||||||
|
if ($conf->use_ajax && $conf->global->MAIN_CONFIRM_AJAX)
|
||||||
|
{
|
||||||
|
$url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_delete&confirm=yes';
|
||||||
|
print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=delete"';
|
||||||
|
}
|
||||||
|
print '>'.$langs->trans('Delete').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
@ -1512,44 +1512,44 @@ class Facture extends CommonObject
|
|||||||
dolibarr_syslog("Facture::Deleteline rowid=".$rowid, LOG_DEBUG);
|
dolibarr_syslog("Facture::Deleteline rowid=".$rowid, LOG_DEBUG);
|
||||||
|
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Libere remise liee a ligne de facture
|
// Libere remise liee a ligne de facture
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
|
||||||
$sql.= ' SET fk_facture = NULL where fk_facture = '.$rowid;
|
$sql.= ' SET fk_facture = NULL where fk_facture = '.$rowid;
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Facture::Deleteline Error ".$this->error);
|
dolibarr_syslog("Facture::Deleteline Error ".$this->error);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Efface ligne de facture
|
// Efface ligne de facture
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid;
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid;
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Facture::Deleteline Error ".$this->error);
|
dolibarr_syslog("Facture::Deleteline Error ".$this->error);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$this->update_price($this->id);
|
$result=$this->update_price($this->id);
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf);
|
$result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user