From fc6382ea7e2c38190788cb31db3f79d6d901c859 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 15:15:36 +0200 Subject: [PATCH 01/21] Fix: [ bug #1463, #1464 ] Proposal triggers problem --- ChangeLog | 1 + htdocs/comm/propal/class/propal.class.php | 162 ++++++++++------------ 2 files changed, 73 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b057b66175..fe765ee1015 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ For users: - Fix: [ bug #1494 ] CATEGORY_CREATE and CATEGORY_MODIFY triggers do not intercept trigger action - Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action - Fix: [ bug #1505, #1504] Project trigger problem +- Fix: [ bug #1463, #1464 ] Proposal triggers problem For translators: diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7f2ebf1de4b..0668b49121d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -856,24 +856,22 @@ class Propal extends CommonObject if (! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PROPAL_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers } } else { + $this->error=$this->db->error(); $error++; } } } else { + $this->error=$this->db->error(); $error++; } @@ -885,7 +883,6 @@ class Propal extends CommonObject } else { - $this->error=$this->db->error(); $this->db->rollback(); return -2; } @@ -1006,14 +1003,10 @@ class Propal extends CommonObject if ($reshook < 0) $error++; } - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CLONE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PROPAL_CLONE',$user); + if ($result < 0) { $error++; } + // End call triggers } // End @@ -1326,14 +1319,10 @@ class Propal extends CommonObject { if (! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_VALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PROPAL_VALIDATE',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -1668,25 +1657,24 @@ class Propal extends CommonObject { if (! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_REOPEN',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PROPAL_REOPEN',$user); + if ($result < 0) { $error++; } + // End call triggers } } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } + if (!empty($this->errors)) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + } $this->db->rollback(); return -1*$error; } @@ -1751,14 +1739,10 @@ class Propal extends CommonObject propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CLOSE_SIGNED',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PROPAL_CLOSE_SIGNED',$user); + if ($result < 0) { $error++; } + // End call triggers } else { @@ -1777,18 +1761,21 @@ class Propal extends CommonObject propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PROPAL_CLOSE_REFUSED',$user); + if ($result < 0) { $error++; } + // End call triggers + } + if ( ! $error ) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; } - - $this->db->commit(); - return 1; } else { @@ -2039,15 +2026,11 @@ class Propal extends CommonObject $this->db->begin(); - if (! $error && ! $notrigger) + if (! $notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PROPAL_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } + // Call trigger + $result=$this->call_trigger('PROPAL_DELETE',$user); + if ($result < 0) { $error++; } // End call triggers } @@ -2145,7 +2128,6 @@ class Propal extends CommonObject } else { - $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; } @@ -2931,14 +2913,14 @@ class PropaleLigne extends CommonObject if (! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEPROPAL_INSERT',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('LINEPROPAL_INSERT',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers } $this->db->commit(); @@ -2981,14 +2963,14 @@ class PropaleLigne extends CommonObject } } - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('LINEPROPAL_DELETE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers $this->db->commit(); @@ -3091,14 +3073,14 @@ class PropaleLigne extends CommonObject if (! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('LINEPROPAL_UPDATE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers } $this->db->commit(); From 1ded34aa9778e3e66f5e6c03b7446a0345468dbb Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 15:33:16 +0200 Subject: [PATCH 02/21] Fix: [ bug #1498, #1499 ] Shipment/Delivery triggers problem --- ChangeLog | 2 +- htdocs/expedition/class/expedition.class.php | 40 +++++++----------- htdocs/expedition/fiche.php | 44 ++++++++++++-------- htdocs/livraison/class/livraison.class.php | 25 +++++------ 4 files changed, 54 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe765ee1015..cb93b839133 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,7 +19,7 @@ For users: - Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action - Fix: [ bug #1505, #1504] Project trigger problem - Fix: [ bug #1463, #1464 ] Proposal triggers problem - +- Fix: [ bug #1498, #1499 ] Shipment/Delivery triggers problem For translators: - Update language files. diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 5b50a18368e..f6a92b91434 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -275,12 +275,10 @@ class Expedition extends CommonObject if (! $error) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SHIPPING_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('SHIPPING_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers if (! $error) { @@ -656,12 +654,10 @@ class Expedition extends CommonObject if (! $error) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SHIPPING_VALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('SHIPPING_VALIDATE',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -867,12 +863,10 @@ class Expedition extends CommonObject { if (! $notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SHIPPING_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // End call triggers + // Call trigger + $result=$this->call_trigger('SHIPPING_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers } } @@ -982,12 +976,10 @@ class Expedition extends CommonObject if ($this->db->query($sql)) { - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('SHIPPING_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // End call triggers + // Call trigger + $result=$this->call_trigger('SHIPPING_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers if (! $error) { diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index ff6b23c10be..c2a2036c25f 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -241,26 +241,34 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->exped $object->fetch_thirdparty(); $result = $object->valid($user); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); - } + if ($result < 0) { - dol_print_error($db,$result); - exit; + $langs->load("errors"); + setEventMessage($langs->trans($object->error),'errors'); + } + else + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); + } + if ($result < 0) + { + dol_print_error($db,$result); + exit; + } } } diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 399050d0547..c46e333c191 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -446,15 +446,12 @@ class Livraison extends CommonObject return -1; } - // Appel des triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers('DELIVERY_VALIDATE', $this, $user, $langs, $conf); - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('DELIVERY_VALIDATE',$user); + // End call triggers if ($result < 0) { $this->db->rollback(); - $this->error = $interface->errors; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); return -1; } @@ -604,14 +601,14 @@ class Livraison extends CommonObject } } - // Call triggers - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('DELIVERY_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // End call triggers + // Call trigger + $result=$this->call_trigger('DELIVERY_DELETE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -4; + } + // End call triggers return 1; } From 012fc4e8fee6b800e09ec7fc6e02ae7792177fd0 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 15:54:20 +0200 Subject: [PATCH 03/21] Fix: [ bug #1465, #1466 ] Product triggers problem --- ChangeLog | 1 + .../interface_90_all_Demo.class.php-NORUN | 4 + htdocs/product/class/product.class.php | 91 +++++++++---------- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb93b839133..0c80f04d4b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ For users: - Fix: [ bug #1505, #1504] Project trigger problem - Fix: [ bug #1463, #1464 ] Proposal triggers problem - Fix: [ bug #1498, #1499 ] Shipment/Delivery triggers problem +- Fix: [ bug #1465, #1466 ] Product triggers problem For translators: - Update language files. diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index 62b758739c7..f19d717043a 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -222,6 +222,10 @@ class InterfaceDemo dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } elseif ($action == 'PRODUCT_DELETE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'PRODUCT_PRICE_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 73859378d65..adf45fed387 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -427,12 +427,10 @@ class Product extends CommonObject if (! $error && ! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PRODUCT_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -665,12 +663,10 @@ class Product extends CommonObject if (! $error && ! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PRODUCT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) @@ -763,34 +759,33 @@ class Product extends CommonObject if (! $error) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PRODUCT_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers } - // Delete all child tables - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock'); - foreach($elements as $table) + // Delete all child tables + if (! $error) { - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; - $sql.= " WHERE fk_product = ".$id; - dol_syslog(get_class($this).'::delete', LOG_DEBUG); - $result = $this->db->query($sql); - if (! $result) - { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } + $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock'); + foreach($elements as $table) + { + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; + $sql.= " WHERE fk_product = ".$id; + dol_syslog(get_class($this).'::delete', LOG_DEBUG); + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + } } - + // Delete product if (! $error) { @@ -1227,6 +1222,8 @@ class Product extends CommonObject $localtax2=get_localtax($newvat,2); if (empty($localtax1)) $localtax1=0; // If = '' then = 0 if (empty($localtax2)) $localtax2=0; // If = '' then = 0 + + $this->db->begin(); // Ne pas mettre de quote sur les numeriques decimaux. // Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes. @@ -1264,19 +1261,21 @@ class Product extends CommonObject $this->level = $level; // Store level of price edited for trigger - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_PRICE_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) - { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('PRODUCT_PRICE_MODIFY',$user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers + + $this->db->commit(); } else { - dol_print_error($this->db); + $this->db->rollback(); + dol_print_error($this->db); } } From 4666de85e2ed4f5b2a9605b2319aba1f6324f467 Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 16:18:54 +0200 Subject: [PATCH 04/21] Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message --- ChangeLog | 2 ++ htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN | 6 ++++++ htdocs/product/class/product.class.php | 4 ++-- htdocs/product/stock/product.php | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c80f04d4b0..989c34bd305 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ For users: - Fix: [ bug #1463, #1464 ] Proposal triggers problem - Fix: [ bug #1498, #1499 ] Shipment/Delivery triggers problem - Fix: [ bug #1465, #1466 ] Product triggers problem +- Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message + For translators: - Update language files. diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index f19d717043a..ee99d202bdd 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -226,6 +226,12 @@ class InterfaceDemo dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } elseif ($action == 'PRODUCT_PRICE_MODIFY') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + + //Stock mouvement + elseif ($action == 'STOCK_MOVEMENT') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index adf45fed387..b9d0da37c80 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2867,7 +2867,7 @@ class Product extends CommonObject } else { - dol_print_error($this->db); + $this->error=$movementstock->error; $this->db->rollback(); return -1; } @@ -3454,7 +3454,7 @@ class Product extends CommonObject } else { - dol_print_error($this->db); + $this->error=$movementstock->error; $this->db->rollback(); return -1; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 338169a6154..a9b9c000553 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -154,6 +154,11 @@ if ($action == "correct_stock" && ! $cancel) header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); exit; } + else + { + setEventMessage($product->error,'errors'); + $action='correction'; + } } } } @@ -253,6 +258,8 @@ if ($id > 0 || $ref) $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'stock', $titre, 0, $picto); + + dol_htmloutput_events(); $form = new Form($db); From c70bdabeda0bf35de0274505e9b0e1340b1fb3cf Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 16:23:10 +0200 Subject: [PATCH 05/21] Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action --- ChangeLog | 1 + .../deplacement/class/deplacement.class.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 989c34bd305..42b145f47cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ For users: - Fix: [ bug #1498, #1499 ] Shipment/Delivery triggers problem - Fix: [ bug #1465, #1466 ] Product triggers problem - Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message +- Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action For translators: diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 942ceb912c8..0f17c543b9d 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -126,15 +126,15 @@ class Deplacement extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement"); - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('DEPLACEMENT_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers - + // Call trigger + $result=$this->call_trigger('DEPLACEMENT_CREATE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + $result=$this->update($user); if ($result > 0) { From e4ad082214047739b4b8fa4b55498a170f4b281b Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 16:39:54 +0200 Subject: [PATCH 06/21] Fix: [ bug #1506, #1507 ] ECM trigger error problem --- ChangeLog | 2 + .../interface_90_all_Demo.class.php-NORUN | 14 ++++ htdocs/ecm/class/ecmdirectory.class.php | 76 +++++++++++++------ 3 files changed, 69 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42b145f47cb..e3c9b80c3cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,8 @@ For users: - Fix: [ bug #1465, #1466 ] Product triggers problem - Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message - Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action +- Fix: [ bug #1506, #1507 ] ECM trigger error problem + For translators: diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index ee99d202bdd..25d7bbb8196 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -232,6 +232,20 @@ class InterfaceDemo //Stock mouvement elseif ($action == 'STOCK_MOVEMENT') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + + //MYECMDIR + elseif ($action == 'MYECMDIR_DELETE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'MYECMDIR_CREATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'MYECMDIR_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 87f3bcd59ba..52c698c240f 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -152,12 +152,10 @@ class EcmDirectory // extends CommonObject $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); - $result=$interface->run_triggers('MYECMDIR_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('MYECMDIR_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers if (! $error) { @@ -219,12 +217,10 @@ class EcmDirectory // extends CommonObject if (! $error && ! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('MYECMDIR_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('MYECMDIR_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -352,7 +348,18 @@ class EcmDirectory // extends CommonObject $this->error="Error ".$this->db->lasterror(); return -2; } - + else + { + // Call trigger + $result=$this->call_trigger('MYECMDIR_DELETE',$user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output . "/" . $relativepath; @@ -371,16 +378,6 @@ class EcmDirectory // extends CommonObject $error++; } - if (! $error) - { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('MYECMDIR_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - } - if (! $error) return 1; else return -1; } @@ -696,5 +693,38 @@ class EcmDirectory // extends CommonObject return -1; } } + + /** + * Call trigger based on this instance + * + * NB: Error from trigger are stacked in errors + * NB2: if trigger fail, action should be canceled. + * NB3: Should be deleted if EcmDirectory extend CommonObject + * + * @param string $trigger_name trigger's name to execute + * @param User $user Object user + * @return int Result of run_triggers + */ + function call_trigger($trigger_name, $user) + { + global $langs,$conf; + + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf); + if ($result < 0) { + if (!empty($this->errors)) + { + $this->errors=array_merge($this->errors,$interface->errors); + } + else + { + $this->errors=$interface->errors; + } + } + return $result; + + } + } From c5bb55064f4dfa224c17d582db6885ef6601b22f Mon Sep 17 00:00:00 2001 From: KreizIT Date: Fri, 4 Jul 2014 17:10:19 +0200 Subject: [PATCH 07/21] Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message --- ChangeLog | 1 + htdocs/contact/class/contact.class.php | 43 +++++++------------ htdocs/contact/fiche.php | 33 ++++++++++---- .../interface_90_all_Demo.class.php-NORUN | 4 ++ 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3c9b80c3cd..da781f4bb5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ For users: - Fix: [ bug #1508 ] STOCK_MOVEMENT does not show trigger error message - Fix: [ bug #1501 ] DEPLACEMENT_CREATE trigger do not intercept trigger action - Fix: [ bug #1506, #1507 ] ECM trigger error problem +- Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 95f949b123f..7858f81dcf9 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -183,12 +183,10 @@ class Contact extends CommonObject if (! $error) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CONTACT_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('CONTACT_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -304,12 +302,10 @@ class Contact extends CommonObject if (! $error && ! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CONTACT_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('CONTACT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -319,7 +315,6 @@ class Contact extends CommonObject } else { - $this->error=join(',',$this->errors); dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); $this->db->rollback(); return -$error; @@ -777,14 +772,10 @@ class Contact extends CommonObject if (! $error && ! $notrigger) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - if ($error) $this->error=join(',',$this->errors); + // Call trigger + $result=$this->call_trigger('CONTACT_DELETE',$user); + if ($result < 0) { $error++; } + // End call triggers } if (! $error) @@ -1067,12 +1058,10 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); if ($result) { - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CONTACT_ENABLEDISABLE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // Call trigger + $result=$this->call_trigger('CONTACT_ENABLEDISABLE',$user); + if ($result < 0) { $error++; } + // End call triggers } if ($error) diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 9cb52738bb8..0d8a26cf81f 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -138,19 +138,30 @@ if (empty($reshook)) if ($action == 'disable') { $object->fetch($id); - $object->setstatus(0); - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; + if ($object->setstatus(0)<0) + { + setEventMessage($object->error,'errors'); + } + else + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } } // Confirmation activation if ($action == 'enable') { $object->fetch($id); - $object->setstatus(1); - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; - + if ($object->setstatus(1)<0) + { + setEventMessage($object->error,'errors'); + } + else + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); + exit; + } } // Add contact @@ -235,7 +246,8 @@ if (empty($reshook)) } else { - $error=$object->error; $errors=$object->errors; + setEventMessage($object->error,'errors'); + setEventMessage($object->errors,'errors'); } } @@ -295,7 +307,8 @@ if (empty($reshook)) } else { - $error=$object->error; $errors=$object->errors; + setEventMessage($object->error,'errors'); + setEventMessage($object->errors,'errors'); $action = 'edit'; } } @@ -367,6 +380,8 @@ else $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); dol_fiche_head($head, 'card', $title, 0, 'contact'); + + dol_htmloutput_events(); } if ($user->rights->societe->contact->creer) diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index 25d7bbb8196..8bc4e42ed3f 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -211,6 +211,10 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + elseif ($action == 'CONTACT_ENABLEDISABLE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } // Products elseif ($action == 'PRODUCT_CREATE') From f29eeceb1a59b360715f89dd6f009c4b88e1dcb1 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sun, 6 Jul 2014 20:49:34 +0200 Subject: [PATCH 08/21] Select bank account for propal and order --- htdocs/comm/propal.php | 32 ++++++++++++++++++- htdocs/comm/propal/class/propal.class.php | 5 +++ htdocs/commande/class/commande.class.php | 7 ++++- htdocs/commande/fiche.php | 35 ++++++++++++++++++++- htdocs/core/class/commonobject.class.php | 34 ++++++++++++++++++++ htdocs/core/class/html.form.class.php | 38 +++++++++++++++++++++++ 6 files changed, 148 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 059af63b708..caf27c0aced 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -254,6 +254,7 @@ else if ($action == 'add' && $user->rights->propal->creer) { $object->duree_validite = $duration; $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_percent = GETPOST('remise_percent'); $object->remise_absolue = GETPOST('remise_absolue'); $object->socid = GETPOST('socid'); @@ -279,7 +280,7 @@ else if ($action == 'add' && $user->rights->propal->creer) { $object->duree_validite = GETPOST('duree_validite'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); - + $object->fk_account = GETPOST('fk_account', 'int'); $object->contactid = GETPOST('contactidp'); $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); @@ -1104,6 +1105,11 @@ else if ($action == 'setmode' && $user->rights->propal->creer) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } +// bank account +else if ($action == 'setbankaccount' && $user->rights->propal->creer) { + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); +} + /* * Ordonnancement des lignes */ @@ -1368,6 +1374,11 @@ if ($action == 'create') { $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); print ''; + // Bank Account + print '' . $langs->trans('BankAccount') . ''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print ''; + // What trigger creation print '' . $langs->trans('Source') . ''; $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1); @@ -1965,6 +1976,25 @@ if ($action == 'create') { } } } + // Bank Account + print ''; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->propal->creer && ! empty($object->brouillon)) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print ''; + if ($action == 'editbankaccount') + { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } + else + { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ""; + print ''; // Amount HT print '' . $langs->trans('AmountHT') . ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7f2ebf1de4b..a2d4d90f6c7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -79,6 +79,7 @@ class Propal extends CommonObject var $cond_reglement_id; var $cond_reglement_code; + var $fk_account; // Id of bank account var $mode_reglement_id; var $mode_reglement_code; var $remise; @@ -714,6 +715,7 @@ class Propal extends CommonObject $sql.= ", fin_validite"; $sql.= ", fk_cond_reglement"; $sql.= ", fk_mode_reglement"; + $sql.= ", fk_account"; $sql.= ", ref_client"; $sql.= ", date_livraison"; $sql.= ", fk_availability"; @@ -739,6 +741,7 @@ class Propal extends CommonObject $sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null"); $sql.= ", ".$this->cond_reglement_id; $sql.= ", ".$this->mode_reglement_id; + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", '".$this->db->escape($this->ref_client)."'"; $sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null"); $sql.= ", ".$this->availability_id; @@ -1056,6 +1059,7 @@ class Propal extends CommonObject $sql.= ", p.fk_input_reason"; $sql.= ", p.fk_cond_reglement"; $sql.= ", p.fk_mode_reglement"; + $sql.= ', p.fk_account'; $sql.= ", c.label as statut_label"; $sql.= ", ca.code as availability_code, ca.label as availability"; $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; @@ -1120,6 +1124,7 @@ class Propal extends CommonObject $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement; + $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 472b46ce925..b6d06abf368 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -60,6 +60,7 @@ class Commande extends CommonOrder var $brouillon; var $cond_reglement_id; var $cond_reglement_code; + var $fk_account; var $mode_reglement_id; var $mode_reglement_code; var $availability_id; @@ -658,7 +659,7 @@ class Commande extends CommonOrder $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande ("; $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_client, ref_int"; - $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; + $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; $sql.= ", remise_absolue, remise_percent"; $sql.= ", entity"; $sql.= ")"; @@ -673,6 +674,7 @@ class Commande extends CommonOrder $sql.= ", '".$this->modelpdf."'"; $sql.= ", ".($this->cond_reglement_id>0?"'".$this->cond_reglement_id."'":"null"); $sql.= ", ".($this->mode_reglement_id>0?"'".$this->mode_reglement_id."'":"null"); + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", ".($this->availability_id>0?"'".$this->availability_id."'":"null"); $sql.= ", ".($this->demand_reason_id>0?"'".$this->demand_reason_id."'":"null"); $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null"); @@ -986,6 +988,7 @@ class Commande extends CommonOrder $this->fk_project = $object->fk_project; $this->cond_reglement_id = $object->cond_reglement_id; $this->mode_reglement_id = $object->mode_reglement_id; + $this->fk_account = $object->fk_account; $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->date_livraison = $object->date_livraison; @@ -1329,6 +1332,7 @@ class Commande extends CommonOrder $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; + $sql.= ', c.fk_account'; $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; @@ -1388,6 +1392,7 @@ class Commande extends CommonOrder $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = $obj->fk_account; $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; $this->demand_reason_id = $obj->fk_input_reason; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 8b1d6ec9ae3..b2f331b051f 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -227,6 +227,7 @@ else if ($action == 'add' && $user->rights->commande->creer) { $object->modelpdf = GETPOST('model'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); $object->date_livraison = $datelivraison; @@ -488,6 +489,11 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) { } } +// bank account +else if ($action == 'setbankaccount' && $user->rights->propal->creer) { + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); +} + else if ($action == 'setremisepercent' && $user->rights->commande->creer) { $result = $object->set_remise($user, GETPOST('remise_percent')); } @@ -1392,6 +1398,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $soc = $objectsrc->client; $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $fk_account = (!empty($objectsrc->fk_account)?$objectsrc->fk_account:(!empty($soc->fk_account)?$soc->fk_account:0)); $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); @@ -1411,6 +1418,7 @@ if ($action == 'create' && $user->rights->commande->creer) { { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; + $fk_account = $soc->fk_account; $availability_id = $soc->availability_id; $demand_reason_id = $soc->demand_reason_id; $remise_percent = $soc->remise_percent; @@ -1506,6 +1514,11 @@ if ($action == 'create' && $user->rights->commande->creer) { $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); print ''; + // Bank Account + print '' . $langs->trans('BankAccount') . ''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print ''; + // Delivery delay print '' . $langs->trans('AvailabilityPeriod') . ''; $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); @@ -2120,7 +2133,27 @@ if ($action == 'create' && $user->rights->commande->creer) { if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) $rowspan ++; - // Total HT + // Bank Account + print ''; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print ''; + if ($action == 'editbankaccount') + { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } + else + { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ""; + print ''; + + // Total HT print '' . $langs->trans('AmountHT') . ''; print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c06c43eb4a4..44554d39180 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1079,6 +1079,40 @@ abstract class CommonObject } + /** + * Change the bank account + * + * @param int $fk_account Id of bank account + * @return int 1 if OK, 0 if KO + */ + function setBankAccount($fk_account) + { + if (! $this->table_element) + { + dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + if ($fk_account<0) $fk_account='NULL'; + dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')'); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET fk_account = ".$fk_account; + $sql.= " WHERE rowid=".$this->id; + + if ($this->db->query($sql)) + { + $this->fk_account = ($fk_account=='NULL')?null:$fk_account; + return 1; + } + else + { + dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return 0; + } + } + + /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1e7f0bb8246..cdc7294c302 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2480,6 +2480,44 @@ class Form } } + /** + * Display form to select bank account + * + * @param string $page Page + * @param int $selected Id of bank account + * @param string $htmlname Name of select html field + * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @return void + */ + function form_select_comptes($page, $selected='', $htmlname='fk_account', $addempty=0) + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + $this->select_comptes($selected, $htmlname, 0, '', $addempty); + print '
'; + } + else + { + if ($selected) + { + require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; + $bankstatic=new Account($this->db); + $bankstatic->fetch($selected); + print $bankstatic->label.' ('.$bankstatic->currency_code.')'; + } else { + print " "; + } + } + } + /** * Return list of categories having choosed type * From 516632e41d744d7831c23827723f776dc0a1f33e Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 7 Jul 2014 17:59:04 +0200 Subject: [PATCH 09/21] Select bank account for customer order --- htdocs/commande/fiche.php | 4 +-- htdocs/compta/facture.php | 35 +++++++++++++++++++ htdocs/compta/facture/class/facture.class.php | 5 +++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index b2f331b051f..aeba517270b 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -490,7 +490,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) { } // bank account -else if ($action == 'setbankaccount' && $user->rights->propal->creer) { +else if ($action == 'setbankaccount' && $user->rights->commande->creer) { $result=$object->setBankAccount(GETPOST('fk_account', 'int')); } @@ -1398,7 +1398,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $soc = $objectsrc->client; $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (!empty($objectsrc->fk_account)?$objectsrc->fk_account:(!empty($soc->fk_account)?$soc->fk_account:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e20173bf30c..1f437feaac7 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -302,6 +302,11 @@ else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) { dol_print_error($db, $object->error); } +// bank account +else if ($action == 'setbankaccount' && $user->rights->facture->creer) { + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); +} + else if ($action == 'setremisepercent' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->set_remise($user, $_POST['remise_percent']); @@ -628,6 +633,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = $_POST['cond_reglement_id']; $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; @@ -670,6 +676,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = 0; $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; @@ -795,6 +802,7 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->fk_account = GETPOST('fk_account', 'int'); $object->amount = $_POST['amount']; $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; @@ -1886,6 +1894,7 @@ if ($action == 'create') $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); @@ -1900,6 +1909,7 @@ if ($action == 'create') { $cond_reglement_id = $soc->cond_reglement_id; $mode_reglement_id = $soc->mode_reglement_id; + $fk_account = $soc->fk_account; $remise_percent = $soc->remise_percent; $remise_absolue = 0; $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); // Do not set 0 here (0 for a date is 1970) @@ -2215,6 +2225,11 @@ if ($action == 'create') $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print ''; + // Bank Account + print '' . $langs->trans('BankAccount') . ''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print ''; + // Project if (! empty($conf->projet->enabled) && $socid > 0) { $formproject = new FormProjets($db); @@ -3166,6 +3181,26 @@ if ($action == 'create') } print ''; + // Bank Account + print ''; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print ''; + if ($action == 'editbankaccount') + { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } + else + { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ""; + print ''; + // Amount print '' . $langs->trans('AmountHT') . ''; print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7ef7162e985..1cfb5fe3725 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -103,6 +103,7 @@ class Facture extends CommonInvoice var $cond_reglement_code; // Code in llx_c_paiement var $mode_reglement_id; // Id in llx_c_paiement var $mode_reglement_code; // Code in llx_c_paiement + var $fk_account; // Id of bank account var $fk_bank; // Field to store bank id to use when payment mode is withdraw var $modelpdf; var $products=array(); // deprecated @@ -239,6 +240,7 @@ class Facture extends CommonInvoice $sql.= ", note_private"; $sql.= ", note_public"; $sql.= ", ref_client, ref_int"; + $sql.= ", fk_account"; $sql.= ", fk_facture_source, fk_user_author, fk_projet"; $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; $sql.= ")"; @@ -256,6 +258,7 @@ class Facture extends CommonInvoice $sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); $sql.= ",".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); $sql.= ",".($user->id > 0 ? "'".$user->id."'":"null"); $sql.= ",".($this->fk_project?$this->fk_project:"null"); @@ -834,6 +837,7 @@ class Facture extends CommonInvoice $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf'; $sql.= ', f.fk_facture_source'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; + $sql.= ', f.fk_account'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; @@ -884,6 +888,7 @@ class Facture extends CommonInvoice $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->fk_account = ($obj->fk_account>0)?$obj->fk_account:null; $this->fk_project = $obj->fk_projet; $this->fk_facture_source = $obj->fk_facture_source; $this->note = $obj->note_private; // deprecated From 83d3af9bf8162468e6ea879dd0169fb83b3fec30 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 7 Jul 2014 18:25:20 +0200 Subject: [PATCH 10/21] Select account for payment --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 1f437feaac7..a92f189fd3a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3463,7 +3463,7 @@ if ($action == 'create') if ($resteapayer == 0) { print '
' . $langs->trans('DoPayment') . '
'; } else { - print ''; + print ''; } } } From 9949713d2043803bdf99758caf0f560cdf28768a Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 7 Jul 2014 18:40:18 +0200 Subject: [PATCH 11/21] Some cleaning --- htdocs/comm/propal.php | 32 +++++++++++------------- htdocs/commande/fiche.php | 9 +++---- htdocs/core/class/commonobject.class.php | 10 +++----- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index caf27c0aced..994894f2b4c 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1976,25 +1976,23 @@ if ($action == 'create') { } } } - // Bank Account - print ''; - print '"; - print ''; + print '
'; - print $langs->trans('BankAccount'); - print ''; + + // Bank Account + print '
'; + print ''; - print '
'; + print $langs->trans('BankAccount'); + print ''; if (($action != 'editbankaccount') && $user->rights->propal->creer && ! empty($object->brouillon)) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; - print '
'; - if ($action == 'editbankaccount') - { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } - else - { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); - } - print "
'; + print ''; + if ($action == 'editbankaccount') { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ''; + print ''; // Amount HT print '' . $langs->trans('AmountHT') . ''; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index aeba517270b..58fede8e275 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2142,15 +2142,12 @@ if ($action == 'create' && $user->rights->commande->creer) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).''; print ''; print ''; - if ($action == 'editbankaccount') - { + if ($action == 'editbankaccount') { $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } - else - { + } else { $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } - print ""; + print ''; print ''; // Total HT diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 44554d39180..fd6f83564ad 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1087,8 +1087,7 @@ abstract class CommonObject */ function setBankAccount($fk_account) { - if (! $this->table_element) - { + if (! $this->table_element) { dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined",LOG_ERR); return -1; } @@ -1099,13 +1098,10 @@ abstract class CommonObject $sql.= " SET fk_account = ".$fk_account; $sql.= " WHERE rowid=".$this->id; - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->fk_account = ($fk_account=='NULL')?null:$fk_account; return 1; - } - else - { + } else { dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error()); $this->error=$this->db->error(); return 0; From 8e612b532a8aaeab33846537e4969e73d0a05e1f Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 7 Jul 2014 18:44:08 +0200 Subject: [PATCH 12/21] Use & instead & --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index a92f189fd3a..b01b6c5dfaa 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3463,7 +3463,7 @@ if ($action == 'create') if ($resteapayer == 0) { print '
' . $langs->trans('DoPayment') . '
'; } else { - print ''; + print ''; } } } From 0cb5220d4db0c0684f765f26e9e04b288d41c220 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Mon, 7 Jul 2014 20:54:41 +0200 Subject: [PATCH 13/21] Use english for the function name --- htdocs/comm/propal.php | 4 ++-- htdocs/commande/fiche.php | 4 ++-- htdocs/compta/facture.php | 4 ++-- htdocs/core/class/html.form.class.php | 12 ++++-------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 994894f2b4c..7ce92a5b569 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1987,9 +1987,9 @@ if ($action == 'create') { print ''; print ''; if ($action == 'editbankaccount') { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ''; print ''; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 58fede8e275..19948e3c1b7 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2143,9 +2143,9 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print ''; if ($action == 'editbankaccount') { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ''; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b01b6c5dfaa..29a25760886 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3192,11 +3192,11 @@ if ($action == 'create') print ''; if ($action == 'editbankaccount') { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { - $form->form_select_comptes($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } print ""; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cdc7294c302..d1b338176a4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2489,11 +2489,10 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - function form_select_comptes($page, $selected='', $htmlname='fk_account', $addempty=0) + function formSelectAccount($page, $selected='', $htmlname='fk_account', $addempty=0) { global $langs; - if ($htmlname != "none") - { + if ($htmlname != "none") { print '
'; print ''; print ''; @@ -2503,11 +2502,8 @@ class Form print ''; print ''; print '
'; - } - else - { - if ($selected) - { + } else { + if ($selected) { require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; $bankstatic=new Account($this->db); $bankstatic->fetch($selected); From a2911cef11d169816e5a5a4d45438e2802838b9e Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 8 Jul 2014 11:46:22 +0200 Subject: [PATCH 14/21] Filter on invoice for "treso" --- htdocs/compta/bank/treso.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index f6c59530605..f628965e976 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -161,6 +161,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid + $sql.= " AND f.fk_account IN (NULL, 0, ".$acct->id.")"; // Id bank account od invoice $sql.= " ORDER BY dlr ASC"; // Supplier invoices From 865fea37e9cc63ee904eeed05b380c6c0b7eaaec Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 8 Jul 2014 16:02:46 +0200 Subject: [PATCH 15/21] Correct filter --- htdocs/compta/bank/treso.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index f628965e976..223e5e9d534 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -161,8 +161,8 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND f.fk_account IN (NULL, 0, ".$acct->id.")"; // Id bank account od invoice - $sql.= " ORDER BY dlr ASC"; + $sql.= " AND (f.fk_account IN (0, ".$acct->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " ORDER BY dlr ASC"; // Supplier invoices $sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref_supplier as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; From beb471980e3f093c5e0060cd915d84b251e56825 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 8 Jul 2014 21:50:21 +0200 Subject: [PATCH 16/21] Add fields for supplier order and invoice --- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 3 +++ htdocs/install/mysql/tables/llx_commande_fournisseur.sql | 1 + htdocs/install/mysql/tables/llx_facture_fourn.sql | 1 + 3 files changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 707772e8981..3ef39a6bab1 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -87,3 +87,6 @@ ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_user_author FOREI ALTER TABLE llx_product_price ADD INDEX idx_product_price_fk_product (fk_product); ALTER TABLE llx_product_price ADD CONSTRAINT fk_product_price_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); +ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_account integer AFTER date_livraison; +ALTER TABLE llx_facture_fourn ADD COLUMN fk_account integer AFTER fk_projet; + diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 51e57452397..d8076c1c06c 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -55,6 +55,7 @@ create table llx_commande_fournisseur model_pdf varchar(255), date_livraison date default NULL, + fk_account integer, -- bank account fk_cond_reglement integer, -- condition de reglement fk_mode_reglement integer, -- mode de reglement fk_input_method integer default 0, diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index c980d43e40f..2bb85f8400e 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -58,6 +58,7 @@ create table llx_facture_fourn fk_facture_source integer, -- facture origine si facture avoir fk_projet integer, -- projet auquel est associee la facture + fk_account integer, -- bank account fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) fk_mode_reglement integer, -- mode de reglement (CHQ, VIR, ...) date_lim_reglement date, -- date limite de reglement From 387d36e4b06a2bf5a57da6d8f3bbf5fde8d3d191 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Wed, 9 Jul 2014 18:00:21 +0200 Subject: [PATCH 17/21] Ste bank account for supplier order --- htdocs/comm/propal.php | 2 +- htdocs/commande/fiche.php | 2 +- .../class/fournisseur.commande.class.php | 5 ++++ htdocs/fourn/commande/fiche.php | 28 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 7ce92a5b569..c2183a2b6e1 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1982,7 +1982,7 @@ if ($action == 'create') { print ''; print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->propal->creer && ! empty($object->brouillon)) + if ($action != 'editbankaccount' && $user->rights->propal->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; print ''; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 19948e3c1b7..7bf3705c07d 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2138,7 +2138,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon)) + if ($action != 'editbankaccount' && $user->rights->commande->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b65fe31ceec..19432c09b78 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -74,6 +74,7 @@ class CommandeFournisseur extends CommonOrder var $fk_project; var $cond_reglement_id; var $cond_reglement_code; + var $fk_account; var $mode_reglement_id; var $mode_reglement_code; var $user_author_id; @@ -126,6 +127,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " c.date_creation, c.date_valid, c.date_approve,"; $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve,"; $sql.= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_input_method,"; + $sql.= " c.fk_account,"; $sql.= " c.note_private, c.note_public, c.model_pdf, c.extraparams,"; $sql.= " cm.libelle as methode_commande,"; $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; @@ -180,6 +182,7 @@ class CommandeFournisseur extends CommonOrder $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle; + $this->fk_account = $obj->fk_account; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; @@ -876,6 +879,7 @@ class CommandeFournisseur extends CommonOrder $sql.= ", model_pdf"; $sql.= ", fk_mode_reglement"; $sql.= ", fk_cond_reglement"; + $sql.= ", fk_account"; $sql.= ") "; $sql.= " VALUES ("; $sql.= "''"; @@ -892,6 +896,7 @@ class CommandeFournisseur extends CommonOrder $sql.= ", '".$conf->global->COMMANDE_SUPPLIER_ADDON_PDF."'"; $sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'null'); $sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'null'); + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 05e2fe8822f..dbac3c4230d 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -125,6 +125,11 @@ else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer) $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); } +// bank account +else if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer) { + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + } + // date de livraison if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer) { @@ -776,6 +781,7 @@ else if ($action == 'add' && $user->rights->fournisseur->commande->creer) $object->socid = $socid; $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); @@ -1116,6 +1122,11 @@ if ($action=="create") $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); print ''; + // Bank Account + print '' . $langs->trans('BankAccount') . ''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print ''; + print ''.$langs->trans('NotePublic').''; print ''; $doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); @@ -1381,6 +1392,23 @@ elseif (! empty($object->id)) } print ''; + // Bank Account + print ''; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if ($action != 'editbankaccount' && $user->rights->fournisseur->commande->creer) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print ''; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ''; + print ''; + // Delivery date planed print ''; print ''; + // Bank Account + print ''; + // Project if (! empty($conf->projet->enabled)) { @@ -1776,6 +1788,23 @@ else } print ''; + // Bank Account + print '"; + print ''; + // Status $alreadypaid=$object->getSommePaiement(); print ''; @@ -2131,7 +2160,7 @@ else // Make payments if ($action != 'edit' && $object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) { - print ''.$langs->trans('DoPayment').''; // must use facid because id is for payment id not invoice + print ''.$langs->trans('DoPayment').''; // must use facid because id is for payment id not invoice } // Classify paid From ab57c236bea95b6b93e6b2630bdf5e20672b40a2 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Thu, 10 Jul 2014 12:06:09 +0200 Subject: [PATCH 19/21] New: Can have half day holiday New: Add Spanish holidays Fix: Holiday log shows nothing --- htdocs/core/lib/date.lib.php | 43 ++++++++++++++++++++++++++ htdocs/holiday/class/holiday.class.php | 4 +-- htdocs/holiday/fiche.php | 7 +++-- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 4201cde9e9d..3c37a79b7dd 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -659,6 +659,49 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; //Samedi (6) et dimanche (0) } + + if ($countrycode == 'ES') + { + $countryfound=1; + + // Definition des dates feriees fixes + if($jour == 1 && $mois == 1) $ferie=true; // Año nuevo + if($jour == 6 && $mois == 1) $ferie=true; // Día Reyes + if($jour == 1 && $mois == 5) $ferie=true; // 1 Mayo + if($jour == 15 && $mois == 8) $ferie=true; // 15 Agosto + if($jour == 12 && $mois == 10) $ferie=true; // Día Hispanidad + if($jour == 1 && $mois == 11) $ferie=true; // 1 noviembre + if($jour == 6 && $mois == 12) $ferie=true; // Constitución + if($jour == 8 && $mois == 12) $ferie=true; // Inmaculada + if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre + + // Calcul día de Pascua + $date_paques = easter_date($annee); + $jour_paques = date("d", $date_paques); + $mois_paques = date("m", $date_paques); + if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; + // Paques + + // Viernes Santo + $date_viernes = mktime( + date("H", $date_paques), + date("i", $date_paques), + date("s", $date_paques), + date("m", $date_paques), + date("d", $date_paques) -2, + date("Y", $date_paques) + ); + $jour_viernes = date("d", $date_viernes); + $mois_viernes = date("m", $date_viernes); + if($jour_viernes == $jour && $mois_viernes == $mois) $ferie=true; + //Viernes Santo + + // Calul des samedis et dimanches + $jour_julien = unixtojd($timestampStart); + $jour_semaine = jddayofweek($jour_julien, 0); + if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; + //Samedi (6) et dimanche (0) + } // Cas pays non defini if (! $countryfound) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 8ff312202f3..0e39f591bdd 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1670,12 +1670,12 @@ class Holiday extends CommonObject // Filtrage de séléction if(!empty($filter)) { - $sql.= $filter; + $sql.= " ".$filter; } // Ordre d'affichage if(!empty($order)) { - $sql.= $order; + $sql.= " ".$order; } dol_syslog(get_class($this)."::fetchLog", LOG_DEBUG); diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index d66d1c8cfbd..93b426b5ad3 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -3,6 +3,7 @@ * Copyright (C) 2012-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2014 Ferran Marcet * * 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 @@ -111,7 +112,7 @@ if ($action == 'create') // Si aucun jours ouvrés dans la demande $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if($nbopenedday < 1) + if($nbopenedday < 0.5) { header('Location: fiche.php?action=request&error=DureeHoliday'); exit; @@ -208,7 +209,7 @@ if ($action == 'update') // Si pas de jours ouvrés dans la demande $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); - if ($nbopenedday < 1) + if ($nbopenedday < 0.5) { header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday'); exit; @@ -398,7 +399,7 @@ if($action == 'confirm_valid') if ($verif > 0) { // Calculcate number of days consummed - $nbopenedday=num_open_day($cp->date_debut_gmt,$cp->date_fin_gmt,0,1); + $nbopenedday=num_open_day($cp->date_debut_gmt,$cp->date_fin_gmt,0,1,$cp->halfday); $soldeActuel = $cp->getCpforUser($cp->fk_user); $newSolde = $soldeActuel - ($nbopenedday * $cp->getConfCP('nbHolidayDeducted')); From d476ca4a682cdecc469a380f0d676cc2527ee987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 10 Jul 2014 15:01:37 +0200 Subject: [PATCH 20/21] Support gigaoctets of session memory --- htdocs/install/check.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index a3d58458d43..063fefd62e0 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -152,6 +152,7 @@ if ($memmaxorig != '') preg_match('/([0-9]+)([a-zA-Z]*)/i',$memmax,$reg); if ($reg[2]) { + if (strtoupper($reg[2]) == 'G') $memmax=$reg[1]*1024*1024*1024; if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024; if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024; } From fb3392a7b2def4c514ac94a3cf7f01bc704e7c56 Mon Sep 17 00:00:00 2001 From: juanjo Date: Thu, 10 Jul 2014 19:49:20 +0200 Subject: [PATCH 21/21] Trad: Update from Transifex --- htdocs/langs/es_ES/agenda.lang | 2 ++ htdocs/langs/es_ES/languages.lang | 1 + htdocs/langs/es_ES/main.lang | 3 ++- htdocs/langs/es_ES/shop.lang | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/es_ES/agenda.lang b/htdocs/langs/es_ES/agenda.lang index fda74dd03d9..fff5641864c 100644 --- a/htdocs/langs/es_ES/agenda.lang +++ b/htdocs/langs/es_ES/agenda.lang @@ -25,6 +25,8 @@ ListOfEvents= Listado de eventos Dolibarr ActionsAskedBy=Eventos registrados por ActionsToDoBy=Eventos asignados a ActionsDoneBy=Eventos realizados por +ActionsForUser=Eventos del usuario +ActionsForUsersGroup=Eventos de todos los usuarios del grupo AllMyActions= Todos mis eventos/tareas AllActions= Todos los eventos/tareas ViewList=Vista listado diff --git a/htdocs/langs/es_ES/languages.lang b/htdocs/langs/es_ES/languages.lang index 124d8ae8cd3..88fba3e586f 100644 --- a/htdocs/langs/es_ES/languages.lang +++ b/htdocs/langs/es_ES/languages.lang @@ -10,6 +10,7 @@ Language_da_DA=Danés Language_da_DK=Danés Language_de_DE=Alemán Language_de_AT=Alemán (Austria) +Language_de_CH=Alemán (Suiza) Language_el_GR=Griego Language_en_AU=Inglés (Australia) Language_en_GB=Inglés (Reino Unido) diff --git a/htdocs/langs/es_ES/main.lang b/htdocs/langs/es_ES/main.lang index 4d743557b16..20ceb3814cb 100644 --- a/htdocs/langs/es_ES/main.lang +++ b/htdocs/langs/es_ES/main.lang @@ -356,6 +356,7 @@ ActionNotApplicable=No aplicable ActionRunningNotStarted=No empezado ActionRunningShort=Empezado ActionDoneShort=Terminado +ActionUncomplete=Incompleto CompanyFoundation=Empresa o institución ContactsForCompany=Contactos de este tercero ContactsAddressesForCompany=Contactos/direcciones de este tercero @@ -507,7 +508,7 @@ NbOfCustomers=Numero de clientes NbOfLines=Números de líneas NbOfObjects=Número de objetos NbOfReferers=Consumición -Referers=Referencias +Referers=Objetos vinculados TotalQuantity=Cantidad total DateFromTo=De %s a %s DateFrom=A partir de %s diff --git a/htdocs/langs/es_ES/shop.lang b/htdocs/langs/es_ES/shop.lang index f6ed51eb407..67bf61fb702 100644 --- a/htdocs/langs/es_ES/shop.lang +++ b/htdocs/langs/es_ES/shop.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - shop -FailedConnectDBCheckModuleSetup=Failed to connect to oscommerce database. Check your module setup +FailedConnectDBCheckModuleSetup=No se pudo conectar con la base de datos oscommerce. Compruebe la configuración del módulo Shop=Tienda ShopWeb=Tienda web LastOrders=Últimos pedidos
'; From 742bdcb7155d46110b55155fb227e0646726c851 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Wed, 9 Jul 2014 18:44:20 +0200 Subject: [PATCH 18/21] Set bank account for supplier invoices --- htdocs/compta/bank/treso.php | 3 +- .../fourn/class/fournisseur.facture.class.php | 7 ++++- htdocs/fourn/facture/fiche.php | 31 ++++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 223e5e9d534..8ae2974b33f 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -171,7 +171,8 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql2.= " WHERE ff.entity = ".$conf->entity; $sql2.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql2.= " ORDER BY dlr ASC"; + $sql2.= " AND (ff.fk_account IN (0, ".$acct->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql2.= " ORDER BY dlr ASC"; // Social contributions $sql3= " SELECT 'social_contribution' as family, cs.rowid as objid, cs.libelle as ref, (-1*cs.amount) as total_ttc, ccs.libelle as type, cs.date_ech as dlr"; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index cb0a0abd17a..b01e3ee7891 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -79,6 +79,7 @@ class FactureFournisseur extends CommonInvoice var $propalid; var $cond_reglement_id; var $cond_reglement_code; + var $fk_account; var $mode_reglement_id; var $mode_reglement_code; @@ -174,6 +175,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", fk_projet"; $sql.= ", fk_cond_reglement"; $sql.= ", fk_mode_reglement"; + $sql.= ", fk_account"; $sql.= ", note_private"; $sql.= ", note_public"; $sql.= ", fk_user_author"; @@ -190,6 +192,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ", ".(isset($this->fk_project)?$this->fk_project:"null"); $sql.= ", ".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null"); $sql.= ", ".(isset($this->mode_reglement_id)?$this->mode_reglement_id:"null"); + $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); $sql.= ", '".$this->db->escape($this->note_private)."'"; $sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", ".$user->id.","; @@ -333,7 +336,8 @@ class FactureFournisseur extends CommonInvoice $sql.= " t.fk_facture_source,"; $sql.= " t.fk_projet,"; $sql.= " t.fk_cond_reglement,"; - $sql.= " t.fk_mode_reglement,"; + $sql.= " t.fk_account,"; + $sql.= " t.fk_mode_reglement,"; $sql.= " t.date_lim_reglement,"; $sql.= " t.note_private,"; $sql.= " t.note_public,"; @@ -394,6 +398,7 @@ class FactureFournisseur extends CommonInvoice $this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement = $obj->cond_reglement_libelle; $this->cond_reglement_doc = $obj->cond_reglement_libelle; + $this->fk_account = $obj->fk_account; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement = $obj->mode_reglement_libelle; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 9cd11bd58bf..4e1c3246eff 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -215,6 +215,10 @@ else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer) $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); } +// bank account +else if ($action == 'setbankaccount' && $user->rights->fournisseur->facture->creer) { + $result=$object->setBankAccount(GETPOST('fk_account', 'int')); +} // Set label elseif ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) @@ -305,6 +309,7 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) $object->note_private = GETPOST('note_private'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; // Auto calculation of date due if not filled by user @@ -1164,6 +1169,7 @@ if ($action == 'create') $soc = $objectsrc->thirdparty; $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:1)); $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; @@ -1178,6 +1184,7 @@ if ($action == 'create') { $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; + $fk_account = $societe->fk_account; $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); @@ -1320,6 +1327,11 @@ if ($action == 'create') $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); print '
'.$langs->trans('BankAccount').''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print '
'; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if ($action != 'editbankaccount' && $user->rights->fournisseur->facture->creer) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print '
'; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print "
'.$langs->trans('Status').''.$object->getLibStatut(4,$alreadypaid).'