';
$companystatic->id=$obj->socid;
$companystatic->name=$obj->name;
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index e1edde93922..7ed5e3097bf 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -424,14 +424,6 @@ class Orders extends DolibarrApi
if ($this->commande->availability($this->commande->availability_id) < 0)
throw new RestException(400, 'Error while updating availability');
}
- // update bank account
- if(!empty($this->commande->fk_account))
- {
- if($this->commande->setBankAccount($this->commande->fk_account) == 0)
- {
- throw new RestException(400,$this->commande->error);
- }
- }
if ($this->commande->update(DolibarrApiAccess::$user) > 0)
{
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 7998a25bd13..65b704693fb 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -3036,6 +3036,8 @@ class Commande extends CommonOrder
*/
function update(User $user, $notrigger=0)
{
+ global $conf;
+
$error=0;
// Clean parameters
@@ -3069,6 +3071,7 @@ class Commande extends CommonOrder
$sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").",";
$sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").",";
$sql.= " fk_mode_reglement=".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null").",";
+ $sql.= " fk_account=".($this->fk_account>0?$this->fk_account:"null").",";
$sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
$sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
$sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").",";
diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php
index 5922b3f5aa7..fe56ea99504 100644
--- a/htdocs/compta/bank/class/paymentvarious.class.php
+++ b/htdocs/compta/bank/class/paymentvarious.class.php
@@ -34,6 +34,8 @@ class PaymentVarious extends CommonObject
public $table_element='payment_various'; //!< Name of table without prefix where object is stored
public $picto = 'bill';
+ var $id;
+ var $ref;
var $tms;
var $datep;
var $datev;
@@ -87,8 +89,7 @@ class PaymentVarious extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET";
-
- $sql.= " tms='".$this->db->idate($this->tms)."',";
+ if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',";
$sql.= " datep='".$this->db->idate($this->datep)."',";
$sql.= " datev='".$this->db->idate($this->datev)."',";
$sql.= " sens=".$this->sens.",";
@@ -102,7 +103,6 @@ class PaymentVarious extends CommonObject
$sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").",";
$sql.= " fk_user_author=".$this->fk_user_author.",";
$sql.= " fk_user_modif=".$this->fk_user_modif;
-
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@@ -146,7 +146,6 @@ class PaymentVarious extends CommonObject
global $langs;
$sql = "SELECT";
$sql.= " v.rowid,";
-
$sql.= " v.tms,";
$sql.= " v.datep,";
$sql.= " v.datev,";
@@ -164,7 +163,6 @@ class PaymentVarious extends CommonObject
$sql.= " b.fk_account,";
$sql.= " b.fk_type,";
$sql.= " b.rappro";
-
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
$sql.= " WHERE v.rowid = ".$id;
@@ -184,7 +182,7 @@ class PaymentVarious extends CommonObject
$this->datev = $this->db->jdate($obj->datev);
$this->sens = $obj->sens;
$this->amount = $obj->amount;
- $this->type_payement = $obj->fk_typepayment;
+ $this->type_payment = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label;
$this->note = $obj->note;
@@ -350,6 +348,7 @@ class PaymentVarious extends CommonObject
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various");
+ $this->ref = $this->id;
if ($this->id > 0)
{
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 90aa3e5e432..b6649250e64 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -49,7 +49,7 @@ $sens=GETPOST("sens","int");
$amount=GETPOST("amount");
$paymenttype=GETPOST("paymenttype");
$accountancy_code=GETPOST("accountancy_code","int");
-$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
+$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int'));
// Security check
$socid = GETPOST("socid","int");
@@ -96,22 +96,23 @@ if (empty($reshook))
{
$error=0;
- $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
- $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
+ $datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int'));
+ $datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int'));
if (empty($datev)) $datev=$datep;
- $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
+ $object->ref=''; // TODO
+ $object->accountid=GETPOST("accountid",'int') > 0 ? GETPOST("accountid","int") : 0;
$object->datev=$datev;
$object->datep=$datep;
- $object->amount=price2num(GETPOST("amount"));
- $object->label=GETPOST("label");
- $object->note=GETPOST("note");
- $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0;
- $object->num_payment=GETPOST("num_payment");
+ $object->amount=price2num(GETPOST("amount",'alpha'));
+ $object->label=GETPOST("label",'none');
+ $object->note=GETPOST("note",'none');
+ $object->type_payment=GETPOST("paymenttype",'int') > 0 ? GETPOST("paymenttype", "int") : 0;
+ $object->num_payment=GETPOST("num_payment",'alpha');
$object->fk_user_author=$user->id;
$object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : "";
$object->sens=GETPOST('sens');
- $object->fk_project= GETPOST('fk_project');
+ $object->fk_project= GETPOST('fk_project','int');
if (empty($datep) || empty($datev))
{
@@ -411,7 +412,7 @@ if ($id)
print '';
// Label
- print '| '.$langs->trans("Label").' | '.$object->label.' | ';
+ print '| '.$langs->trans("Label").' | '.$object->label.' | ';
// Payment date
print "";
diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php
index e32dc8818e2..d52cbeb7595 100644
--- a/htdocs/compta/bank/various_payment/index.php
+++ b/htdocs/compta/bank/various_payment/index.php
@@ -108,21 +108,19 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.row
$sql.= " WHERE v.entity IN (".getEntity('payment_various').")";
// Search criteria
-if ($search_ref) $sql.=" AND v.rowid=".$search_ref;
-if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
-if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1);
-if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1);
-if ($search_account > 0) $sql.=" AND b.fk_account=".$search_account;
-if ($search_date) $sql.=" AND v.datep=".$search_date;
-if ($search_accountancy_code) $sql.=" AND v.accountancy_code=".$search_accountancy_code;
-
+if ($search_ref) $sql.=" AND v.rowid=".$search_ref;
+if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
+if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1);
+if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1);
+if ($search_account > 0) $sql.=" AND b.fk_account=".$search_account;
+if ($search_date) $sql.=" AND v.datep=".$search_date;
+if ($search_accountancy_code > 0) $sql.=" AND v.accountancy_code=".$search_accountancy_code;
+if ($typeid > 0) $sql .= " AND v.fk_typepayment=".$typeid;
if ($filtre) {
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
}
-if ($typeid) {
- $sql .= " AND v.fk_typepayment=".$typeid;
-}
+
$sql.= $db->order($sortfield,$sortorder);
$totalnboflines=0;
@@ -142,10 +140,18 @@ if ($result)
$var=true;
$param='';
- if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
- if ($typeid) $param.='&typeid='.$typeid;
- if ($optioncss != '') $param.='&optioncss='.$optioncss;
+ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+ if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
+ if ($search_label) $param.='&search_label='.urlencode($search_label);
+ if ($typeid > 0) $param.='&typeid='.urlencode($typeid);
+ if ($search_amount_deb) $param.='&search_amount_deb='.urlencode($search_amount_deb);
+ if ($search_amount_cred) $param.='&search_amount_cred='.urlencode($search_amount_cred);
+ if ($search_account > 0) $param.='&search_amount='.urlencode($search_account);
+ //if ($search_date) $param.='&search_date='.$search_date;
+ if ($search_accountancy_code > 0) $param.='&search_accountancy_code='.urlencode($search_accountancy_code);
+
+ if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
print ' |