From ca8c1adf55dc1f3ded447626064e9815d8856306 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Wed, 21 Oct 2015 10:07:53 +0200 Subject: [PATCH 01/14] Add trigger "SUPPLIER_PRODUCT_BUYPRICE_DELETE" for frounisseur.product remove_product_fournisseur_price() --- .../fourn/class/fournisseur.product.class.php | 19 ++++++++++++++++--- htdocs/product/fournisseurs.php | 9 +++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 490b5cf1ea3..346f69a4cef 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -121,7 +121,7 @@ class ProductFournisseur extends Product */ function remove_product_fournisseur_price($rowid) { - global $conf; + global $conf, $user; $this->db->begin(); @@ -132,8 +132,21 @@ class ProductFournisseur extends Product $resql = $this->db->query($sql); if ($resql) { - $this->db->commit(); - return 1; + // Call trigger + $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + + if (empty($error)) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } } else { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 72f8ed2b0b2..526b67b123c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -95,9 +95,14 @@ if (empty($reshook)) { if ($rowid) { - $result=$object->remove_product_fournisseur_price($rowid); $action = ''; - setEventMessage($langs->trans("PriceRemoved")); + $result=$product->remove_product_fournisseur_price($rowid); + if($result > 0){ + setEventMessage($langs->trans("PriceRemoved")); + }else{ + $error++; + setEventMessages($product->error, $product->errors, 'errors'); + } } } From ceae04b76e243dff282cba2fdd4b68990e933454 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Thu, 22 Oct 2015 12:03:01 +0200 Subject: [PATCH 02/14] move trigger before query --- .../fourn/class/fournisseur.product.class.php | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 346f69a4cef..c143e2e98be 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -123,35 +123,34 @@ class ProductFournisseur extends Product { global $conf, $user; - $this->db->begin(); + // Call trigger + $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) + if (empty($error)) { - // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); - if ($result < 0) $error++; - // End call triggers + $this->db->begin(); - if (empty($error)) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql.= " WHERE rowid = ".$rowid; + + dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { $this->db->commit(); return 1; } else { + $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; } } else { - $this->error=$this->db->lasterror(); - $this->db->rollback(); return -1; } } From 00c2b1a32a6231eb7dc371bd198ad2563bbe0baa Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Thu, 22 Oct 2015 14:30:11 +0200 Subject: [PATCH 03/14] move db->begin() before trigger --- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index c143e2e98be..acbeba8a720 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -123,6 +123,8 @@ class ProductFournisseur extends Product { global $conf, $user; + $this->db->begin(); + // Call trigger $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user); if ($result < 0) $error++; @@ -130,7 +132,6 @@ class ProductFournisseur extends Product if (empty($error)) { - $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE rowid = ".$rowid; From e5063010b2d1b813cd69b686cdd12c3cf0c53ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2015 19:07:00 +0100 Subject: [PATCH 04/14] Update actions_printing.inc.php --- htdocs/core/actions_printing.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 431ac89a94e..6dfd1122eac 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -46,7 +46,12 @@ if ($action == 'print_file' and $user->rights->printing->read) if (! empty($conf->global->{$printer->active})) { $subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':''); - $errorprint = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'), $subdir); + $module = GETPOST('printer', 'alpha'); + if ($module =='commande_fournisseur') { + $module = 'fournisseur'; + $subdir = 'commande'; + } + $errorprint = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir); //if ($errorprint < 0) { // setEventMessage($interface->errors, 'errors'); //} From b1c4e032fc09f5447058d11a4969deb9f952fa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2015 19:08:38 +0100 Subject: [PATCH 05/14] Update html.formfile.class.php --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 230ffa99504..59a7c183d76 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -285,7 +285,7 @@ class FormFile } $printer=0; - if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition'))) // The direct print feature is implemented only for such elements + if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition', 'commande_fournisseur'))) // The direct print feature is implemented only for such elements { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; } From ff9648eed9fa59ecb7e85a4f546b0303f424456d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 29 Oct 2015 19:09:37 +0100 Subject: [PATCH 06/14] Update card.php --- htdocs/fourn/commande/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 37809f6bf87..cb1754fa8d3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -872,6 +872,8 @@ if (empty($reshook)) } } + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + /* * Create an order From d49d3808b939399bd8c534076742d467397daae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 11:19:01 +0100 Subject: [PATCH 07/14] Update list.php --- htdocs/adherents/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 7d86c04869c..dc7266603ca 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -202,7 +202,7 @@ if ($resql) if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall)); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } // Filter on categories From 08dccf341c83cb7a76c7ca8412e6cae0025da1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 11:24:49 +0100 Subject: [PATCH 08/14] Update list.php --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index c623069cd85..8bd5407ef03 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -281,7 +281,7 @@ if ($result) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); //sort($fieldstosearchall); - print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall)); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } $i = 0; From 8a07efb995e3ffaf5affd81b79186cbc26f0d2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 11:25:59 +0100 Subject: [PATCH 09/14] Update list.php --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 2a1163111ed..ebe4c9c337d 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -287,7 +287,7 @@ if ($result) if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall)); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } if ($search_firstlast_only) { From 6e2d4aebb19b5faed9cc4fddd95f734cabf4690d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 11:27:50 +0100 Subject: [PATCH 10/14] Update list.php --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index dc9dcb7ed58..4e84508fbd6 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -333,7 +333,7 @@ else if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall)); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } // Filter on categories From ee94aea1ef759af2a0d549a32258236e3172d51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 11:28:49 +0100 Subject: [PATCH 11/14] Update list.php --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 17aa5cac222..7481a6bf05c 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -259,7 +259,7 @@ if ($resql) if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } $colspan=8; From 0f6a401eddce5835692ac192e16a565c8af7f28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2015 11:30:11 +0100 Subject: [PATCH 12/14] Update list.php --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 6c554aa5137..c8c25acdd24 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -445,7 +445,7 @@ if ($resql) if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } // Filter on categories From 0fd7ba478a79bc2cf6f675b4de07930dddd66fa4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Nov 2015 17:27:41 +0100 Subject: [PATCH 13/14] Fix: add Mac OS --- htdocs/core/lib/functions.lib.php | 43 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5b990ac509c..fcadfb9e521 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -179,6 +179,7 @@ function getBrowserInfo($user_agent) // OS if (preg_match('/linux/i', $user_agent)) { $os='linux'; } + elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } // Name if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } @@ -703,7 +704,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0) { global $conf,$langs, $hookmanager; - + $out="\n".'
'."\n"; // Show title @@ -733,7 +734,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi $displaytab=0; $nbintab=0; $popuptab=0; - + for ($i = 0 ; $i <= $maxkey ; $i++) { if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) @@ -777,7 +778,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi else { // The popup with the other tabs - if (! $popuptab) + if (! $popuptab) { $popuptab=1; $outmore.='
'; @@ -795,13 +796,13 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi $outmore.=''.$links[$i][1].''."\n"; $outmore.='
'; - + $nbintab++; } $displaytab=$i; } if ($popuptab) $outmore.='
'; - + if ($displaytab > $limittoshow) { $tabsname=str_replace("@", "", $picto); @@ -817,7 +818,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi } $out.="\n"; - + if (! $notab) $out.="\n".'
'."\n"; $parameters=array('tabname' => $active); @@ -900,7 +901,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r print '
'; print '
'; } - + /** * Show a string with the label tag dedicated to the HTML edit field. * @@ -1382,7 +1383,7 @@ function dol_print_size($size,$shortvalue=0,$shortunit=0) function dol_print_url($url,$target='_blank',$max=32,$withpicto=0) { global $langs; - + if (empty($url)) return ''; $link=''; return $out; @@ -2958,7 +2959,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so if ($cpt > 2) $pagelist.='dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'class="inactive"':'data-role="button"').'>...'; else if ($cpt == 2) $pagelist.='dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'':'data-role="button" ').'href="'.$file.'?page=1'.$options.'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">2'; } - + do { if ($cpt==$page) @@ -2972,7 +2973,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so $cpt++; } while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage); - + if ($cpt<$nbpages) { if ($cpt<$nbpages-2) $pagelist.= 'dol_use_jmobile)?' class="pagination"':'').'>dol_use_jmobile)?'class="inactive"':'data-role="button"').'>...'; @@ -4402,7 +4403,7 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) } else if ($nameorder == 2) { - $ret.=$firstname; + $ret.=$firstname; } else { @@ -5225,7 +5226,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) /** * Return the filename of file to get the thumbs - * + * * @param string $file Original filename * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini') * @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image. @@ -5235,10 +5236,10 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') { $dirName = dirname($file); if ($dirName == '.') $dirName=''; - + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); - + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':''); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.gif$/i',$file)?'.gif':''); @@ -5246,9 +5247,9 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.bmp$/i',$file)?'.bmp':''); if (! $extImgTarget) return $file; - + $subdir=''; if ($extName) $subdir = 'thumbs/'; - + return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb } From a658ff7e90f6a50170390af11ab72105d70c2297 Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Mon, 2 Nov 2015 10:26:07 +0100 Subject: [PATCH 14/14] add commit or rollback if error --- .../fourn/class/fournisseur.product.class.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index acbeba8a720..ef776342aa5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -138,22 +138,21 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else + if (!$resql) { $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; + $error++; } } - else - { + + if (empty($error)){ + $this->db->commit(); + return 1; + }else{ + $this->db->rollback(); return -1; } + }