';
print '| ';
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index de4db61574c..950a25496f9 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -121,7 +121,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
}
// Change status of invoice
-if ($action == 'reopen' && $user->rights->facture->creer)
+else if ($action == 'reopen' && $user->rights->facture->creer)
{
$result = $object->fetch($id);
if ($object->statut == 2
@@ -141,7 +141,7 @@ if ($action == 'reopen' && $user->rights->facture->creer)
}
// Delete invoice
-if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
+else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
if ($user->rights->facture->supprimer)
{
@@ -160,7 +160,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->
}
// Delete line
-if ($action == 'confirm_deleteline' && $confirm == 'yes')
+else if ($action == 'confirm_deleteline' && $confirm == 'yes')
{
if ($user->rights->facture->creer)
{
@@ -200,7 +200,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes')
}
// Delete link of credit note to invoice
-if ($action == 'unlinkdiscount')
+else if ($action == 'unlinkdiscount')
{
if ($user->rights->facture->creer)
{
@@ -211,7 +211,7 @@ if ($action == 'unlinkdiscount')
}
// Validation
-if ($action == 'valid')
+else if ($action == 'valid')
{
$object->fetch($id);
@@ -236,7 +236,7 @@ if ($action == 'valid')
}
}
-if ($action == 'set_thirdparty')
+else if ($action == 'set_thirdparty')
{
$object->fetch($id);
$object->setValueFrom('fk_soc',$socid);
@@ -245,20 +245,20 @@ if ($action == 'set_thirdparty')
exit;
}
-if ($action == 'classin')
+else if ($action == 'classin')
{
$object->fetch($id);
$object->setProject($_POST['projectid']);
}
-if ($action == 'setmode')
+else if ($action == 'setmode')
{
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
}
-if ($action == 'setinvoicedate')
+else if ($action == 'setinvoicedate')
{
$object->fetch($id);
$object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']);
@@ -267,16 +267,7 @@ if ($action == 'setinvoicedate')
if ($result < 0) dol_print_error($db,$object->error);
}
-// TODO obsolete ? not used
-if ($action == 'setpaymentterm')
-{
- $object->fetch($id);
- $date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
- $result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement);
- if ($result < 0) dol_print_error($db,$object->error);
-}
-
-if ($action == 'setconditions')
+else if ($action == 'setconditions')
{
$object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
@@ -289,7 +280,7 @@ if ($action == 'setremisepercent' && $user->rights->facture->creer)
$result = $object->set_remise($user, $_POST['remise_percent']);
}
-if ($action == "setabsolutediscount" && $user->rights->facture->creer)
+else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
{
// POST[remise_id] ou POST[remise_id_for_payment]
if (! empty($_POST["remise_id"]))
@@ -322,14 +313,14 @@ if ($action == "setabsolutediscount" && $user->rights->facture->creer)
}
}
-if ($action == 'set_ref_client')
+else if ($action == 'set_ref_client')
{
$object->fetch($id);
$object->set_ref_client($_POST['ref_client']);
}
// Classify to validated
-if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider)
+else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider)
{
$idwarehouse=GETPOST('idwarehouse');
@@ -376,7 +367,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->v
}
// Go back to draft status (unvalidate)
-if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
+else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate))
{
$idwarehouse=GETPOST('idwarehouse');
@@ -449,13 +440,13 @@ if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS
}
// Classify "paid"
-if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
+else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$object->fetch($id);
$result = $object->set_paid($user);
}
// Classif "paid partialy"
-if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement)
+else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement)
{
$object->fetch($id);
$close_code=$_POST["close_code"];
@@ -470,7 +461,7 @@ if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->f
}
}
// Classify "abandoned"
-if ($action == 'confirm_canceled' && $confirm == 'yes')
+else if ($action == 'confirm_canceled' && $confirm == 'yes')
{
$object->fetch($id);
$close_code=$_POST["close_code"];
@@ -486,7 +477,7 @@ if ($action == 'confirm_canceled' && $confirm == 'yes')
}
// Convertir en reduc
-if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
+else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer)
{
$db->begin();
@@ -561,7 +552,7 @@ if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->f
/*
* Insert new invoice in database
*/
-if ($action == 'add' && $user->rights->facture->creer)
+else if ($action == 'add' && $user->rights->facture->creer)
{
$object->socid=GETPOST('socid','int');
@@ -922,7 +913,7 @@ if ($action == 'add' && $user->rights->facture->creer)
}
// Add a new line
-if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
+else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
{
$result=0;
@@ -1130,7 +1121,7 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact
$action='';
}
-if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
+else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save'))
{
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
@@ -1218,15 +1209,14 @@ if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save']
}
}
-if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
+else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
{
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // Pour reaffichage de la fiche en cours d'edition
exit;
}
-
// Modify line position (up)
-if ($action == 'up' && $user->rights->facture->creer)
+else if ($action == 'up' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
@@ -1248,7 +1238,7 @@ if ($action == 'up' && $user->rights->facture->creer)
exit;
}
// Modify line position (down)
-if ($action == 'down' && $user->rights->facture->creer)
+else if ($action == 'down' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
@@ -1478,7 +1468,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
/*
* Generate document
*/
-if (GETPOST('action') == 'builddoc') // En get ou en post
+else if ($action == 'builddoc') // En get ou en post
{
$object->fetch($id);
$object->fetch_thirdparty();
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index d5247846507..dad4757f61d 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2686,93 +2686,6 @@ class Facture extends CommonObject
}
}
- /**
- * Change les conditions de reglement de la facture
- *
- * @param int $cond_reglement_id Id de la nouvelle condition de reglement
- * @param date $date Date to force payment term
- * @return int >0 si ok, <0 si ko
- * TODO deprecated, not used
- */
- function cond_reglement($cond_reglement_id,$date='')
- {
- if ($this->statut >= 0 && $this->paye == 0)
- {
- // Define cond_reglement_id and datelim
- if (strval($date) != '')
- {
- $datelim=$date;
- $cond_reglement_id=0;
- }
- else
- {
- $datelim=$this->calculate_date_lim_reglement($cond_reglement_id);
- $cond_reglement_id=$cond_reglement_id;
- }
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
- $sql.= ' SET fk_cond_reglement = '.$cond_reglement_id.',';
- $sql.= ' date_lim_reglement='.$this->db->idate($datelim);
- $sql.= ' WHERE rowid='.$this->id;
-
- dol_syslog(get_class($this)."::cond_reglement sql=".$sql, LOG_DEBUG);
- if ( $this->db->query($sql) )
- {
- $this->cond_reglement_id = $cond_reglement_id;
- return 1;
- }
- else
- {
- dol_syslog(get_class($this)."::cond_reglement Erreur ".$sql.' - '.$this->db->error());
- $this->error=$this->db->error();
- return -1;
- }
- }
- else
- {
- dol_syslog(get_class($this)."::cond_reglement, etat facture incompatible");
- $this->error='Entity status not compatible '.$this->statut.' '.$this->paye;
- return -2;
- }
- }
-
-
- /**
- * Change le mode de reglement
- *
- * @param int $mode_reglement_id Id du nouveau mode
- * @return int >0 if OK, <0 if KO
- * TODO deprecated
- */
- function mode_reglement($mode_reglement_id)
- {
- dol_syslog(get_class($this).'::mode_reglement('.$mode_reglement_id.')', LOG_DEBUG);
- if ($this->statut >= 0 && $this->paye == 0)
- {
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
- $sql .= ' SET fk_mode_reglement = '.$mode_reglement_id;
- $sql .= ' WHERE rowid='.$this->id;
- if ( $this->db->query($sql) )
- {
- $this->mode_reglement_id = $mode_reglement_id;
- return 1;
- }
- else
- {
- dol_syslog(get_class($this).'::mode_reglement Erreur '.$sql.' - '.$this->db->error());
- $this->error=$this->db->error();
- return -1;
- }
- }
- else
- {
- dol_syslog(get_class($this).'::mode_reglement, etat facture incompatible');
- $this->error='Etat facture incompatible '.$this->statut.' '.$this->paye;
- return -2;
- }
- }
-
-
/**
* Renvoi si les lignes de facture sont ventilees et/ou exportees en compta
*
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8df1964c1de..497607988e8 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -942,6 +942,33 @@ abstract class CommonObject
}
}
+ /**
+ * Define delivery address
+ *
+ * @param int $id Address id
+ * @return int <0 si ko, >0 si ok
+ */
+ function setDeliveryAddress($id)
+ {
+ $fieldname = 'fk_adresse_livraison';
+ if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id;
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
+
+ if ($this->db->query($sql))
+ {
+ $this->fk_delivery_address = $id;
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error);
+ return -1;
+ }
+ }
+
/**
* Set last model used by doc generator
*
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index c1640110553..1c70695994c 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -733,6 +733,8 @@ class FormOther
function form_address($page, $selected, $socid, $htmlname='address_id', $origin='', $originid='')
{
global $langs,$conf;
+ global $form;
+
if ($htmlname != "none")
{
print ' |
|