From 395066519b5c7f3d6dafa8dcdd45583509f612d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 16:18:18 +0100 Subject: [PATCH 01/20] Fix: [ bug #1163 ] SQL Error when searching for supplier orders --- ChangeLog | 2 ++ htdocs/fourn/commande/liste.php | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f18248c35fc..1ea35d60a0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ -------------------------------------------------------------- English Dolibarr ChangeLog -------------------------------------------------------------- + ***** ChangeLog for 3.4.2 compared to 3.4.1 ***** Fix: field's problem into company's page (RIB) Fix: Document cerfa doesn't contained firstname & lastname from donator @@ -12,6 +13,7 @@ Fix: [ bug #1142 ] Set paiement on invoice (PGSql) Fix: [ bug #1145 ] Agenda button list type do not display Fix: [ bug #1148 ] Product consomation : supplier order bad status Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists +Fix: [ bug #1163 ] SQL Error when searching for supplier orders ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index 76270c8ea20..b20d73f84f9 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -105,16 +105,17 @@ if ($sttc) } if ($sall) { - $sql.= " AND (cf.ref LIKE '%".$db->escape($sall)."%' OR cf.note LIKE '%".$db->escape($sall)."%')"; + $sql.= " AND (cf.ref LIKE '%".$db->escape($sall)."%' OR cf.note_private LIKE '%".$db->escape($sall)."%' OR cf.note_public LIKE '%".$db->escape($sall)."%')"; } if ($socid) $sql.= " AND s.rowid = ".$socid; if (GETPOST('statut')) { - $sql .= " AND fk_statut =".GETPOST('statut'); + $sql .= " AND fk_statut =".GETPOST('statut','int'); } -$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); +$sql.= " ORDER BY $sortfield $sortorder "; +$sql.= $db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); if ($resql) From 8f1a5533951ccd7847252fa2f3315a836ecffbd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 16:22:06 +0100 Subject: [PATCH 02/20] =?UTF-8?q?Fix:=20[=20bug=20#1162=20]=20Traduction?= =?UTF-8?q?=20des=20mi-journ=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 1 + htdocs/langs/en_US/main.lang | 2 ++ htdocs/langs/fr_FR/main.lang | 2 ++ 3 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1ea35d60a0a..375bd99b338 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ Fix: [ bug #1145 ] Agenda button list type do not display Fix: [ bug #1148 ] Product consomation : supplier order bad status Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists Fix: [ bug #1163 ] SQL Error when searching for supplier orders +Fix: [ bug #1162 ] Traduction des mi-journées ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 6876d0c6b2b..2bc80f696bd 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -256,6 +256,8 @@ Seconds=Seconds Today=Today Yesterday=Yesterday Tomorrow=Tomorrow +Morning=Morning +Afternoon=Afternoon Quadri=Quadri MonthOfDay=Month of the day HourShort=H diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index f642fe4c9b5..9ad1a71b1a8 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -252,6 +252,8 @@ Seconds=Secondes Today=Aujourd'hui Yesterday=Hier Tomorrow=Demain +Morning=Matin +Afternoon=Après-midi Quadri=Trimestre MonthOfDay=Mois du jour HourShort=H From 84e345702378c617d6ce1ff9df6cdbe022ae5f7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 16:30:35 +0100 Subject: [PATCH 03/20] Fix: [ bug #1161 ] Search on product label --- ChangeLog | 3 ++- htdocs/societe/consumption.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 375bd99b338..6227e174763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,7 +14,8 @@ Fix: [ bug #1145 ] Agenda button list type do not display Fix: [ bug #1148 ] Product consomation : supplier order bad status Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists Fix: [ bug #1163 ] SQL Error when searching for supplier orders -Fix: [ bug #1162 ] Traduction des mi-journées +Fix: [ bug #1162 ] Translaction for morning and afternoon +Fix: [ bug #1161 ] Search on product label ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 21d98fbd64c..16d2c4fea7d 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -214,6 +214,7 @@ if ($month > 0) { $sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; } if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'"; +if ($sprod_fulldescr) $sql.= " AND (d.description LIKE '%".$sprod_fulldescr."%' OR p.label LIKE '%".$sprod_fulldescr."%')"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1, $offset); @@ -249,7 +250,7 @@ print $formother->select_month($month?$month:-1,'month',1); $formother->select_year($year?$year:-1,'year',1, 20, 1); print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; From eaa6d987b6012e7d45f924fa8146b9096d5e7172 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 17:32:05 +0100 Subject: [PATCH 04/20] Fix: When database is not synchronized with dir, we clean database. --- htdocs/ecm/ajax/ecmdatabase.php | 17 ++++++++++++++++- htdocs/ecm/class/ecmdirectory.class.php | 19 ++++++++++++------- htdocs/ecm/index.php | 21 ++++++++++++++++++--- htdocs/ecm/tpl/builddatabase.tpl.php | 21 +++++++++------------ 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index cfdfb7fe26d..7a1a667d332 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -51,7 +51,9 @@ if (isset($action) && ! empty($action)) require DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php'; $ecmdirstatic = new EcmDirectory($db); + $ecmdirtmp = new EcmDirectory($db); + // This part of code is same than into file index.php for action refreshmanual TODO Remove duplicate clearstatcache(); $diroutputslash=str_replace('\\', '/', $conf->$element->dir_output); @@ -129,7 +131,6 @@ if (isset($action) && ! empty($action)) if ($fk_parent >= 0) { - $ecmdirtmp=new EcmDirectory($db); $ecmdirtmp->ref = 'NOTUSEDYET'; $ecmdirtmp->label = dol_basename($dirdesc['fullname']); $ecmdirtmp->description = ''; @@ -163,7 +164,21 @@ if (isset($action) && ! empty($action)) } } + // Loop now on each sql tree to check if dir exists + foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + { + $dirtotest=$conf->$element->dir_output.'/'.$dirdesc['fullrelativename']; + if (! dol_is_dir($dirtotest)) + { + $mesg.=$dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."
\n"; + $ecmdirtmp->id=$dirdesc['id']; + $ecmdirtmp->delete($user,'databaseonly'); + //exit; + } + } + $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" + dol_syslog("sql = ".$sql); $db->query($sql); } } diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 3c12fe066e9..ff914772b2f 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -143,7 +143,7 @@ class EcmDirectory // extends CommonObject $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath(); $result=dol_mkdir($dir); if ($result < 0) { $error++; $this->error="ErrorFailedToCreateDir"; } - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -317,21 +317,23 @@ class EcmDirectory // extends CommonObject /** - * Delete object on database and on disk + * Delete object on database and/or on disk * * @param User $user User that delete + * @param int $mode 'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented) * @return int <0 if KO, >0 if OK */ - function delete($user) + function delete($user, $mode='all') { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; + $result=0; - $relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3 + if ($mode != 'databaseonly') $relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3 - dol_syslog(get_class($this)."::delete remove directory ".$relativepath); + dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly')?'':' relativepath='.$relativepath)); $this->db->begin(); @@ -348,8 +350,11 @@ class EcmDirectory // extends CommonObject return -2; } - $file = $conf->ecm->dir_output . "/" . $relativepath; - $result=@dol_delete_dir($file); + if ($mode != 'databaseonly') + { + $file = $conf->ecm->dir_output . "/" . $relativepath; + $result=@dol_delete_dir($file); + } if ($result || ! @is_dir(dol_osencode($file))) { diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index bb8844eafc6..0939dc9a77d 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -201,7 +201,10 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') // Refresh directory view if ($action == 'refreshmanual') { - clearstatcache(); + $ecmdirtmp = new EcmDirectory($db); + + // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate + clearstatcache(); $diroutputslash=str_replace('\\','/',$conf->ecm->dir_output); $diroutputslash.='/'; @@ -264,7 +267,7 @@ if ($action == 'refreshmanual') //break; // We found parent, we can stop the while loop } else - { + { dol_syslog("No"); //print "No
\n"; } @@ -277,7 +280,6 @@ if ($action == 'refreshmanual') if ($fk_parent >= 0) { - $ecmdirtmp=new EcmDirectory($db); $ecmdirtmp->ref = 'NOTUSEDYET'; $ecmdirtmp->label = dol_basename($dirdesc['fullname']); $ecmdirtmp->description = ''; @@ -311,6 +313,19 @@ if ($action == 'refreshmanual') } } + // Loop now on each sql tree to check if dir exists + foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk + { + $dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename']; + if (! dol_is_dir($dirtotest)) + { + $mesg.=$dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."
\n"; + $ecmdirtmp->id=$dirdesc['id']; + $ecmdirtmp->delete($user,'databaseonly'); + //exit; + } + } + $sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("sql = ".$sql); $db->query($sql); diff --git a/htdocs/ecm/tpl/builddatabase.tpl.php b/htdocs/ecm/tpl/builddatabase.tpl.php index 7f997ed6209..38137fa4997 100644 --- a/htdocs/ecm/tpl/builddatabase.tpl.php +++ b/htdocs/ecm/tpl/builddatabase.tpl.php @@ -39,7 +39,15 @@ $(document).ready( function() { ); $('#refreshbutton').click( function() { - ecmBuildDatabase(); + $.pleaseBePatient("trans('PleaseBePatient'); ?>"); + $.getJSON( "", { + action: "build", + element: "ecm" + }, + function(response) { + $.unblockUI(); + location.href=""; + }); }); }); @@ -67,16 +75,5 @@ function loadandshowpreview(filedirname,section) }); } -ecmBuildDatabase = function() { - $.pleaseBePatient("trans('PleaseBePatient'); ?>"); - $.getJSON( "", { - action: "build", - element: "ecm" - }, - function(response) { - $.unblockUI(); - location.href=""; - }); -}; \ No newline at end of file From fdc12099860f65e258b29207704d0be353fc4289 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 18:12:15 +0100 Subject: [PATCH 05/20] Fix: [ bug #1163 ] SQL Error when searching for supplier orders Conflicts: ChangeLog --- ChangeLog | 1 - 1 file changed, 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6227e174763..46c847acadd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,7 +46,6 @@ Fix: there was no escaping on filter fields in supplier product list Fix: bugs on margin reports and better margin calculation on credit notes Qual: Add travis-ci integration - ***** ChangeLog for 3.4 compared to 3.3.* ***** For users: - New: Can use ODS templates as document templates. From 2f88406677c94686040c8c607d5f4cb45d477ebc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 20:12:47 +0100 Subject: [PATCH 06/20] Fix: [ bug #1075 ] POS module doesn't decrement stock of products in Delayed payment mode. --- htdocs/cashdesk/validation_verif.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 893768a9aec..3cd7784d59d 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -212,7 +212,7 @@ switch ($action) $resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiementLe())); if ($resultcreate > 0) { - $resultvalid=$invoice->validate($user,$obj_facturation->numInvoice()); + $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0)); } else { From 131bbce6f3c60854368ee2b98214929e2e73fad1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 20:17:22 +0100 Subject: [PATCH 07/20] Update changelog --- ChangeLog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 46c847acadd..016dde9b28a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,7 +16,9 @@ Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists Fix: [ bug #1163 ] SQL Error when searching for supplier orders Fix: [ bug #1162 ] Translaction for morning and afternoon Fix: [ bug #1161 ] Search on product label - +Fix: [ bug #1075 ] POS module doesn't decrement stock of products in + delayed payment mode. + ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined Fix: Retrieving of margin info when invoice created automatically from order From c54c06e8d320bf6859aa4fe40397ae9b79c85924 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 21:03:12 +0100 Subject: [PATCH 08/20] Fix: [ bug #1171 ] Documents lost in interventions after validating --- htdocs/fichinter/class/fichinter.class.php | 68 +++++++++++++++++----- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6e3079c6d7d..d2c379563c4 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -368,6 +368,7 @@ class Fichinter extends CommonObject function setValid($user) { global $langs, $conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error=0; @@ -390,7 +391,7 @@ class Fichinter extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter"; $sql.= " SET fk_statut = 1"; $sql.= ", ref = '".$num."'"; - $sql.= ", date_valid = ".$this->db->idate($now); + $sql.= ", date_valid = '".$this->db->idate($now)."'"; $sql.= ", fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; $sql.= " AND entity = ".$conf->entity; @@ -398,7 +399,52 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::setValid sql=".$sql); $resql=$this->db->query($sql); - if ($resql) + if (! $resql) + { + dol_syslog(get_class($this)."::setValid Echec update - 10 - sql=".$sql, LOG_ERR); + dol_print_error($this->db); + $error++; + } + + if (! $error) + { + $this->oldref = ''; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of object directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $snum = dol_sanitizeFileName($num); + $dirsource = $conf->ficheinter->dir_output.'/'.$oldref; + $dirdest = $conf->ficheinter->dir_output.'/'.$snum; + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) + { + $this->oldref = $oldref; + + dol_syslog("Rename ok"); + // Suppression ancien fichier PDF dans nouveau rep + dol_delete_file($conf->ficheinter->dir_output.'/'.$snum.'/'.$oldref.'*.*'); + } + } + } + } + + // Set new ref and define current statut + if (! $error) + { + $this->ref = $num; + $this->statut=1; + $this->brouillon=0; + $this->date_validation=$now; + } + + if (! $error) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; @@ -408,24 +454,16 @@ class Fichinter extends CommonObject $error++; $this->errors=$interface->errors; } // Fin appel triggers + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - $this->error=join(',',$this->errors); - dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR); - return -1; - } + if (! $error) + { + $this->db->commit(); + return 1; } else { $this->db->rollback(); - $this->error=$this->db->lasterror(); dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR); return -1; } From 4aea74d6fd7807a6154e1eb3dc9eac3897074489 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2013 21:05:22 +0100 Subject: [PATCH 09/20] Fix: [ bug #1171 ] Documents lost in interventions after validating --- ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 016dde9b28a..d2cad1045fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,7 +18,8 @@ Fix: [ bug #1162 ] Translaction for morning and afternoon Fix: [ bug #1161 ] Search on product label Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed payment mode. - +Fix: [ bug #1171 ] Documents lost in interventions after validating + ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined Fix: Retrieving of margin info when invoice created automatically from order From c6991f97d40a3e710900dcb12bd9e06ef7e3f68c Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Sun, 1 Dec 2013 22:47:22 +0100 Subject: [PATCH 10/20] [ bug #1174 ] Product translated description not good into PDF Country --- ChangeLog | 2 ++ htdocs/core/lib/pdf.lib.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f18248c35fc..f980c7fa7cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ Fix: [ bug #1142 ] Set paiement on invoice (PGSql) Fix: [ bug #1145 ] Agenda button list type do not display Fix: [ bug #1148 ] Product consomation : supplier order bad status Fix: [ bug #1159 ] Commercial search "other" give p.note do not exists +Fix: [ bug #1174 ] Product translated description not good into PDF + ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 5301f5daa04..059cb0fe285 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -923,7 +923,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && strpos($desc,$prodser->description)!==false) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } From ff9c84fd0e8fd6e1cd1939f77ad1a3145578e62a Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 00:20:50 +0100 Subject: [PATCH 11/20] Better test for HTMLentities desc translation --- htdocs/core/lib/pdf.lib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 059cb0fe285..f11a0fa7ec8 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -923,7 +923,19 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && strpos($desc,$prodser->description)!==false) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + + //Manage HTML entities description test + if ($conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { + $desctest=dol_htmlentities($desc, ENT_COMPAT | ENT_HTML401); + } else { + $desctest=$desc; + } + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && + ((strpos($desctest,$prodser->description)!==false) || + (strpos($desc,$prodser->description)!==false))) { + $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + } + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } From c0ef63fd746e99f31eb1870e5048108441d11c68 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 00:22:49 +0100 Subject: [PATCH 12/20] Bteer fix --- htdocs/comm/propal.php | 4 ++-- htdocs/core/lib/pdf.lib.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 33fed6c76d1..60e29a74543 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -786,7 +786,7 @@ else if ($action == "addline" && $user->rights->propal->creer) $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - + if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency)); @@ -920,7 +920,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $error++; } } - + if (! $error) { $result = $object->updateline( diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index f11a0fa7ec8..475991831e4 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -930,6 +930,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl } else { $desctest=$desc; } + //Test with htmlenties for update and no htmlentities for creation if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ((strpos($desctest,$prodser->description)!==false) || (strpos($desc,$prodser->description)!==false))) { From 1b38d36f2884a56e3e265f3cf6a1b099489d791f Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 10:27:41 +0100 Subject: [PATCH 13/20] Better Fix --- htdocs/core/lib/pdf.lib.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 475991831e4..2bc5ebab145 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -925,18 +925,14 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; //Manage HTML entities description test + //Cause $prodser->description is store with htmlentities but $desc no if ($conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { - $desctest=dol_htmlentities($desc, ENT_COMPAT | ENT_HTML401); + $testDescNeedTranslated=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); } else { - $desctest=$desc; - } - //Test with htmlenties for update and no htmlentities for creation - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && - ((strpos($desctest,$prodser->description)!==false) || - (strpos($desc,$prodser->description)!==false))) { - $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + $testDescNeedTranslated=true; } + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testDescNeedTranslated || (strpos($desc,$prodser->description)!==false))) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } From 1ad1b25f6e6f19040d0eb559a6a8e2b312f5981f Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 10:29:58 +0100 Subject: [PATCH 14/20] remove useless space --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2bc5ebab145..dcf5ebff74b 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -932,7 +932,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $testDescNeedTranslated=true; } - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testDescNeedTranslated || (strpos($desc,$prodser->description)!==false))) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testDescNeedTranslated || (strpos($desc,$prodser->description)!==false))) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } From 0907d81fcb816263ae2ddfc1b4b2179b492bde4a Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 11:05:07 +0100 Subject: [PATCH 15/20] Avoid strpos bug if string is empty or null --- htdocs/core/lib/pdf.lib.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dcf5ebff74b..fdb07237bac 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -926,13 +926,21 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl //Manage HTML entities description test //Cause $prodser->description is store with htmlentities but $desc no + $testHTMLDescNeedTranslated=true; + $testDescNeedTranslated=true; if ($conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { - $testDescNeedTranslated=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); + if (!empty($desc) && !empty($prodser->description)) { + $testHTMLDescNeedTranslated=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); + } } else { - $testDescNeedTranslated=true; + if (!empty($desc) && !empty($prodser->description)) { + $testDescNeedTranslated = (strpos($desc,$prodser->description)!==false); + } else { + $testDescNeedTranslated=false; + } } - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testDescNeedTranslated || (strpos($desc,$prodser->description)!==false))) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testHTMLDescNeedTranslated || $testDescNeedTranslated)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } From 3e712c9c8c8f33a80d74ab04e965394aeea5d7b3 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 11:11:08 +0100 Subject: [PATCH 16/20] Finnaly make it works --- htdocs/core/lib/pdf.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index fdb07237bac..fa8de1c0352 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -932,6 +932,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (!empty($desc) && !empty($prodser->description)) { $testHTMLDescNeedTranslated=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); } + $testDescNeedTranslated=false; } else { if (!empty($desc) && !empty($prodser->description)) { $testDescNeedTranslated = (strpos($desc,$prodser->description)!==false); @@ -939,7 +940,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $testDescNeedTranslated=false; } } - + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testHTMLDescNeedTranslated || $testDescNeedTranslated)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } From bc4cfd66dbd13c12f498527dcba108dd7abb64a7 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 2 Dec 2013 15:07:34 +0100 Subject: [PATCH 17/20] Fix: fix unsubscribe URL into mailing when sending manually (not by script) --- ChangeLog | 1 + htdocs/comm/mailing/fiche.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e86e0f7279..d6caeca60c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ Fix: [ bug #1162 ] Translaction for morning and afternoon Fix: [ bug #1161 ] Search on product label Fix: [ bug #1075 ] POS module doesn't decrement stock of products in delayed payment mode. Fix: [ bug #1171 ] Documents lost in interventions after validating +Fix: fix unsubscribe URL into mailing when sending manually (not by script) ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 88ee011bf8f..c3f87e6e4e8 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -221,8 +221,8 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes') $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, - '__CHECK_READ__' => '', - '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', + '__CHECK_READ__' => '', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'', '__MAILTOEMAIL__' => ''.$obj->email.'', '__LASTNAME__' => $obj->lastname, '__FIRSTNAME__' => $obj->firstname, From c2a8967b52cf3b154be7d35fdec1eaa427156111 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 3 Dec 2013 17:06:19 +0100 Subject: [PATCH 18/20] Much better fix for translated product description into PDF --- htdocs/core/lib/pdf.lib.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index fa8de1c0352..1f5ef92f711 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -926,22 +926,14 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl //Manage HTML entities description test //Cause $prodser->description is store with htmlentities but $desc no - $testHTMLDescNeedTranslated=true; - $testDescNeedTranslated=true; - if ($conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) { - if (!empty($desc) && !empty($prodser->description)) { - $testHTMLDescNeedTranslated=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); - } - $testDescNeedTranslated=false; + $needdesctranslation=false; + if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { + $needdesctranslation=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false); } else { - if (!empty($desc) && !empty($prodser->description)) { - $testDescNeedTranslated = (strpos($desc,$prodser->description)!==false); - } else { - $testDescNeedTranslated=false; - } + $needdesctranslation=($desc == $prodser->description); } - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($testHTMLDescNeedTranslated || $testDescNeedTranslated)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($needdesctranslation)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } From 73e60e0629c4af5da868ec4e1c19b6ba7e6b4bd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2013 12:06:41 +0100 Subject: [PATCH 19/20] Fix: Mass update of vat must work also for supplier prices Conflicts: htdocs/product/admin/product_tools.php --- htdocs/product/admin/product_tools.php | 217 +++++++++++++++++-------- 1 file changed, 146 insertions(+), 71 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index e3ba408bc16..c32cfd53ad4 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $langs->load("admin"); $langs->load("products"); @@ -41,6 +43,7 @@ $newvatrate=GETPOST('newvatrate'); //$price_base_type=GETPOST('price_base_type'); $objectstatic = new Product($db); +$objectstatic2 = new ProductFournisseur($db); /* @@ -60,104 +63,176 @@ if ($action == 'convert') if (! $error) { + $country_id=$mysoc->country_id; // TODO Allow to choose country into form + + $nbrecordsmodified=0; + $db->begin(); - $sql = 'SELECT rowid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product'; - $sql.= ' WHERE entity IN ('.getEntity('product',1).')'; - $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; - //$sql.= ' AND price_base_type = "'..'"'; - //print $sql; + // If country to edit is my country, so we change customer prices + if ($country_id == $mysoc->country_id) + { + $sql = 'SELECT rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product'; + $sql.= ' WHERE entity IN ('.getEntity('product',1).')'; + $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $ret=$objectstatic->fetch($obj->rowid); + if ($ret > 0) + { + $ret=0; $retm=0; $updatelevel1=false; + + // Update multiprice + $listofmulti=array_reverse($objectstatic->multiprices, true); // To finish with level 1 + foreach ($listofmulti as $level => $multiprices) + { + $price_base_type = $objectstatic->multiprices_base_type[$level]; // Get price_base_type of product/service to keep the same for update + if (empty($price_base_type)) continue; // Discard not defined price levels + + if ($price_base_type == 'TTC') + { + $newprice=price2num($objectstatic->multiprices_ttc[$level],'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) + $newminprice=$objectstatic->multiprices_min_ttc[$level]; + } + else + { + $newprice=price2num($objectstatic->multiprices[$level],'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) + $newminprice=$objectstatic->multiprices_min[$level]; + } + if ($newminprice > $newprice) $newminprice=$newprice; + $newvat=str_replace('*','',$newvatrate); + $newnpr=$objectstatic->multiprices_recuperableonly[$level]; + $newlevel=$level; + + //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; + $retm=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + if ($retm < 0) + { + $error++; + break; + } + + if ($newlevel == 1) $updatelevel1=true; + } + + // Update single price + $price_base_type = $objectstatic->price_base_type; // Get price_base_type of product/service to keep the same for update + if ($price_base_type == 'TTC') + { + $newprice=price2num($objectstatic->price_ttc,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) + $newminprice=$objectstatic->price_min_ttc; + } + else + { + $newprice=price2num($objectstatic->price,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) + $newminprice=$objectstatic->price_min; + } + if ($newminprice > $newprice) $newminprice=$newprice; + $newvat=str_replace('*','',$newvatrate); + $newnpr=$objectstatic->recuperableonly; + $newlevel=0; + if (! empty($price_base_type) && ! $updatelevel1) + { + //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; + $ret=$objectstatic->updatePrice($objectstatic->id,$newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + } + + if ($ret < 0 || $retm < 0) $error++; + else $nbrecordsmodified++; + } + + $i++; + } + } + else dol_print_error($db); + } + + $fourn = new Fournisseur($db); + + // Change supplier prices + $sql = 'SELECT pfp.rowid, pfp.fk_soc, pfp.price as price, pfp.quantity as qty, pfp.fk_availability, pfp.ref_fourn'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'societe as s'; + $sql.= ' WHERE pfp.fk_soc = s.rowid AND pfp.entity IN ('.getEntity('product',1).')'; + $sql.= " AND tva_tx = '".$db->escape($oldvatrate)."'"; + $sql.= " AND s.fk_pays = '".$country_id."'"; + //print $sql; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i = 0; $nbrecordsmodified=0; + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $ret=$objectstatic->fetch($obj->rowid); + $ret=$objectstatic2->fetch_product_fournisseur_price($obj->rowid); if ($ret > 0) { $ret=0; $retm=0; $updatelevel1=false; - // Update multiprice - $listofmulti=array_reverse($objectstatic->multiprices, true); // To finish with level 1 - foreach ($listofmulti as $level => $multiprices) - { - $price_base_type = $objectstatic->multiprices_base_type[$level]; // Get price_base_type of product/service to keep the same for update - if (empty($price_base_type)) continue; // Discard not defined price levels - - if ($price_base_type == 'TTC') - { - $newprice=price2num($objectstatic->multiprices_ttc[$level],'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) - $newminprice=$objectstatic->multiprices_min_ttc[$level]; - } - else - { - $newprice=price2num($objectstatic->multiprices[$level],'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) - $newminprice=$objectstatic->multiprices_min[$level]; - } - if ($newminprice > $newprice) $newminprice=$newprice; - $newvat=str_replace('*','',$newvatrate); - $newnpr=$objectstatic->multiprices_recuperableonly[$level]; - $newlevel=$level; - - //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; - $retm=$objectstatic->updatePrice($objectstatic->id, $newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); - if ($retm < 0) - { - $error++; - break; - } - - if ($newlevel == 1) $updatelevel1=true; - } - - // Update single price - $price_base_type = $objectstatic->price_base_type; // Get price_base_type of product/service to keep the same for update - if ($price_base_type == 'TTC') - { - $newprice=price2num($objectstatic->price_ttc,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) - $newminprice=$objectstatic->price_min_ttc; - } - else - { - $newprice=price2num($objectstatic->price,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) - $newminprice=$objectstatic->price_min; - } - if ($newminprice > $newprice) $newminprice=$newprice; + $price_base_type='HT'; + //$price_base_type = $objectstatic2->price_base_type; // Get price_base_type of product/service to keep the same for update + //if ($price_base_type == 'TTC') + //{ + // $newprice=price2num($objectstatic2->price_ttc,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) + // $newminprice=$objectstatic2->price_min_ttc; + //} + //else + //{ + $newprice=price2num($obj->price,'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals) + //$newminprice=$objectstatic2->fourn_price_min; + //} + //if ($newminprice > $newprice) $newminprice=$newprice; $newvat=str_replace('*','',$newvatrate); - $newnpr=$objectstatic->recuperableonly; + //$newnpr=$objectstatic2->recuperableonly; $newlevel=0; if (! empty($price_base_type) && ! $updatelevel1) { - //print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; - $ret=$objectstatic->updatePrice($objectstatic->id,$newprice, $price_base_type, $user, $newvat, $newminprice, $newlevel, $newnpr); + //print "$objectstatic2->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr
\n"; + $fourn->id=$obj->fk_soc; + $ret=$objectstatic2->update_buyprice($obj->qty, $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, $newvat); } if ($ret < 0 || $retm < 0) $error++; else $nbrecordsmodified++; } - $i++; } - - if (! $error) - { - if ($nbrecordsmodified > 0) setEventMessage($langs->trans("RecordsModified",$nbrecordsmodified)); - else setEventMessage($langs->trans("NoRecordFound"),'warnings'); - $db->commit(); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - $db->rollback(); - } } + else dol_print_error($db); + + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + // Output result + if (! $error) + { + if ($nbrecordsmodified > 0) setEventMessage($langs->trans("RecordsModified",$nbrecordsmodified)); + else setEventMessage($langs->trans("NoRecordFound"),'warnings'); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } + } } From b637b28c8b5f086b9a6586f3e15c24c10b565e84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2013 18:47:58 +0100 Subject: [PATCH 20/20] Update ignore files --- htdocs/.gitignore | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/.gitignore b/htdocs/.gitignore index bc4b1c974ae..a4ebd2bb7c7 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -1,9 +1,11 @@ /test.php /custom* -/bootstrap -/multicompany -/ovh -/numberingpack -/google -/skincoloreditor +/extensions* +/nltechno* +/bootstrap* +/google* +/multicompany* +/numberingpack* +/ovh* /pos +/ultimatepdf*