Skip to content

Commit

Permalink
add the trigger to prefix on new event
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent De Coninck committed Oct 31, 2023
1 parent bcf7e51 commit 41d5694
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

class InterfacePrefixTitleByBalloon extends DolibarrTriggers
{

public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
if('ACTION_CREATE' !== $action){
return 0 ;
}

if(!($object instanceof ActionComm)){
return 0 ;
}

if(!isset($object->array_options['options_bal']) || empty($object->array_options['options_bal'])){
return 0 ; // No balloon
}

$balloon = new Bbc_ballons($this->db);
$balloon->fetch($object->array_options['options_bal']);
if(empty($balloon->id)){
return 0 ; // No balloon found
}

$object->label = '['.$balloon->immat.'] - '.$object->label;
$object->update($user, true);

return 1;
}
}

0 comments on commit 41d5694

Please sign in to comment.