Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
Browse files Browse the repository at this point in the history
develop

Conflicts:
	ChangeLog
  • Loading branch information
eldy committed Jun 26, 2014
2 parents 93611e6 + 31c60cc commit a2f610f
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 36 deletions.
10 changes: 5 additions & 5 deletions ChangeLog
Expand Up @@ -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.
Expand All @@ -91,18 +89,20 @@ 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:

- 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".

Expand Down
77 changes: 49 additions & 28 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -164,7 +164,6 @@ function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger
{
global $user,$conf,$langs;

$error=0;

dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source");

Expand Down Expand Up @@ -205,6 +204,8 @@ function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger

$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) ";
Expand All @@ -219,20 +220,16 @@ function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger
{
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();
Expand Down Expand Up @@ -311,8 +308,9 @@ function delete_contact($rowid, $notrigger=0)
{
global $user,$langs,$conf;

$error=0;

$this->db->begin();

$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid;

Expand All @@ -321,21 +319,17 @@ function delete_contact($rowid, $notrigger=0)
{
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;
}
Expand Down Expand Up @@ -3354,8 +3348,9 @@ function delete_resource($rowid, $element, $notrigger=0)
{
global $user,$langs,$conf;

$error=0;

$this->db->begin();

$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE rowid =".$rowid;

Expand All @@ -3364,21 +3359,16 @@ function delete_resource($rowid, $element, $notrigger=0)
{
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;
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
dol_syslog(get_class($this)."::delete_resource error=".$this->error, LOG_ERR);
return -1;
}
Expand All @@ -3402,5 +3392,36 @@ function __clone()
}
}
}

/**
* 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;

}

}
6 changes: 4 additions & 2 deletions htdocs/fourn/class/fournisseur.commande.class.php
Expand Up @@ -1917,7 +1917,7 @@ function load_board($user)
$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)
{
Expand All @@ -1935,7 +1935,9 @@ function load_board($user)
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;
}
Expand Down
11 changes: 10 additions & 1 deletion htdocs/fourn/commande/liste.php
Expand Up @@ -33,6 +33,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php';

$langs->load("orders");
$langs->load("sendings");


$search_ref=GETPOST('search_ref');
Expand Down Expand Up @@ -84,7 +85,7 @@
*/

$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";
Expand Down Expand Up @@ -166,6 +167,7 @@
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 "</tr>\n";
Expand All @@ -178,6 +180,7 @@
print '<td class="liste_titre"><input type="text" class="flat" name="search_user" value="'.$search_user.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_ttc" value="'.$search_ttc.'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$formorder->selectSupplierOrderStatus($search_status,1,'search_status');
print '</td>';
Expand Down Expand Up @@ -236,6 +239,12 @@
}
print '</td>';

// Delivery date
print '<td align="right">';
print dol_print_date($db->jdate($obj->date_livraison), 'day');
print '</td>';


// Statut
print '<td align="right" colspan="2">'.$commandestatic->LibStatut($obj->fk_statut, 5).'</td>';

Expand Down
4 changes: 4 additions & 0 deletions htdocs/webservices/server_invoice.php
Expand Up @@ -102,6 +102,7 @@
'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'),
Expand Down Expand Up @@ -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
));
}
Expand Down Expand Up @@ -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
);
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a2f610f

Please sign in to comment.