Hello there!
I am trying to add records to a table after a thrid-party is created. I made a trigger that runs fine:
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
if (empty($conf->crm->enabled)) { return 0; } // If module is not enabled, we do nothing
switch ($action) {
case 'COMPANY_CREATE': addCRMStep($object->id, 0,'Company created',$user->id);
break;
default:
dol_syslog("Trigger '".$this->name."' for action '$action'");
break;
}
return 0;
}
This trigger calls the function addCRMStep, and does it fine. The problem I have is that I cannot find a way to actually add any new records, no matter what I do. This function is in another file and added to the interface file with:
require_once DOL_DOCUMENT_ROOT.‘/custom/crm/lib/crm.lib.php’;
Here is the function
function addCRMStep($societe, $step, $note, $usr)
{ global $db;
$slq = "INSERT INTO llxmn_crm (_societe, crm_step, crm_step_note, fk_user_author, fk_user_mod) VALUES (".$societe.", ".$step.", '".$note."', ".$usr.", ".$usr_mod.")";
if ( $db->query($sql) ) { return 1; } else { return -1; }
}
I don’t see any errors, but nothing get inserted into the table.
What am I doing wrong?
Thanks!