Merge pull request #5232 from atm-florian/develop
Add trigger into expedition class
This commit is contained in:
commit
4c93340de1
@ -478,9 +478,20 @@ class Commande extends CommonOrder
|
||||
}
|
||||
}
|
||||
|
||||
$this->statut=self::STATUS_DRAFT;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
if (!$error) {
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('ORDER_SETDRAFT',$user);
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->statut=self::STATUS_DRAFT;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -119,6 +119,7 @@ class InterfaceDemo extends DolibarrTriggers
|
||||
case 'ORDER_CANCEL':
|
||||
case 'ORDER_SENTBYMAIL':
|
||||
case 'ORDER_CLASSIFY_BILLED':
|
||||
case 'ORDER_SETDRAFT':
|
||||
case 'LINEORDER_INSERT':
|
||||
case 'LINEORDER_UPDATE':
|
||||
case 'LINEORDER_DELETE':
|
||||
@ -258,6 +259,9 @@ class InterfaceDemo extends DolibarrTriggers
|
||||
case 'SHIPPING_MODIFY':
|
||||
case 'SHIPPING_VALIDATE':
|
||||
case 'SHIPPING_SENTBYMAIL':
|
||||
case 'SHIPPING_BILLED':
|
||||
case 'SHIPPING_CLOSED':
|
||||
case 'SHIPPING_REOPEN':
|
||||
case 'SHIPPING_DELETE':
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
break;
|
||||
|
||||
@ -1801,6 +1801,10 @@ class Expedition extends CommonObject
|
||||
function setClosed()
|
||||
{
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
|
||||
|
||||
@ -1809,11 +1813,27 @@ class Expedition extends CommonObject
|
||||
{
|
||||
// TODO: Add option/checkbox to set order billed if 100% of order is shipped
|
||||
$this->statut=2;
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('SHIPPING_CLOSED',$user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[]=$this->db->lasterror;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dol_print_error($this->db);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1825,6 +1845,9 @@ class Expedition extends CommonObject
|
||||
*/
|
||||
function set_billed()
|
||||
{
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2, billed=1'; // TODO Update only billed
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
|
||||
@ -1834,11 +1857,27 @@ class Expedition extends CommonObject
|
||||
{
|
||||
$this->statut=2;
|
||||
$this->billed=1;
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('SHIPPING_BILLED',$user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[]=$this->db->lasterror;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dol_print_error($this->db);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1851,6 +1890,10 @@ class Expedition extends CommonObject
|
||||
function reOpen()
|
||||
{
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
|
||||
|
||||
@ -1859,11 +1902,27 @@ class Expedition extends CommonObject
|
||||
{
|
||||
$this->statut=1;
|
||||
$this->billed=0;
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('SHIPPING_REOPEN',$user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
} else {
|
||||
$error++;
|
||||
$this->errors[]=$this->db->lasterror;
|
||||
}
|
||||
|
||||
if (empty($error)) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dol_print_error($this->db);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user