From 1ecc24216fece3ed11e319389fe30b6f64dd0384 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Thu, 13 Jun 2013 15:07:50 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Fix=20[=20bug=20#934=20]=20Impossible=20de?= =?UTF-8?q?=20cr=C3=A9er=20une=20facture=20pr=C3=A9d=C3=A9finie=20(pgsql)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture/class/facture-rec.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1651407d746..565e63fd749 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -125,8 +125,8 @@ class FactureRec extends Facture $sql.= ", '".$facsrc->socid."'"; $sql.= ", ".$conf->entity; $sql.= ", ".$this->db->idate($now); - $sql.= ", '".$facsrc->amount."'"; - $sql.= ", '".$facsrc->remise."'"; + $sql.= ", ".(!empty($facsrc->amount)?$facsrc->amount:'0'); + $sql.= ", ".(!empty($facsrc->remise)?$this->remise:'0'); $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); $sql.= ", '".$user->id."'"; From eb298e055760710207fb015b9fe842de423358bf Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Thu, 13 Jun 2013 15:24:09 +0200 Subject: [PATCH 2/4] Merge file from Jean Heimberger --- htdocs/product/class/product.class.php | 1 + htdocs/product/price.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6888c144a7c..5a9d075b4ff 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -57,6 +57,7 @@ class Product extends CommonObject //! Base price ('TTC' for price including tax or 'HT' for net price) var $price_base_type; //! Arrays for multiprices + var $pricelevel; var $multiprices=array(); var $multiprices_ttc=array(); var $multiprices_base_type=array(); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2d0a1816982..6b8f6b90ae3 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -88,6 +88,16 @@ if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit-> $newpsq = empty($newpsq) ? 0 : $newpsq; } + //save level and multiprices for trigger + $object->pricelevel = $level; + if ($level) + { + $object->multiprices[$level]=$newprice; + $object->multiprices_base_type[$level]=$newpricebase; + $object->multiprices_tva_tx[$level]=$newvat; + $object->multiprices_min[$level]=$newprice_min; + } + if ($object->updatePrice($object->id, $newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) { $action = ''; From 2704ba5f36692d39d2088c7c0f2f1a6ed1845f55 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Thu, 13 Jun 2013 18:11:23 +0200 Subject: [PATCH 3/4] Fix bug on attach element in element.php (simply not work before...) --- htdocs/projet/class/project.class.php | 27 +++++++++++++++++++-------- htdocs/projet/element.php | 15 +++++++++++---- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index dc438d2b929..bb37d9eeeb8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1286,7 +1286,6 @@ class Project extends CommonObject */ function select_element($Tablename) { - global $db; $projectkey="fk_projet"; switch ($Tablename) @@ -1316,25 +1315,27 @@ class Project extends CommonObject } $sql.= " ORDER BY ref DESC"; - dol_syslog("Project.Lib::select_element sql=".$sql); + dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG); - $resql=$db->query($sql); + $resql=$this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; if ($num > 0) { $sellist = ''; } return $sellist ; + + $this->db->free($resql); } } @@ -1347,8 +1348,8 @@ class Project extends CommonObject */ function update_element($TableName, $ElementSelectId) { - global $db; - $sql="update ".MAIN_DB_PREFIX.$TableName; + $sql="UPDATE ".MAIN_DB_PREFIX.$TableName; + if ($TableName=="actioncomm") { $sql.= " SET fk_project=".$this->id; @@ -1359,7 +1360,17 @@ class Project extends CommonObject $sql.= " SET fk_projet=".$this->id; $sql.= " WHERE rowid=".$ElementSelectId; } - $resql=$db->query($sql); + + dol_syslog(get_class($this)."::update_element sql=" . $sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if (!$resql) { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::update_element error : " . $this->error, LOG_ERR); + return -1; + }else { + return 1; + } + } } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index e47c36fa191..3f686bdecaf 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -46,8 +46,10 @@ if (! empty($conf->commande->enabled)) $langs->load("orders"); if (! empty($conf->propal->enabled)) $langs->load("propal"); if (! empty($conf->ficheinter->enabled)) $langs->load("interventions"); -$projectid=GETPOST('id'); -$ref=GETPOST('ref'); +$projectid=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); + if ($projectid == '' && $ref == '') { dol_print_error('','Bad parameter'); @@ -62,6 +64,8 @@ if ($ref) { $project->fetch(0,$ref); $projectid=$project->id; +}else { + $project->fetch($projectid); } // Security check @@ -82,7 +86,7 @@ $form = new Form($db); $userstatic=new User($db); $project = new Project($db); -$project->fetch($_GET["id"],$_GET["ref"]); +$project->fetch($projectid,$ref); $project->societe->fetch($project->societe->id); // To verify role of users @@ -191,7 +195,10 @@ if ($action=="addelement") { $tablename = GETPOST("tablename"); $elementselectid = GETPOST("elementselect"); - $project->update_element($tablename, $elementselectid); + $result=$project->update_element($tablename, $elementselectid); + if ($result<0) { + setEventMessage($mailchimp->error,'errors'); + } } foreach ($listofreferent as $key => $value) From 184f1a4b159495a657981c4e3f9362796424b7cc Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Fri, 14 Jun 2013 00:44:58 +0200 Subject: [PATCH 4/4] revert Jean modif --- htdocs/product/class/product.class.php | 1 - htdocs/product/price.php | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5a9d075b4ff..6888c144a7c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -57,7 +57,6 @@ class Product extends CommonObject //! Base price ('TTC' for price including tax or 'HT' for net price) var $price_base_type; //! Arrays for multiprices - var $pricelevel; var $multiprices=array(); var $multiprices_ttc=array(); var $multiprices_base_type=array(); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 6b8f6b90ae3..2d0a1816982 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -88,16 +88,6 @@ if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit-> $newpsq = empty($newpsq) ? 0 : $newpsq; } - //save level and multiprices for trigger - $object->pricelevel = $level; - if ($level) - { - $object->multiprices[$level]=$newprice; - $object->multiprices_base_type[$level]=$newpricebase; - $object->multiprices_tva_tx[$level]=$newvat; - $object->multiprices_min[$level]=$newprice_min; - } - if ($object->updatePrice($object->id, $newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) { $action = '';