diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4790b2ffd8d..631ea4b53fc 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -85,13 +85,13 @@ $form=new Form($db); if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') { if ($user->rights->propale->supprimer) - { - $propal = new Propal($db, 0, $_GET['propalid']); - $propal->fetch($_GET['propalid']); - $propal->delete($user); - $propalid = 0; - $brouillon = 1; - } + { + $propal = new Propal($db, 0, $_GET['propalid']); + $propal->fetch($_GET['propalid']); + $propal->delete($user); + $propalid = 0; + $brouillon = 1; + } Header('Location: '.$_SERVER["PHP_SELF"]); exit; } @@ -106,7 +106,7 @@ if (($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes { $propal = new Propal($db); $propal->fetch($_GET['propalid']); - $result = $propal->delete_product($_GET['ligne']); + $result = $propal->delete_product($_GET['lineid']); if ($_REQUEST['lang_id']) { $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); if (! $propal->fetch($_POST['propalid']) > 0) dolibarr_print_error($db); - $result = $propal->updateline($_POST['ligne'], + $result = $propal->updateline($_POST['lineid'], $_POST['subprice'], $_POST['qty'], $_POST['remise_percent'], @@ -719,7 +719,7 @@ if ($_GET['propalid'] > 0) */ 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 '
'; } @@ -1050,7 +1050,7 @@ if ($_GET['propalid'] > 0) $var=!$var; // Ligne en mode visu - if ($_GET['action'] != 'editline' || $_GET['ligne'] != $objp->rowid) + if ($_GET['action'] != 'editline' || $_GET['lineid'] != $objp->rowid) { print ''; @@ -1216,7 +1216,7 @@ if ($_GET['propalid'] > 0) } else { - print 'rowid.'#'.$objp->rowid.'">'; + print 'rowid.'#'.$objp->rowid.'">'; print img_edit(); print ''; } @@ -1226,21 +1226,19 @@ if ($_GET['propalid'] > 0) { 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 'trans("No").'\',\'deleteline'.$i.'\')">'; - print img_delete(); } else { - print 'rowid.'">'; - print img_delete(); + print 'rowid.'">'; } } else { - print 'rowid.'">'; - print img_delete(); + print 'rowid.'">'; } + print img_delete(); print ''; if ($num > 1) { @@ -1269,12 +1267,12 @@ if ($_GET['propalid'] > 0) } // 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 '
rowid.'" method="post">'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; // ancre pour retourner sur la ligne diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 58fe35f3756..d45d90bb7b3 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -641,8 +641,8 @@ class Commande extends CommonObject $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); $txtva = price2num($txtva); - - if ($price_base_type=='HT') $pu=$pu; + + if ($price_base_type=='HT') $pu=$pu_ht; else $pu=$pu_ttc; // Calcul du total TTC et de la TVA pour la ligne a partir de diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1f17d3e50a7..6565bd7b434 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -82,7 +82,7 @@ if ($_GET["projetid"]) /******************************************************************************/ // 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 ) { @@ -97,7 +97,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') /* * 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)) { if ($user->rights->commande->creer) @@ -105,12 +105,19 @@ if (($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'ye $commande = new Commande($db); $commande->fetch($_GET['id']); $result = $commande->delete_line($_GET['lineid']); - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); + if ($result > 0) + { + 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); + } + else + { + print $commande->error; } - commande_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs); } Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET['id']); exit; @@ -320,16 +327,16 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) // multiprix if ($conf->global->PRODUIT_MULTIPRICES == 1) { - $pu = $prod->multiprices[$commande->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$commande->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$commande->client->price_level]; + $pu = $prod->multiprices[$commande->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$commande->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$commande->client->price_level]; } else { $pu = $prod->price; - $pu_ttc = $prod->price_ttc; + $pu_ttc = $prod->price_ttc; } - + // La description de la ligne est celle saisie ou // celle du produit si PRODUIT_CHANGE_PROD_DESC est défini if ($conf->global->PRODUIT_CHANGE_PROD_DESC) @@ -350,7 +357,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $desc=$_POST['np_desc']; } - $commande->addline( + $result = $commande->addline( $_POST['id'], $desc, $pu, @@ -364,12 +371,19 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer) $pu_ttc ); - if ($_REQUEST['lang_id']) + if ($result > 0) { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); + 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); + } + 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; } -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->fetch($_GET['id']); $soc = new Societe($db); $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->fetch($_GET['id']); $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->fetch($_GET['id']); $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) { /* @@ -1013,30 +1017,29 @@ else /* * 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 - $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 '
'; + $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_validate'); + print '
'; + } /* * 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'); print '
'; } @@ -1044,7 +1047,7 @@ else /* * 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'); print '
'; @@ -1053,9 +1056,9 @@ else /* * 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 '
'; } @@ -1425,7 +1428,15 @@ else print ''; if ($conf->global->PRODUIT_CONFIRM_DELETE_LINE) { - print '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 'trans("No").'\',\'deleteline'.$i.'\')">'; + } + else + { + print 'rowid.'">'; + } } else { @@ -1649,12 +1660,29 @@ else print '
'; // Valid - if ($commande->statut == 0) + if ($commande->statut == 0 && $commande->total_ttc > 0 && $user->rights->commande->valider) { - if ($user->rights->commande->valider) + print 'use_ajax && $conf->global->MAIN_CONFIRM_AJAX) { - print ''.$langs->trans('Valid').''; + // 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').''; } // Edit @@ -1711,26 +1739,59 @@ else } } + // Cloturer if ($commande->statut == 1 || $commande->statut == 2) { if ($user->rights->commande->cloturer) { - print ''.$langs->trans('Close').''; + print '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').''; } } + // Annuler commande if ($commande->statut == 1) { $nb_expedition = $commande->nb_expedition(); if ($user->rights->commande->annuler && $nb_expedition == 0) { - print ''.$langs->trans('CancelOrder').''; + print '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').''; } } + // Supprimer commande if ($commande->statut == 0 && $user->rights->commande->supprimer) { - print ''.$langs->trans('Delete').''; + print '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').''; } print '
'; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index eae5e5f2206..eb31a127050 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1512,44 +1512,44 @@ class Facture extends CommonObject dolibarr_syslog("Facture::Deleteline rowid=".$rowid, LOG_DEBUG); if ($this->brouillon) - { - $this->db->begin(); - - // Libere remise liee a ligne de facture - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = NULL where fk_facture = '.$rowid; - $result = $this->db->query($sql); - if ($result < 0) - { - $this->error=$this->db->error(); - dolibarr_syslog("Facture::Deleteline Error ".$this->error); - $this->db->rollback(); - return -1; - } - - // Efface ligne de facture - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid; - $result = $this->db->query($sql); - if ($result < 0) - { - $this->error=$this->db->error(); - dolibarr_syslog("Facture::Deleteline Error ".$this->error); - $this->db->rollback(); - return -1; - } - - $result=$this->update_price($this->id); - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf); - // Fin appel triggers - - $this->db->commit(); - - return 1; - } + { + $this->db->begin(); + + // Libere remise liee a ligne de facture + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' SET fk_facture = NULL where fk_facture = '.$rowid; + $result = $this->db->query($sql); + if ($result < 0) + { + $this->error=$this->db->error(); + dolibarr_syslog("Facture::Deleteline Error ".$this->error); + $this->db->rollback(); + return -1; + } + + // Efface ligne de facture + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid; + $result = $this->db->query($sql); + if ($result < 0) + { + $this->error=$this->db->error(); + dolibarr_syslog("Facture::Deleteline Error ".$this->error); + $this->db->rollback(); + return -1; + } + + $result=$this->update_price($this->id); + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf); + // Fin appel triggers + + $this->db->commit(); + + return 1; + } } /**