diff --git a/ChangeLog b/ChangeLog index c31068aaa08..71957fbb206 100644 --- a/ChangeLog +++ b/ChangeLog @@ -67,9 +67,7 @@ For users: - Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers. - Fix: [ bug #1439 ] impossible to remove a a translation (multilanguage-feature) - New: If multilangue is enabled, mail (from propal, invoice, etc...) message is pre-defaulted in Customer language - -TODO -- New: Predefined product and free product use same form. +- Fix: [ bug #1459 ] _ADD_CONTACT and _DEL_CONTACT triggers do not intercept insertion when reported an error For translators: - Update language files. @@ -91,6 +89,8 @@ For developers: - New: A module can disable a standard ECM view. - New: Add multilang support into product webservice. - New: Add hooks on project card page. +- New: Add call_trigger method on CommonObject class. So new trigger call within object is just : +$result = $this->call_trigger($trigger_name, $user) WARNING: Following change may create regression for some external modules, but was necessary to make Dolibarr better: @@ -98,11 +98,11 @@ Dolibarr better: - The deprecated way (with 4 parameters) to declare a new tab into a module descriptor file has been removed. You must now use the 6 parameters way. See file modMyModule.class.php for example. - Remove the javascript function ac_delay() that is not used anymore by core code. -- Properties "dictionnaries" into module descriptor files has been renamed into "dictionaries". +- Properties "dictionnaries" into module descriptor files have been renamed into "dictionaries". - Method form->select_currency() has been removed. Use instead print form->selectCurrency(). - Method form->select_methodes_commande() has been renamed into english name selectInputMethod(). - The following hooks are now 'addreplace' hooks: "formCreateThirdpartyOptions" - So check that return value is 0 to keep default standard behaviour after hook or 1 to disable + So check that return value is 0 to keep default standard behaviour after hook, or 1 to disable default standard behaviour. - Properties "civilite_id" were renamed into "civility_id". diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 914d9be59a3..0c1d18e28ed 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -164,7 +164,6 @@ abstract class CommonObject { global $user,$conf,$langs; - $error=0; dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source"); @@ -205,6 +204,8 @@ abstract class CommonObject $datecreate = dol_now(); + $this->db->begin(); + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; @@ -219,20 +220,16 @@ abstract class CommonObject { if (! $notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers(strtoupper($this->element).'_ADD_CONTACT',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // End call triggers + $result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user); + if ($result < 0) { $this->db->rollback(); return -1; } } - + + $this->db->commit(); return 1; } else { + $this->db->rollback(); if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $this->error=$this->db->errno(); @@ -311,8 +308,9 @@ abstract class CommonObject { global $user,$langs,$conf; - $error=0; + $this->db->begin(); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql.= " WHERE rowid =".$rowid; @@ -321,21 +319,17 @@ abstract class CommonObject { if (! $notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers(strtoupper($this->element).'_DELETE_CONTACT',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // End call triggers + $result=$this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); + if ($result < 0) { $this->db->rollback(); return -1; } } + $this->db->commit(); return 1; } else { $this->error=$this->db->lasterror(); + $this->db->rollback(); dol_syslog(get_class($this)."::delete_contact error=".$this->error, LOG_ERR); return -1; } @@ -3354,8 +3348,9 @@ abstract class CommonObject { global $user,$langs,$conf; - $error=0; + $this->db->begin(); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; $sql.= " WHERE rowid =".$rowid; @@ -3364,14 +3359,8 @@ abstract class CommonObject { if (! $notrigger) { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers(strtoupper($element).'_DELETE_RESOURCE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // End call triggers + $result=$this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user); + if ($result < 0) { $this->db->rollback(); return -1; } } return 1; @@ -3379,6 +3368,7 @@ abstract class CommonObject else { $this->error=$this->db->lasterror(); + $this->db->rollback(); dol_syslog(get_class($this)."::delete_resource error=".$this->error, LOG_ERR); return -1; } @@ -3402,5 +3392,36 @@ abstract class CommonObject } } } + + /** + * Call trigger based on this instance + * + * NB: Error from trigger are stacked in errors + * NB2: if trigger fail, action should be canceled. + * + * @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; + + } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 591fce671b1..704e06b2f3b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1917,7 +1917,7 @@ class CommandeFournisseur extends CommonOrder $this->nbtodo=$this->nbtodolate=0; $clause = " WHERE"; - $sql = "SELECT c.rowid, c.date_creation as datec, c.fk_statut"; + $sql = "SELECT c.rowid, c.date_creation as datec, c.fk_statut,c.date_livraison as delivery_date"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { @@ -1935,7 +1935,9 @@ class CommandeFournisseur extends CommonOrder while ($obj=$this->db->fetch_object($resql)) { $this->nbtodo++; - if ($obj->fk_statut != 3 && $this->db->jdate($obj->datec) < ($now - $conf->commande->fournisseur->warning_delay)) $this->nbtodolate++; + + $date_to_test = empty($obj->delivery_date) ? $obj->datec : $obj->delivery_date; + if ($obj->fk_statut != 3 && $this->db->jdate($date_to_test) < ($now - $conf->commande->fournisseur->warning_delay)) $this->nbtodolate++; } return 1; } diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index 9e0c12ecf5f..9ecbf0e0c17 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; $langs->load("orders"); +$langs->load("sendings"); $search_ref=GETPOST('search_ref'); @@ -84,7 +85,7 @@ $offset = $conf->liste_limit * $page ; */ $sql = "SELECT s.rowid as socid, s.nom, cf.date_commande as dc,"; -$sql.= " cf.rowid,cf.ref, cf.ref_supplier, cf.fk_statut, cf.total_ttc, cf.fk_user_author,"; +$sql.= " cf.rowid,cf.ref, cf.ref_supplier, cf.fk_statut, cf.total_ttc, cf.fk_user_author,cf.date_livraison,"; $sql.= " u.login"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur as cf"; @@ -166,6 +167,7 @@ if ($resql) print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.login","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"total_ttc","",$param,$sortfield,$sortorder); print_liste_field_titre($langs->trans("OrderDate"),$_SERVER["PHP_SELF"],"dc","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('DateDeliveryPlanned'),$_SERVER["PHP_SELF"],'cf.date_livraison','',$param, 'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"cf.fk_statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; @@ -178,6 +180,7 @@ if ($resql) print ''; print ''; print ' '; + print ' '; print ''; $formorder->selectSupplierOrderStatus($search_status,1,'search_status'); print ''; @@ -236,6 +239,12 @@ if ($resql) } print ''; + // Delivery date + print ''; + print dol_print_date($db->jdate($obj->date_livraison), 'day'); + print ''; + + // Statut print ''.$commandestatic->LibStatut($obj->fk_statut, 5).''; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index c79c862146c..e8c6f166890 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -102,6 +102,7 @@ $server->wsdl->addComplexType( 'total' => array('name'=>'total','type'=>'xsd:double'), 'date_start' => array('name'=>'date_start','type'=>'xsd:date'), 'date_end' => array('name'=>'date_end','type'=>'xsd:date'), + 'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:string'), // From product 'product_id' => array('name'=>'product_id','type'=>'xsd:int'), 'product_ref' => array('name'=>'product_ref','type'=>'xsd:string'), @@ -329,6 +330,7 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='') 'status'=> $invoice->statut, 'close_code' => $invoice->close_code?$invoice->close_code:'', 'close_note' => $invoice->close_note?$invoice->close_note:'', + 'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'', 'lines' => $linesresp )); } @@ -454,6 +456,7 @@ function getInvoicesForThirdParty($authentication,$idthirdparty) 'status'=> $invoice->statut, 'close_code' => $invoice->close_code?$invoice->close_code:'', 'close_note' => $invoice->close_note?$invoice->close_note:'', + 'payment_mode_id' => $invoice->mode_reglement_id?$invoice->mode_reglement_id:'', 'lines' => $linesresp ); } @@ -518,6 +521,7 @@ function createInvoice($authentication,$invoice) $newobject->statut=0; // We start with status draft $newobject->fk_project=$invoice['project_id']; $newobject->date_creation=$now; + $newobject->mode_reglement_id = $invoice['payment_mode_id']; // Trick because nusoap does not store data with same structure if there is one or several lines $arrayoflines=array();